@workflow/web 4.1.0-beta.43 → 4.1.0-beta.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. package/build/client/assets/{highlighted-body-B3W2YXNL-BdpKyd6t.js → highlighted-body-B3W2YXNL-BAmp2St7.js} +1 -1
  2. package/build/client/assets/{home-C884R8Ik.js → home-CFxVErsy.js} +1 -1
  3. package/build/client/assets/{manifest-14123a0c.js → manifest-beaac576.js} +1 -1
  4. package/build/client/assets/{mermaid-3ZIDBTTL-D6v4WgFl.js → mermaid-3ZIDBTTL-CrmlsXj3.js} +63 -63
  5. package/build/client/assets/{root-CxkGJJO9.js → root-DXnpwJxc.js} +1 -1
  6. package/build/client/assets/{root-DUJPWGN3.css → root-DtrAdcW8.css} +1 -1
  7. package/build/client/assets/run-detail-C6LG6p9l.js +37 -0
  8. package/build/client/assets/{server-build-BFalDDpv.css → server-build-8B6V768r.css} +1 -1
  9. package/build/client/assets/use-workflow-graph-DGcT3V07.js +166 -0
  10. package/build/server/assets/{app-KW-1KXCl.js → app-DiZXH6x4.js} +1 -1
  11. package/build/server/assets/{highlighted-body-B3W2YXNL-DapKdL2n.js → highlighted-body-B3W2YXNL-CmDnR6fu.js} +2 -2
  12. package/build/server/assets/{index-93Io7SSr.js → index-cxStGfMq.js} +2 -2
  13. package/build/server/assets/{mermaid-3ZIDBTTL-BdsOvyTU.js → mermaid-3ZIDBTTL-CxsJnUQo.js} +2 -2
  14. package/build/server/assets/{server-build-D9d_jMLb.js → server-build-CZMYXF52.js} +842 -277
  15. package/build/server/assets/{token-Bf2BqxEG.js → token-C7BfiMAN.js} +2 -2
  16. package/build/server/assets/{token-util-C8FlMBAQ.js → token-util-CxDoe-ao.js} +2 -2
  17. package/build/server/index.js +1 -1
  18. package/package.json +6 -6
  19. package/build/client/assets/run-detail-D_eXHYm3.js +0 -36
  20. package/build/client/assets/use-workflow-graph-WEp5s5k_.js +0 -166
@@ -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, _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, _reader;
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, M as Meta, L as Links, d as ScrollRestoration, e as Scripts, O as Outlet, u as useNavigate, f as useSearchParams, h as Link$1, i as useLocation, j as useParams } from "./app-KW-1KXCl.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, M as Meta, L as Links, d as ScrollRestoration, e as Scripts, O as Outlet, u as useNavigate, f as useSearchParams, h as Link$1, i as useLocation, j as useParams } from "./app-DiZXH6x4.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";
@@ -24,7 +24,7 @@ import minproc from "node:process";
24
24
  import path$3, { join as join$1, resolve, dirname, isAbsolute, sep as sep$1 } from "node:path";
25
25
  import { fileURLToPath } from "node:url";
26
26
  import { createRequire } from "module";
27
- import require$$0$8, { readdir, readlink, readFile, mkdir, access, constants as constants$5, writeFile, unlink, rm } from "node:fs/promises";
27
+ import fs$1, { readdir, readlink, readFile, mkdir, access, constants as constants$5, writeFile, unlink, rm } from "node:fs/promises";
28
28
  import crypto, { createHash, webcrypto } from "node:crypto";
29
29
  import require$$1$1 from "tty";
30
30
  import require$$0$1 from "os";
@@ -30646,9 +30646,13 @@ function formatDuration(ms2, compact = false) {
30646
30646
  }
30647
30647
  if (compact) {
30648
30648
  if (ms2 < MS_IN_HOUR) {
30649
- return `${durationFormatter.format(ms2 / MS_IN_MINUTE)}m`;
30649
+ const m3 = Math.floor(ms2 / MS_IN_MINUTE);
30650
+ const s2 = Math.floor(ms2 % MS_IN_MINUTE / MS_IN_SECOND);
30651
+ return s2 > 0 ? `${m3}m ${s2}s` : `${m3}m`;
30650
30652
  }
30651
- return `${durationFormatter.format(ms2 / MS_IN_HOUR)}h`;
30653
+ const h2 = Math.floor(ms2 / MS_IN_HOUR);
30654
+ const m2 = Math.floor(ms2 % MS_IN_HOUR / MS_IN_MINUTE);
30655
+ return m2 > 0 ? `${h2}h ${m2}m` : `${h2}h`;
30652
30656
  }
30653
30657
  const days = Math.floor(ms2 / MS_IN_DAY);
30654
30658
  const hours = Math.floor(ms2 % MS_IN_DAY / MS_IN_HOUR);
@@ -34545,6 +34549,21 @@ function decodeFormatPrefix$1(data) {
34545
34549
  const payload = data.subarray(FORMAT_PREFIX_LENGTH$1);
34546
34550
  return { format: format2, payload };
34547
34551
  }
34552
+ function isExpiredObject(data) {
34553
+ if (data === null || typeof data !== "object" || Array.isArray(data)) {
34554
+ return false;
34555
+ }
34556
+ const keys2 = Object.keys(data);
34557
+ return keys2.length === 1 && keys2[0] === "expiredAt" && typeof data.expiredAt === "string";
34558
+ }
34559
+ function isExpiredStub(data) {
34560
+ if (isExpiredObject(data))
34561
+ return true;
34562
+ if (Array.isArray(data) && data.length === 1 && isExpiredObject(data[0])) {
34563
+ return true;
34564
+ }
34565
+ return false;
34566
+ }
34548
34567
  function isEncryptedData(data) {
34549
34568
  if (!(data instanceof Uint8Array) || data.length < FORMAT_PREFIX_LENGTH$1) {
34550
34569
  return false;
@@ -34759,6 +34778,7 @@ const serializationFormat = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object
34759
34778
  hydrateDataWithKey,
34760
34779
  hydrateResourceIO: hydrateResourceIO$1,
34761
34780
  isEncryptedData,
34781
+ isExpiredStub,
34762
34782
  observabilityRevivers,
34763
34783
  serializedClassToString,
34764
34784
  serializedInstanceToRef,
@@ -34836,7 +34856,7 @@ function getRevivers() {
34836
34856
  }
34837
34857
  function hydrateResourceIO(resource) {
34838
34858
  const hydrated = hydrateResourceIO$1(resource, getRevivers());
34839
- return replaceEncryptedWithMarkers(hydrated);
34859
+ return replaceEncryptedAndExpiredWithMarkers(hydrated);
34840
34860
  }
34841
34861
  const ENCRYPTED_DISPLAY_NAME = "Encrypted";
34842
34862
  function createEncryptedMarker(data) {
@@ -34854,22 +34874,35 @@ function isEncryptedMarker(value) {
34854
34874
  var _a3;
34855
34875
  return value !== null && typeof value === "object" && ((_a3 = value.constructor) == null ? void 0 : _a3.name) === ENCRYPTED_DISPLAY_NAME;
34856
34876
  }
34857
- function replaceEncryptedWithMarkers(resource) {
34877
+ const EXPIRED_DISPLAY_NAME = "Expired Data";
34878
+ function createExpiredMarker() {
34879
+ const ctor = { [EXPIRED_DISPLAY_NAME]: function() {
34880
+ } }[EXPIRED_DISPLAY_NAME];
34881
+ return Object.create(ctor.prototype);
34882
+ }
34883
+ function isExpiredMarker(value) {
34884
+ var _a3;
34885
+ return value !== null && typeof value === "object" && ((_a3 = value.constructor) == null ? void 0 : _a3.name) === EXPIRED_DISPLAY_NAME;
34886
+ }
34887
+ function toDisplayMarker(value) {
34888
+ if (isEncryptedData(value))
34889
+ return createEncryptedMarker(value);
34890
+ if (isExpiredStub(value))
34891
+ return createExpiredMarker();
34892
+ return value;
34893
+ }
34894
+ function replaceEncryptedAndExpiredWithMarkers(resource) {
34858
34895
  if (!resource || typeof resource !== "object")
34859
34896
  return resource;
34860
34897
  const r2 = resource;
34861
34898
  const result = { ...r2 };
34862
34899
  for (const key of ["input", "output", "metadata", "error"]) {
34863
- if (isEncryptedData(result[key])) {
34864
- result[key] = createEncryptedMarker(result[key]);
34865
- }
34900
+ result[key] = toDisplayMarker(result[key]);
34866
34901
  }
34867
34902
  if (result.eventData && typeof result.eventData === "object") {
34868
34903
  const ed = { ...result.eventData };
34869
34904
  for (const key of EVENT_DATA_SERIALIZED_FIELDS) {
34870
- if (isEncryptedData(ed[key])) {
34871
- ed[key] = createEncryptedMarker(ed[key]);
34872
- }
34905
+ ed[key] = toDisplayMarker(ed[key]);
34873
34906
  }
34874
34907
  result.eventData = ed;
34875
34908
  }
@@ -64866,7 +64899,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
64866
64899
  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 });
64867
64900
  var Se = reactExports.createContext({ code: "" }), de$1 = () => reactExports.useContext(Se);
64868
64901
  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 }) });
64869
- var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-DapKdL2n.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
64902
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-CmDnR6fu.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
64870
64903
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
64871
64904
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
64872
64905
  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 }) })] }) });
@@ -65188,7 +65221,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
65188
65221
  }, []), 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] });
65189
65222
  };
65190
65223
  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 }) })] });
65191
- var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-BdsOvyTU.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
65224
+ var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-CxsJnUQo.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
65192
65225
  function ke(e, t) {
65193
65226
  if (!(e != null && e.position || t != null && t.position)) return true;
65194
65227
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -65823,6 +65856,13 @@ function EncryptedFieldBlock() {
65823
65856
  color: "var(--ds-gray-700)"
65824
65857
  }, children: [jsxRuntimeExports.jsx(Lock, { className: "h-3 w-3" }), jsxRuntimeExports.jsx("span", { className: "font-medium", children: "Encrypted" })] });
65825
65858
  }
65859
+ function ExpiredFieldBlock() {
65860
+ return jsxRuntimeExports.jsx("div", { className: "flex items-center gap-1.5 rounded-md border px-3 py-2 text-xs", style: {
65861
+ borderColor: "var(--ds-gray-300)",
65862
+ backgroundColor: "var(--ds-gray-100)",
65863
+ color: "var(--ds-gray-700)"
65864
+ }, children: jsxRuntimeExports.jsx("span", { className: "font-medium", children: "Data expired" }) });
65865
+ }
65826
65866
  function JsonBlock(value) {
65827
65867
  return jsxRuntimeExports.jsx(CopyableDataBlock, { data: value });
65828
65868
  }
@@ -65990,11 +66030,15 @@ const attributeToDisplayFn = {
65990
66030
  return null;
65991
66031
  if (isEncryptedMarker(value))
65992
66032
  return jsxRuntimeExports.jsx(EncryptedFieldBlock, {});
66033
+ if (isExpiredMarker(value))
66034
+ return jsxRuntimeExports.jsx(ExpiredFieldBlock, {});
65993
66035
  return JsonBlock(value);
65994
66036
  },
