@workflow/web 4.1.20 → 4.1.22

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.
@@ -1 +1 @@
1
- window.__reactRouterManifest={"entry":{"module":"/assets/entry.client-C_C46bD6.js","imports":["/assets/index-BsV8i_Jn.js"],"css":[]},"routes":{"root":{"id":"root","path":"","hasAction":true,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":true,"module":"/assets/root-BxnaECGo.js","imports":["/assets/index-BsV8i_Jn.js","/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js"],"css":["/assets/root-BOS11TzD.css","/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"]},"routes/home":{"id":"routes/home","parentId":"root","index":true,"hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/home-Blj6TeEE.js","imports":["/assets/index-BsV8i_Jn.js","/assets/workflow-graph-viewer-C6PWoIIU.js","/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js","/assets/index-DZSXezpI.js"],"css":["/assets/workflow-graph-viewer-yls6qlc0.css","/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"]},"routes/run-detail":{"id":"routes/run-detail","parentId":"root","path":"run/:runId","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/run-detail-Cbuf5qtv.js","imports":["/assets/index-BsV8i_Jn.js","/assets/workflow-graph-viewer-C6PWoIIU.js","/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js","/assets/encryption-BRhjWsZh.js","/assets/index-DZSXezpI.js"],"css":["/assets/workflow-graph-viewer-yls6qlc0.css","/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"]},"routes/api.rpc":{"id":"routes/api.rpc","parentId":"root","path":"api/rpc","hasAction":true,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/api.rpc-l0sNRNKZ.js","imports":[],"css":[]},"routes/api.stream.$streamId":{"id":"routes/api.stream.$streamId","parentId":"root","path":"api/stream/:streamId","hasAction":false,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/api.stream._streamId-l0sNRNKZ.js","imports":[],"css":[]}},"url":"/assets/manifest-0285e96f.js","version":"0285e96f"};
1
+ window.__reactRouterManifest={"entry":{"module":"/assets/entry.client-C_C46bD6.js","imports":["/assets/index-BsV8i_Jn.js"],"css":[]},"routes":{"root":{"id":"root","path":"","hasAction":true,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":true,"module":"/assets/root-BxnaECGo.js","imports":["/assets/index-BsV8i_Jn.js","/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js"],"css":["/assets/root-BOS11TzD.css","/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"]},"routes/home":{"id":"routes/home","parentId":"root","index":true,"hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/home-Blj6TeEE.js","imports":["/assets/index-BsV8i_Jn.js","/assets/workflow-graph-viewer-C6PWoIIU.js","/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js","/assets/index-DZSXezpI.js"],"css":["/assets/workflow-graph-viewer-yls6qlc0.css","/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"]},"routes/run-detail":{"id":"routes/run-detail","parentId":"root","path":"run/:runId","hasAction":false,"hasLoader":false,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":true,"hasErrorBoundary":false,"module":"/assets/run-detail-DivTczoC.js","imports":["/assets/index-BsV8i_Jn.js","/assets/workflow-graph-viewer-C6PWoIIU.js","/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js","/assets/encryption-BRhjWsZh.js","/assets/index-DZSXezpI.js"],"css":["/assets/workflow-graph-viewer-yls6qlc0.css","/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"]},"routes/api.rpc":{"id":"routes/api.rpc","parentId":"root","path":"api/rpc","hasAction":true,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/api.rpc-l0sNRNKZ.js","imports":[],"css":[]},"routes/api.stream.$streamId":{"id":"routes/api.stream.$streamId","parentId":"root","path":"api/stream/:streamId","hasAction":false,"hasLoader":true,"hasClientAction":false,"hasClientLoader":false,"hasClientMiddleware":false,"hasDefaultExport":false,"hasErrorBoundary":false,"module":"/assets/api.stream._streamId-l0sNRNKZ.js","imports":[],"css":[]}},"url":"/assets/manifest-7bf3847b.js","version":"7bf3847b"};
@@ -641,7 +641,6 @@ function EventRow({ event, index, isFirst, isLast, isExpanded, onToggleExpand, a
641
641
  }, []);
642
642
  reactExports.useEffect(() => {
643
643
  if (encryptionKey && hasAttemptedLoad && onLoadEventData) {
644
- setLoadedEventData(null);
645
644
  setHasAttemptedLoad(false);
646
645
  onLoadEventData(event).then((data) => {
647
646
  if (data !== null && data !== void 0) {
@@ -6175,6 +6174,7 @@ function useEventsListData(env, runId, options = {}) {
6175
6174
  }
6176
6175
  const { error: fetchError, result } = await unwrapServerActionResult(
6177
6176
  fetchEventsByCorrelationId(env, id, {
6177
+ runId,
6178
6178
  cursor: nextCursor,
6179
6179
  sortOrder,
6180
6180
  limit: 100,
@@ -9180,7 +9180,7 @@ const app = express();
9180
9180
  app.all(
9181
9181
  "/{*splat}",
9182
9182
  createRequestHandler({
9183
- build: () => import("./server-build-DMT2kgzu.js").then((n) => n.a6)
9183
+ build: () => import("./server-build-B1ehSvPo.js").then((n) => n.a6)
9184
9184
  })
9185
9185
  );
9186
9186
  app.use(
@@ -2,8 +2,8 @@ import { createRequire as __wkfCreateRequire } from "node:module";
2
2
  if (typeof globalThis.require === "undefined") {
3
3
  globalThis.require = __wkfCreateRequire(import.meta.url);
4
4
  }
5
- import { a0 as R, a1 as Ks, a2 as jsxRuntimeExports, a3 as Qe } from "./server-build-DMT2kgzu.js";
6
- import { r as reactExports } from "./app-C6I0cOSv.js";
5
+ import { a0 as R, a1 as Ks, a2 as jsxRuntimeExports, a3 as Qe } from "./server-build-B1ehSvPo.js";
6
+ import { r as reactExports } from "./app-RN9KG5Qq.js";
7
7
  import "node:stream";
8
8
  import "util";
9
9
  import "crypto";
@@ -2,9 +2,9 @@ import { createRequire as __wkfCreateRequire } from "node:module";
2
2
  if (typeof globalThis.require === "undefined") {
3
3
  globalThis.require = __wkfCreateRequire(import.meta.url);
4
4
  }
5
- import { H as HookSchema } from "./server-build-DMT2kgzu.js";
6
- import { B, D, a, E, b, c, d, e, L, M, f, g, P, Q, h, R, S, i, j, k, l, m, n, o, p, T, q, r, s, t, u, V, W, v, w, x, y, z, A, C, F, G, I, J, K, O, U, X, Y, Z, _, $ } from "./server-build-DMT2kgzu.js";
7
- import "./app-C6I0cOSv.js";
5
+ import { H as HookSchema } from "./server-build-B1ehSvPo.js";
6
+ import { B, D, a, E, b, c, d, e, L, M, f, g, P, Q, h, R, S, i, j, k, l, m, n, o, p, T, q, r, s, t, u, V, W, v, w, x, y, z, A, C, F, G, I, J, K, O, U, X, Y, Z, _, $ } from "./server-build-B1ehSvPo.js";
7
+ import "./app-RN9KG5Qq.js";
8
8
  import "stream";
9
9
  import "express";
10
10
  import "node:stream";
@@ -2,8 +2,8 @@ import { createRequire as __wkfCreateRequire } from "node:module";
2
2
  if (typeof globalThis.require === "undefined") {
3
3
  globalThis.require = __wkfCreateRequire(import.meta.url);
4
4
  }
5
- import { N as Nt } from "./server-build-DMT2kgzu.js";
6
- import "./app-C6I0cOSv.js";
5
+ import { N as Nt } from "./server-build-B1ehSvPo.js";
6
+ import "./app-RN9KG5Qq.js";
7
7
  import "stream";
8
8
  import "express";
9
9
  import "node:stream";
@@ -18,7 +18,7 @@ import { createRequire as __wkfCreateRequire } from "node:module";
18
18
  if (typeof globalThis.require === "undefined") {
19
19
  globalThis.require = __wkfCreateRequire(import.meta.url);
20
20
  }
21
- import { a as requireReact, S as ServerRouter, c as createReadableStreamFromReadable, r as reactExports, g as getDefaultExportFromCjs, R as React, b as ReactExports, w as withComponentProps, d as withErrorBoundaryProps, M as Meta, L as Links, e as ScrollRestoration, f as Scripts, O as Outlet, u as useNavigate, h as useSearchParams, i as Link$1, j as useRouteError, k as isRouteErrorResponse, l as useLocation, m as useParams } from "./app-C6I0cOSv.js";
21
+ import { a as requireReact, S as ServerRouter, c as createReadableStreamFromReadable, r as reactExports, g as getDefaultExportFromCjs, R as React, b as ReactExports, w as withComponentProps, d as withErrorBoundaryProps, M as Meta, L as Links, e as ScrollRestoration, f as Scripts, O as Outlet, u as useNavigate, h as useSearchParams, i as Link$1, j as useRouteError, k as isRouteErrorResponse, l as useLocation, m as useParams } from "./app-RN9KG5Qq.js";
22
22
  import require$$0$5, { PassThrough, Transform as Transform$1 } from "node:stream";
23
23
  import require$$0 from "util";
24
24
  import require$$1 from "crypto";
@@ -48889,7 +48889,8 @@ const QueuePayloadSchema = union([
48889
48889
  StepInvokePayloadSchema,
48890
48890
  HealthCheckPayloadSchema
48891
48891
  ]);
48892
- async function reenqueueActiveRuns(runs, enqueue, label) {
48892
+ async function reenqueueActiveRuns(runs, enqueue, label, namespace2) {
48893
+ const workflowQueuePrefix = getQueueTopicPrefix("workflow", resolveQueueNamespace(namespace2));
48893
48894
  let reenqueued = 0;
48894
48895
  for (const status of ["pending", "running"]) {
48895
48896
  let cursor;
@@ -48902,7 +48903,7 @@ async function reenqueueActiveRuns(runs, enqueue, label) {
48902
48903
  });
48903
48904
  for (const run2 of page.data) {
48904
48905
  try {
48905
- const queueName = `__wkf_workflow_${run2.workflowName}`;
48906
+ const queueName = `${workflowQueuePrefix}${run2.workflowName}`;
48906
48907
  await enqueue(queueName, { runId: run2.runId });
48907
48908
  reenqueued++;
48908
48909
  } catch (err) {
@@ -53039,7 +53040,6 @@ function EventRow({ event, index: index2, isFirst, isLast, isExpanded, onToggleE
53039
53040
  }, []);
53040
53041
  reactExports.useEffect(() => {
53041
53042
  if (encryptionKey && hasAttemptedLoad && onLoadEventData) {
53042
- setLoadedEventData(null);
53043
53043
  setHasAttemptedLoad(false);
53044
53044
  onLoadEventData(event).then((data) => {
53045
53045
  if (data !== null && data !== void 0) {
@@ -81857,7 +81857,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
81857
81857
  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 });
81858
81858
  var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
81859
81859
  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 }) });
81860
- var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-cjj8MLkd.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
81860
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-BHd4-kG6.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
81861
81861
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
81862
81862
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
81863
81863
  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 }) })] }) });
@@ -82179,7 +82179,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
82179
82179
  }, []), 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] });
82180
82180
  };
82181
82181
  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 }) })] });
82182
- var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-hoeX1Afz.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
82182
+ var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-DNnc363s.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
82183
82183
  function ke(e, t) {
82184
82184
  if (!(e != null && e.position || t != null && t.position)) return true;
82185
82185
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -92071,7 +92071,7 @@ createLogger("build", {
92071
92071
  debugNamespace: "workflow:build"
92072
92072
  });
92073
92073
  const MAX_QUEUE_DELIVERIES = 48;
92074
- const version$1 = "4.8.4";
92074
+ const version$1 = "4.8.6";
92075
92075
  const execFileAsync = promisify(execFile);
92076
92076
  function parsePort$1(value, radix = 10) {
92077
92077
  const port = parseInt(value, radix);
@@ -92320,6 +92320,18 @@ const config = once(() => {
92320
92320
  const baseUrl = getBaseUrlFromEnv();
92321
92321
  return { dataDir, baseUrl };
92322
92322
  });
92323
+ function resolveRecoverActiveRuns(config2) {
92324
+ var _a3;
92325
+ if (config2.recoverActiveRuns !== void 0) {
92326
+ return config2.recoverActiveRuns;
92327
+ }
92328
+ const raw2 = (_a3 = process.env.WORKFLOW_LOCAL_RECOVER_ACTIVE_RUNS) == null ? void 0 : _a3.toLowerCase();
92329
+ if (raw2 === "0" || raw2 === "false")
92330
+ return false;
92331
+ if (raw2 === "1" || raw2 === "true")
92332
+ return true;
92333
+ return true;
92334
+ }
92323
92335
  function resolveDirectBaseUrl(config2) {
92324
92336
  return config2.baseUrl ?? process.env.WORKFLOW_LOCAL_BASE_URL ?? createWorkflowBaseUrl("http://localhost");
92325
92337
  }
@@ -92392,8 +92404,10 @@ async function withWindowsRetry(fn2, maxRetries = 5) {
92392
92404
  throw new Error("Retry loop exited unexpectedly");
92393
92405
  }
92394
92406
  const createdFilesCache = /* @__PURE__ */ new Set();
92407
+ const createdDirectoriesCache = /* @__PURE__ */ new Set();
92395
92408
  function clearCreatedFilesCache() {
92396
92409
  createdFilesCache.clear();
92410
+ createdDirectoriesCache.clear();
92397
92411
  }
92398
92412
  const TAG_PATTERN = /\.[a-zA-Z][a-zA-Z0-9-]*$/;
92399
92413
  function stripTag(fileId) {
@@ -92446,11 +92460,29 @@ async function listTaggedFilesByExtension(dirPath, tag, extension2) {
92446
92460
  }
92447
92461
  }
92448
92462
  async function ensureDir(dirPath) {
92463
+ const resolvedPath = path$3.resolve(dirPath);
92464
+ if (createdDirectoriesCache.has(resolvedPath)) {
92465
+ return;
92466
+ }
92449
92467
  try {
92450
- await promises.mkdir(dirPath, { recursive: true });
92468
+ await promises.mkdir(resolvedPath, { recursive: true });
92469
+ createdDirectoriesCache.add(resolvedPath);
92451
92470
  } catch (_error) {
92452
92471
  }
92453
92472
  }
92473
+ async function withEnsuredDirectory(dirPath, operation) {
92474
+ await ensureDir(dirPath);
92475
+ try {
92476
+ return await operation();
92477
+ } catch (error2) {
92478
+ if (error2.code !== "ENOENT") {
92479
+ throw error2;
92480
+ }
92481
+ createdDirectoriesCache.delete(path$3.resolve(dirPath));
92482
+ await ensureDir(dirPath);
92483
+ return operation();
92484
+ }
92485
+ }
92454
92486
  function jsonReplacer(_key, value) {
92455
92487
  if (value instanceof Uint8Array) {
92456
92488
  return {
@@ -92487,10 +92519,11 @@ async function write(filePath, data, opts) {
92487
92519
  const tempPath = `${filePath}.tmp.${ulid$1()}`;
92488
92520
  let tempFileCreated = false;
92489
92521
  try {
92490
- await ensureDir(path$3.dirname(filePath));
92491
- await promises.writeFile(tempPath, data);
92492
- tempFileCreated = true;
92493
- await withWindowsRetry(() => promises.rename(tempPath, filePath));
92522
+ await withEnsuredDirectory(path$3.dirname(filePath), async () => {
92523
+ await promises.writeFile(tempPath, data);
92524
+ tempFileCreated = true;
92525
+ await withWindowsRetry(() => promises.rename(tempPath, filePath));
92526
+ });
92494
92527
  createdFilesCache.add(filePath);
92495
92528
  } catch (error2) {
92496
92529
  if (tempFileCreated) {
@@ -92533,21 +92566,22 @@ async function deleteJSON(filePath) {
92533
92566
  }
92534
92567
  }
92535
92568
  async function writeExclusive(filePath, data) {
92536
- await ensureDir(path$3.dirname(filePath));
92537
92569
  const tempPath = `${filePath}.tmp.${ulid$1()}`;
92538
92570
  let tempFileCreated = false;
92539
92571
  try {
92540
- await promises.writeFile(tempPath, data, { flag: "wx" });
92541
- tempFileCreated = true;
92542
- try {
92543
- await withWindowsRetry(() => promises.link(tempPath, filePath));
92544
- return true;
92545
- } catch (error2) {
92546
- if (error2.code === "EEXIST") {
92547
- return false;
92572
+ return await withEnsuredDirectory(path$3.dirname(filePath), async () => {
92573
+ await promises.writeFile(tempPath, data, { flag: "wx" });
92574
+ tempFileCreated = true;
92575
+ try {
92576
+ await withWindowsRetry(() => promises.link(tempPath, filePath));
92577
+ return true;
92578
+ } catch (error2) {
92579
+ if (error2.code === "EEXIST") {
92580
+ return false;
92581
+ }
92582
+ throw error2;
92548
92583
  }
92549
- throw error2;
92550
- }
92584
+ });
92551
92585
  } finally {
92552
92586
  if (tempFileCreated) {
92553
92587
  await withWindowsRetry(() => promises.unlink(tempPath), 3).catch(() => {
@@ -92581,11 +92615,12 @@ function createCursor(timestamp, id2) {
92581
92615
  return id2 ? `${timestamp.toISOString()}|${id2}` : timestamp.toISOString();
92582
92616
  }
92583
92617
  async function paginatedFileSystemQuery(config2) {
92584
- const { directory, schema, filePrefix, fileIdFilter, filter: filter2, sortOrder = "desc", limit = 20, cursor, getCreatedAt, getId } = config2;
92618
+ const { directory, schema, cachedItems, filePrefix, fileIdFilter, filter: filter2, sortOrder = "desc", limit = 20, cursor, getCreatedAt, getId } = config2;
92585
92619
  if (filePrefix !== void 0) {
92586
92620
  assertSafeEntityId("filePrefix", filePrefix);
92587
92621
  }
92588
- const fileIds = await listJSONFiles(directory);
92622
+ const resolvedDirectory = path$3.resolve(directory);
92623
+ const fileIds = await listJSONFiles(resolvedDirectory);
92589
92624
  const relevantFileIds = filePrefix ? fileIds.filter((fileId) => fileId.startsWith(filePrefix)) : fileIds;
92590
92625
  const filteredFileIds = fileIdFilter ? relevantFileIds.filter(fileIdFilter) : relevantFileIds;
92591
92626
  const parsedCursor = parseCursor(cursor);
@@ -92607,10 +92642,11 @@ async function paginatedFileSystemQuery(config2) {
92607
92642
  }
92608
92643
  const validItems = [];
92609
92644
  for (const fileId of candidateFileIds) {
92610
- const filePath = path$3.join(directory, `${fileId}.json`);
92645
+ const filePath = path$3.join(resolvedDirectory, `${fileId}.json`);
92611
92646
  let item = null;
92612
92647
  try {
92613
- item = await readJSON(filePath, schema);
92648
+ const cachedItem = cachedItems == null ? void 0 : cachedItems.get(filePath);
92649
+ item = cachedItem === void 0 ? await readJSON(filePath, schema) : structuredClone(cachedItem);
92614
92650
  } catch (error2) {
92615
92651
  if (error2 instanceof ZodError) {
92616
92652
  console.warn(`Skipping item ${fileId} due to malformed JSON: ${error2.message}`);
@@ -118870,6 +118906,8 @@ function createQueue$2(config2) {
118870
118906
  const transport = new TypedJsonTransport();
118871
118907
  const generateId2 = monotonicFactory();
118872
118908
  const semaphore = new libExports.Sema(WORKFLOW_LOCAL_QUEUE_CONCURRENCY);
118909
+ const closeController = new AbortController();
118910
+ const closeSignal = closeController.signal;
118873
118911
  const inflightMessages = /* @__PURE__ */ new Map();
118874
118912
  const directHandlers = /* @__PURE__ */ new Map();
118875
118913
  const queue = async (queueName, message2, opts) => {
@@ -118928,6 +118966,7 @@ function createQueue$2(config2) {
118928
118966
  headers: new Headers(headers2),
118929
118967
  body: body2,
118930
118968
  agents: nodeHttpAgents,
118969
+ signal: closeSignal,
118931
118970
  headersTimeoutMs: agentOptions.headersTimeout,
118932
118971
  bodyTimeoutMs: agentOptions.bodyTimeout
118933
118972
  }) : (
@@ -118937,7 +118976,8 @@ function createQueue$2(config2) {
118937
118976
  duplex: "half",
118938
118977
  dispatcher: httpAgent,
118939
118978
  headers: headers2,
118940
- body: body2
118979
+ body: body2,
118980
+ signal: closeSignal
118941
118981
  })
118942
118982
  );
118943
118983
  }
@@ -119043,6 +119083,9 @@ function createQueue$2(config2) {
119043
119083
  directHandlers.set(prefix, handler);
119044
119084
  },
119045
119085
  async close() {
119086
+ if (closeSignal.aborted)
119087
+ return;
119088
+ closeController.abort();
119046
119089
  if (nodeHttpAgents)
119047
119090
  destroyNodeHttpAgents(nodeHttpAgents);
119048
119091
  await (httpAgent == null ? void 0 : httpAgent.close());
@@ -119451,8 +119494,75 @@ async function deleteAllWaitsForRun(basedir, runId) {
119451
119494
  }
119452
119495
  }
119453
119496
  function createEventsStorage(basedir, tag) {
119497
+ const maxCachedEventBytes = 4 * 1024 * 1024;
119498
+ const maxCachedEventEntries = 1e3;
119499
+ const eventCache = /* @__PURE__ */ new Map();
119500
+ const cachedEventBytes = /* @__PURE__ */ new Map();
119501
+ const cachedPathsByRunId = /* @__PURE__ */ new Map();
119502
+ let totalCachedEventBytes = 0;
119503
+ function deleteCachedEvent(eventPath) {
119504
+ const event = eventCache.get(eventPath);
119505
+ if (!event) {
119506
+ return;
119507
+ }
119508
+ eventCache.delete(eventPath);
119509
+ totalCachedEventBytes -= cachedEventBytes.get(eventPath) ?? 0;
119510
+ cachedEventBytes.delete(eventPath);
119511
+ const cachedPaths = cachedPathsByRunId.get(event.runId);
119512
+ cachedPaths == null ? void 0 : cachedPaths.delete(eventPath);
119513
+ if ((cachedPaths == null ? void 0 : cachedPaths.size) === 0) {
119514
+ cachedPathsByRunId.delete(event.runId);
119515
+ }
119516
+ }
119517
+ function clearRunCache(runId) {
119518
+ for (const cachedPath of cachedPathsByRunId.get(runId) ?? []) {
119519
+ deleteCachedEvent(cachedPath);
119520
+ }
119521
+ }
119522
+ function clearCache() {
119523
+ eventCache.clear();
119524
+ cachedEventBytes.clear();
119525
+ cachedPathsByRunId.clear();
119526
+ totalCachedEventBytes = 0;
119527
+ }
119528
+ function cacheEvent(eventPath, cachedEvent, serializedBytes) {
119529
+ if (serializedBytes > maxCachedEventBytes) {
119530
+ return;
119531
+ }
119532
+ while (eventCache.size > 0 && (eventCache.size >= maxCachedEventEntries || totalCachedEventBytes + serializedBytes > maxCachedEventBytes)) {
119533
+ const oldestPath = eventCache.keys().next().value;
119534
+ deleteCachedEvent(oldestPath);
119535
+ }
119536
+ eventCache.set(eventPath, cachedEvent);
119537
+ cachedEventBytes.set(eventPath, serializedBytes);
119538
+ totalCachedEventBytes += serializedBytes;
119539
+ const cachedPaths = cachedPathsByRunId.get(cachedEvent.runId) ?? /* @__PURE__ */ new Set();
119540
+ cachedPaths.add(eventPath);
119541
+ cachedPathsByRunId.set(cachedEvent.runId, cachedPaths);
119542
+ }
119543
+ function rememberStoredEvent(event, eventPath, serializedEvent) {
119544
+ if (event.eventType === "run_completed" || event.eventType === "run_failed" || event.eventType === "run_cancelled") {
119545
+ clearRunCache(event.runId);
119546
+ return;
119547
+ }
119548
+ const serializedBytes = Buffer.byteLength(serializedEvent);
119549
+ if (serializedBytes > maxCachedEventBytes) {
119550
+ return;
119551
+ }
119552
+ const cachedEvent = EventSchema.safeParse(JSON.parse(serializedEvent, jsonReviver));
119553
+ if (cachedEvent.success) {
119554
+ cacheEvent(eventPath, cachedEvent.data, serializedBytes);
119555
+ }
119556
+ }
119557
+ async function storeEvent(event) {
119558
+ const eventPath = taggedPath(basedir, "events", `${event.runId}-${event.eventId}`, tag);
119559
+ const serializedEvent = JSON.stringify(event, jsonReplacer, 2);
119560
+ await write(eventPath, serializedEvent);
119561
+ rememberStoredEvent(event, eventPath, serializedEvent);
119562
+ }
119454
119563
  const hookLocks = /* @__PURE__ */ new Map();
119455
119564
  return {
119565
+ clearCache,
119456
119566
  async create(runId, data, params) {
119457
119567
  if (runId != null && runId !== "") {
119458
119568
  assertSafeEntityId("runId", runId);
@@ -119523,8 +119633,7 @@ function createEventsStorage(basedir, tag) {
119523
119633
  executionContext: runInputData.executionContext
119524
119634
  }
119525
119635
  };
119526
- const createdCompositeKey = `${effectiveRunId}-${runCreatedEventId}`;
119527
- await writeJSON(taggedPath(basedir, "events", createdCompositeKey, tag), runCreatedEvent);
119636
+ await storeEvent(runCreatedEvent);
119528
119637
  currentRun = createdRun;
119529
119638
  } else {
119530
119639
  currentRun = await readJSONWithFallback(basedir, "runs", effectiveRunId, WorkflowRunSchema, tag);
@@ -119554,8 +119663,7 @@ function createEventsStorage(basedir, tag) {
119554
119663
  createdAt: now2,
119555
119664
  specVersion: effectiveSpecVersion
119556
119665
  };
119557
- const compositeKey2 = `${effectiveRunId}-${eventId}`;
119558
- await writeJSON(taggedPath(basedir, "events", compositeKey2, tag), event2);
119666
+ await storeEvent(event2);
119559
119667
  const resolveData2 = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
119560
119668
  return {
119561
119669
  event: stripEventDataRefs(event2, resolveData2),
@@ -119904,8 +120012,7 @@ function createEventsStorage(basedir, tag) {
119904
120012
  createdAt: now2,
119905
120013
  specVersion: effectiveSpecVersion
119906
120014
  };
119907
- const compositeKey2 = `${effectiveRunId}-${eventId}`;
119908
- await writeJSON(taggedPath(basedir, "events", compositeKey2, tag), conflictEvent);
120015
+ await storeEvent(conflictEvent);
119909
120016
  const resolveData2 = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
119910
120017
  const filteredEvent2 = stripEventDataRefs(conflictEvent, resolveData2);
119911
120018
  return {
@@ -119989,13 +120096,16 @@ function createEventsStorage(basedir, tag) {
119989
120096
  await writeJSON(taggedPath(basedir, "waits", waitCompositeKey, tag), wait2, { overwrite: true });
119990
120097
  }
119991
120098
  const compositeKey = `${effectiveRunId}-${eventId}`;
119992
- const eventPublished = await writeExclusive(taggedPath(basedir, "events", compositeKey, tag), JSON.stringify(event, jsonReplacer, 2));
120099
+ const eventPath = taggedPath(basedir, "events", compositeKey, tag);
120100
+ const serializedEvent = JSON.stringify(event, jsonReplacer, 2);
120101
+ const eventPublished = await writeExclusive(eventPath, serializedEvent);
119993
120102
  if (!eventPublished) {
119994
120103
  if (data.eventType === "hook_created" && data.correlationId) {
119995
120104
  await repairHookEntityFromPersistedEvent(basedir, effectiveRunId, data.correlationId, eventId, tag);
119996
120105
  }
119997
120106
  throw new EntityConflictError(`Event "${eventId}" already exists for run "${effectiveRunId}"`);
119998
120107
  }
120108
+ rememberStoredEvent(event, eventPath, serializedEvent);
119999
120109
  if (hook && data.eventType === "hook_created") {
120000
120110
  await writeJSON(taggedPath(basedir, "hooks", hook.hookId, tag), hook, hookEntityWriteOptions);
120001
120111
  }
@@ -120008,6 +120118,7 @@ function createEventsStorage(basedir, tag) {
120008
120118
  const allEvents = await paginatedFileSystemQuery({
120009
120119
  directory: path$3.join(basedir, "events"),
120010
120120
  schema: EventSchema,
120121
+ cachedItems: eventCache,
120011
120122
  filePrefix: `${effectiveRunId}-`,
120012
120123
  sortOrder: "asc",
120013
120124
  limit: 1e3,
@@ -120051,6 +120162,7 @@ function createEventsStorage(basedir, tag) {
120051
120162
  const result = await paginatedFileSystemQuery({
120052
120163
  directory: path$3.join(basedir, "events"),
120053
120164
  schema: EventSchema,
120165
+ cachedItems: eventCache,
120054
120166
  filePrefix: `${runId}-`,
120055
120167
  // Events in chronological order (oldest first) by default,
120056
120168
  // different from the default for other list calls.
@@ -120076,8 +120188,9 @@ function createEventsStorage(basedir, tag) {
120076
120188
  const result = await paginatedFileSystemQuery({
120077
120189
  directory: path$3.join(basedir, "events"),
120078
120190
  schema: EventSchema,
120191
+ cachedItems: eventCache,
120079
120192
  // No filePrefix - search all events
120080
- filter: (event) => event.correlationId === correlationId,
120193
+ filter: (event) => event.correlationId === correlationId && (params.runId === void 0 || event.runId === params.runId),
120081
120194
  // Events in chronological order (oldest first) by default,
120082
120195
  // different from the default for other list calls.
120083
120196
  sortOrder: ((_a3 = params.pagination) == null ? void 0 : _a3.sortOrder) ?? "asc",
@@ -120202,7 +120315,8 @@ function createStorage$1(basedir, tag) {
120202
120315
  runs: instrumentObject$1("world.runs", runs),
120203
120316
  steps: instrumentObject$1("world.steps", steps),
120204
120317
  events: instrumentObject$1("world.events", events2),
120205
- hooks: instrumentObject$1("world.hooks", hooks)
120318
+ hooks: instrumentObject$1("world.hooks", hooks),
120319
+ clearCache: () => events2.clearCache()
120206
120320
  };
120207
120321
  }
120208
120322
  const monotonicUlid = monotonicFactory(() => Math.random());
@@ -120582,8 +120696,8 @@ function createLocalWorld(args) {
120582
120696
  const mergedConfig = { ...config.value, ...definedArgs };
120583
120697
  const tag = mergedConfig.tag;
120584
120698
  const queue = createQueue$2(mergedConfig);
120585
- const storage = createStorage$1(mergedConfig.dataDir, tag);
120586
- const recoverActiveRuns = mergedConfig.recoverActiveRuns ?? true;
120699
+ const { clearCache: clearStorageCache, ...storage } = createStorage$1(mergedConfig.dataDir, tag);
120700
+ const recoverActiveRuns = resolveRecoverActiveRuns(mergedConfig);
120587
120701
  return {
120588
120702
  specVersion: SPEC_VERSION_CURRENT,
120589
120703
  ...queue,
@@ -120610,14 +120724,16 @@ function createLocalWorld(args) {
120610
120724
  await reenqueueActiveRuns(recoveryRuns, queue.queue, "world-local");
120611
120725
  },
120612
120726
  async close() {
120727
+ clearStorageCache();
120613
120728
  await queue.close();
120614
120729
  },
120615
120730
  async clear() {
120731
+ clearStorageCache();
120616
120732
  if (tag) {
120617
120733
  const basedir = mergedConfig.dataDir;
120618
120734
  const hooksDir = path$3.join(basedir, "hooks");
120619
120735
  const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
120620
- const { HookSchema: HookSchema2 } = await import("./index-DKbGT0YI.js");
120736
+ const { HookSchema: HookSchema2 } = await import("./index-9aIXU-9S.js");
120621
120737
  await Promise.all(taggedHookFiles.map(async (hookFile) => {
120622
120738
  const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
120623
120739
  if (hook == null ? void 0 : hook.token) {
@@ -120646,6 +120762,7 @@ function createLocalWorld(args) {
120646
120762
  })));
120647
120763
  clearCreatedFilesCache();
120648
120764
  } else {
120765
+ clearCreatedFilesCache();
120649
120766
  await rm(mergedConfig.dataDir, { recursive: true, force: true });
120650
120767
  await initDataDir(mergedConfig.dataDir);
120651
120768
  }
@@ -121043,8 +121160,8 @@ function requireGetVercelOidcToken() {
121043
121160
  }
121044
121161
  try {
121045
121162
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
121046
- await import("./token-util-VIl8FT7v.js").then((n) => n.t),
121047
- await import("./token-BY9pJoVX.js").then((n) => n.t)
121163
+ await import("./token-util-0IzeGP3A.js").then((n) => n.t),
121164
+ await import("./token-Csl_4rgO.js").then((n) => n.t)
121048
121165
  ]);
121049
121166
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
121050
121167
  await refreshToken(options);
@@ -121769,7 +121886,7 @@ function httpClientSpanAttributes(args) {
121769
121886
  };
121770
121887
  }
121771
121888
  async function instrumentedFetch(opts) {
121772
- const { method, url: url2, headers: headers2, body: body2, dispatcher: dispatcher2, peerService = "workflow-server", timeoutMs = REQUEST_TIMEOUT_MS, signal: callerSignal, injectTraceContext = true, cacheBust = true, logLabel, buildError, onTransportOutcome } = opts;
121889
+ const { method, url: url2, headers: headers2, body: body2, dispatcher: dispatcher2, peerService = "workflow-server", timeoutMs = REQUEST_TIMEOUT_MS, signal: callerSignal, injectTraceContext = true, cacheBust = true, logLabel, buildError, onTransportOutcome, deferTransportSuccessUntilBody = false } = opts;
121773
121890
  const label = logLabel ?? url2;
121774
121891
  return trace(`http ${method}`, { kind: await getSpanKind("CLIENT") }, async (span) => {
121775
121892
  var _a3, _b2, _c;
@@ -121818,18 +121935,31 @@ async function instrumentedFetch(opts) {
121818
121935
  throw error2;
121819
121936
  }
121820
121937
  const ms2 = Date.now() - start2;
121821
- onTransportOutcome == null ? void 0 : onTransportOutcome();
121938
+ if (!deferTransportSuccessUntilBody)
121939
+ onTransportOutcome == null ? void 0 : onTransportOutcome();
121822
121940
  httpLog(method, label, response2, ms2);
121823
121941
  span == null ? void 0 : span.setAttributes({ ...HttpResponseStatusCode(response2.status) });
121824
121942
  if (!response2.ok) {
121825
121943
  span == null ? void 0 : span.setAttributes({ ...ErrorType(`HTTP ${response2.status}`) });
121826
121944
  logCurlRepro(method, url2, headers2);
121827
121945
  if (buildError) {
121828
- const error3 = await buildError(response2);
121946
+ let error3;
121947
+ try {
121948
+ error3 = await buildError(response2);
121949
+ } catch (cause) {
121950
+ if (deferTransportSuccessUntilBody) {
121951
+ onTransportOutcome == null ? void 0 : onTransportOutcome(cause);
121952
+ }
121953
+ throw cause;
121954
+ }
121955
+ if (deferTransportSuccessUntilBody)
121956
+ onTransportOutcome == null ? void 0 : onTransportOutcome();
121829
121957
  (_b2 = span == null ? void 0 : span.recordException) == null ? void 0 : _b2.call(span, error3);
121830
121958
  throw error3;
121831
121959
  }
121832
121960
  const text2 = await response2.text().catch(() => "");
121961
+ if (deferTransportSuccessUntilBody)
121962
+ onTransportOutcome == null ? void 0 : onTransportOutcome();
121833
121963
  const error2 = errorForResponse(response2.status, `${method} ${label} -> HTTP ${response2.status}: ${response2.statusText}${text2 ? ` ${text2}` : ""}${formatVercelDiagnostics(response2.headers)}`, {
121834
121964
  url: url2,
121835
121965
  retryAfter: parseRetryAfter(response2.headers.get("Retry-After"))
@@ -126531,7 +126661,7 @@ var QueueClient = class {
126531
126661
  setApi(this, new ApiClient({ ...options, region }));
126532
126662
  }
126533
126663
  };
126534
- const version = "4.7.0";
126664
+ const version = "4.7.2";
126535
126665
  const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
126536
126666
  const MAX_BODY_PARSE_RETRIES = 2;
126537
126667
  const BODY_PARSE_RETRY_BASE_MS = 100;
@@ -127033,17 +127163,30 @@ function createQueue$1(config2) {
127033
127163
  const ResolveLatestDeploymentResponseSchema = object$1({
127034
127164
  id: string$3()
127035
127165
  });
127166
+ async function resolveDeploymentIdentityToken(config2) {
127167
+ if (config2 == null ? void 0 : config2.token)
127168
+ return config2.token;
127169
+ if (process.env.VERCEL === "1") {
127170
+ const oidcToken = await distExports.getVercelOidcToken().catch(() => null);
127171
+ if (oidcToken)
127172
+ return oidcToken;
127173
+ }
127174
+ return resolveVercelApiToken(config2);
127175
+ }
127036
127176
  function createResolveLatestDeploymentId(config2) {
127037
127177
  return async function resolveLatestDeploymentId() {
127178
+ var _a3;
127038
127179
  const currentDeploymentId = process.env.VERCEL_DEPLOYMENT_ID;
127039
127180
  if (!currentDeploymentId) {
127040
127181
  throw new Error("Cannot resolve latest deployment: VERCEL_DEPLOYMENT_ID environment variable is not set");
127041
127182
  }
127042
- const token = await resolveVercelApiToken(config2);
127183
+ const token = await resolveDeploymentIdentityToken(config2);
127043
127184
  if (!token) {
127044
127185
  throw new Error("Cannot resolve latest deployment: no OIDC token or VERCEL_TOKEN available");
127045
127186
  }
127046
- const url2 = `https://api.vercel.com/v1/workflow/resolve-latest-deployment/${encodeURIComponent(currentDeploymentId)}`;
127187
+ const teamId = (_a3 = config2 == null ? void 0 : config2.projectConfig) == null ? void 0 : _a3.teamId;
127188
+ const query = teamId ? `?${new URLSearchParams({ teamId })}` : "";
127189
+ const url2 = `https://api.vercel.com/v1/workflow/resolve-latest-deployment/${encodeURIComponent(currentDeploymentId)}${query}`;
127047
127190
  const response2 = await instrumentedFetch({
127048
127191
  method: "GET",
127049
127192
  url: url2,
@@ -127060,7 +127203,8 @@ function createResolveLatestDeploymentId(config2) {
127060
127203
  } catch {
127061
127204
  body2 = "<unable to read response body>";
127062
127205
  }
127063
- return new Error(`Failed to resolve latest deployment for ${currentDeploymentId}: HTTP ${res.status} ${res.statusText}${body2 ? ` ${body2}` : ""}`);
127206
+ const hint = res.status === 404 ? ". The deployment exists but was not visible to the identity this request authenticated as, which means the request resolved to a different team. Set the World's `projectConfig.teamId` to scope it explicitly." : "";
127207
+ return new Error(`Failed to resolve latest deployment for ${currentDeploymentId}: HTTP ${res.status} ${res.statusText}${body2 ? ` — ${body2}` : ""}${hint}`);
127064
127208
  }
127065
127209
  });
127066
127210
  const data = await response2.json();
@@ -127326,7 +127470,7 @@ async function* readerToIterator(reader) {
127326
127470
  }
127327
127471
  async function fetchV4(url2, init2, config2, opName) {
127328
127472
  const dispatcher2 = getEventsDispatcher(config2);
127329
- return instrumentedFetch({
127473
+ const response2 = await instrumentedFetch({
127330
127474
  method: init2.method,
127331
127475
  url: url2,
127332
127476
  headers: init2.headers,
@@ -127337,9 +127481,40 @@ async function fetchV4(url2, init2, config2, opName) {
127337
127481
  // service indefinitely, so without this every request routed onto it fails
127338
127482
  // until the compute instance is recycled — see noteEventsTransportOutcome.
127339
127483
  onTransportOutcome: (error2) => noteEventsTransportOutcome(dispatcher2, error2),
127484
+ deferTransportSuccessUntilBody: true,
127340
127485
  timeoutMs: null,
127341
127486
  logLabel: opName,
127342
- buildError: async (response2) => errorFromV4Response(response2.status, headersToRecord(response2.headers), await response2.text(), opName, url2)
127487
+ buildError: async (response3) => errorFromV4Response(response3.status, headersToRecord(response3.headers), await response3.text(), opName, url2)
127488
+ });
127489
+ if (!response2.body) {
127490
+ noteEventsTransportOutcome(dispatcher2);
127491
+ return response2;
127492
+ }
127493
+ const reader = response2.body.getReader();
127494
+ const body2 = new ReadableStream({
127495
+ async pull(controller) {
127496
+ try {
127497
+ const chunk = await reader.read();
127498
+ if (chunk.done) {
127499
+ noteEventsTransportOutcome(dispatcher2);
127500
+ controller.close();
127501
+ } else {
127502
+ controller.enqueue(chunk.value);
127503
+ }
127504
+ } catch (cause) {
127505
+ noteEventsTransportOutcome(dispatcher2, cause);
127506
+ controller.error(cause);
127507
+ }
127508
+ },
127509
+ cancel(reason) {
127510
+ noteEventsTransportOutcome(dispatcher2);
127511
+ return reader.cancel(reason);
127512
+ }
127513
+ });
127514
+ return new Response(body2, {
127515
+ status: response2.status,
127516
+ statusText: response2.statusText,
127517
+ headers: response2.headers
127343
127518
  });
127344
127519
  }
127345
127520
  function headersToRecord(headers2) {
@@ -127508,10 +127683,12 @@ async function getWorkflowRunEventsV4(runId, params = {}, config2) {
127508
127683
  const url2 = `${baseUrl}/v4/runs/${encodeURIComponent(runId)}/events` + paginationToQuery(params);
127509
127684
  return consumeListFrameStream(url2, headers2, config2, "listEvents");
127510
127685
  }
127511
- async function getEventsByCorrelationIdV4(correlationId, params = {}, config2) {
127686
+ async function getEventsByCorrelationIdV4(correlationId, params = {}, config2, runId) {
127512
127687
  const { baseUrl, headers: headers2 } = await getHttpConfig(config2);
127513
127688
  const sp = new URLSearchParams();
127514
127689
  sp.set("correlationId", correlationId);
127690
+ if (runId !== void 0)
127691
+ sp.set("runId", runId);
127515
127692
  appendListParams(sp, params);
127516
127693
  const url2 = `${baseUrl}/v4/events?${sp.toString()}`;
127517
127694
  return consumeListFrameStream(url2, headers2, config2, "listEventsByCorrelationId");
@@ -127896,10 +128073,13 @@ async function getWorkflowRunEvents(params, config2) {
127896
128073
  sortOrder: pagination == null ? void 0 : pagination.sortOrder,
127897
128074
  remoteRefBehavior: resolveData === "none" ? "lazy" : "resolve"
127898
128075
  };
127899
- const result = await ("correlationId" in params ? getEventsByCorrelationIdV4(params.correlationId, wirePagination, config2) : getWorkflowRunEventsV4(params.runId, wirePagination, config2));
128076
+ const runId = "correlationId" in params ? params.runId : void 0;
128077
+ const result = await ("correlationId" in params ? getEventsByCorrelationIdV4(params.correlationId, wirePagination, config2, runId) : getWorkflowRunEventsV4(params.runId, wirePagination, config2));
127900
128078
  const events2 = result.events.map((listed) => buildEventFromV4(listed.event, listed.body, resolveData));
127901
128079
  return {
127902
- data: events2,
128080
+ // Older servers may ignore the runId query parameter. Keep the client
128081
+ // filter as a compatibility guard until every server honors it.
128082
+ data: runId !== void 0 ? events2.filter((event) => event.runId === runId) : events2,
127903
128083
  cursor: result.next ?? null,
127904
128084
  hasMore: Boolean(result.next)
127905
128085
  };
@@ -129048,7 +129228,7 @@ class WorkflowServerReadableStream extends ReadableStream {
129048
129228
  _reader = new WeakMap();
129049
129229
  const FRAMED_STREAM_MAX_RECONNECTS = 50;
129050
129230
  const FRAMED_STREAM_MAX_TOTAL_RECONNECTS = 1e3;
129051
- function createReconnectingFramedStream(name2, startIndex) {
129231
+ function createReconnectingFramedStream(runId, name2, startIndex) {
129052
129232
  const reconnectSupported = startIndex === void 0 || startIndex >= 0;
129053
129233
  let currentStartIndex = startIndex ?? 0;
129054
129234
  let consumedFrames = 0;
@@ -129062,6 +129242,15 @@ function createReconnectingFramedStream(name2, startIndex) {
129062
129242
  const stream = await world.readFromStream(name2, effectiveStartIndex);
129063
129243
  reader = stream.getReader();
129064
129244
  }
129245
+ async function isVerifiedComplete() {
129246
+ try {
129247
+ const world = getWorld();
129248
+ const info = await world.getStreamInfo(name2, runId);
129249
+ return info.done && currentStartIndex + consumedFrames > info.tailIndex;
129250
+ } catch {
129251
+ return true;
129252
+ }
129253
+ }
129065
129254
  async function reconnect() {
129066
129255
  if (reader) {
129067
129256
  await reader.cancel().catch(() => {
@@ -129116,6 +129305,15 @@ function createReconnectingFramedStream(name2, startIndex) {
129116
129305
  }
129117
129306
  if (result.done || !result.value) {
129118
129307
  reader = void 0;
129308
+ if (reconnectSupported && !await isVerifiedComplete()) {
129309
+ try {
129310
+ await reconnect();
129311
+ } catch (reconnectErr) {
129312
+ controller.error(reconnectErr);
129313
+ return;
129314
+ }
129315
+ continue;
129316
+ }
129119
129317
  controller.close();
129120
129318
  return;
129121
129319
  }
@@ -129643,7 +129841,7 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey) {
129643
129841
  pollReadableLock(userReadable, state);
129644
129842
  return userReadable;
129645
129843
  } else {
129646
- const readable2 = createReconnectingFramedStream(value.name, value.startIndex);
129844
+ const readable2 = createReconnectingFramedStream(runId, value.name, value.startIndex);
129647
129845
  const transform2 = getDeserializeStream(getExternalRevivers(global2, ops, runId, cryptoKey), cryptoKey);
129648
129846
  const state = createFlushableState();
129649
129847
  ops.push(state.promise);
@@ -130030,6 +130228,10 @@ async function dehydrateStepReturnValue(value, runId, key, ops = [], global2 = g
130030
130228
  throw new WorkflowRuntimeError(formatSerializationError("step return value", error2), { slug: "serialization-failed", cause: error2 });
130031
130229
  }
130032
130230
  }
130231
+ const UNSERIALIZABLE_FLAG = "__workflowUnserializableStepInput";
130232
+ function isUnserializableStepInputPlaceholder(hydratedInput) {
130233
+ return typeof hydratedInput === "object" && hydratedInput !== null && hydratedInput[UNSERIALIZABLE_FLAG] === true;
130234
+ }
130033
130235
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
130034
130236
  var intToChar = new Uint8Array(64);
130035
130237
  var charToInt = new Uint8Array(128);
@@ -133644,6 +133846,9 @@ createQueueHandler(stepPrefix, async (message_, metadata) => {
133644
133846
  let userCodeFailed = false;
133645
133847
  const executionStartTime = Date.now();
133646
133848
  try {
133849
+ if (isUnserializableStepInputPlaceholder(hydratedInput)) {
133850
+ throw new FatalError(formatSerializationError("step arguments", void 0));
133851
+ }
133647
133852
  result = await trace$2("step.execute", {}, async () => {
133648
133853
  return await contextStorage.run({
133649
133854
  stepMetadata: {
@@ -134431,11 +134636,18 @@ async function fetchEvent(worldEnv, runId, eventId, resolveData = "all") {
134431
134636
  }
134432
134637
  }
134433
134638
  async function fetchEventsByCorrelationId(worldEnv, correlationId, params) {
134434
- const { cursor, sortOrder = "asc", limit = 100, withData = false } = params;
134639
+ const {
134640
+ runId,
134641
+ cursor,
134642
+ sortOrder = "asc",
134643
+ limit = 100,
134644
+ withData = false
134645
+ } = params;
134435
134646
  try {
134436
134647
  const world = await getWorldFromEnv(worldEnv);
134437
134648
  const result = await world.events.listByCorrelationId({
134438
134649
  correlationId,
134650
+ runId,
134439
134651
  pagination: { cursor, limit, sortOrder },
134440
134652
  resolveData: withData ? "all" : "none"
134441
134653
  });
@@ -154893,6 +155105,7 @@ function useEventsListData(env2, runId, options = {}) {
154893
155105
  }
154894
155106
  const { error: fetchError, result } = await unwrapServerActionResult(
154895
155107
  fetchEventsByCorrelationId$1(env2, id2, {
155108
+ runId,
154896
155109
  cursor: nextCursor,
154897
155110
  sortOrder,
154898
155111
  limit: 100,
@@ -155649,7 +155862,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
155649
155862
  __proto__: null,
155650
155863
  loader
155651
155864
  }, Symbol.toStringTag, { value: "Module" }));
155652
- const serverManifest = { "entry": { "module": "/assets/entry.client-C_C46bD6.js", "imports": ["/assets/index-BsV8i_Jn.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": true, "module": "/assets/root-BxnaECGo.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js"], "css": ["/assets/root-BOS11TzD.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.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-Blj6TeEE.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/workflow-graph-viewer-C6PWoIIU.js", "/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js", "/assets/index-DZSXezpI.js"], "css": ["/assets/workflow-graph-viewer-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.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-Cbuf5qtv.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/workflow-graph-viewer-C6PWoIIU.js", "/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js", "/assets/encryption-BRhjWsZh.js", "/assets/index-DZSXezpI.js"], "css": ["/assets/workflow-graph-viewer-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.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-0285e96f.js", "version": "0285e96f", "sri": void 0 };
155865
+ const serverManifest = { "entry": { "module": "/assets/entry.client-C_C46bD6.js", "imports": ["/assets/index-BsV8i_Jn.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": true, "module": "/assets/root-BxnaECGo.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js"], "css": ["/assets/root-BOS11TzD.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.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-Blj6TeEE.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/workflow-graph-viewer-C6PWoIIU.js", "/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js", "/assets/index-DZSXezpI.js"], "css": ["/assets/workflow-graph-viewer-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.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-DivTczoC.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/workflow-graph-viewer-C6PWoIIU.js", "/assets/mermaid-3ZIDBTTL-Bp6ZST9_.js", "/assets/encryption-BRhjWsZh.js", "/assets/index-DZSXezpI.js"], "css": ["/assets/workflow-graph-viewer-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.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-7bf3847b.js", "version": "7bf3847b", "sri": void 0 };
155653
155866
  const assetsBuildDirectory = "build/client";
155654
155867
  const basename = "/";
155655
155868
  const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };
@@ -2,8 +2,8 @@ import { createRequire as __wkfCreateRequire } from "node:module";
2
2
  if (typeof globalThis.require === "undefined") {
3
3
  globalThis.require = __wkfCreateRequire(import.meta.url);
4
4
  }
5
- import { g as getDefaultExportFromCjs } from "./app-C6I0cOSv.js";
6
- import { a5 as requireTokenError, a4 as requireTokenUtil } from "./server-build-DMT2kgzu.js";
5
+ import { g as getDefaultExportFromCjs } from "./app-RN9KG5Qq.js";
6
+ import { a5 as requireTokenError, a4 as requireTokenUtil } from "./server-build-B1ehSvPo.js";
7
7
  function _mergeNamespaces(n, m) {
8
8
  for (var i = 0; i < m.length; i++) {
9
9
  const e = m[i];
@@ -2,8 +2,8 @@ import { createRequire as __wkfCreateRequire } from "node:module";
2
2
  if (typeof globalThis.require === "undefined") {
3
3
  globalThis.require = __wkfCreateRequire(import.meta.url);
4
4
  }
5
- import { g as getDefaultExportFromCjs } from "./app-C6I0cOSv.js";
6
- import { a4 as requireTokenUtil } from "./server-build-DMT2kgzu.js";
5
+ import { g as getDefaultExportFromCjs } from "./app-RN9KG5Qq.js";
6
+ import { a4 as requireTokenUtil } from "./server-build-B1ehSvPo.js";
7
7
  function _mergeNamespaces(n, m) {
8
8
  for (var i = 0; i < m.length; i++) {
9
9
  const e = m[i];
@@ -2,7 +2,7 @@ import { createRequire as __wkfCreateRequire } from "node:module";
2
2
  if (typeof globalThis.require === "undefined") {
3
3
  globalThis.require = __wkfCreateRequire(import.meta.url);
4
4
  }
5
- import { n } from "./assets/app-C6I0cOSv.js";
5
+ import { n } from "./assets/app-RN9KG5Qq.js";
6
6
  import "express";
7
7
  import "stream";
8
8
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@workflow/web",
3
3
  "description": "Workflow Observability UI",
4
- "version": "4.1.20",
4
+ "version": "4.1.22",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "files": [
@@ -71,12 +71,12 @@
71
71
  "vite": "^6",
72
72
  "vitest": "^3",
73
73
  "jsdom": "^26",
74
- "@workflow/core": "4.8.4",
74
+ "@workflow/core": "4.8.6",
75
75
  "@workflow/errors": "4.2.1",
76
76
  "@workflow/utils": "4.1.4",
77
- "@workflow/web-shared": "4.1.20",
78
- "@workflow/world": "4.4.0",
79
- "@workflow/world-vercel": "4.7.0"
77
+ "@workflow/web-shared": "4.1.22",
78
+ "@workflow/world": "4.5.0",
79
+ "@workflow/world-vercel": "4.7.2"
80
80
  },
81
81
  "scripts": {
82
82
  "dev": "react-router dev",