65995
66037
  input: (value, context) => {
65996
66038
  if (isEncryptedMarker(value))
65997
66039
  return jsxRuntimeExports.jsx(EncryptedFieldBlock, {});
66040
+ if (isExpiredMarker(value))
66041
+ return jsxRuntimeExports.jsx(ExpiredFieldBlock, {});
65998
66042
  if (value && typeof value === "object" && "args" in value) {
65999
66043
  const { args, closureVars, thisVal } = value;
66000
66044
  const argCount2 = Array.isArray(args) ? args.length : 0;
@@ -66025,11 +66069,15 @@ const attributeToDisplayFn = {
66025
66069
  return null;
66026
66070
  if (isEncryptedMarker(value))
66027
66071
  return jsxRuntimeExports.jsx(EncryptedFieldBlock, {});
66072
+ if (isExpiredMarker(value))
66073
+ return jsxRuntimeExports.jsx(ExpiredFieldBlock, {});
66028
66074
  return jsxRuntimeExports.jsx(DetailCard, { summary: "Output", summaryClassName: "text-base py-2", contentClassName: "mt-0", children: JsonBlock(value) });
66029
66075
  },
66030
66076
  error: (value) => {
66031
66077
  if (isEncryptedMarker(value))
66032
66078
  return jsxRuntimeExports.jsx(EncryptedFieldBlock, {});
66079
+ if (isExpiredMarker(value))
66080
+ return jsxRuntimeExports.jsx(ExpiredFieldBlock, {});
66033
66081
  if (!hasDisplayContent(value))
66034
66082
  return null;
66035
66083
  if (isStructuredErrorWithStack(value)) {
@@ -66040,6 +66088,8 @@ const attributeToDisplayFn = {
66040
66088
  eventData: (value) => {
66041
66089
  if (isEncryptedMarker(value))
66042
66090
  return jsxRuntimeExports.jsx(EncryptedFieldBlock, {});
66091
+ if (isExpiredMarker(value))
66092
+ return jsxRuntimeExports.jsx(ExpiredFieldBlock, {});
66043
66093
  if (!hasDisplayContent(value))
66044
66094
  return null;
66045
66095
  return jsxRuntimeExports.jsx(DetailCard, { summary: "Event Data", children: JsonBlock(value) });
@@ -66059,7 +66109,7 @@ const ExpiredDataMessage = () => jsxRuntimeExports.jsx("div", { className: "text
66059
66109
  }, children: jsxRuntimeExports.jsx("span", { children: "The data for this run has expired and is no longer available." }) });
66060
66110
  const AttributeBlock = ({ attribute, value, isLoading, inline = false, context }) => {
66061
66111
  const isExpandableLoadingTarget = attribute === "input" || attribute === "output" || attribute === "eventData";
66062
- if (isLoading && isExpandableLoadingTarget) {
66112
+ if (isLoading && isExpandableLoadingTarget && !hasDisplayContent(value)) {
66063
66113
  return jsxRuntimeExports.jsxs("div", { className: `my-2 flex flex-col ${attribute === "input" || attribute === "output" ? "gap-2 my-3.5" : "gap-0"}`, children: [jsxRuntimeExports.jsx("span", { className: `${attribute === "input" || attribute === "output" ? "text-base" : "text-xs"} font-medium first-letter:uppercase`, style: { color: "var(--ds-gray-700)" }, children: attribute }), jsxRuntimeExports.jsx(Skeleton$2, { className: "h-9 w-full rounded-md" })] });
66064
66114
  }
66065
66115
  const displayFn = attributeToDisplayFn[attribute];
@@ -66220,7 +66270,23 @@ function EventItem({ event, onLoadEventData, encryptionKey }) {
66220
66270
  borderColor: "var(--ds-gray-300)"
66221
66271
  }, children: [jsxRuntimeExports.jsx(Skeleton$2, { className: "h-4 w-[35%]" }), jsxRuntimeExports.jsx(Skeleton$2, { className: "mt-2 h-4 w-[90%]" }), jsxRuntimeExports.jsx(Skeleton$2, { className: "mt-2 h-4 w-[75%]" })] }), loadError && jsxRuntimeExports.jsx(ErrorCard, { title: "Failed to load event data", details: loadError, className: "mt-2" }), displayData != null && jsxRuntimeExports.jsx("div", { className: "mt-2", children: jsxRuntimeExports.jsx(EventDataBlock, { eventType: event.eventType, data: displayData }) })] });
66222
66272
  }
66273
+ function hasOnlyExpiredFields(data) {
66274
+ if (data === null || typeof data !== "object" || Array.isArray(data)) {
66275
+ return false;
66276
+ }
66277
+ const record2 = data;
66278
+ const serializedKeys = ["result", "input", "output", "metadata", "payload"];
66279
+ const presentKeys = serializedKeys.filter((k2) => k2 in record2);
66280
+ return presentKeys.length > 0 && presentKeys.every((k2) => isExpiredMarker(record2[k2]));
66281
+ }
66223
66282
  function EventDataBlock({ eventType, data }) {
66283
+ if (isExpiredMarker(data) || hasOnlyExpiredFields(data)) {
66284
+ return jsxRuntimeExports.jsx("div", { className: "flex items-center gap-1.5 rounded-md border px-3 py-2 text-xs", style: {
66285
+ borderColor: "var(--ds-gray-300)",
66286
+ backgroundColor: "var(--ds-gray-100)",
66287
+ color: "var(--ds-gray-700)"
66288
+ }, children: jsxRuntimeExports.jsx("span", { className: "font-medium", children: "Data expired" }) });
66289
+ }
66224
66290
  if (ERROR_EVENT_TYPES.has(eventType) && data != null && typeof data === "object") {
66225
66291
  const record2 = data;
66226
66292
  if (isStructuredErrorWithStack(record2.error)) {
@@ -67065,8 +67131,7 @@ function formatWallClockTime(epochMs) {
67065
67131
  const h2 = String(d2.getHours()).padStart(2, "0");
67066
67132
  const m2 = String(d2.getMinutes()).padStart(2, "0");
67067
67133
  const s2 = String(d2.getSeconds()).padStart(2, "0");
67068
- const ms2 = String(d2.getMilliseconds()).padStart(3, "0");
67069
- return `${h2}:${m2}:${s2}.${ms2}`;
67134
+ return `${h2}:${m2}:${s2}`;
67070
67135
  }
67071
67136
  const SEGMENT_CLASS_MAP = {
67072
67137
  queued: "segQueued",
@@ -73762,6 +73827,9 @@ const BASE_URL = "https://useworkflow.dev/err";
73762
73827
  function isError(value) {
73763
73828
  return typeof value === "object" && value !== null && "name" in value && "message" in value;
73764
73829
  }
73830
+ const ERROR_SLUGS = {
73831
+ STEP_NOT_REGISTERED: "step-not-registered"
73832
+ };
73765
73833
  class WorkflowError extends Error {
73766
73834
  constructor(message2, options) {
73767
73835
  const msgDocs = (options == null ? void 0 : options.slug) ? `${message2}
@@ -73779,7 +73847,7 @@ Caused by: ${options.cause.stack}`;
73779
73847
  return isError(value) && value.name === "WorkflowError";
73780
73848
  }
73781
73849
  }
73782
- class WorkflowAPIError extends WorkflowError {
73850
+ class WorkflowWorldError extends WorkflowError {
73783
73851
  constructor(message2, options) {
73784
73852
  super(message2, {
73785
73853
  cause: options == null ? void 0 : options.cause
@@ -73787,16 +73855,16 @@ class WorkflowAPIError extends WorkflowError {
73787
73855
  __publicField(this, "status");
73788
73856
  __publicField(this, "code");
73789
73857
  __publicField(this, "url");
73790
- /** Retry-After value in seconds, present on 429 responses */
73858
+ /** Retry-After value in seconds, present on 429 and 425 responses */
73791
73859
  __publicField(this, "retryAfter");
73792
- this.name = "WorkflowAPIError";
73860
+ this.name = "WorkflowWorldError";
73793
73861
  this.status = options == null ? void 0 : options.status;
73794
73862
  this.code = options == null ? void 0 : options.code;
73795
73863
  this.url = options == null ? void 0 : options.url;
73796
73864
  this.retryAfter = options == null ? void 0 : options.retryAfter;
73797
73865
  }
73798
73866
  static is(value) {
73799
- return isError(value) && value.name === "WorkflowAPIError";
73867
+ return isError(value) && value.name === "WorkflowWorldError";
73800
73868
  }
73801
73869
  }
73802
73870
  class WorkflowRunFailedError extends WorkflowError {
@@ -73843,6 +73911,17 @@ class WorkflowRuntimeError extends WorkflowError {
73843
73911
  return isError(value) && value.name === "WorkflowRuntimeError";
73844
73912
  }
73845
73913
  }
73914
+ class StepNotRegisteredError extends WorkflowRuntimeError {
73915
+ constructor(stepName) {
73916
+ super(`Step "${stepName}" is not registered in the current deployment. This usually indicates a build or bundling issue that caused the step to not be included in the deployment.`, { slug: ERROR_SLUGS.STEP_NOT_REGISTERED });
73917
+ __publicField(this, "stepName");
73918
+ this.name = "StepNotRegisteredError";
73919
+ this.stepName = stepName;
73920
+ }
73921
+ static is(value) {
73922
+ return isError(value) && value.name === "StepNotRegisteredError";
73923
+ }
73924
+ }
73846
73925
  class WorkflowRunNotFoundError extends WorkflowError {
73847
73926
  constructor(runId) {
73848
73927
  super(`Workflow run "${runId}" not found`, {});
@@ -73865,6 +73944,44 @@ class HookNotFoundError extends WorkflowError {
73865
73944
  return isError(value) && value.name === "HookNotFoundError";
73866
73945
  }
73867
73946
  }
73947
+ class EntityConflictError extends WorkflowWorldError {
73948
+ constructor(message2) {
73949
+ super(message2);
73950
+ this.name = "EntityConflictError";
73951
+ }
73952
+ static is(value) {
73953
+ return isError(value) && value.name === "EntityConflictError";
73954
+ }
73955
+ }
73956
+ class RunExpiredError extends WorkflowWorldError {
73957
+ constructor(message2) {
73958
+ super(message2);
73959
+ this.name = "RunExpiredError";
73960
+ }
73961
+ static is(value) {
73962
+ return isError(value) && value.name === "RunExpiredError";
73963
+ }
73964
+ }
73965
+ class TooEarlyError extends WorkflowWorldError {
73966
+ constructor(message2, options) {
73967
+ super(message2, { retryAfter: options == null ? void 0 : options.retryAfter });
73968
+ this.name = "TooEarlyError";
73969
+ }
73970
+ static is(value) {
73971
+ return isError(value) && value.name === "TooEarlyError";
73972
+ }
73973
+ }
73974
+ class ThrottleError extends WorkflowWorldError {
73975
+ constructor(message2, options) {
73976
+ super(message2);
73977
+ __publicField(this, "retryAfter");
73978
+ this.name = "ThrottleError";
73979
+ this.retryAfter = options == null ? void 0 : options.retryAfter;
73980
+ }
73981
+ static is(value) {
73982
+ return isError(value) && value.name === "ThrottleError";
73983
+ }
73984
+ }
73868
73985
  class WorkflowRunCancelledError extends WorkflowError {
73869
73986
  constructor(runId) {
73870
73987
  super(`Workflow run "${runId}" cancelled`, {});
@@ -73918,6 +74035,7 @@ class RetryableError extends Error {
73918
74035
  }
73919
74036
  }
73920
74037
  const VERCEL_403_ERROR_MESSAGE = "Your current vercel account does not have access to this resource. Use `vercel login` or `vercel switch` to ensure you are linked to the right account.";
74038
+ const MAX_QUEUE_DELIVERIES = 48;
73921
74039
  const NEVER = Object.freeze({
73922
74040
  status: "aborted"
73923
74041
  });
@@ -87856,7 +87974,7 @@ const StructuredErrorSchema = object$1({
87856
87974
  message: string$1(),
87857
87975
  stack: string$1().optional(),
87858
87976
  code: string$1().optional()
87859
- // TODO: currently unused. make this an enum maybe
87977
+ // Populated with RunErrorCode values (USER_ERROR, RUNTIME_ERROR) for run_failed events
87860
87978
  });
87861
87979
  const WorkflowRunStatusSchema = _enum([
87862
87980
  "pending",
@@ -87869,6 +87987,26 @@ const WorkflowRunBaseSchema = object$1({
87869
87987
  runId: string$1(),
87870
87988
  status: WorkflowRunStatusSchema,
87871
87989
  deploymentId: string$1(),
87990
+ /**
87991
+ * The machine-readable name of the workflow function.
87992
+ *
87993
+ * This field contains a structured identifier like `workflow//./src/workflows/order//processOrder`
87994
+ * that encodes the workflow's module specifier and function name.
87995
+ *
87996
+ * Use `parseWorkflowName()` from `@workflow/utils/parse-name` to extract:
87997
+ * - `shortName`: User-friendly display name (e.g., `"processOrder"`)
87998
+ * - `moduleSpecifier`: The module path or package (e.g., `"./src/workflows/order"`)
87999
+ * - `functionName`: The full function path (e.g., `"processOrder"`)
88000
+ *
88001
+ * @example
88002
+ * ```ts
88003
+ * import { parseWorkflowName } from "@workflow/utils/parse-name";
88004
+ *
88005
+ * const parsed = parseWorkflowName(run.workflowName);
88006
+ * // parsed.shortName → "processOrder"
88007
+ * // parsed.moduleSpecifier → "./src/workflows/order"
88008
+ * ```
88009
+ */
87872
88010
  workflowName: string$1(),
87873
88011
  // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
87874
88012
  specVersion: number$1().optional(),
@@ -87934,6 +88072,26 @@ const StepStatusSchema = _enum([
87934
88072
  const StepSchema = object$1({
87935
88073
  runId: string$1(),
87936
88074
  stepId: string$1(),
88075
+ /**
88076
+ * The machine-readable name of the step function.
88077
+ *
88078
+ * This field contains a structured identifier like `step//./src/workflows/order//processPayment`
88079
+ * that encodes the step's module specifier and function name.
88080
+ *
88081
+ * Use `parseStepName()` from `@workflow/utils/parse-name` to extract:
88082
+ * - `shortName`: User-friendly display name (e.g., `"processPayment"`)
88083
+ * - `moduleSpecifier`: The module path or package (e.g., `"./src/workflows/order"`)
88084
+ * - `functionName`: The full function path (e.g., `"processPayment"` or `"outer/nested"`)
88085
+ *
88086
+ * @example
88087
+ * ```ts
88088
+ * import { parseStepName } from "@workflow/utils/parse-name";
88089
+ *
88090
+ * const parsed = parseStepName(step.stepName);
88091
+ * // parsed.shortName → "processPayment"
88092
+ * // parsed.moduleSpecifier → "./src/workflows/order"
88093
+ * ```
88094
+ */
87937
88095
  stepName: string$1(),
87938
88096
  status: StepStatusSchema,
87939
88097
  input: SerializedDataSchema,
@@ -87957,17 +88115,6 @@ const StepSchema = object$1({
87957
88115
  // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
87958
88116
  specVersion: number$1().optional()
87959
88117
  });
87960
- const WaitStatusSchema = _enum(["waiting", "completed"]);
87961
- const WaitSchema = object$1({
87962
- waitId: string$1(),
87963
- runId: string$1(),
87964
- status: WaitStatusSchema,
87965
- resumeAt: date$2().optional(),
87966
- completedAt: date$2().optional(),
87967
- createdAt: date$2(),
87968
- updatedAt: date$2(),
87969
- specVersion: number$1().optional()
87970
- });
87971
88118
  const ENCODING = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
87972
88119
  const ENCODING_LEN = 32;
87973
88120
  const RANDOM_LEN = 16;
@@ -88136,6 +88283,17 @@ function validateUlidTimestamp(prefixedUlid, prefix, thresholdMs = DEFAULT_TIMES
88136
88283
  const thresholdSeconds = Math.round(thresholdMs / 1e3);
88137
88284
  return `Invalid runId timestamp: embedded timestamp differs from server time by ${driftSeconds}s (threshold: ${thresholdSeconds}s)`;
88138
88285
  }
88286
+ const WaitStatusSchema = _enum(["waiting", "completed"]);
88287
+ const WaitSchema = object$1({
88288
+ waitId: string$1(),
88289
+ runId: string$1(),
88290
+ status: WaitStatusSchema,
88291
+ resumeAt: date$2().optional(),
88292
+ completedAt: date$2().optional(),
88293
+ createdAt: date$2(),
88294
+ updatedAt: date$2(),
88295
+ specVersion: number$1().optional()
88296
+ });
88139
88297
  const NONCE_LENGTH = 12;
88140
88298
  const TAG_LENGTH = 128;
88141
88299
  const KEY_LENGTH = 32;
@@ -89426,12 +89584,12 @@ async function writeJSON(filePath, data, opts) {
89426
89584
  async function write(filePath, data, opts) {
89427
89585
  if (!(opts == null ? void 0 : opts.overwrite)) {
89428
89586
  if (createdFilesCache.has(filePath)) {
89429
- throw new WorkflowAPIError(`File ${filePath} already exists and 'overwrite' is false`, { status: 409 });
89587
+ throw new EntityConflictError(`File ${filePath} already exists and 'overwrite' is false`);
89430
89588
  }
89431
89589
  try {
89432
89590
  await promises.access(filePath);
89433
89591
  createdFilesCache.add(filePath);
89434
- throw new WorkflowAPIError(`File ${filePath} already exists and 'overwrite' is false`, { status: 409 });
89592
+ throw new EntityConflictError(`File ${filePath} already exists and 'overwrite' is false`);
89435
89593
  } catch (error2) {
89436
89594
  if (error2.code !== "ENOENT") {
89437
89595
  throw error2;
@@ -92211,8 +92369,8 @@ function requireGetVercelOidcToken() {
92211
92369
  }
92212
92370
  try {
92213
92371
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
92214
- await import("./token-util-C8FlMBAQ.js").then((n) => n.t),
92215
- await import("./token-Bf2BqxEG.js").then((n) => n.t)
92372
+ await import("./token-util-CxDoe-ao.js").then((n) => n.t),
92373
+ await import("./token-C7BfiMAN.js").then((n) => n.t)
92216
92374
  ]);
92217
92375
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
92218
92376
  await refreshToken(options);
@@ -107826,7 +107984,7 @@ function requireSnapshotRecorder() {
107826
107984
  var _flushTimeout, _isUrlExcluded, _snapshots, _snapshotPath, _maxSnapshots, _autoFlush, _headerFilters, _SnapshotRecorder_instances, startAutoFlush_fn, stopAutoFlush_fn, scheduleFlush_fn;
107827
107985
  if (hasRequiredSnapshotRecorder) return snapshotRecorder;
107828
107986
  hasRequiredSnapshotRecorder = 1;
107829
- const { writeFile: writeFile2, readFile: readFile2, mkdir: mkdir2 } = require$$0$8;
107987
+ const { writeFile: writeFile2, readFile: readFile2, mkdir: mkdir2 } = fs$1;
107830
107988
  const { dirname: dirname2, resolve: resolve2 } = path$3;
107831
107989
  const { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = require$$2$3;
107832
107990
  const { InvalidArgumentError, UndiciError } = requireErrors();
@@ -119058,6 +119216,9 @@ function createQueue$2(config2) {
119058
119216
  const body2 = transport.serialize(message2);
119059
119217
  const { pathname, prefix } = getQueueRoute(queueName);
119060
119218
  const messageId = MessageId.parse(`msg_${generateId2()}`);
119219
+ const msg = message2;
119220
+ const runId = msg.runId ?? msg.workflowRunId ?? void 0;
119221
+ const stepId = msg.stepId ?? void 0;
119061
119222
  if (opts == null ? void 0 : opts.idempotencyKey) {
119062
119223
  const key = opts.idempotencyKey;
119063
119224
  inflightMessages.set(key, messageId);
@@ -119071,10 +119232,9 @@ function createQueue$2(config2) {
119071
119232
  console.warn(`[world-local]: concurrency limit (${WORKFLOW_LOCAL_QUEUE_CONCURRENCY}) reached, waiting for queue to free up`);
119072
119233
  await semaphore.acquire();
119073
119234
  }
119235
+ const MAX_LOCAL_SAFETY_LIMIT = 256;
119074
119236
  try {
119075
- let defaultRetriesLeft = 3;
119076
- for (let attempt = 0; defaultRetriesLeft > 0; attempt++) {
119077
- defaultRetriesLeft--;
119237
+ for (let attempt = 0; attempt < MAX_LOCAL_SAFETY_LIMIT; attempt++) {
119078
119238
  const headers2 = {
119079
119239
  ...opts == null ? void 0 : opts.headers,
119080
119240
  "content-type": "application/json",
@@ -119110,22 +119270,27 @@ function createQueue$2(config2) {
119110
119270
  const timeoutMs = Math.min(timeoutSeconds * 1e3, MAX_SAFE_TIMEOUT_MS);
119111
119271
  await setTimeout$1(timeoutMs);
119112
119272
  }
119113
- defaultRetriesLeft++;
119114
119273
  continue;
119115
119274
  }
119116
119275
  } catch {
119117
119276
  }
119118
119277
  return;
119119
119278
  }
119120
- console.error(`[local world] Failed to queue message`, {
119279
+ console.error(`[world-local] Queue message failed (attempt ${attempt + 1}, HTTP ${response2.status})`, {
119121
119280
  queueName,
119122
- text: text2,
119123
- status: response2.status,
119124
- headers: Object.fromEntries(response2.headers.entries()),
119125
- body: body2.toString()
119281
+ messageId,
119282
+ ...runId && { runId },
119283
+ ...stepId && { stepId },
119284
+ handlerError: text2
119126
119285
  });
119286
+ await setTimeout$1(5e3);
119127
119287
  }
119128
- console.error(`[local world] Reached max retries of local world queue implementation`);
119288
+ console.error(`[world-local] Queue message exhausted safety limit (${MAX_LOCAL_SAFETY_LIMIT} attempts)`, {
119289
+ queueName,
119290
+ messageId,
119291
+ ...runId && { runId },
119292
+ ...stepId && { stepId }
119293
+ });
119129
119294
  } finally {
119130
119295
  semaphore.release();
119131
119296
  }
@@ -119480,12 +119645,12 @@ function createEventsStorage(basedir, tag) {
119480
119645
  if (data.eventType === "run_created" && runId && runId !== "") {
119481
119646
  const validationError = validateUlidTimestamp(effectiveRunId, "wrun_");
119482
119647
  if (validationError) {
119483
- throw new WorkflowAPIError(validationError, { status: 400 });
119648
+ throw new WorkflowWorldError(validationError);
119484
119649
  }
119485
119650
  }
119486
119651
  const effectiveSpecVersion = data.specVersion ?? SPEC_VERSION_CURRENT;
119487
119652
  const isRunTerminal = (status) => ["completed", "failed", "cancelled"].includes(status);
119488
- const isStepTerminal = (status) => ["completed", "failed"].includes(status);
119653
+ const isStepTerminal = (status) => ["completed", "failed", "cancelled"].includes(status);
119489
119654
  let currentRun = null;
119490
119655
  const skipRunValidationEvents = ["step_completed", "step_retrying"];
119491
119656
  if (data.eventType !== "run_created" && !skipRunValidationEvents.includes(data.eventType)) {
@@ -119522,10 +119687,10 @@ function createEventsStorage(basedir, tag) {
119522
119687
  };
119523
119688
  }
119524
119689
  if (runTerminalEvents.includes(data.eventType) || data.eventType === "run_cancelled") {
119525
- throw new WorkflowAPIError(`Cannot transition run from terminal state "${currentRun.status}"`, { status: 409 });
119690
+ throw new EntityConflictError(`Cannot transition run from terminal state "${currentRun.status}"`);
119526
119691
  }
119527
119692
  if (data.eventType === "step_created" || data.eventType === "hook_created" || data.eventType === "wait_created") {
119528
- throw new WorkflowAPIError(`Cannot create new entities on run in terminal state "${currentRun.status}"`, { status: 409 });
119693
+ throw new EntityConflictError(`Cannot create new entities on run in terminal state "${currentRun.status}"`);
119529
119694
  }
119530
119695
  }
119531
119696
  let validatedStep = null;
@@ -119539,26 +119704,22 @@ function createEventsStorage(basedir, tag) {
119539
119704
  const stepCompositeKey = `${effectiveRunId}-${data.correlationId}`;
119540
119705
  validatedStep = await readJSONWithFallback(basedir, "steps", stepCompositeKey, StepSchema, tag);
119541
119706
  if (!validatedStep) {
119542
- throw new WorkflowAPIError(`Step "${data.correlationId}" not found`, {
119543
- status: 404
119544
- });
119707
+ throw new WorkflowWorldError(`Step "${data.correlationId}" not found`);
119545
119708
  }
119546
119709
  if (isStepTerminal(validatedStep.status)) {
119547
- throw new WorkflowAPIError(`Cannot modify step in terminal state "${validatedStep.status}"`, { status: 409 });
119710
+ throw new EntityConflictError(`Cannot modify step in terminal state "${validatedStep.status}"`);
119548
119711
  }
119549
119712
  if (currentRun && isRunTerminal(currentRun.status)) {
119550
119713
  if (validatedStep.status !== "running") {
119551
- throw new WorkflowAPIError(`Cannot modify non-running step on run in terminal state "${currentRun.status}"`, { status: 410 });
119714
+ throw new RunExpiredError(`Cannot modify non-running step on run in terminal state "${currentRun.status}"`);
119552
119715
  }
119553
119716
  }
119554
119717
  }
119555
- const hookEventsRequiringExistence = ["hook_disposed", "hook_received"];
119556
- if (hookEventsRequiringExistence.includes(data.eventType) && data.correlationId) {
119718
+ const hookEventsRequiringExistence2 = ["hook_disposed", "hook_received"];
119719
+ if (hookEventsRequiringExistence2.includes(data.eventType) && data.correlationId) {
119557
119720
  const existingHook = await readJSONWithFallback(basedir, "hooks", data.correlationId, HookSchema, tag);
119558
119721
  if (!existingHook) {
119559
- throw new WorkflowAPIError(`Hook "${data.correlationId}" not found`, {
119560
- status: 404
119561
- });
119722
+ throw new HookNotFoundError(data.correlationId);
119562
119723
  }
119563
119724
  }
119564
119725
  const event = {
@@ -119715,14 +119876,15 @@ function createEventsStorage(basedir, tag) {
119715
119876
  } else if (data.eventType === "step_started") {
119716
119877
  if (validatedStep) {
119717
119878
  if (validatedStep.retryAfter && validatedStep.retryAfter.getTime() > Date.now()) {
119718
- const err = new WorkflowAPIError(`Cannot start step "${data.correlationId}": retryAfter timestamp has not been reached yet`, { status: 425 });
119719
- err.meta = {
119720
- stepId: data.correlationId,
119721
- retryAfter: validatedStep.retryAfter.toISOString()
119722
- };
119723
- throw err;
119879
+ throw new TooEarlyError(`Cannot start step "${data.correlationId}": retryAfter timestamp has not been reached yet`, {
119880
+ retryAfter: Math.ceil((validatedStep.retryAfter.getTime() - Date.now()) / 1e3)
119881
+ });
119724
119882
  }
119725
119883
  const stepCompositeKey = `${effectiveRunId}-${data.correlationId}`;
119884
+ const freshStep = await readJSONWithFallback(basedir, "steps", stepCompositeKey, StepSchema, tag);
119885
+ if (freshStep && isStepTerminal(freshStep.status)) {
119886
+ throw new EntityConflictError(`Cannot modify step in terminal state "${freshStep.status}"`);
119887
+ }
119726
119888
  step = {
119727
119889
  ...validatedStep,
119728
119890
  status: "running",
@@ -119740,6 +119902,12 @@ function createEventsStorage(basedir, tag) {
119740
119902
  const completedData = data.eventData;
119741
119903
  if (validatedStep) {
119742
119904
  const stepCompositeKey = `${effectiveRunId}-${data.correlationId}`;
119905
+ const lockName = tag ? `${stepCompositeKey}.terminal.${tag}` : `${stepCompositeKey}.terminal`;
119906
+ const terminalLockPath = path$3.join(basedir, ".locks", "steps", lockName);
119907
+ const claimed = await writeExclusive(terminalLockPath, "");
119908
+ if (!claimed) {
119909
+ throw new EntityConflictError("Cannot modify step in terminal state");
119910
+ }
119743
119911
  step = {
119744
119912
  ...validatedStep,
119745
119913
  status: "completed",
@@ -119753,6 +119921,12 @@ function createEventsStorage(basedir, tag) {
119753
119921
  const failedData = data.eventData;
119754
119922
  if (validatedStep) {
119755
119923
  const stepCompositeKey = `${effectiveRunId}-${data.correlationId}`;
119924
+ const lockName = tag ? `${stepCompositeKey}.terminal.${tag}` : `${stepCompositeKey}.terminal`;
119925
+ const terminalLockPath = path$3.join(basedir, ".locks", "steps", lockName);
119926
+ const claimed = await writeExclusive(terminalLockPath, "");
119927
+ if (!claimed) {
119928
+ throw new EntityConflictError("Cannot modify step in terminal state");
119929
+ }
119756
119930
  const error2 = {
119757
119931
  message: typeof failedData.error === "string" ? failedData.error : ((_c = failedData.error) == null ? void 0 : _c.message) ?? "Unknown error",
119758
119932
  stack: failedData.stack
@@ -119843,7 +120017,7 @@ function createEventsStorage(basedir, tag) {
119843
120017
  const waitCompositeKey = `${effectiveRunId}-${data.correlationId}`;
119844
120018
  const existingWait = await readJSONWithFallback(basedir, "waits", waitCompositeKey, WaitSchema, tag);
119845
120019
  if (existingWait) {
119846
- throw new WorkflowAPIError(`Wait "${data.correlationId}" already exists`, { status: 409 });
120020
+ throw new EntityConflictError(`Wait "${data.correlationId}" already exists`);
119847
120021
  }
119848
120022
  wait = {
119849
120023
  waitId: waitCompositeKey,
@@ -119858,14 +120032,17 @@ function createEventsStorage(basedir, tag) {
119858
120032
  await writeJSON(taggedPath(basedir, "waits", waitCompositeKey, tag), wait);
119859
120033
  } else if (data.eventType === "wait_completed") {
119860
120034
  const waitCompositeKey = `${effectiveRunId}-${data.correlationId}`;
120035
+ const waitLockName = tag ? `${waitCompositeKey}.completed.${tag}` : `${waitCompositeKey}.completed`;
120036
+ const lockPath = path$3.join(basedir, ".locks", "waits", waitLockName);
120037
+ const claimed = await writeExclusive(lockPath, "");
120038
+ if (!claimed) {
120039
+ throw new EntityConflictError(`Wait "${data.correlationId}" already completed`);
120040
+ }
119861
120041
  const existingWait = await readJSONWithFallback(basedir, "waits", waitCompositeKey, WaitSchema, tag);
119862
120042
  if (!existingWait) {
119863
- throw new WorkflowAPIError(`Wait "${data.correlationId}" not found`, {
119864
- status: 404
120043
+ await fs$1.unlink(lockPath).catch(() => {
119865
120044
  });
119866
- }
119867
- if (existingWait.status === "completed") {
119868
- throw new WorkflowAPIError(`Wait "${data.correlationId}" already completed`, { status: 409 });
120045
+ throw new WorkflowWorldError(`Wait "${data.correlationId}" not found`);
119869
120046
  }
119870
120047
  wait = {
119871
120048
  ...existingWait,
@@ -120060,6 +120237,9 @@ function serializeChunk(chunk) {
120060
120237
  const eofByte = Buffer.from([chunk.eof ? 1 : 0]);
120061
120238
  return Buffer.concat([eofByte, chunk.chunk]);
120062
120239
  }
120240
+ function isEofChunk(serialized) {
120241
+ return serialized[0] === 1;
120242
+ }
120063
120243
  function deserializeChunk(serialized) {
120064
120244
  const eof = serialized[0] === 1;
120065
120245
  const chunk = Buffer.from(serialized.subarray(1));
@@ -120152,6 +120332,117 @@ function createStreamer$1(basedir, tag) {
120152
120332
  const data = await readJSONWithFallback(basedir, "streams/runs", runId, RunStreamsSchema, tag);
120153
120333
  return (data == null ? void 0 : data.streams) ?? [];
120154
120334
  },
120335
+ async getStreamChunks(name2, _runId, options) {
120336
+ const limit = (options == null ? void 0 : options.limit) ?? 100;
120337
+ const chunksDir = path$3.join(basedir, "streams", "chunks");
120338
+ const listPromises = [
120339
+ listFilesByExtension(chunksDir, ".bin"),
120340
+ listFilesByExtension(chunksDir, ".json")
120341
+ ];
120342
+ if (tag) {
120343
+ listPromises.push(listFilesByExtension(chunksDir, `.${tag}.bin`));
120344
+ }
120345
+ const [binFiles, jsonFiles, ...taggedResults] = await Promise.all(listPromises);
120346
+ const taggedBinFiles = taggedResults[0] ?? [];
120347
+ const fileExtMap = /* @__PURE__ */ new Map();
120348
+ for (const f2 of jsonFiles)
120349
+ fileExtMap.set(f2, ".json");
120350
+ const tagSfx = tag ? `.${tag}` : "";
120351
+ for (const f2 of binFiles) {
120352
+ if (tag && f2.endsWith(tagSfx))
120353
+ continue;
120354
+ fileExtMap.set(f2, ".bin");
120355
+ }
120356
+ for (const f2 of taggedBinFiles)
120357
+ fileExtMap.set(f2, `.${tag}.bin`);
120358
+ const chunkFiles = [...fileExtMap.keys()].filter((file2) => file2.startsWith(`${name2}-`)).sort();
120359
+ let startIndex = 0;
120360
+ if (options == null ? void 0 : options.cursor) {
120361
+ try {
120362
+ const decoded = JSON.parse(Buffer.from(options.cursor, "base64").toString("utf-8"));
120363
+ startIndex = decoded.i;
120364
+ } catch {
120365
+ startIndex = 0;
120366
+ }
120367
+ }
120368
+ let streamDone = false;
120369
+ const resultChunks = [];
120370
+ let dataIndex = 0;
120371
+ for (const file2 of chunkFiles) {
120372
+ const ext2 = fileExtMap.get(file2) ?? ".bin";
120373
+ const filePath = path$3.join(chunksDir, `${file2}${ext2}`);
120374
+ if (dataIndex < startIndex) {
120375
+ if (isEofChunk(await readBuffer(filePath))) {
120376
+ streamDone = true;
120377
+ break;
120378
+ }
120379
+ dataIndex++;
120380
+ continue;
120381
+ }
120382
+ if (resultChunks.length >= limit) {
120383
+ if (isEofChunk(await readBuffer(filePath))) {
120384
+ streamDone = true;
120385
+ } else {
120386
+ dataIndex++;
120387
+ }
120388
+ break;
120389
+ }
120390
+ const chunk = deserializeChunk(await readBuffer(filePath));
120391
+ if (chunk.eof) {
120392
+ streamDone = true;
120393
+ break;
120394
+ }
120395
+ resultChunks.push({
120396
+ index: dataIndex,
120397
+ data: Uint8Array.from(chunk.chunk)
120398
+ });
120399
+ dataIndex++;
120400
+ }
120401
+ const hasMore = !streamDone && dataIndex > startIndex + resultChunks.length;
120402
+ const nextIndex = startIndex + resultChunks.length;
120403
+ const nextCursor = hasMore ? Buffer.from(JSON.stringify({ i: nextIndex })).toString("base64") : null;
120404
+ return {
120405
+ data: resultChunks,
120406
+ cursor: nextCursor,
120407
+ hasMore,
120408
+ done: streamDone
120409
+ };
120410
+ },
120411
+ async getStreamInfo(name2, _runId) {
120412
+ const chunksDir = path$3.join(basedir, "streams", "chunks");
120413
+ const listPromises = [
120414
+ listFilesByExtension(chunksDir, ".bin"),
120415
+ listFilesByExtension(chunksDir, ".json")
120416
+ ];
120417
+ if (tag) {
120418
+ listPromises.push(listFilesByExtension(chunksDir, `.${tag}.bin`));
120419
+ }
120420
+ const [binFiles, jsonFiles, ...taggedResults] = await Promise.all(listPromises);
120421
+ const taggedBinFiles = taggedResults[0] ?? [];
120422
+ const fileExtMap = /* @__PURE__ */ new Map();
120423
+ for (const f2 of jsonFiles)
120424
+ fileExtMap.set(f2, ".json");
120425
+ const tagSfx = tag ? `.${tag}` : "";
120426
+ for (const f2 of binFiles) {
120427
+ if (tag && f2.endsWith(tagSfx))
120428
+ continue;
120429
+ fileExtMap.set(f2, ".bin");
120430
+ }
120431
+ for (const f2 of taggedBinFiles)
120432
+ fileExtMap.set(f2, `.${tag}.bin`);
120433
+ const chunkFiles = [...fileExtMap.keys()].filter((file2) => file2.startsWith(`${name2}-`)).sort();
120434
+ let streamDone = false;
120435
+ let dataCount = 0;
120436
+ for (const file2 of chunkFiles) {
120437
+ const ext2 = fileExtMap.get(file2) ?? ".bin";
120438
+ if (isEofChunk(await readBuffer(path$3.join(chunksDir, `${file2}${ext2}`)))) {
120439
+ streamDone = true;
120440
+ break;
120441
+ }
120442
+ dataCount++;
120443
+ }
120444
+ return { tailIndex: dataCount - 1, done: streamDone };
120445
+ },
120155
120446
  async readFromStream(name2, startIndex = 0) {
120156
120447
  const chunksDir = path$3.join(basedir, "streams", "chunks");
120157
120448
  let removeListeners = () => {
@@ -120212,8 +120503,18 @@ function createStreamer$1(basedir, tag) {
120212
120503
  for (const f2 of taggedBinFiles)
120213
120504
  fileExtMap.set(f2, `.${tag}.bin`);
120214
120505
  const chunkFiles = [...fileExtMap.keys()].filter((file2) => file2.startsWith(`${name2}-`)).sort();
120506
+ let dataChunkCount = chunkFiles.length;
120507
+ if (typeof startIndex === "number" && startIndex < 0 && chunkFiles.length > 0) {
120508
+ const lastFile = chunkFiles[chunkFiles.length - 1];
120509
+ const lastExt = fileExtMap.get(lastFile) ?? ".bin";
120510
+ const lastChunk = deserializeChunk(await readBuffer(path$3.join(chunksDir, `${lastFile}${lastExt}`)));
120511
+ if ((lastChunk == null ? void 0 : lastChunk.eof) === true) {
120512
+ dataChunkCount--;
120513
+ }
120514
+ }
120515
+ const resolvedStartIndex = typeof startIndex === "number" && startIndex < 0 ? Math.max(0, dataChunkCount + startIndex) : startIndex;
120215
120516
  let isComplete = false;
120216
- for (let i = startIndex; i < chunkFiles.length; i++) {
120517
+ for (let i = resolvedStartIndex; i < chunkFiles.length; i++) {
120217
120518
  const file2 = chunkFiles[i];
120218
120519
  const rawChunkId = file2.substring(name2.length + 1);
120219
120520
  const chunkId = tag ? rawChunkId.replace(`.${tag}`, "") : rawChunkId;
@@ -120267,7 +120568,7 @@ function createLocalWorld(args) {
120267
120568
  return {
120268
120569
  ...queue,
120269
120570
  ...createStorage$1(mergedConfig.dataDir, tag),
120270
- ...createStreamer$1(mergedConfig.dataDir, tag),
120571
+ ...instrumentObject$1("world.streams", createStreamer$1(mergedConfig.dataDir, tag)),
120271
120572
  async start() {
120272
120573
  await initDataDir(mergedConfig.dataDir);
120273
120574
  },
@@ -120279,7 +120580,7 @@ function createLocalWorld(args) {
120279
120580
  const basedir = mergedConfig.dataDir;
120280
120581
  const hooksDir = path$3.join(basedir, "hooks");
120281
120582
  const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
120282
- const { HookSchema: HookSchema2 } = await import("./index-93Io7SSr.js");
120583
+ const { HookSchema: HookSchema2 } = await import("./index-cxStGfMq.js");
120283
120584
  await Promise.all(taggedHookFiles.map(async (hookFile) => {
120284
120585
  const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
120285
120586
  if (hook == null ? void 0 : hook.token) {
@@ -120299,6 +120600,8 @@ function createLocalWorld(args) {
120299
120600
  const files = await listTaggedFiles(fullDir, tag);
120300
120601
  await Promise.all(files.map((f2) => deleteJSON(path$3.join(fullDir, f2))));
120301
120602
  }));
120603
+ await promises.rm(path$3.join(basedir, ".locks"), { recursive: true, force: true }).catch(() => {
120604
+ });
120302
120605
  const chunksDir = path$3.join(basedir, "streams", "chunks");
120303
120606
  const taggedBinFiles = await listTaggedFilesByExtension(chunksDir, tag, ".bin");
120304
120607
  await Promise.all(taggedBinFiles.map((f2) => promises.unlink(path$3.join(chunksDir, f2)).catch(() => {
@@ -120482,10 +120785,60 @@ const PeerService = SemanticConvention("peer.service");
120482
120785
  const RpcSystem = SemanticConvention("rpc.system");
120483
120786
  const RpcService = SemanticConvention("rpc.service");
120484
120787
  const RpcMethod = SemanticConvention("rpc.method");
120485
- const version$1 = "4.1.0-beta.44";
120788
+ const WORKFLOW_SERVER_SERVICE = {
120789
+ peerService: "workflow-server",
120790
+ rpcSystem: "http",
120791
+ rpcService: "workflow-server"
120792
+ };
120793
+ function extractEventType(args) {
120794
+ if (args.length >= 2 && typeof args[1] === "object" && args[1] !== null) {
120795
+ const data = args[1];
120796
+ if (typeof data.eventType === "string") {
120797
+ return data.eventType;
120798
+ }
120799
+ }
120800
+ return void 0;
120801
+ }
120802
+ function instrumentObject(prefix, o) {
120803
+ const handlers2 = {};
120804
+ for (const key of Object.keys(o)) {
120805
+ if (typeof o[key] !== "function") {
120806
+ handlers2[key] = o[key];
120807
+ } else {
120808
+ const f2 = o[key];
120809
+ const methodName = String(key);
120810
+ handlers2[key] = async (...args) => {
120811
+ let spanName2 = `${prefix}.${methodName}`;
120812
+ if (prefix === "world.events" && methodName === "create") {
120813
+ const eventType = extractEventType(args);
120814
+ if (eventType) {
120815
+ spanName2 = `${prefix}.${methodName} ${eventType}`;
120816
+ }
120817
+ }
120818
+ return trace(spanName2, { kind: await getSpanKind("CLIENT") }, async (span) => {
120819
+ span == null ? void 0 : span.setAttributes({
120820
+ ...PeerService(WORKFLOW_SERVER_SERVICE.peerService),
120821
+ ...RpcSystem(WORKFLOW_SERVER_SERVICE.rpcSystem),
120822
+ ...RpcService(WORKFLOW_SERVER_SERVICE.rpcService),
120823
+ ...RpcMethod(spanName2)
120824
+ });
120825
+ return f2(...args);
120826
+ });
120827
+ };
120828
+ }
120829
+ }
120830
+ return handlers2;
120831
+ }
120832
+ const version$1 = "4.1.0-beta.45";
120833
+ const HTTP_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
120834
+ function httpLog(method, endpoint, status, ms2) {
120835
+ if (HTTP_DEBUG_ENABLED) {
120836
+ console.debug(`[workflow:world-vercel:http] ${method} ${endpoint} -> ${status} (${ms2}ms)`);
120837
+ }
120838
+ }
120486
120839
  const DEFAULT_RESOLVE_DATA_OPTION = "all";
120487
120840
  function deserializeError(obj) {
120488
- const { error: error2, ...rest } = obj;
120841
+ const { error: error2, errorCode, ...rest } = obj;
120489
120842
  if (!error2) {
120490
120843
  return obj;
120491
120844
  }
@@ -120497,7 +120850,7 @@ function deserializeError(obj) {
120497
120850
  error: {
120498
120851
  message: result.data.message,
120499
120852
  stack: result.data.stack,
120500
- code: result.data.code
120853
+ code: errorCode ?? result.data.code
120501
120854
  }
120502
120855
  };
120503
120856
  }
@@ -120510,14 +120863,15 @@ function deserializeError(obj) {
120510
120863
  error: {
120511
120864
  message: parsed.message,
120512
120865
  stack: parsed.stack,
120513
- code: parsed.code
120866
+ code: errorCode ?? parsed.code
120514
120867
  }
120515
120868
  };
120516
120869
  } catch {
120517
120870
  return {
120518
120871
  ...rest,
120519
120872
  error: {
120520
- message: error2
120873
+ message: error2,
120874
+ code: errorCode
120521
120875
  }
120522
120876
  };
120523
120877
  }
@@ -120577,7 +120931,6 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
120577
120931
  } catch {
120578
120932
  }
120579
120933
  return trace(`http ${method}`, { kind: await getSpanKind("CLIENT") }, async (span) => {
120580
- var _a3;
120581
120934
  span == null ? void 0 : span.setAttributes({
120582
120935
  ...HttpRequestMethod(method),
120583
120936
  ...UrlFull(url2),
@@ -120600,35 +120953,57 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
120600
120953
  body: body2,
120601
120954
  headers: headers2
120602
120955
  });
120956
+ const fetchStart = Date.now();
120603
120957
  const response2 = await fetch(request2, {
120604
120958
  dispatcher: getDispatcher()
120605
120959
  });
120960
+ const fetchMs = Date.now() - fetchStart;
120961
+ httpLog(method, endpoint, response2.status, fetchMs);
120606
120962
  span == null ? void 0 : span.setAttributes({
120607
120963
  ...HttpResponseStatusCode(response2.status)
120608
120964
  });
120609
120965
  if (!response2.ok) {
120610
120966
  const errorData = await parseResponseBody(response2).then((r2) => r2.data).catch(() => ({}));
120611
- if (process.env.DEBUG === "1") {
120612
- const stringifiedHeaders = Array.from(headers2.entries()).map(([key, value]) => `-H "${key}: ${value}"`).join(" ");
120967
+ if (process.env.DEBUG) {
120968
+ const stringifiedHeaders = Array.from(headers2.entries()).filter(([key]) => key.toLowerCase() !== "authorization").map(([key, value]) => `-H "${key}: ${value}"`).join(" ");
120613
120969
  console.error(`Failed to fetch, reproduce with:
120614
120970
  curl -X ${request2.method} ${stringifiedHeaders} "${url2}"`);
120615
120971
  }
120616
120972
  let retryAfter;
120617
- if (response2.status === 429) {
120618
- const retryAfterHeader = response2.headers.get("Retry-After");
120619
- if (retryAfterHeader) {
120620
- const parsed = parseInt(retryAfterHeader, 10);
120621
- if (!Number.isNaN(parsed)) {
120622
- retryAfter = parsed;
120623
- }
120973
+ const retryAfterHeader = response2.headers.get("Retry-After");
120974
+ if (retryAfterHeader) {
120975
+ const parsed = parseInt(retryAfterHeader, 10);
120976
+ if (!Number.isNaN(parsed)) {
120977
+ retryAfter = parsed;
120624
120978
  }
120625
120979
  }
120626
- const error2 = new WorkflowAPIError(errorData.message || `${request2.method} ${endpoint} -> HTTP ${response2.status}: ${response2.statusText}`, { url: url2, status: response2.status, code: errorData.code, retryAfter });
120627
- span == null ? void 0 : span.setAttributes({
120628
- ...ErrorType(errorData.code || `HTTP ${response2.status}`)
120629
- });
120630
- (_a3 = span == null ? void 0 : span.recordException) == null ? void 0 : _a3.call(span, error2);
120631
- throw error2;
120980
+ const defaultMessage = errorData.message || `${request2.method} ${endpoint} -> HTTP ${response2.status}: ${response2.statusText}`;
120981
+ const throwWithTrace = (error2) => {
120982
+ var _a3;
120983
+ span == null ? void 0 : span.setAttributes({
120984
+ ...ErrorType(errorData.code || `HTTP ${response2.status}`)
120985
+ });
120986
+ (_a3 = span == null ? void 0 : span.recordException) == null ? void 0 : _a3.call(span, error2);
120987
+ throw error2;
120988
+ };
120989
+ if (response2.status === 409) {
120990
+ throwWithTrace(new EntityConflictError(defaultMessage));
120991
+ }
120992
+ if (response2.status === 410) {
120993
+ throwWithTrace(new RunExpiredError(defaultMessage));
120994
+ }
120995
+ if (response2.status === 425) {
120996
+ throwWithTrace(new TooEarlyError(defaultMessage, { retryAfter }));
120997
+ }
120998
+ if (response2.status === 429) {
120999
+ throwWithTrace(new ThrottleError(defaultMessage, { retryAfter }));
121000
+ }
121001
+ throwWithTrace(new WorkflowWorldError(defaultMessage, {
121002
+ url: url2,
121003
+ status: response2.status,
121004
+ code: errorData.code,
121005
+ retryAfter
121006
+ }));
120632
121007
  }
120633
121008
  onResponse == null ? void 0 : onResponse(response2);
120634
121009
  let parseResult;
@@ -120644,18 +121019,19 @@ curl -X ${request2.method} ${stringifiedHeaders} "${url2}"`);
120644
121019
  });
120645
121020
  } catch (error2) {
120646
121021
  const contentType = response2.headers.get("Content-Type") || "unknown";
120647
- throw new WorkflowAPIError(`Failed to parse response body for ${request2.method} ${endpoint} (Content-Type: ${contentType}):
121022
+ throw new WorkflowWorldError(`Failed to parse response body for ${request2.method} ${endpoint} (Content-Type: ${contentType}):
120648
121023
 
120649
121024
  ${error2}`, { url: url2, cause: error2 });
120650
121025
  }
120651
121026
  const result = await trace("world.validate", async () => {
120652
121027
  const validationResult = schema.safeParse(parseResult.data);
120653
121028
  if (!validationResult.success) {
120654
- throw new WorkflowAPIError(`Schema validation failed for ${method} ${endpoint}:
120655
-
120656
- ${validationResult.error}
121029
+ const issues = validationResult.error.issues.map((i) => ` ${i.path.length > 0 ? i.path.join(".") : "<root>"}: ${i.message}`).join("\n");
121030
+ const debugContext = process.env.DEBUG ? `
120657
121031
 
120658
- Response context: ${parseResult.getDebugContext()}`, { url: url2, cause: validationResult.error });
121032
+ Response context: ${parseResult.getDebugContext()}` : "";
121033
+ throw new WorkflowWorldError(`Schema validation failed for ${method} ${endpoint}:
121034
+ ${issues}${debugContext}`, { url: url2, cause: validationResult.error });
120659
121035
  }
120660
121036
  return validationResult.data;
120661
121037
  });
@@ -120881,7 +121257,7 @@ async function resolveRefDescriptor(descriptor, runId, config2) {
120881
121257
  ...HttpResponseStatusCode(response2.status)
120882
121258
  });
120883
121259
  if (!response2.ok) {
120884
- const error2 = new WorkflowAPIError(`Failed to resolve ref: HTTP ${response2.status}`, { url: url2, status: response2.status });
121260
+ const error2 = new WorkflowWorldError(`Failed to resolve ref: HTTP ${response2.status}`, { url: url2, status: response2.status });
120885
121261
  span == null ? void 0 : span.setAttributes({
120886
121262
  ...ErrorType(`HTTP ${response2.status}`)
120887
121263
  });
@@ -120928,6 +121304,9 @@ const WorkflowRunWireBaseSchema = WorkflowRunBaseSchema.omit({
120928
121304
  }).extend({
120929
121305
  // Backend returns error as either a JSON string or structured object
120930
121306
  error: union([string$1(), StructuredErrorSchema]).optional(),
121307
+ // errorCode is stored inline on the run entity (not inside errorRef).
121308
+ // It's merged into StructuredError.code by deserializeError().
121309
+ errorCode: string$1().optional(),
120931
121310
  // Not part of the World interface, but passed through for direct consumers and debugging
120932
121311
  blobStorageBytes: number$1().optional(),
120933
121312
  streamStorageBytes: number$1().optional()
@@ -121010,7 +121389,7 @@ async function getWorkflowRun(id2, params, config2) {
121010
121389
  });
121011
121390
  return filterRunData(run, resolveData);
121012
121391
  } catch (error2) {
121013
- if (error2 instanceof WorkflowAPIError && error2.status === 404) {
121392
+ if (error2 instanceof WorkflowWorldError && error2.status === 404) {
121014
121393
  throw new WorkflowRunNotFoundError(id2);
121015
121394
  }
121016
121395
  throw error2;
@@ -121032,7 +121411,7 @@ async function cancelWorkflowRunV1(id2, params, config2) {
121032
121411
  });
121033
121412
  return filterRunData(run, resolveData);
121034
121413
  } catch (error2) {
121035
- if (error2 instanceof WorkflowAPIError && error2.status === 404) {
121414
+ if (error2 instanceof WorkflowWorldError && error2.status === 404) {
121036
121415
  throw new WorkflowRunNotFoundError(id2);
121037
121416
  }
121038
121417
  throw error2;
@@ -121184,7 +121563,8 @@ const eventDataRefFieldMap = {
121184
121563
  step_completed: "result",
121185
121564
  step_failed: "error",
121186
121565
  step_retrying: "error",
121187
- hook_created: "metadata"
121566
+ hook_created: "metadata",
121567
+ hook_received: "payload"
121188
121568
  };
121189
121569
  const eventsNeedingResolve = /* @__PURE__ */ new Set([
121190
121570
  "run_created",
@@ -121275,7 +121655,7 @@ async function getEvent(runId, eventId, params, config2) {
121275
121655
  const searchParams = new URLSearchParams();
121276
121656
  searchParams.set("remoteRefBehavior", remoteRefBehavior);
121277
121657
  const queryString = searchParams.toString();
121278
- const endpoint = `/v2/runs/${encodeURIComponent(runId)}/events/${encodeURIComponent(eventId)}${queryString ? `?${queryString}` : ""}`;
121658
+ const endpoint = `/v3/runs/${encodeURIComponent(runId)}/events/${encodeURIComponent(eventId)}${queryString ? `?${queryString}` : ""}`;
121279
121659
  const event = await makeRequest({
121280
121660
  endpoint,
121281
121661
  options: { method: "GET" },
@@ -121308,7 +121688,7 @@ async function getWorkflowRunEvents(params, config2) {
121308
121688
  searchParams.set("remoteRefBehavior", "lazy");
121309
121689
  const queryString = searchParams.toString();
121310
121690
  const query = queryString ? `?${queryString}` : "";
121311
- const endpoint = correlationId ? `/v2/events${query}` : `/v2/runs/${encodeURIComponent(runId)}/events${query}`;
121691
+ const endpoint = correlationId ? `/v2/events${query}` : `/v3/runs/${encodeURIComponent(runId)}/events${query}`;
121312
121692
  let refResolveConcurrency;
121313
121693
  const response2 = await makeRequest({
121314
121694
  endpoint,
@@ -121347,7 +121727,21 @@ async function getWorkflowRunEvents(params, config2) {
121347
121727
  data: response2.data.map((event) => stripEventAndLegacyRefs(event, resolveData))
121348
121728
  };
121349
121729
  }
121730
+ const hookEventsRequiringExistence = /* @__PURE__ */ new Set([
121731
+ "hook_disposed",
121732
+ "hook_received"
121733
+ ]);
121350
121734
  async function createWorkflowRunEvent(id2, data, params, config2) {
121735
+ try {
121736
+ return await createWorkflowRunEventInner(id2, data, params, config2);
121737
+ } catch (err) {
121738
+ if (hookEventsRequiringExistence.has(data.eventType) && WorkflowWorldError.is(err) && err.status === 404 && data.correlationId) {
121739
+ throw new HookNotFoundError(data.correlationId);
121740
+ }
121741
+ throw err;
121742
+ }
121743
+ }
121744
+ async function createWorkflowRunEventInner(id2, data, params, config2) {
121351
121745
  const resolveData = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION;
121352
121746
  const v1Compat = (params == null ? void 0 : params.v1Compat) ?? false;
121353
121747
  if (v1Compat) {
@@ -121370,14 +121764,14 @@ async function createWorkflowRunEvent(id2, data, params, config2) {
121370
121764
  if (data.eventType === "run_created" && id2) {
121371
121765
  const validationError = validateUlidTimestamp(id2, "wrun_");
121372
121766
  if (validationError) {
121373
- throw new WorkflowAPIError(validationError, { status: 400 });
121767
+ throw new WorkflowWorldError(validationError, { status: 400 });
121374
121768
  }
121375
121769
  }
121376
121770
  const runIdPath = id2 === null ? "null" : encodeURIComponent(id2);
121377
121771
  const remoteRefBehavior = eventsNeedingResolve.has(data.eventType) ? "resolve" : "lazy";
121378
121772
  if (remoteRefBehavior === "resolve") {
121379
121773
  const wireResult2 = await makeRequest({
121380
- endpoint: `/v2/runs/${runIdPath}/events`,
121774
+ endpoint: `/v3/runs/${runIdPath}/events`,
121381
121775
  options: { method: "POST" },
121382
121776
  data: {
121383
121777
  ...data,
@@ -121395,7 +121789,7 @@ async function createWorkflowRunEvent(id2, data, params, config2) {
121395
121789
  };
121396
121790
  }
121397
121791
  const wireResult = await makeRequest({
121398
- endpoint: `/v2/runs/${runIdPath}/events`,
121792
+ endpoint: `/v3/runs/${runIdPath}/events`,
121399
121793
  options: { method: "POST" },
121400
121794
  data: {
121401
121795
  ...data,
@@ -121472,56 +121866,12 @@ async function getHookByToken(token, config2) {
121472
121866
  schema: HookSchema
121473
121867
  });
121474
121868
  } catch (error2) {
121475
- if (WorkflowAPIError.is(error2) && error2.status === 404) {
121869
+ if (WorkflowWorldError.is(error2) && error2.status === 404) {
121476
121870
  throw new HookNotFoundError(token);
121477
121871
  }
121478
121872
  throw error2;
121479
121873
  }
121480
121874
  }
121481
- const WORKFLOW_SERVER_SERVICE = {
121482
- peerService: "workflow-server",
121483
- rpcSystem: "http",
121484
- rpcService: "workflow-server"
121485
- };
121486
- function extractEventType(args) {
121487
- if (args.length >= 2 && typeof args[1] === "object" && args[1] !== null) {
121488
- const data = args[1];
121489
- if (typeof data.eventType === "string") {
121490
- return data.eventType;
121491
- }
121492
- }
121493
- return void 0;
121494
- }
121495
- function instrumentObject(prefix, o) {
121496
- const handlers2 = {};
121497
- for (const key of Object.keys(o)) {
121498
- if (typeof o[key] !== "function") {
121499
- handlers2[key] = o[key];
121500
- } else {
121501
- const f2 = o[key];
121502
- const methodName = String(key);
121503
- handlers2[key] = async (...args) => {
121504
- let spanName2 = `${prefix}.${methodName}`;
121505
- if (prefix === "world.events" && methodName === "create") {
121506
- const eventType = extractEventType(args);
121507
- if (eventType) {
121508
- spanName2 = `${prefix}.${methodName} ${eventType}`;
121509
- }
121510
- }
121511
- return trace(spanName2, { kind: await getSpanKind("CLIENT") }, async (span) => {
121512
- span == null ? void 0 : span.setAttributes({
121513
- ...PeerService(WORKFLOW_SERVER_SERVICE.peerService),
121514
- ...RpcSystem(WORKFLOW_SERVER_SERVICE.rpcSystem),
121515
- ...RpcService(WORKFLOW_SERVER_SERVICE.rpcService),
121516
- ...RpcMethod(spanName2)
121517
- });
121518
- return f2(...args);
121519
- });
121520
- };
121521
- }
121522
- }
121523
- return handlers2;
121524
- }
121525
121875
  function createStorage(config2) {
121526
121876
  const storage = {
121527
121877
  // Storage interface with namespaced methods
@@ -121578,6 +121928,19 @@ function encodeMultiChunks(chunks) {
121578
121928
  }
121579
121929
  return result;
121580
121930
  }
121931
+ const StreamInfoResponseSchema = object$1({
121932
+ tailIndex: number$1(),
121933
+ done: boolean$1()
121934
+ });
121935
+ const StreamChunksResponseSchema = object$1({
121936
+ data: array$1(object$1({
121937
+ index: number$1(),
121938
+ data: _instanceof(Uint8Array)
121939
+ })),
121940
+ cursor: string$1().nullable(),
121941
+ hasMore: boolean$1(),
121942
+ done: boolean$1()
121943
+ });
121581
121944
  function createStreamer(config2) {
121582
121945
  return {
121583
121946
  async writeToStream(name2, runId, chunk) {
@@ -121631,6 +121994,30 @@ function createStreamer(config2) {
121631
121994
  }
121632
121995
  return response2.body;
121633
121996
  },
121997
+ async getStreamChunks(name2, runId, options) {
121998
+ const params = new URLSearchParams();
121999
+ if ((options == null ? void 0 : options.limit) != null) {
122000
+ params.set("limit", String(options.limit));
122001
+ }
122002
+ if (options == null ? void 0 : options.cursor) {
122003
+ params.set("cursor", options.cursor);
122004
+ }
122005
+ const qs = params.toString();
122006
+ const endpoint = `/v2/runs/${encodeURIComponent(runId)}/streams/${encodeURIComponent(name2)}/chunks${qs ? `?${qs}` : ""}`;
122007
+ return makeRequest({
122008
+ endpoint,
122009
+ config: config2,
122010
+ schema: StreamChunksResponseSchema
122011
+ });
122012
+ },
122013
+ async getStreamInfo(name2, runId) {
122014
+ const endpoint = `/v2/runs/${encodeURIComponent(runId)}/streams/${encodeURIComponent(name2)}/info`;
122015
+ return makeRequest({
122016
+ endpoint,
122017
+ config: config2,
122018
+ schema: StreamInfoResponseSchema
122019
+ });
122020
+ },
121634
122021
  async listStreamsByRunId(runId) {
121635
122022
  const httpConfig = await getHttpConfig(config2);
121636
122023
  const url2 = new URL(`${httpConfig.baseUrl}/v2/runs/${encodeURIComponent(runId)}/streams`);
@@ -121650,7 +122037,7 @@ function createVercelWorld(config2) {
121650
122037
  return {
121651
122038
  ...createQueue$1(config2),
121652
122039
  ...createStorage(config2),
121653
- ...createStreamer(config2),
122040
+ ...instrumentObject("world.streams", createStreamer(config2)),
121654
122041
  getEncryptionKeyForRun: createGetEncryptionKeyForRun(projectId, (_b = config2 == null ? void 0 : config2.projectConfig) == null ? void 0 : _b.teamId, config2 == null ? void 0 : config2.token),
121655
122042
  resolveLatestDeploymentId: createResolveLatestDeploymentId(config2)
121656
122043
  };
@@ -123092,6 +123479,11 @@ async function flushablePipe(source, sink, state) {
123092
123479
  }
123093
123480
  const contextStorage = /* @__PURE__ */ new AsyncLocalStorage();
123094
123481
  const registeredSteps = /* @__PURE__ */ new Map();
123482
+ const BUILTIN_RESPONSE_STEP_NAMES = /* @__PURE__ */ new Set([
123483
+ "__builtin_response_array_buffer",
123484
+ "__builtin_response_json",
123485
+ "__builtin_response_text"
123486
+ ]);
123095
123487
  function getStepIdAliasCandidates(stepId) {
123096
123488
  const parts = stepId.split("//");
123097
123489
  if (parts.length !== 3 || parts[0] !== "step") {
@@ -123120,6 +123512,17 @@ function getStepIdAliasCandidates(stepId) {
123120
123512
  }
123121
123513
  return Array.from(modulePathAliases, (aliasModulePath) => `step//${aliasModulePath}//${fnName}`);
123122
123514
  }
123515
+ function getBuiltinResponseStepAlias(stepId) {
123516
+ if (!BUILTIN_RESPONSE_STEP_NAMES.has(stepId)) {
123517
+ return void 0;
123518
+ }
123519
+ for (const [registeredStepId, stepFn] of registeredSteps.entries()) {
123520
+ if (registeredStepId.endsWith(`//${stepId}`)) {
123521
+ return stepFn;
123522
+ }
123523
+ }
123524
+ return void 0;
123525
+ }
123123
123526
  function getStepFunction(stepId) {
123124
123527
  const directMatch = registeredSteps.get(stepId);
123125
123528
  if (directMatch) {
@@ -123131,6 +123534,10 @@ function getStepFunction(stepId) {
123131
123534
  return aliasMatch;
123132
123535
  }
123133
123536
  }
123537
+ const builtinAliasMatch = getBuiltinResponseStepAlias(stepId);
123538
+ if (builtinAliasMatch) {
123539
+ return builtinAliasMatch;
123540
+ }
123134
123541
  return void 0;
123135
123542
  }
123136
123543
  const SerializationFormat = {
@@ -123371,12 +123778,21 @@ class WorkflowServerWritableStream extends WritableStream {
123371
123778
  }
123372
123779
  buffer = [];
123373
123780
  };
123781
+ let flushWaiters = [];
123374
123782
  const scheduleFlush = () => {
123375
123783
  if (flushTimer)
123376
123784
  return;
123377
123785
  flushTimer = setTimeout(() => {
123378
123786
  flushTimer = null;
123379
- flushPromise = flush();
123787
+ const currentWaiters = flushWaiters;
123788
+ flushWaiters = [];
123789
+ flushPromise = flush().then(() => {
123790
+ for (const w2 of currentWaiters)
123791
+ w2.resolve();
123792
+ }, (err) => {
123793
+ for (const w2 of currentWaiters)
123794
+ w2.reject(err);
123795
+ });
123380
123796
  }, STREAM_FLUSH_INTERVAL_MS);
123381
123797
  };
123382
123798
  super({
@@ -123387,6 +123803,9 @@ class WorkflowServerWritableStream extends WritableStream {
123387
123803
  }
123388
123804
  buffer.push(chunk);
123389
123805
  scheduleFlush();
123806
+ await new Promise((resolve2, reject) => {
123807
+ flushWaiters.push({ resolve: resolve2, reject });
123808
+ });
123390
123809
  },
123391
123810
  async close() {
123392
123811
  if (flushPromise) {
@@ -123396,12 +123815,17 @@ class WorkflowServerWritableStream extends WritableStream {
123396
123815
  await flush();
123397
123816
  await world.closeStream(name2, runId);
123398
123817
  },
123399
- abort() {
123818
+ abort(reason) {
123400
123819
  if (flushTimer) {
123401
123820
  clearTimeout(flushTimer);
123402
123821
  flushTimer = null;
123403
123822
  }
123404
123823
  buffer = [];
123824
+ const waiters = flushWaiters;
123825
+ flushWaiters = [];
123826
+ const abortError = reason ?? new Error("Stream aborted");
123827
+ for (const w2 of waiters)
123828
+ w2.reject(abortError);
123405
123829
  }
123406
123830
  });
123407
123831
  }
@@ -124871,7 +125295,7 @@ async function resumeHook$2(tokenOrHook, payload, encryptionKeyOverride) {
124871
125295
  });
124872
125296
  });
124873
125297
  }
124874
- const version = "4.2.0-beta.71";
125298
+ const version = "4.2.0-beta.72";
124875
125299
  const ulid = monotonicFactory();
124876
125300
  async function start$1(workflow, argsOrOptions, options) {
124877
125301
  return await waitedUntil(() => {
@@ -125037,7 +125461,7 @@ async function wakeUpRun$2(world, runId, options) {
125037
125461
  await world.events.create(runId, eventData, { v1Compat: compatMode });
125038
125462
  stoppedCount++;
125039
125463
  } catch (err) {
125040
- if (WorkflowAPIError.is(err) && err.status === 409) {
125464
+ if (EntityConflictError.is(err)) {
125041
125465
  stoppedCount++;
125042
125466
  } else {
125043
125467
  errors2.push(err instanceof Error ? err : new Error(String(err)));
@@ -125178,17 +125602,30 @@ class Run {
125178
125602
  * Retrieves the workflow run's default readable stream, which reads chunks
125179
125603
  * written to the corresponding writable stream {@link getWritable}.
125180
125604
  *
125605
+ * The returned stream has an additional {@link WorkflowReadableStream.getTailIndex | getTailIndex()}
125606
+ * helper that returns the index of the last known chunk. This is useful when
125607
+ * building reconnection endpoints that need to inform clients where the
125608
+ * stream starts.
125609
+ *
125181
125610
  * @param options - The options for the readable stream.
125182
- * @returns The `ReadableStream` for the workflow run.
125611
+ * @returns A `WorkflowReadableStream` for the workflow run.
125183
125612
  */
125184
125613
  getReadable(options = {}) {
125185
125614
  const { ops = [], global: global2 = globalThis, startIndex, namespace: namespace2 } = options;
125186
125615
  const name2 = getWorkflowRunStreamId(this.runId, namespace2);
125187
125616
  const encryptionKey = this.getEncryptionKey();
125188
- return getExternalRevivers(global2, ops, this.runId, encryptionKey).ReadableStream({
125617
+ const stream = getExternalRevivers(global2, ops, this.runId, encryptionKey).ReadableStream({
125189
125618
  name: name2,
125190
125619
  startIndex
125191
125620
  });
125621
+ const world = this.world;
125622
+ const runId = this.runId;
125623
+ return Object.assign(stream, {
125624
+ getTailIndex: async () => {
125625
+ const info = await world.getStreamInfo(name2, runId);
125626
+ return info.tailIndex;
125627
+ }
125628
+ });
125192
125629
  }
125193
125630
  /**
125194
125631
  * Polls the workflow return value every 1 second until it is completed.
@@ -125229,6 +125666,41 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125229
125666
  }
125230
125667
  const { workflowName, workflowRunId, workflowStartedAt, stepId, traceCarrier: traceContext, requestedAt } = StepInvokePayloadSchema.parse(message_);
125231
125668
  const { requestId } = metadata;
125669
+ if (metadata.attempt > MAX_QUEUE_DELIVERIES) {
125670
+ runtimeLogger.error(`Step handler exceeded max deliveries (${metadata.attempt}/${MAX_QUEUE_DELIVERIES})`, {
125671
+ workflowRunId,
125672
+ stepId,
125673
+ stepName: metadata.queueName.slice("__wkf_step_".length),
125674
+ attempt: metadata.attempt
125675
+ });
125676
+ try {
125677
+ const world = getWorld();
125678
+ await world.events.create(workflowRunId, {
125679
+ eventType: "step_failed",
125680
+ specVersion: SPEC_VERSION_CURRENT,
125681
+ correlationId: stepId,
125682
+ eventData: {
125683
+ error: `Step exceeded maximum queue deliveries (${metadata.attempt}/${MAX_QUEUE_DELIVERIES})`
125684
+ }
125685
+ }, { requestId });
125686
+ await queueMessage(world, getWorkflowQueueName(workflowName), {
125687
+ runId: workflowRunId,
125688
+ traceCarrier: await serializeTraceCarrier(),
125689
+ requestedAt: /* @__PURE__ */ new Date()
125690
+ });
125691
+ } catch (err) {
125692
+ if (EntityConflictError.is(err) || RunExpiredError.is(err)) {
125693
+ return;
125694
+ }
125695
+ runtimeLogger.error(`Failed to mark step as failed after ${metadata.attempt} delivery attempts. A persistent error is preventing the step from being terminated. The run will remain in its current state until manually resolved. This is most likely due to a persistent outage of the workflow backend or a bug in the workflow runtime and should be reported to the Workflow team.`, {
125696
+ workflowRunId,
125697
+ stepId,
125698
+ attempt: metadata.attempt,
125699
+ error: err instanceof Error ? err.message : String(err)
125700
+ });
125701
+ }
125702
+ return;
125703
+ }
125232
125704
  const spanLinks = await linkToCurrentContext();
125233
125705
  return await withTraceContext(traceContext, async () => {
125234
125706
  const stepName = metadata.queueName.slice("__wkf_step_".length);
@@ -125239,7 +125711,7 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125239
125711
  getSpanKind$2("CONSUMER")
125240
125712
  ]);
125241
125713
  return trace$2(`STEP ${stepName}`, { kind: spanKind, links: spanLinks }, async (span) => {
125242
- var _a3, _b, _c, _d, _e2, _f, _g;
125714
+ var _a3, _b, _c, _d, _e2, _f;
125243
125715
  span == null ? void 0 : span.setAttributes({
125244
125716
  ...StepName(stepName),
125245
125717
  ...StepAttempt(metadata.attempt),
@@ -125251,18 +125723,10 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125251
125723
  ...getQueueOverhead({ requestedAt })
125252
125724
  });
125253
125725
  const stepFn = getStepFunction(stepName);
125254
- if (!stepFn) {
125255
- throw new Error(`Step "${stepName}" not found`);
125256
- }
125257
- if (typeof stepFn !== "function") {
125258
- throw new Error(`Step "${stepName}" is not a function (got ${typeof stepFn})`);
125259
- }
125260
- const maxRetries = stepFn.maxRetries ?? DEFAULT_STEP_MAX_RETRIES;
125261
125726
  span == null ? void 0 : span.setAttributes({
125262
125727
  ...WorkflowName(workflowName),
125263
125728
  ...WorkflowRunId(workflowRunId),
125264
125729
  ...StepId(stepId),
125265
- ...StepMaxRetries(maxRetries),
125266
125730
  ...StepTracePropagated(!!traceContext)
125267
125731
  });
125268
125732
  let step;
@@ -125277,62 +125741,56 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125277
125741
  }
125278
125742
  step = startResult.step;
125279
125743
  } catch (err) {
125280
- if (WorkflowAPIError.is(err)) {
125281
- if (err.status === 429) {
125282
- const retryRetryAfter = Math.max(1, typeof err.retryAfter === "number" ? err.retryAfter : 1);
125283
- runtimeLogger.info("Throttled again on retry, deferring to queue", {
125284
- retryAfterSeconds: retryRetryAfter
125285
- });
125286
- return { timeoutSeconds: retryRetryAfter };
125287
- }
125288
- if (err.status === 410) {
125289
- runtimeLogger.info(`Workflow run "${workflowRunId}" has already completed, skipping step "${stepId}": ${err.message}`);
125290
- return;
125291
- }
125292
- if (err.status === 409) {
125293
- runtimeLogger.debug("Step in terminal state, re-enqueuing workflow", {
125294
- stepName,
125295
- stepId,
125296
- workflowRunId,
125297
- error: err.message
125298
- });
125299
- span == null ? void 0 : span.setAttributes({
125300
- ...StepSkipped(true),
125301
- // Use 'completed' as a representative terminal state for the skip reason
125302
- ...StepSkipReason("completed")
125303
- });
125304
- (_a3 = span == null ? void 0 : span.addEvent) == null ? void 0 : _a3.call(span, "step.skipped", {
125305
- "skip.reason": "terminal_state",
125306
- "step.name": stepName,
125307
- "step.id": stepId
125308
- });
125309
- await queueMessage(world, getWorkflowQueueName(workflowName), {
125310
- runId: workflowRunId,
125311
- traceCarrier: await serializeTraceCarrier(),
125312
- requestedAt: /* @__PURE__ */ new Date()
125313
- });
125314
- return;
125315
- }
125316
- if (err.status === 425) {
125317
- const retryAfterStr = (_b = err.meta) == null ? void 0 : _b.retryAfter;
125318
- const retryAfter = retryAfterStr ? new Date(retryAfterStr) : new Date(Date.now() + 1e3);
125319
- const timeoutSeconds = Math.max(1, Math.ceil((retryAfter.getTime() - Date.now()) / 1e3));
125320
- span == null ? void 0 : span.setAttributes({
125321
- ...StepRetryTimeoutSeconds(timeoutSeconds)
125322
- });
125323
- (_c = span == null ? void 0 : span.addEvent) == null ? void 0 : _c.call(span, "step.delayed", {
125324
- "delay.reason": "retry_after_not_reached",
125325
- "delay.timeout_seconds": timeoutSeconds,
125326
- "delay.retry_after": retryAfter.toISOString()
125327
- });
125328
- runtimeLogger.debug("Step retryAfter timestamp not yet reached", {
125329
- stepName,
125330
- stepId,
125331
- retryAfter,
125332
- timeoutSeconds
125333
- });
125334
- return { timeoutSeconds };
125335
- }
125744
+ if (ThrottleError.is(err)) {
125745
+ const retryRetryAfter = Math.max(1, typeof err.retryAfter === "number" ? err.retryAfter : 1);
125746
+ runtimeLogger.info("Throttled again on retry, deferring to queue", {
125747
+ retryAfterSeconds: retryRetryAfter
125748
+ });
125749
+ return { timeoutSeconds: retryRetryAfter };
125750
+ }
125751
+ if (RunExpiredError.is(err)) {
125752
+ runtimeLogger.info(`Workflow run "${workflowRunId}" has already completed, skipping step "${stepId}": ${err.message}`);
125753
+ return;
125754
+ }
125755
+ if (EntityConflictError.is(err)) {
125756
+ runtimeLogger.debug("Step in terminal state, re-enqueuing workflow", {
125757
+ stepName,
125758
+ stepId,
125759
+ workflowRunId,
125760
+ error: err.message
125761
+ });
125762
+ span == null ? void 0 : span.setAttributes({
125763
+ ...StepSkipped(true),
125764
+ ...StepSkipReason("completed")
125765
+ });
125766
+ (_a3 = span == null ? void 0 : span.addEvent) == null ? void 0 : _a3.call(span, "step.skipped", {
125767
+ "skip.reason": "terminal_state",
125768
+ "step.name": stepName,
125769
+ "step.id": stepId
125770
+ });
125771
+ await queueMessage(world, getWorkflowQueueName(workflowName), {
125772
+ runId: workflowRunId,
125773
+ traceCarrier: await serializeTraceCarrier(),
125774
+ requestedAt: /* @__PURE__ */ new Date()
125775
+ });
125776
+ return;
125777
+ }
125778
+ if (TooEarlyError.is(err)) {
125779
+ const timeoutSeconds = Math.max(1, err.retryAfter ?? 1);
125780
+ span == null ? void 0 : span.setAttributes({
125781
+ ...StepRetryTimeoutSeconds(timeoutSeconds)
125782
+ });
125783
+ (_b = span == null ? void 0 : span.addEvent) == null ? void 0 : _b.call(span, "step.delayed", {
125784
+ "delay.reason": "retry_after_not_reached",
125785
+ "delay.timeout_seconds": timeoutSeconds
125786
+ });
125787
+ runtimeLogger.debug("Step retryAfter timestamp not yet reached", {
125788
+ stepName,
125789
+ stepId,
125790
+ retryAfterSeconds: err.retryAfter,
125791
+ timeoutSeconds
125792
+ });
125793
+ return { timeoutSeconds };
125336
125794
  }
125337
125795
  throw err;
125338
125796
  }
@@ -125345,6 +125803,51 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125345
125803
  span == null ? void 0 : span.setAttributes({
125346
125804
  ...StepStatus(step.status)
125347
125805
  });
125806
+ if (!stepFn || typeof stepFn !== "function") {
125807
+ const err = new StepNotRegisteredError(stepName);
125808
+ runtimeLogger.error("Step function not registered, failing step (not run)", {
125809
+ workflowRunId,
125810
+ stepName,
125811
+ stepId,
125812
+ error: err.message
125813
+ });
125814
+ try {
125815
+ await world.events.create(workflowRunId, {
125816
+ eventType: "step_failed",
125817
+ specVersion: SPEC_VERSION_CURRENT,
125818
+ correlationId: stepId,
125819
+ eventData: {
125820
+ error: err.message,
125821
+ stack: err.stack
125822
+ }
125823
+ }, { requestId });
125824
+ } catch (stepFailErr) {
125825
+ if (EntityConflictError.is(stepFailErr)) {
125826
+ runtimeLogger.info("Tried failing step for missing function, but step has already finished.", {
125827
+ workflowRunId,
125828
+ stepId,
125829
+ stepName,
125830
+ message: stepFailErr.message
125831
+ });
125832
+ return;
125833
+ }
125834
+ throw stepFailErr;
125835
+ }
125836
+ span == null ? void 0 : span.setAttributes({
125837
+ ...StepStatus("failed"),
125838
+ ...StepFatalError(true)
125839
+ });
125840
+ await queueMessage(world, getWorkflowQueueName(workflowName), {
125841
+ runId: workflowRunId,
125842
+ traceCarrier: await serializeTraceCarrier(),
125843
+ requestedAt: /* @__PURE__ */ new Date()
125844
+ });
125845
+ return;
125846
+ }
125847
+ const maxRetries = stepFn.maxRetries ?? DEFAULT_STEP_MAX_RETRIES;
125848
+ span == null ? void 0 : span.setAttributes({
125849
+ ...StepMaxRetries(maxRetries)
125850
+ });
125348
125851
  let result;
125349
125852
  if (step.attempt > maxRetries + 1) {
125350
125853
  const retryCount = step.attempt - 1;
@@ -125361,11 +125864,11 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125361
125864
  correlationId: stepId,
125362
125865
  eventData: {
125363
125866
  error: errorMessage,
125364
- stack: (_d = step.error) == null ? void 0 : _d.stack
125867
+ stack: (_c = step.error) == null ? void 0 : _c.stack
125365
125868
  }
125366
125869
  }, { requestId });
125367
125870
  } catch (err) {
125368
- if (WorkflowAPIError.is(err) && err.status === 409) {
125871
+ if (EntityConflictError.is(err)) {
125369
125872
  runtimeLogger.info("Tried failing step, but step has already finished.", {
125370
125873
  workflowRunId,
125371
125874
  stepId,
@@ -125406,7 +125909,7 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125406
125909
  }
125407
125910
  }, { requestId });
125408
125911
  } catch (failErr) {
125409
- if (WorkflowAPIError.is(failErr) && failErr.status === 409) {
125912
+ if (EntityConflictError.is(failErr)) {
125410
125913
  return;
125411
125914
  }
125412
125915
  throw failErr;
@@ -125420,7 +125923,7 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125420
125923
  }
125421
125924
  const stepStartedAt = step.startedAt;
125422
125925
  const ops = [];
125423
- const rawKey = await ((_e2 = world.getEncryptionKeyForRun) == null ? void 0 : _e2.call(world, workflowRunId));
125926
+ const rawKey = await ((_d = world.getEncryptionKeyForRun) == null ? void 0 : _d.call(world, workflowRunId));
125424
125927
  const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
125425
125928
  const hydratedInput = await trace$2("step.hydrate", {}, async (hydrateSpan) => {
125426
125929
  const startTime = Date.now();
@@ -125469,15 +125972,15 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125469
125972
  });
125470
125973
  if (userCodeFailed) {
125471
125974
  const err = userCodeError;
125472
- if (WorkflowAPIError.is(err)) {
125473
- if (err.status === 410) {
125474
- stepLogger.info("Workflow run already completed, skipping step", {
125475
- workflowRunId,
125476
- stepId,
125477
- message: err.message
125478
- });
125479
- return;
125480
- }
125975
+ if (RunExpiredError.is(err)) {
125976
+ stepLogger.info("Workflow run already completed, skipping step", {
125977
+ workflowRunId,
125978
+ stepId,
125979
+ message: err.message
125980
+ });
125981
+ return;
125982
+ }
125983
+ if (WorkflowWorldError.is(err)) {
125481
125984
  if (err.status !== void 0 && err.status >= 500) {
125482
125985
  throw err;
125483
125986
  }
@@ -125485,7 +125988,7 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125485
125988
  const normalizedError = await normalizeUnknownError(err);
125486
125989
  const normalizedStack = normalizedError.stack || getErrorStack(err) || "";
125487
125990
  if (err instanceof Error) {
125488
- (_f = span == null ? void 0 : span.recordException) == null ? void 0 : _f.call(span, err);
125991
+ (_e2 = span == null ? void 0 : span.recordException) == null ? void 0 : _e2.call(span, err);
125489
125992
  }
125490
125993
  const isFatal = FatalError.is(err);
125491
125994
  const isRetryable = RetryableError.is(err);
@@ -125514,7 +126017,7 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125514
126017
  }
125515
126018
  }, { requestId });
125516
126019
  } catch (stepFailErr) {
125517
- if (WorkflowAPIError.is(stepFailErr) && stepFailErr.status === 409) {
126020
+ if (EntityConflictError.is(stepFailErr)) {
125518
126021
  runtimeLogger.info("Tried failing step, but step has already finished.", {
125519
126022
  workflowRunId,
125520
126023
  stepId,
@@ -125557,7 +126060,7 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125557
126060
  }
125558
126061
  }, { requestId });
125559
126062
  } catch (stepFailErr) {
125560
- if (WorkflowAPIError.is(stepFailErr) && stepFailErr.status === 409) {
126063
+ if (EntityConflictError.is(stepFailErr)) {
125561
126064
  runtimeLogger.info("Tried failing step, but step has already finished.", {
125562
126065
  workflowRunId,
125563
126066
  stepId,
@@ -125602,7 +126105,7 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125602
126105
  }
125603
126106
  }, { requestId });
125604
126107
  } catch (stepRetryErr) {
125605
- if (WorkflowAPIError.is(stepRetryErr) && stepRetryErr.status === 409) {
126108
+ if (EntityConflictError.is(stepRetryErr)) {
125606
126109
  runtimeLogger.info("Tried retrying step, but step has already finished.", {
125607
126110
  workflowRunId,
125608
126111
  stepId,
@@ -125618,7 +126121,7 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125618
126121
  ...StepRetryTimeoutSeconds(timeoutSeconds),
125619
126122
  ...StepRetryWillRetry(true)
125620
126123
  });
125621
- (_g = span == null ? void 0 : span.addEvent) == null ? void 0 : _g.call(span, "retry.scheduled", {
126124
+ (_f = span == null ? void 0 : span.addEvent) == null ? void 0 : _f.call(span, "retry.scheduled", {
125622
126125
  "retry.timeout_seconds": timeoutSeconds,
125623
126126
  "retry.attempt": currentAttempt,
125624
126127
  "retry.max_retries": maxRetries2
@@ -125658,7 +126161,7 @@ getWorldHandlers().createQueueHandler("__wkf_step_", async (message_, metadata)
125658
126161
  result
125659
126162
  }
125660
126163
  }, { requestId }).catch((err) => {
125661
- if (WorkflowAPIError.is(err) && err.status === 409) {
126164
+ if (EntityConflictError.is(err)) {
125662
126165
  runtimeLogger.info("Tried completing step, but step has already finished.", {
125663
126166
  workflowRunId,
125664
126167
  stepId,
@@ -126033,7 +126536,7 @@ async function getWorldFromEnv(userEnvMap) {
126033
126536
  function createServerActionError(error2, operation, requestParams) {
126034
126537
  const err = error2 instanceof Error ? error2 : new Error(String(error2));
126035
126538
  let errorResponse;
126036
- if (WorkflowAPIError.is(error2)) {
126539
+ if (WorkflowWorldError.is(error2)) {
126037
126540
  const status = error2.status ?? 500;
126038
126541
  const isClientError = status >= 400 && status < 500;
126039
126542
  if (!isClientError) {
@@ -126376,7 +126879,7 @@ async function fetchWorkflowsManifest(_worldEnv) {
126376
126879
  }
126377
126880
  for (const manifestPath of manifestPaths) {
126378
126881
  try {
126379
- const content2 = await require$$0$8.readFile(manifestPath, "utf-8");
126882
+ const content2 = await fs$1.readFile(manifestPath, "utf-8");
126380
126883
  const manifest = JSON.parse(content2);
126381
126884
  return createResponse(manifest);
126382
126885
  } catch (_err) {
@@ -132197,12 +132700,17 @@ function useWorkflowResourceData(env2, resource, resourceId, options = {}) {
132197
132700
  async (resource2) => encryptionKey ? hydrateResourceIOWithKey(resource2, encryptionKey) : hydrateResourceIO(resource2),
132198
132701
  [encryptionKey]
132199
132702
  );
132703
+ const prevSelectionRef = reactExports.useRef("");
132200
132704
  const fetchData = reactExports.useCallback(async () => {
132201
132705
  if (!enabled) {
132202
132706
  setLoading(false);
132203
132707
  return;
132204
132708
  }
132205
- setData(null);
132709
+ const selectionKey = `${resource}:${resourceId}`;
132710
+ if (selectionKey !== prevSelectionRef.current) {
132711
+ setData(null);
132712
+ prevSelectionRef.current = selectionKey;
132713
+ }
132206
132714
  setError(null);
132207
132715
  setLoading(true);
132208
132716
  if (resource === "hook") {
@@ -134533,6 +135041,12 @@ function SelectionBar({
134533
135041
  }
134534
135042
  );
134535
135043
  }
135044
+ function getErrorCode(error2) {
135045
+ if (error2 !== null && typeof error2 === "object" && "code" in error2 && typeof error2.code === "string") {
135046
+ return error2.code;
135047
+ }
135048
+ return void 0;
135049
+ }
134536
135050
  function StatusBadge({
134537
135051
  status,
134538
135052
  context,
@@ -134571,41 +135085,41 @@ function StatusBadge({
134571
135085
  ")"
134572
135086
  ] })
134573
135087
  ] });
134574
- if (status === "failed" && (context == null ? void 0 : context.error)) {
134575
- return /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorStatusBadge, { content: content2, error: context.error });
135088
+ const errorCode = status === "failed" ? getErrorCode(context == null ? void 0 : context.error) : void 0;
135089
+ if (errorCode) {
135090
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorCodeBadge, { content: content2, errorCode });
134576
135091
  }
134577
135092
  return content2;
134578
135093
  }
134579
- function ErrorStatusBadge({
135094
+ function ErrorCodeBadge({
134580
135095
  content: content2,
134581
- error: error2
135096
+ errorCode
134582
135097
  }) {
134583
135098
  const [copied, setCopied] = reactExports.useState(false);
134584
- const errorMessage = typeof error2 === "string" ? error2 : error2 instanceof Error ? error2.message : JSON.stringify(error2);
134585
135099
  const handleCopy = async (e) => {
134586
135100
  e.stopPropagation();
134587
- await navigator.clipboard.writeText(errorMessage);
134588
- setCopied(true);
134589
- setTimeout(() => setCopied(false), 2e3);
135101
+ try {
135102
+ await navigator.clipboard.writeText(errorCode);
135103
+ setCopied(true);
135104
+ setTimeout(() => setCopied(false), 2e3);
135105
+ } catch {
135106
+ }
134590
135107
  };
134591
135108
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
134592
135109
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "cursor-help", children: content2 }) }),
134593
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TooltipContent, { className: "max-w-md p-0", children: [
134594
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between gap-2 p-1 border-b", children: [
134595
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-medium pl-1 pt-1", children: "Error Details" }),
134596
- /* @__PURE__ */ jsxRuntimeExports.jsx(
134597
- Button,
134598
- {
134599
- variant: "ghost",
134600
- size: "icon",
134601
- className: "h-6 w-6 shrink-0",
134602
- onClick: handleCopy,
134603
- children: copied ? /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-2.5 w-2.5 text-muted-foreground" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Copy, { className: "h-2.5 w-2.5 text-muted-foreground" })
134604
- }
134605
- )
134606
- ] }),
134607
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "max-h-48 overflow-auto p-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs whitespace-pre-wrap break-words font-mono", children: errorMessage }) })
134608
- ] })
135110
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "p-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 p-1.5", children: [
135111
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-mono", children: errorCode }),
135112
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
135113
+ Button,
135114
+ {
135115
+ variant: "ghost",
135116
+ size: "icon",
135117
+ className: "h-5 w-5 shrink-0",
135118
+ onClick: handleCopy,
135119
+ children: copied ? /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "h-2.5 w-2.5 text-muted-foreground" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Copy, { className: "h-2.5 w-2.5 text-muted-foreground" })
135120
+ }
135121
+ )
135122
+ ] }) })
134609
135123
  ] });
134610
135124
  }
134611
135125
  function useRunActions({
@@ -148423,6 +148937,13 @@ function mapRunToExecution(run, steps, events2, graph) {
148423
148937
  return result;
148424
148938
  }
148425
148939
  const FRAME_HEADER_SIZE = 4;
148940
+ function detectEncoding(data) {
148941
+ if (data.length < FRAME_HEADER_SIZE) return "framed";
148942
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
148943
+ const len = view.getUint32(0, false);
148944
+ if (len > 0 && len <= 10 * 1024 * 1024) return "framed";
148945
+ return "legacy";
148946
+ }
148426
148947
  function useStreamReader(env2, streamId, runId, encryptionKey) {
148427
148948
  const [chunks, setChunks] = reactExports.useState([]);
148428
148949
  const [isLive, setIsLive] = reactExports.useState(false);
@@ -148452,21 +148973,62 @@ function useStreamReader(env2, streamId, runId, encryptionKey) {
148452
148973
  );
148453
148974
  const cryptoKey = encryptionKey ? await importKey(encryptionKey) : void 0;
148454
148975
  const reader = rawStream.getReader();
148976
+ const decoder2 = new TextDecoder();
148455
148977
  let buffer = new Uint8Array(0);
148978
+ let encoding2 = null;
148979
+ let textRemainder = "";
148456
148980
  const appendToBuffer = (data) => {
148457
148981
  const newBuffer = new Uint8Array(buffer.length + data.length);
148458
148982
  newBuffer.set(buffer, 0);
148459
148983
  newBuffer.set(data, buffer.length);
148460
148984
  buffer = newBuffer;
148461
148985
  };
148986
+ const addLegacyLine = (line) => {
148987
+ if (!mounted || !line) return;
148988
+ const chunkId = chunkIdRef.current++;
148989
+ let text2;
148990
+ try {
148991
+ const parsed = JSON.parse(line);
148992
+ text2 = JSON.stringify(parsed, null, 2);
148993
+ } catch {
148994
+ text2 = line;
148995
+ }
148996
+ setChunks((prev) => [...prev, { id: chunkId, text: text2 }]);
148997
+ };
148462
148998
  for (; ; ) {
148463
148999
  if (abortController.signal.aborted) break;
148464
149000
  const { value, done } = await reader.read();
148465
149001
  if (done) {
149002
+ if (encoding2 === "legacy" && textRemainder.trim()) {
149003
+ addLegacyLine(textRemainder.trim());
149004
+ textRemainder = "";
149005
+ }
148466
149006
  if (mounted) setIsLive(false);
148467
149007
  break;
148468
149008
  }
148469
- appendToBuffer(value);
149009
+ if (encoding2 === null) {
149010
+ appendToBuffer(value);
149011
+ if (buffer.length >= FRAME_HEADER_SIZE) {
149012
+ encoding2 = detectEncoding(buffer);
149013
+ }
149014
+ if (encoding2 === "legacy") {
149015
+ textRemainder = decoder2.decode(buffer, { stream: true });
149016
+ buffer = new Uint8Array(0);
149017
+ }
149018
+ } else if (encoding2 === "legacy") {
149019
+ textRemainder += decoder2.decode(value, { stream: true });
149020
+ } else {
149021
+ appendToBuffer(value);
149022
+ }
149023
+ if (encoding2 === "legacy") {
149024
+ const lines = textRemainder.split("\n");
149025
+ textRemainder = lines.pop() ?? "";
149026
+ for (const line of lines) {
149027
+ const trimmed = line.trim();
149028
+ if (trimmed) addLegacyLine(trimmed);
149029
+ }
149030
+ continue;
149031
+ }
148470
149032
  while (buffer.length >= FRAME_HEADER_SIZE) {
148471
149033
  const view = new DataView(
148472
149034
  buffer.buffer,
@@ -148474,6 +149036,9 @@ function useStreamReader(env2, streamId, runId, encryptionKey) {
148474
149036
  buffer.byteLength
148475
149037
  );
148476
149038
  const frameLength = view.getUint32(0, false);
149039
+ if (frameLength === 0 || frameLength > 10 * 1024 * 1024) {
149040
+ break;
149041
+ }
148477
149042
  if (buffer.length < FRAME_HEADER_SIZE + frameLength) {
148478
149043
  break;
148479
149044
  }
@@ -150254,7 +150819,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
150254
150819
  __proto__: null,
150255
150820
  loader
150256
150821
  }, Symbol.toStringTag, { value: "Module" }));
150257
- const serverManifest = { "entry": { "module": "/assets/entry.client-BjpmGyLC.js", "imports": ["/assets/index-DklpUtP3.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": false, "module": "/assets/root-CxkGJJO9.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/mermaid-3ZIDBTTL-D6v4WgFl.js"], "css": ["/assets/root-DUJPWGN3.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-C884R8Ik.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/use-workflow-graph-WEp5s5k_.js", "/assets/mermaid-3ZIDBTTL-D6v4WgFl.js"], "css": ["/assets/use-workflow-graph-yls6qlc0.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-D_eXHYm3.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/use-workflow-graph-WEp5s5k_.js", "/assets/mermaid-3ZIDBTTL-D6v4WgFl.js", "/assets/encryption-8OvC6eoJ.js"], "css": ["/assets/use-workflow-graph-yls6qlc0.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-14123a0c.js", "version": "14123a0c", "sri": void 0 };
150822
+ const serverManifest = { "entry": { "module": "/assets/entry.client-BjpmGyLC.js", "imports": ["/assets/index-DklpUtP3.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": false, "module": "/assets/root-DXnpwJxc.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/mermaid-3ZIDBTTL-CrmlsXj3.js"], "css": ["/assets/root-DtrAdcW8.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-CFxVErsy.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/use-workflow-graph-DGcT3V07.js", "/assets/mermaid-3ZIDBTTL-CrmlsXj3.js"], "css": ["/assets/use-workflow-graph-yls6qlc0.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-C6LG6p9l.js", "imports": ["/assets/index-DklpUtP3.js", "/assets/use-workflow-graph-DGcT3V07.js", "/assets/mermaid-3ZIDBTTL-CrmlsXj3.js", "/assets/encryption-8OvC6eoJ.js"], "css": ["/assets/use-workflow-graph-yls6qlc0.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-beaac576.js", "version": "beaac576", "sri": void 0 };
150258
150823
  const assetsBuildDirectory = "build/client";
150259
150824
  const basename = "/";
150260
150825
  const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };