@workflow/web 5.3.0 → 5.3.2

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 (39) hide show
  1. package/README.md +11 -34
  2. package/build/client/assets/app-BHCSMHev.css +1 -0
  3. package/build/client/assets/{arrow-up-right-CNHh1bh2.js → arrow-up-right-DyaB_ak4.js} +1 -1
  4. package/build/client/assets/{entry.client-DDsh88VE.js → entry.client-xzxVCL3o.js} +1 -1
  5. package/build/client/assets/{highlighted-body-JLMTFACH-CWHg5f-6.js → highlighted-body-JLMTFACH-1yzOVKg0.js} +2 -2
  6. package/build/client/assets/{home-DZqYMSiD.js → home--wf0CrF6.js} +5 -3
  7. package/build/client/assets/{index-BS6T0Zjc.js → index-wl5l5E8H.js} +30 -25
  8. package/build/client/assets/manifest-7b81d8d4.js +1 -0
  9. package/build/client/assets/{mermaid-WFAXDIZX-BLO7Z8RE.js → mermaid-WFAXDIZX-CB__BxYb.js} +272 -2736
  10. package/build/client/assets/meta-9cjJ0pVb.js +6 -0
  11. package/build/client/assets/{root-wdKzRZGT.js → root-C1XwTNUK.js} +14 -8
  12. package/build/client/assets/root-C3ED6Dwc.css +1 -0
  13. package/build/client/assets/rpc-client-SbyXJdFV.js +2482 -0
  14. package/build/client/assets/{run-detail-DyXpnv9C.js → run-detail-2CnpdXm1.js} +426 -618
  15. package/build/client/assets/run-usage-C3aywyqa.js +33 -0
  16. package/build/client/assets/run-usage-DRV6lopZ.js +1261 -0
  17. package/build/client/assets/skeleton-DMLgjvZZ.js +94 -0
  18. package/build/client/assets/{url-state-DhOv2zv0.js → url-state-JAVaNZ_m.js} +79 -159
  19. package/build/client/assets/{zstd-browser-decoder-BNeg7hxG.js → zstd-browser-decoder-Z5736ep5.js} +2 -2
  20. package/build/server/assets/{app-CR0ndNHl.js → app-C4Vf0mu1.js} +2399 -494
  21. package/build/server/assets/{highlighted-body-JLMTFACH-j-e-XD1V.js → highlighted-body-JLMTFACH-CF_5tt3-.js} +1 -1
  22. package/build/server/assets/{index-BZ4PHwlc.js → index-BrYeW--s.js} +4 -4
  23. package/build/server/assets/{mermaid-WFAXDIZX-B19UvP0H.js → mermaid-WFAXDIZX-BHZz_uL6.js} +1 -1
  24. package/build/server/assets/{token-CPc7to8F.js → token-B94O3LuJ.js} +1 -1
  25. package/build/server/assets/{token-LLLE1g03.js → token-k0na1G9v.js} +2 -2
  26. package/build/server/assets/{token-util-CIYqGbhA.js → token-util-DFlzY9Hw.js} +2 -2
  27. package/build/server/assets/{token-util-D91uzxKb.js → token-util-DgTmPzWb.js} +1 -1
  28. package/build/server/assets/{wrapper-BKFP-Nku.js → wrapper-BEqyNEir.js} +2 -2
  29. package/build/server/assets/{zstd-browser-decoder-B228nPFT.js → zstd-browser-decoder-LnaKiDUZ.js} +1 -1
  30. package/build/server/index.js +1 -1
  31. package/handler.d.ts +9 -0
  32. package/handler.js +16 -2
  33. package/host-guard.js +179 -0
  34. package/package.json +8 -7
  35. package/server.d.ts +15 -1
  36. package/server.js +14 -1
  37. package/build/client/assets/app-BE8uqS_d.css +0 -1
  38. package/build/client/assets/manifest-f2e93220.js +0 -1
  39. package/build/client/assets/root-BBptRWmF.css +0 -1
@@ -1841,24 +1841,24 @@ function flattenAndRankRoutes(routes2) {
1841
1841
  }
1842
1842
  function flattenRoutes(routes2, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
1843
1843
  let flattenRoute = (route, index2, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
1844
- let meta = {
1844
+ let meta2 = {
1845
1845
  relativePath: relativePath === void 0 ? route.path || "" : relativePath,
1846
1846
  caseSensitive: route.caseSensitive === true,
1847
1847
  childrenIndex: index2,
1848
1848
  route
1849
1849
  };
1850
- if (meta.relativePath.startsWith("/")) {
1851
- if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
1850
+ if (meta2.relativePath.startsWith("/")) {
1851
+ if (!meta2.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
1852
1852
  return;
1853
1853
  }
1854
1854
  invariant$1(
1855
- meta.relativePath.startsWith(parentPath),
1856
- `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
1855
+ meta2.relativePath.startsWith(parentPath),
1856
+ `Absolute route path "${meta2.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
1857
1857
  );
1858
- meta.relativePath = meta.relativePath.slice(parentPath.length);
1858
+ meta2.relativePath = meta2.relativePath.slice(parentPath.length);
1859
1859
  }
1860
- let path2 = joinPaths([parentPath, meta.relativePath]);
1861
- let routesMeta = parentsMeta.concat(meta);
1860
+ let path2 = joinPaths([parentPath, meta2.relativePath]);
1861
+ let routesMeta = parentsMeta.concat(meta2);
1862
1862
  if (route.children && route.children.length > 0) {
1863
1863
  invariant$1(
1864
1864
  // Our types know better, but runtime JS may not!
@@ -1880,14 +1880,14 @@ function flattenRoutes(routes2, branches = [], parentsMeta = [], parentPath = ""
1880
1880
  branches.push({
1881
1881
  path: path2,
1882
1882
  score: computeScore(path2, route.index),
1883
- routesMeta: routesMeta.map((meta2, i) => {
1883
+ routesMeta: routesMeta.map((meta22, i) => {
1884
1884
  let [matcher2, params] = compilePath(
1885
- meta2.relativePath,
1886
- meta2.caseSensitive,
1885
+ meta22.relativePath,
1886
+ meta22.caseSensitive,
1887
1887
  i === routesMeta.length - 1
1888
1888
  );
1889
1889
  return {
1890
- ...meta2,
1890
+ ...meta22,
1891
1891
  matcher: matcher2,
1892
1892
  compiledParams: params
1893
1893
  };
@@ -1932,8 +1932,8 @@ function explodeOptionalSegments(path2) {
1932
1932
  function rankRouteBranches(branches) {
1933
1933
  branches.sort(
1934
1934
  (a2, b2) => a2.score !== b2.score ? b2.score - a2.score : compareIndexes(
1935
- a2.routesMeta.map((meta) => meta.childrenIndex),
1936
- b2.routesMeta.map((meta) => meta.childrenIndex)
1935
+ a2.routesMeta.map((meta2) => meta2.childrenIndex),
1936
+ b2.routesMeta.map((meta2) => meta2.childrenIndex)
1937
1937
  )
1938
1938
  );
1939
1939
  }
@@ -1978,29 +1978,29 @@ function matchRouteBranch(branch, pathname, allowPartial = false) {
1978
1978
  let matchedPathname = "/";
1979
1979
  let matches = [];
1980
1980
  for (let i = 0; i < routesMeta.length; ++i) {
1981
- let meta = routesMeta[i];
1981
+ let meta2 = routesMeta[i];
1982
1982
  let end = i === routesMeta.length - 1;
1983
1983
  let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
1984
1984
  let pattern2 = {
1985
- path: meta.relativePath,
1986
- caseSensitive: meta.caseSensitive,
1985
+ path: meta2.relativePath,
1986
+ caseSensitive: meta2.caseSensitive,
1987
1987
  end
1988
1988
  };
1989
1989
  let match2 = (
1990
1990
  // Use precomputed matcher if it exists
1991
- meta.matcher && meta.compiledParams ? matchPathImpl(
1991
+ meta2.matcher && meta2.compiledParams ? matchPathImpl(
1992
1992
  pattern2,
1993
1993
  remainingPathname,
1994
- meta.matcher,
1995
- meta.compiledParams
1994
+ meta2.matcher,
1995
+ meta2.compiledParams
1996
1996
  ) : matchPath(pattern2, remainingPathname)
1997
1997
  );
1998
- let route = meta.route;
1998
+ let route = meta2.route;
1999
1999
  if (!match2 && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
2000
2000
  match2 = matchPath(
2001
2001
  {
2002
- path: meta.relativePath,
2003
- caseSensitive: meta.caseSensitive,
2002
+ path: meta2.relativePath,
2003
+ caseSensitive: meta2.caseSensitive,
2004
2004
  end: false
2005
2005
  },
2006
2006
  remainingPathname
@@ -4308,6 +4308,9 @@ function useNavigateUnstable() {
4308
4308
  return navigate;
4309
4309
  }
4310
4310
  var OutletContext = reactExports.createContext(null);
4311
+ function useOutletContext() {
4312
+ return reactExports.useContext(OutletContext);
4313
+ }
4311
4314
  function useOutlet(context) {
4312
4315
  let outlet = reactExports.useContext(RouteContext).outlet;
4313
4316
  return reactExports.useMemo(
@@ -6589,7 +6592,7 @@ function Meta() {
6589
6592
  if (errors2) {
6590
6593
  error2 = errors2[_matches[_matches.length - 1].route.id];
6591
6594
  }
6592
- let meta = [];
6595
+ let meta2 = [];
6593
6596
  let leafMeta = null;
6594
6597
  let matches = [];
6595
6598
  for (let i = 0; i < _matches.length; i++) {
@@ -6630,10 +6633,10 @@ function Meta() {
6630
6633
  }
6631
6634
  match2.meta = routeMeta;
6632
6635
  matches[i] = match2;
6633
- meta = [...routeMeta];
6634
- leafMeta = meta;
6636
+ meta2 = [...routeMeta];
6637
+ leafMeta = meta2;
6635
6638
  }
6636
- return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, meta.flat().map((metaProps) => {
6639
+ return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, meta2.flat().map((metaProps) => {
6637
6640
  if (!metaProps) {
6638
6641
  return null;
6639
6642
  }
@@ -41716,7 +41719,7 @@ const createLucideIcon = (iconName, iconNode) => {
41716
41719
  * This source code is licensed under the ISC license.
41717
41720
  * See the LICENSE file in the root directory of this source tree.
41718
41721
  */
41719
- const __iconNode$K = [
41722
+ const __iconNode$L = [
41720
41723
  [
41721
41724
  "path",
41722
41725
  {
@@ -41725,14 +41728,14 @@ const __iconNode$K = [
41725
41728
  }
41726
41729
  ]
41727
41730
  ];
41728
- const Activity = createLucideIcon("activity", __iconNode$K);
41731
+ const Activity = createLucideIcon("activity", __iconNode$L);
41729
41732
  /**
41730
41733
  * @license lucide-react v0.575.0 - ISC
41731
41734
  *
41732
41735
  * This source code is licensed under the ISC license.
41733
41736
  * See the LICENSE file in the root directory of this source tree.
41734
41737
  */
41735
- const __iconNode$J = [
41738
+ const __iconNode$K = [
41736
41739
  ["path", { d: "M6.87 6.87a8 8 0 1 0 11.26 11.26", key: "3on8tj" }],
41737
41740
  ["path", { d: "M19.9 14.25a8 8 0 0 0-9.15-9.15", key: "15ghsc" }],
41738
41741
  ["path", { d: "m22 6-3-3", key: "1opdir" }],
@@ -41740,75 +41743,75 @@ const __iconNode$J = [
41740
41743
  ["path", { d: "m2 2 20 20", key: "1ooewy" }],
41741
41744
  ["path", { d: "M4 4 2 6", key: "1ycko6" }]
41742
41745
  ];
41743
- const AlarmClockOff = createLucideIcon("alarm-clock-off", __iconNode$J);
41746
+ const AlarmClockOff = createLucideIcon("alarm-clock-off", __iconNode$K);
41744
41747
  /**
41745
41748
  * @license lucide-react v0.575.0 - ISC
41746
41749
  *
41747
41750
  * This source code is licensed under the ISC license.
41748
41751
  * See the LICENSE file in the root directory of this source tree.
41749
41752
  */
41750
- const __iconNode$I = [
41753
+ const __iconNode$J = [
41751
41754
  ["path", { d: "m3 16 4 4 4-4", key: "1co6wj" }],
41752
41755
  ["path", { d: "M7 20V4", key: "1yoxec" }],
41753
41756
  ["path", { d: "M20 8h-5", key: "1vsyxs" }],
41754
41757
  ["path", { d: "M15 10V6.5a2.5 2.5 0 0 1 5 0V10", key: "ag13bf" }],
41755
41758
  ["path", { d: "M15 14h5l-5 6h5", key: "ur5jdg" }]
41756
41759
  ];
41757
- const ArrowDownAZ = createLucideIcon("arrow-down-a-z", __iconNode$I);
41760
+ const ArrowDownAZ = createLucideIcon("arrow-down-a-z", __iconNode$J);
41758
41761
  /**
41759
41762
  * @license lucide-react v0.575.0 - ISC
41760
41763
  *
41761
41764
  * This source code is licensed under the ISC license.
41762
41765
  * See the LICENSE file in the root directory of this source tree.
41763
41766
  */
41764
- const __iconNode$H = [
41767
+ const __iconNode$I = [
41765
41768
  ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
41766
41769
  ["path", { d: "M19 12H5", key: "x3x0zl" }]
41767
41770
  ];
41768
- const ArrowLeft = createLucideIcon("arrow-left", __iconNode$H);
41771
+ const ArrowLeft = createLucideIcon("arrow-left", __iconNode$I);
41769
41772
  /**
41770
41773
  * @license lucide-react v0.575.0 - ISC
41771
41774
  *
41772
41775
  * This source code is licensed under the ISC license.
41773
41776
  * See the LICENSE file in the root directory of this source tree.
41774
41777
  */
41775
- const __iconNode$G = [
41778
+ const __iconNode$H = [
41776
41779
  ["path", { d: "M5 12h14", key: "1ays0h" }],
41777
41780
  ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
41778
41781
  ];
41779
- const ArrowRight = createLucideIcon("arrow-right", __iconNode$G);
41782
+ const ArrowRight = createLucideIcon("arrow-right", __iconNode$H);
41780
41783
  /**
41781
41784
  * @license lucide-react v0.575.0 - ISC
41782
41785
  *
41783
41786
  * This source code is licensed under the ISC license.
41784
41787
  * See the LICENSE file in the root directory of this source tree.
41785
41788
  */
41786
- const __iconNode$F = [
41789
+ const __iconNode$G = [
41787
41790
  ["path", { d: "m3 8 4-4 4 4", key: "11wl7u" }],
41788
41791
  ["path", { d: "M7 4v16", key: "1glfcx" }],
41789
41792
  ["path", { d: "M20 8h-5", key: "1vsyxs" }],
41790
41793
  ["path", { d: "M15 10V6.5a2.5 2.5 0 0 1 5 0V10", key: "ag13bf" }],
41791
41794
  ["path", { d: "M15 14h5l-5 6h5", key: "ur5jdg" }]
41792
41795
  ];
41793
- const ArrowUpAZ = createLucideIcon("arrow-up-a-z", __iconNode$F);
41796
+ const ArrowUpAZ = createLucideIcon("arrow-up-a-z", __iconNode$G);
41794
41797
  /**
41795
41798
  * @license lucide-react v0.575.0 - ISC
41796
41799
  *
41797
41800
  * This source code is licensed under the ISC license.
41798
41801
  * See the LICENSE file in the root directory of this source tree.
41799
41802
  */
41800
- const __iconNode$E = [
41803
+ const __iconNode$F = [
41801
41804
  ["path", { d: "M7 7h10v10", key: "1tivn9" }],
41802
41805
  ["path", { d: "M7 17 17 7", key: "1vkiza" }]
41803
41806
  ];
41804
- const ArrowUpRight = createLucideIcon("arrow-up-right", __iconNode$E);
41807
+ const ArrowUpRight = createLucideIcon("arrow-up-right", __iconNode$F);
41805
41808
  /**
41806
41809
  * @license lucide-react v0.575.0 - ISC
41807
41810
  *
41808
41811
  * This source code is licensed under the ISC license.
41809
41812
  * See the LICENSE file in the root directory of this source tree.
41810
41813
  */
41811
- const __iconNode$D = [
41814
+ const __iconNode$E = [
41812
41815
  ["path", { d: "M12 8V4H8", key: "hb8ula" }],
41813
41816
  ["rect", { width: "16", height: "12", x: "4", y: "8", rx: "2", key: "enze0r" }],
41814
41817
  ["path", { d: "M2 14h2", key: "vft8re" }],
@@ -41816,7 +41819,20 @@ const __iconNode$D = [
41816
41819
  ["path", { d: "M15 13v2", key: "1xurst" }],
41817
41820
  ["path", { d: "M9 13v2", key: "rq6x2g" }]
41818
41821
  ];
41819
- const Bot = createLucideIcon("bot", __iconNode$D);
41822
+ const Bot = createLucideIcon("bot", __iconNode$E);
41823
+ /**
41824
+ * @license lucide-react v0.575.0 - ISC
41825
+ *
41826
+ * This source code is licensed under the ISC license.
41827
+ * See the LICENSE file in the root directory of this source tree.
41828
+ */
41829
+ const __iconNode$D = [
41830
+ ["path", { d: "M3 3v16a2 2 0 0 0 2 2h16", key: "c24i48" }],
41831
+ ["path", { d: "M18 17V9", key: "2bz60n" }],
41832
+ ["path", { d: "M13 17V5", key: "1frdt8" }],
41833
+ ["path", { d: "M8 17v-3", key: "17ska0" }]
41834
+ ];
41835
+ const ChartColumn = createLucideIcon("chart-column", __iconNode$D);
41820
41836
  /**
41821
41837
  * @license lucide-react v0.575.0 - ISC
41822
41838
  *
@@ -52707,10 +52723,10 @@ class $ZodRegistry {
52707
52723
  this._idmap = /* @__PURE__ */ new Map();
52708
52724
  }
52709
52725
  add(schema, ..._meta) {
52710
- const meta = _meta[0];
52711
- this._map.set(schema, meta);
52712
- if (meta && typeof meta === "object" && "id" in meta) {
52713
- this._idmap.set(meta.id, schema);
52726
+ const meta2 = _meta[0];
52727
+ this._map.set(schema, meta2);
52728
+ if (meta2 && typeof meta2 === "object" && "id" in meta2) {
52729
+ this._idmap.set(meta2.id, schema);
52714
52730
  }
52715
52731
  return this;
52716
52732
  }
@@ -52720,9 +52736,9 @@ class $ZodRegistry {
52720
52736
  return this;
52721
52737
  }
52722
52738
  remove(schema) {
52723
- const meta = this._map.get(schema);
52724
- if (meta && typeof meta === "object" && "id" in meta) {
52725
- this._idmap.delete(meta.id);
52739
+ const meta2 = this._map.get(schema);
52740
+ if (meta2 && typeof meta2 === "object" && "id" in meta2) {
52741
+ this._idmap.delete(meta2.id);
52726
52742
  }
52727
52743
  this._map.delete(schema);
52728
52744
  return this;
@@ -52741,10 +52757,10 @@ class $ZodRegistry {
52741
52757
  return this._map.has(schema);
52742
52758
  }
52743
52759
  }
52744
- function registry() {
52760
+ function registry$1() {
52745
52761
  return new $ZodRegistry();
52746
52762
  }
52747
- (_a$2 = globalThis).__zod_globalRegistry ?? (_a$2.__zod_globalRegistry = registry());
52763
+ (_a$2 = globalThis).__zod_globalRegistry ?? (_a$2.__zod_globalRegistry = registry$1());
52748
52764
  const globalRegistry = globalThis.__zod_globalRegistry;
52749
52765
  const INVALID = Symbol.for("zod.compile.invalid");
52750
52766
  const FALLBACK_FLAG = Symbol.for("zod.compile.fallback");
@@ -55003,9 +55019,9 @@ function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
55003
55019
  ctx.seen.get(parent).isParent = true;
55004
55020
  }
55005
55021
  }
55006
- const meta = ctx.metadataRegistry.get(schema);
55007
- if (meta)
55008
- assignProps(result.schema, meta);
55022
+ const meta2 = ctx.metadataRegistry.get(schema);
55023
+ if (meta2)
55024
+ assignProps(result.schema, meta2);
55009
55025
  if (ctx.io === "input" && isTransforming(schema)) {
55010
55026
  delete result.schema.examples;
55011
55027
  delete result.schema.default;
@@ -56097,8 +56113,8 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
56097
56113
  brand() {
56098
56114
  return this;
56099
56115
  },
56100
- register(reg, meta) {
56101
- reg.add(this, meta);
56116
+ register(reg, meta2) {
56117
+ reg.add(this, meta2);
56102
56118
  return this;
56103
56119
  },
56104
56120
  refine(check, params) {
@@ -59383,6 +59399,398 @@ function validateUlidTimestamp(prefixedUlid, prefix, pastThresholdMs = DEFAULT_T
59383
59399
  const thresholdSeconds = Math.round(thresholdMs / 1e3);
59384
59400
  return `Invalid runId timestamp: embedded timestamp is ${driftSeconds}s in the ${direction} (threshold: ${thresholdSeconds}s)`;
59385
59401
  }
59402
+ const USAGE_DOCS_URL = "https://workflow-sdk.dev/docs/observability/usage";
59403
+ const USAGE_SPANS_SHOWN = 5;
59404
+ const RUN_USAGE_ENTITIES = [
59405
+ "run",
59406
+ "step",
59407
+ "hook",
59408
+ "stream"
59409
+ ];
59410
+ const RUN_USAGE_RUN_EVENT_TYPES = [
59411
+ "created",
59412
+ "started",
59413
+ "completed",
59414
+ "failed",
59415
+ "cancelled"
59416
+ ];
59417
+ const RUN_USAGE_STEP_EVENT_TYPES = [
59418
+ "created",
59419
+ "started",
59420
+ "completed",
59421
+ "failed",
59422
+ "retrying"
59423
+ ];
59424
+ const UNKNOWN_STEP_NAME = "(unknown step)";
59425
+ function spanOf(eventType, workflowName) {
59426
+ if (eventType.startsWith("hook_"))
59427
+ return { kind: "hook", name: "hook" };
59428
+ if (eventType.startsWith("wait_"))
59429
+ return { kind: "wait", name: "sleep" };
59430
+ if (eventType.startsWith("run_"))
59431
+ return { kind: "run", name: workflowName };
59432
+ if (eventType === "attr_set") {
59433
+ return { kind: "attributes", name: "attributes" };
59434
+ }
59435
+ return { kind: "other", name: "other" };
59436
+ }
59437
+ function compareCodeUnits(a2, b2) {
59438
+ return a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
59439
+ }
59440
+ function toCount(value) {
59441
+ const n = Number(value);
59442
+ return Number.isFinite(n) && n > 0 ? n : 0;
59443
+ }
59444
+ function usageEntityOfEventType(eventType) {
59445
+ if (isSealedNoopEvent$1({ eventType }))
59446
+ return null;
59447
+ if (eventType.startsWith("step_"))
59448
+ return "step";
59449
+ if (eventType.startsWith("hook_"))
59450
+ return "hook";
59451
+ return "run";
59452
+ }
59453
+ function buildRunUsage(input) {
59454
+ var _a3;
59455
+ const spans = /* @__PURE__ */ new Map();
59456
+ const byEntity = {
59457
+ run: 0,
59458
+ step: 0,
59459
+ hook: 0,
59460
+ stream: toCount(input.streamBytes)
59461
+ };
59462
+ let events2 = 0;
59463
+ let retries = 0;
59464
+ const add = (kind, name2, entity, count2, retryCount, bytes) => {
59465
+ if (count2 <= 0)
59466
+ return;
59467
+ const key = `${kind}\0${name2}`;
59468
+ let span = spans.get(key);
59469
+ if (!span) {
59470
+ span = { kind, name: name2, events: 0, share: 0, retries: 0, calls: 0 };
59471
+ spans.set(key, span);
59472
+ }
59473
+ span.events += count2;
59474
+ span.retries += retryCount;
59475
+ events2 += count2;
59476
+ retries += retryCount;
59477
+ byEntity[entity] += bytes;
59478
+ };
59479
+ const created = { hook: 0, wait: 0 };
59480
+ const hookGroups = input.hookGroups;
59481
+ let hookEvents = 0;
59482
+ const runEvents = {
59483
+ events: 0,
59484
+ byType: { created: 0, started: 0, completed: 0, failed: 0, cancelled: 0 }
59485
+ };
59486
+ for (const group of input.eventGroups) {
59487
+ const entity = usageEntityOfEventType(group.eventType);
59488
+ if (!entity)
59489
+ continue;
59490
+ const runType = group.eventType.slice("run_".length);
59491
+ if (group.eventType.startsWith("run_") && RUN_USAGE_RUN_EVENT_TYPES.includes(runType)) {
59492
+ runEvents.byType[runType] += toCount(group.events);
59493
+ }
59494
+ if (group.eventType.startsWith("run_")) {
59495
+ runEvents.events += toCount(group.events);
59496
+ }
59497
+ if (group.eventType === "hook_created")
59498
+ created.hook += toCount(group.events);
59499
+ if (group.eventType === "wait_created")
59500
+ created.wait += toCount(group.events);
59501
+ const { kind, name: name2 } = spanOf(group.eventType, input.workflowName);
59502
+ if (kind === "hook" && hookGroups) {
59503
+ hookEvents += toCount(group.events);
59504
+ events2 += toCount(group.events);
59505
+ byEntity[entity] += toCount(group.bytes);
59506
+ continue;
59507
+ }
59508
+ add(kind, name2, entity, toCount(group.events), 0, toCount(group.bytes));
59509
+ }
59510
+ if (hookGroups) {
59511
+ let grouped = 0;
59512
+ for (const group of hookGroups) {
59513
+ const count2 = toCount(group.events);
59514
+ if (count2 <= 0 || !group.hookId)
59515
+ continue;
59516
+ grouped += count2;
59517
+ spans.set(`hook\0${group.hookId}`, {
59518
+ kind: "hook",
59519
+ name: group.token || group.hookId,
59520
+ id: group.hookId,
59521
+ events: count2,
59522
+ share: 0,
59523
+ retries: 0,
59524
+ calls: 1
59525
+ });
59526
+ }
59527
+ if (hookEvents > grouped) {
59528
+ spans.set("hook\0", {
59529
+ kind: "hook",
59530
+ name: "hook",
59531
+ events: hookEvents - grouped,
59532
+ share: 0,
59533
+ retries: 0,
59534
+ calls: 0
59535
+ });
59536
+ }
59537
+ }
59538
+ const calls = {
59539
+ hook: toCount(created.hook),
59540
+ wait: toCount(((_a3 = input.calls) == null ? void 0 : _a3.wait) ?? created.wait)
59541
+ };
59542
+ const stepEvents = {
59543
+ steps: 0,
59544
+ events: 0,
59545
+ byType: {
59546
+ created: 0,
59547
+ started: 0,
59548
+ completed: 0,
59549
+ failed: 0,
59550
+ retrying: 0,
59551
+ other: 0
59552
+ }
59553
+ };
59554
+ let restarts = 0;
59555
+ for (const group of input.stepGroups) {
59556
+ restarts += toCount(group.restarts);
59557
+ const counts = {
59558
+ created: toCount(group.created),
59559
+ started: toCount(group.started),
59560
+ completed: toCount(group.completed),
59561
+ failed: toCount(group.failed),
59562
+ retrying: toCount(group.retries)
59563
+ };
59564
+ const total = toCount(group.events);
59565
+ if (total <= 0)
59566
+ continue;
59567
+ stepEvents.steps += toCount(group.steps);
59568
+ stepEvents.events += total;
59569
+ let known = 0;
59570
+ for (const type of RUN_USAGE_STEP_EVENT_TYPES) {
59571
+ stepEvents.byType[type] += counts[type];
59572
+ known += counts[type];
59573
+ }
59574
+ stepEvents.byType.other += Math.max(0, total - known);
59575
+ const name2 = group.stepName || UNKNOWN_STEP_NAME;
59576
+ add("step", name2, "step", toCount(group.events), toCount(group.retries), toCount(group.bytes));
59577
+ const span = spans.get(`step\0${name2}`);
59578
+ if (span)
59579
+ span.calls += toCount(group.steps);
59580
+ }
59581
+ for (const span of spans.values()) {
59582
+ if (span.kind === "run")
59583
+ span.calls = 1;
59584
+ if (span.kind === "hook" && !hookGroups)
59585
+ span.calls = calls.hook;
59586
+ if (span.kind === "wait")
59587
+ span.calls = calls.wait;
59588
+ if (span.kind === "attributes" || span.kind === "other") {
59589
+ span.calls = span.events;
59590
+ }
59591
+ }
59592
+ const eventsBySpan = [...spans.values()].map((span) => ({ ...span, share: events2 > 0 ? span.events / events2 : 0 })).sort((a2, b2) => b2.events - a2.events || compareCodeUnits(a2.name, b2.name) || compareCodeUnits(a2.kind, b2.kind) || compareCodeUnits(a2.id ?? "", b2.id ?? ""));
59593
+ return {
59594
+ runId: input.runId,
59595
+ status: input.status,
59596
+ workflowName: input.workflowName,
59597
+ billed: input.billed === true,
59598
+ inProgress: !isTerminalWorkflowRunStatus(input.status),
59599
+ events: events2,
59600
+ billableEvents: events2,
59601
+ retries: { count: retries, events: retries + restarts },
59602
+ runEvents,
59603
+ stepEvents,
59604
+ eventsBySpan,
59605
+ dataWritten: dataWrittenOf(input, byEntity),
59606
+ dataPurged: input.dataPurged === true,
59607
+ dataRetained: input.dataRetained ?? null
59608
+ };
59609
+ }
59610
+ function dataWrittenOf(input, measured) {
59611
+ const saved = input.dataPurged ? input.savedDataWritten : void 0;
59612
+ const byEntity = saved ? {
59613
+ run: toCount(saved.run),
59614
+ step: toCount(saved.step),
59615
+ hook: toCount(saved.hook),
59616
+ stream: toCount(saved.stream)
59617
+ } : measured;
59618
+ return {
59619
+ bytes: byEntity.run + byEntity.step + byEntity.hook + byEntity.stream,
59620
+ byEntity,
59621
+ source: !input.dataPurged ? "log" : saved ? "saved-at-purge" : "left-after-purge"
59622
+ };
59623
+ }
59624
+ function plural(count2, one2, many) {
59625
+ return `${count2.toLocaleString("en-US")} ${count2 === 1 ? one2 : many}`;
59626
+ }
59627
+ function usageSpanLabel(span) {
59628
+ var _a3, _b2;
59629
+ if (span.kind === "step") {
59630
+ return ((_a3 = parseStepName(span.name)) == null ? void 0 : _a3.shortName) || span.name;
59631
+ }
59632
+ if (span.kind === "run") {
59633
+ return ((_b2 = parseWorkflowName(span.name)) == null ? void 0 : _b2.shortName) || span.name;
59634
+ }
59635
+ return span.name;
59636
+ }
59637
+ function formatUsageEvents(count2) {
59638
+ return plural(count2, "event", "events");
59639
+ }
59640
+ function formatUsageBytes(bytes) {
59641
+ const units = ["B", "KB", "MB", "GB", "TB"];
59642
+ let value = Math.max(0, bytes);
59643
+ let unit = 0;
59644
+ while (value >= 1e3 && unit < units.length - 1) {
59645
+ value /= 1e3;
59646
+ unit++;
59647
+ }
59648
+ if (unit === 0)
59649
+ return `${Math.round(value)} B`;
59650
+ const digits = value >= 100 ? 0 : value >= 10 ? 1 : 2;
59651
+ return `${Number(value.toFixed(digits))} ${units[unit]}`;
59652
+ }
59653
+ function formatUsageShare(share) {
59654
+ if (share > 0 && share < 0.01)
59655
+ return "<1%";
59656
+ return `${Math.round(share * 100)}%`;
59657
+ }
59658
+ function formatCount(count2, one2, many) {
59659
+ return plural(count2, one2, many);
59660
+ }
59661
+ function formatOtherSteps(steps) {
59662
+ return `+ ${steps.toLocaleString("en-US")} other ${steps === 1 ? "step" : "steps"}`;
59663
+ }
59664
+ function formatDataWrittenHeading(usage) {
59665
+ return usage.billed ? "Storage" : "Storage (local)";
59666
+ }
59667
+ function formatLocalDataWrittenNote(usage) {
59668
+ if (usage.billed)
59669
+ return null;
59670
+ return "The bytes of the run's payloads as the SDK sent them, plus the bytes it wrote to streams, counted the way Vercel counts Data Written. It doesn't include QuickJS VM snapshots or a dynamic workflow's code.";
59671
+ }
59672
+ function formatUsageFooter(usage) {
59673
+ return usage.billed ? "Not your final bill." : "Local runs aren't billed. Counted from this run's log in your local data directory.";
59674
+ }
59675
+ const RUN_EVENT_LABELS = {
59676
+ created: "created",
59677
+ started: "started",
59678
+ completed: "completed",
59679
+ failed: "failed",
59680
+ cancelled: "cancelled"
59681
+ };
59682
+ function formatRunEventsLine(usage) {
59683
+ const { events: events2, byType } = usage.runEvents;
59684
+ if (events2 <= 0)
59685
+ return null;
59686
+ const parts = RUN_USAGE_RUN_EVENT_TYPES.flatMap((type) => byType[type] > 0 ? [`${byType[type].toLocaleString("en-US")} ${RUN_EVENT_LABELS[type]}`] : []);
59687
+ const known = RUN_USAGE_RUN_EVENT_TYPES.reduce((n, t) => n + byType[t], 0);
59688
+ if (events2 > known) {
59689
+ parts.push(`${(events2 - known).toLocaleString("en-US")} other`);
59690
+ }
59691
+ const sofar = usage.inProgress ? " so far" : "";
59692
+ return `The run wrote ${formatUsageEvents(events2)}${sofar}: ${parts.join(", ")}.`;
59693
+ }
59694
+ function formatDataPurgedNote(usage) {
59695
+ if (!usage.dataPurged)
59696
+ return null;
59697
+ return usage.dataWritten.source === "saved-at-purge" ? "This run's data was deleted; sizes show what it wrote." : "This run's data was deleted before its sizes were kept; sizes show what is left.";
59698
+ }
59699
+ const USAGE_ROW_TYPES = [
59700
+ "steps",
59701
+ "hooks",
59702
+ "attributes",
59703
+ "sleeps",
59704
+ "run",
59705
+ "other"
59706
+ ];
59707
+ const USAGE_ROW_TYPE_LABELS = {
59708
+ steps: "Steps",
59709
+ hooks: "Hooks",
59710
+ attributes: "Attributes",
59711
+ sleeps: "Sleeps",
59712
+ run: "Run",
59713
+ other: "Other events"
59714
+ };
59715
+ const SPAN_KIND_OF_ROW_TYPE = {
59716
+ steps: "step",
59717
+ hooks: "hook",
59718
+ attributes: "attributes",
59719
+ sleeps: "wait",
59720
+ run: "run",
59721
+ other: "other"
59722
+ };
59723
+ function usageRows(usage, limit = USAGE_SPANS_SHOWN) {
59724
+ const runNote = formatRunEventsLine(usage) ?? void 0;
59725
+ return USAGE_ROW_TYPES.flatMap((type) => {
59726
+ const spans = usage.eventsBySpan.filter((span) => span.kind === SPAN_KIND_OF_ROW_TYPE[type]);
59727
+ if (spans.length === 0)
59728
+ return [];
59729
+ const total = sumRows(spans);
59730
+ const group = {
59731
+ type,
59732
+ key: type,
59733
+ events: total.events,
59734
+ share: total.share,
59735
+ retries: total.retries,
59736
+ calls: type === "hooks" ? spans.length : total.calls,
59737
+ children: [],
59738
+ otherChildren: null,
59739
+ ...type === "run" && runNote ? { note: runNote } : {}
59740
+ };
59741
+ if (type !== "steps" && type !== "hooks")
59742
+ return [group];
59743
+ const { shown, other } = collapseUsageSpans(spans, limit);
59744
+ group.children = childRowsOf(shown);
59745
+ group.otherChildren = other && {
59746
+ key: `${type}:other`,
59747
+ count: other.spans,
59748
+ label: type === "steps" ? formatOtherSteps(other.spans) : `+ ${other.spans.toLocaleString("en-US")} other ${other.spans === 1 ? "hook" : "hooks"}`,
59749
+ events: other.events,
59750
+ share: other.share,
59751
+ retries: other.retries,
59752
+ calls: other.calls
59753
+ };
59754
+ return [group];
59755
+ });
59756
+ }
59757
+ function sumRows(spans) {
59758
+ return spans.reduce((sum, span) => ({
59759
+ events: sum.events + span.events,
59760
+ share: sum.share + span.share,
59761
+ retries: sum.retries + span.retries,
59762
+ calls: sum.calls + span.calls
59763
+ }), { events: 0, share: 0, retries: 0, calls: 0 });
59764
+ }
59765
+ function childRowsOf(spans) {
59766
+ const labels = spans.map((span) => usageSpanLabel(span));
59767
+ const seen = /* @__PURE__ */ new Map();
59768
+ for (const label of labels)
59769
+ seen.set(label, (seen.get(label) ?? 0) + 1);
59770
+ return spans.map((span, i) => ({
59771
+ key: span.kind === "hook" ? span.id ?? span.name : span.name,
59772
+ label: (seen.get(labels[i]) ?? 0) > 1 ? span.kind === "step" ? formatStepName(span.name) : `${labels[i]} (${span.id ?? span.name})` : labels[i],
59773
+ events: span.events,
59774
+ share: span.share,
59775
+ retries: span.retries,
59776
+ calls: span.calls
59777
+ }));
59778
+ }
59779
+ function collapseUsageSpans(spans, limit = USAGE_SPANS_SHOWN) {
59780
+ if (spans.length <= limit + 1)
59781
+ return { shown: spans, other: null };
59782
+ const rest = spans.slice(limit);
59783
+ return {
59784
+ shown: spans.slice(0, limit),
59785
+ other: {
59786
+ spans: rest.length,
59787
+ events: rest.reduce((sum, span) => sum + span.events, 0),
59788
+ share: rest.reduce((sum, span) => sum + span.share, 0),
59789
+ retries: rest.reduce((sum, span) => sum + span.retries, 0),
59790
+ calls: rest.reduce((sum, span) => sum + span.calls, 0)
59791
+ }
59792
+ };
59793
+ }
59386
59794
  const SINGLETON_EVENT_CLASSES = /* @__PURE__ */ new Set([
59387
59795
  "run_started"
59388
59796
  ]);
@@ -59468,8 +59876,8 @@ function globalSingleton(name2, shapeVersion, create2) {
59468
59876
  store[key] = created;
59469
59877
  return created;
59470
59878
  }
59471
- function pluralize(singular, plural, count2) {
59472
- return count2 === 1 ? singular : plural;
59879
+ function pluralize(singular, plural2, count2) {
59880
+ return count2 === 1 ? singular : plural2;
59473
59881
  }
59474
59882
  function withResolvers$1() {
59475
59883
  let resolve2;
@@ -59636,20 +60044,20 @@ function requireMs() {
59636
60044
  function fmtLong(ms2) {
59637
60045
  var msAbs = Math.abs(ms2);
59638
60046
  if (msAbs >= d2) {
59639
- return plural(ms2, msAbs, d2, "day");
60047
+ return plural2(ms2, msAbs, d2, "day");
59640
60048
  }
59641
60049
  if (msAbs >= h2) {
59642
- return plural(ms2, msAbs, h2, "hour");
60050
+ return plural2(ms2, msAbs, h2, "hour");
59643
60051
  }
59644
60052
  if (msAbs >= m2) {
59645
- return plural(ms2, msAbs, m2, "minute");
60053
+ return plural2(ms2, msAbs, m2, "minute");
59646
60054
  }
59647
60055
  if (msAbs >= s2) {
59648
- return plural(ms2, msAbs, s2, "second");
60056
+ return plural2(ms2, msAbs, s2, "second");
59649
60057
  }
59650
60058
  return ms2 + " ms";
59651
60059
  }
59652
- function plural(ms2, msAbs, n, name2) {
60060
+ function plural2(ms2, msAbs, n, name2) {
59653
60061
  var isPlural = msAbs >= n * 1.5;
59654
60062
  return Math.round(ms2 / n) + " " + name2 + (isPlural ? "s" : "");
59655
60063
  }
@@ -60568,6 +60976,26 @@ class WorkflowStartError extends WorkflowError {
60568
60976
  return isError(value) && value.name === "WorkflowStartError";
60569
60977
  }
60570
60978
  }
60979
+ const DYNAMIC_WORKFLOWS_ENV_VAR = "WORKFLOW_EXPERIMENTAL_DYNAMIC_WORKFLOWS";
60980
+ const DYNAMIC_WORKFLOWS_DOCS_URL = "https://workflow-sdk.dev/docs/advanced/dynamic-workflows#enabling-dynamic-workflows";
60981
+ const DYNAMIC_WORKFLOWS_NOT_ENABLED_HINT = `Set the ${DYNAMIC_WORKFLOWS_ENV_VAR}=1 environment variable on your project, then redeploy (or restart your dev server) so the new value takes effect.`;
60982
+ class DynamicWorkflowsNotEnabledError extends WorkflowError {
60983
+ /**
60984
+ * @param message - What was refused, e.g. that `start()` created no run.
60985
+ * The fix-it hint and a docs link are appended to it.
60986
+ */
60987
+ constructor(message2, options) {
60988
+ super(appendFramedDetails(message2, [
60989
+ { label: "hint", value: DYNAMIC_WORKFLOWS_NOT_ENABLED_HINT },
60990
+ { label: "docs", value: DYNAMIC_WORKFLOWS_DOCS_URL }
60991
+ ]), { cause: options == null ? void 0 : options.cause });
60992
+ __publicField(this, "fatal", true);
60993
+ this.name = "DynamicWorkflowsNotEnabledError";
60994
+ }
60995
+ static is(value) {
60996
+ return isError(value) && value.name === "DynamicWorkflowsNotEnabledError";
60997
+ }
60998
+ }
60571
60999
  class WorkflowRunFailedError extends WorkflowError {
60572
61000
  constructor(runId, error2, options = {}) {
60573
61001
  const message2 = error2 instanceof Error ? error2.message : typeof error2 === "string" ? error2 : error2 && typeof error2 === "object" && "message" in error2 ? String(error2.message) : "Unknown error";
@@ -63364,7 +63792,7 @@ function replaceEncryptedAndExpiredWithMarkers(resource) {
63364
63792
  }
63365
63793
  async function hydrateResourceIOAsync(resource, key, extraRevivers) {
63366
63794
  const { hydrateDataWithKey: hydrateDataWithKey2, deriveRunPayloadKeys: deriveRunPayloadKeys2 } = await Promise.resolve().then(() => serializationFormat);
63367
- const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-B228nPFT.js");
63795
+ const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-LnaKiDUZ.js");
63368
63796
  ensureZstdDecoderRegistered();
63369
63797
  const cryptoKey = key ? await deriveRunPayloadKeys2(key) : void 0;
63370
63798
  const revivers = extraRevivers ? { ...getRevivers(), ...extraRevivers } : getRevivers();
@@ -68517,13 +68945,36 @@ function formatTimeDifference(diff) {
68517
68945
  }
68518
68946
  return result.join(", ");
68519
68947
  }
68948
+ function formatTimeAgo(date2, now2) {
68949
+ const diff = now2 - date2;
68950
+ const formattedDiff = formatTimeDifference(diff);
68951
+ if (!formattedDiff)
68952
+ return "Just now";
68953
+ return diff < 0 ? `in ${formattedDiff}` : `${formattedDiff} ago`;
68954
+ }
68955
+ function formatShortTimeAgo(date2, now2) {
68956
+ const diff = now2 - date2;
68957
+ const abs = Math.abs(diff);
68958
+ const days = Math.floor(abs / (1e3 * 60 * 60 * 24));
68959
+ const hours = Math.floor(abs / (1e3 * 60 * 60));
68960
+ const minutes = Math.floor(abs / (1e3 * 60));
68961
+ let value;
68962
+ if (days > 0) {
68963
+ value = `${days} day${days > 1 ? "s" : ""}`;
68964
+ } else if (hours > 0) {
68965
+ value = `${hours} hour${hours > 1 ? "s" : ""}`;
68966
+ } else if (minutes > 0) {
68967
+ value = `${minutes} minute${minutes > 1 ? "s" : ""}`;
68968
+ } else {
68969
+ return diff < 0 ? "In less than a minute" : "Just now";
68970
+ }
68971
+ return diff < 0 ? `In ${value}` : `${value} ago`;
68972
+ }
68520
68973
  function useTimeAgo(date2) {
68521
68974
  const [timeAgo, setTimeAgo] = reactExports.useState("");
68522
68975
  reactExports.useEffect(() => {
68523
68976
  const updateTimeAgo = () => {
68524
- const diff = Date.now() - date2;
68525
- const formattedDiff = formatTimeDifference(diff);
68526
- setTimeAgo(formattedDiff ? `${formattedDiff} ago` : "Just now");
68977
+ setTimeAgo(formatTimeAgo(date2, Date.now()));
68527
68978
  };
68528
68979
  updateTimeAgo();
68529
68980
  const timer2 = setInterval(updateTimeAgo, 1e3);
@@ -68539,19 +68990,7 @@ function useShortTimeAgo(date2) {
68539
68990
  return;
68540
68991
  }
68541
68992
  const updateShortTimeAgo = () => {
68542
- const diff = Date.now() - date2;
68543
- const days = Math.floor(diff / (1e3 * 60 * 60 * 24));
68544
- const hours = Math.floor(diff / (1e3 * 60 * 60));
68545
- const minutes = Math.floor(diff / (1e3 * 60));
68546
- if (days > 0) {
68547
- setShortTimeAgo(`${days} day${days > 1 ? "s" : ""} ago`);
68548
- } else if (hours > 0) {
68549
- setShortTimeAgo(`${hours} hour${hours > 1 ? "s" : ""} ago`);
68550
- } else if (minutes > 0) {
68551
- setShortTimeAgo(`${minutes} minute${minutes > 1 ? "s" : ""} ago`);
68552
- } else {
68553
- setShortTimeAgo("Just now");
68554
- }
68993
+ setShortTimeAgo(formatShortTimeAgo(date2, Date.now()));
68555
68994
  };
68556
68995
  updateShortTimeAgo();
68557
68996
  const timer2 = setInterval(updateShortTimeAgo, 6e4);
@@ -68611,7 +69050,7 @@ const COL = {
68611
69050
  name: "w-[280px]",
68612
69051
  duration: "w-[96px] justify-end"
68613
69052
  };
68614
- const CELL = "flex h-full shrink-0 items-center overflow-hidden px-1.5";
69053
+ const CELL$1 = "flex h-full shrink-0 items-center overflow-hidden px-1.5";
68615
69054
  const LEVEL_ROW_CLASS = {
68616
69055
  default: "text-gray-1000 hover:bg-gray-100",
68617
69056
  muted: "text-gray-700 hover:bg-gray-100",
@@ -68632,7 +69071,7 @@ const LEVEL_SELECTED_CLASS = {
68632
69071
  };
68633
69072
  function TimestampCell({ date: date2, secondaryClass }) {
68634
69073
  const parts = formatTimestampParts(date2);
68635
- return jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.time, "tabular-nums"), children: jsxRuntimeExports.jsx(TimestampTooltip, { date: date2, children: jsxRuntimeExports.jsxs("span", { className: "whitespace-pre", children: [jsxRuntimeExports.jsx("span", { className: secondaryClass, children: `${parts.day} ` }), parts.clock, jsxRuntimeExports.jsx("span", { className: secondaryClass, children: parts.ms })] }) }) });
69074
+ return jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.time, "tabular-nums"), children: jsxRuntimeExports.jsx(TimestampTooltip, { date: date2, children: jsxRuntimeExports.jsxs("span", { className: "whitespace-pre", children: [jsxRuntimeExports.jsx("span", { className: secondaryClass, children: `${parts.day} ` }), parts.clock, jsxRuntimeExports.jsx("span", { className: secondaryClass, children: parts.ms })] }) }) });
68636
69075
  }
68637
69076
  function LevelIcon({ level }) {
68638
69077
  if (level === "warning") {
@@ -68647,8 +69086,8 @@ function SortIndicator({ order: order2 }) {
68647
69086
  return jsxRuntimeExports.jsxs("span", { "aria-hidden": true, className: "flex flex-col gap-px", children: [jsxRuntimeExports.jsx("span", { className: cn$2("-my-0.5 flex size-3 items-center justify-center rounded-full transition-all duration-[280ms] ease-in-out", order2 === "asc" ? "translate-y-1 bg-gray-300 text-gray-900" : "-translate-y-1 opacity-0"), children: jsxRuntimeExports.jsx(ChevronUp, { className: "size-2", strokeWidth: 3 }) }), jsxRuntimeExports.jsx("span", { className: cn$2("-my-0.5 flex size-3 items-center justify-center rounded-full transition-all duration-[280ms] ease-in-out", order2 === "desc" ? "-translate-y-1 bg-gray-300 text-gray-900" : "opacity-0"), children: jsxRuntimeExports.jsx(ChevronDown, { className: "size-2 translate-y-[0.5px]", strokeWidth: 3 }) })] });
68648
69087
  }
68649
69088
  function EventListHeader({ showOccurred, sortOrder, onSortOrderChange }) {
68650
- const sortButton = (label) => jsxRuntimeExports.jsxs("button", { type: "button", "aria-label": `${label}, ${sortOrder === "asc" ? "oldest" : "newest"} first`, onClick: () => onSortOrderChange(sortOrder === "asc" ? "desc" : "asc"), className: cn$2(CELL, COL.time, "cursor-pointer gap-1.5 border-0 bg-transparent text-left font-sans text-label-14 text-gray-900 hover:text-gray-1000"), children: [label, jsxRuntimeExports.jsx(SortIndicator, { order: sortOrder })] });
68651
- return jsxRuntimeExports.jsxs("div", { role: "row", className: "flex h-10 shrink-0 items-center border-b border-gray-alpha-400 px-1 font-sans text-label-14 text-gray-900", children: [jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.level) }), showOccurred ? jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [sortButton("Occurred"), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.time), children: "Created" })] }) : sortButton("Time"), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.since) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.name), children: "Name" }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.event), children: "Event" }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, "min-w-0 flex-1 h-3.5 border-l border-gray-400"), children: "Message" }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.duration), children: "Duration" })] });
69089
+ const sortButton = (label) => jsxRuntimeExports.jsxs("button", { type: "button", "aria-label": `${label}, ${sortOrder === "asc" ? "oldest" : "newest"} first`, onClick: () => onSortOrderChange(sortOrder === "asc" ? "desc" : "asc"), className: cn$2(CELL$1, COL.time, "cursor-pointer gap-1.5 border-0 bg-transparent text-left font-sans text-label-14 text-gray-900 hover:text-gray-1000"), children: [label, jsxRuntimeExports.jsx(SortIndicator, { order: sortOrder })] });
69090
+ return jsxRuntimeExports.jsxs("div", { role: "row", className: "flex h-10 shrink-0 items-center border-b border-gray-alpha-400 px-1 font-sans text-label-14 text-gray-900", children: [jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.level) }), showOccurred ? jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [sortButton("Occurred"), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.time), children: "Created" })] }) : sortButton("Time"), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.since) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.name), children: "Name" }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.event), children: "Event" }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, "min-w-0 flex-1 h-3.5 border-l border-gray-400"), children: "Message" }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.duration), children: "Duration" })] });
68652
69091
  }
68653
69092
  function IdleGapRow({ ms: ms2, reason }) {
68654
69093
  return jsxRuntimeExports.jsxs("div", { className: "mx-1 mt-px flex h-6 items-center gap-2.5 pl-[30px] pr-2 font-mono text-label-12-mono text-gray-700", children: [jsxRuntimeExports.jsx("span", { className: "h-px w-3 shrink-0 bg-gray-400" }), jsxRuntimeExports.jsxs("span", { className: "shrink-0", children: [formatDurationPrecise(ms2), " idle", reason ? ` · ${reason}` : ""] }), jsxRuntimeExports.jsx("span", { className: "h-px flex-1 bg-gray-400" })] });
@@ -68666,13 +69105,13 @@ function EventRow({ row, index: index2, isSelected, isTabStop, relation, onSelec
68666
69105
  e.preventDefault();
68667
69106
  onSelect(event);
68668
69107
  }
68669
- }, className: cn$2("mx-1 mt-px flex h-6 cursor-pointer items-center rounded-md font-mono text-[13px] leading-5 outline-none focus-visible:relative focus-visible:z-10 focus-visible:shadow-[0_0_0_2px_var(--ds-focus-color)]", LEVEL_ROW_CLASS[level], !isTinted && !relation && index2 % 2 === 1 && "bg-background-200", isRelated && !isTinted && "bg-blue-300/50 hover:bg-blue-300/75", isMuted && "text-gray-700 [&_svg]:text-gray-700", isSelected && LEVEL_SELECTED_CLASS[level]), children: [jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.level), children: jsxRuntimeExports.jsx(LevelIcon, { level }) }), showSeparateEventOccurrenceTimestamps && (occurredAt ? jsxRuntimeExports.jsx(TimestampCell, { date: occurredAt, secondaryClass }) : jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.time, secondaryClass), children: "—" })), jsxRuntimeExports.jsx(TimestampCell, { date: displayedAt, secondaryClass }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.since, "tabular-nums", secondaryClass), children: row.sinceStartMs !== void 0 ? formatSinceStart(row.sinceStartMs) : "" }), jsxRuntimeExports.jsxs("div", { className: cn$2(CELL, COL.name, "gap-2"), title: name2 || void 0, children: [jsxRuntimeExports.jsx(ResourceIcon, { resource: row.resource, isErrored: level === "error", isCancelled: event.eventType === "run_cancelled" }), name2 ? jsxRuntimeExports.jsx("span", { className: cn$2("-mx-1 truncate rounded px-1", isRelated && "text-blue-900", isRelated && isTinted && "bg-blue-100"), children: name2 }) : null] }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.event), children: jsxRuntimeExports.jsx(EventNoticeTooltip, { notice, children: jsxRuntimeExports.jsx("span", { className: cn$2("truncate", notice && "line-through"), title: event.eventType, children: event.eventType }) }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, "min-w-0 flex-1 h-3.5 border-l", LEVEL_SEPARATOR_CLASS[level]), title: message2 || void 0, children: jsxRuntimeExports.jsx("span", { className: "truncate", children: message2 }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.duration, "tabular-nums"), children: row.durationMs !== void 0 ? formatDurationPrecise(row.durationMs) : "" })] });
69108
+ }, className: cn$2("mx-1 mt-px flex h-6 cursor-pointer items-center rounded-md font-mono text-[13px] leading-5 outline-none focus-visible:relative focus-visible:z-10 focus-visible:shadow-[0_0_0_2px_var(--ds-focus-color)]", LEVEL_ROW_CLASS[level], !isTinted && !relation && index2 % 2 === 1 && "bg-background-200", isRelated && !isTinted && "bg-blue-300/50 hover:bg-blue-300/75", isMuted && "text-gray-700 [&_svg]:text-gray-700", isSelected && LEVEL_SELECTED_CLASS[level]), children: [jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.level), children: jsxRuntimeExports.jsx(LevelIcon, { level }) }), showSeparateEventOccurrenceTimestamps && (occurredAt ? jsxRuntimeExports.jsx(TimestampCell, { date: occurredAt, secondaryClass }) : jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.time, secondaryClass), children: "—" })), jsxRuntimeExports.jsx(TimestampCell, { date: displayedAt, secondaryClass }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.since, "tabular-nums", secondaryClass), children: row.sinceStartMs !== void 0 ? formatSinceStart(row.sinceStartMs) : "" }), jsxRuntimeExports.jsxs("div", { className: cn$2(CELL$1, COL.name, "gap-2"), title: name2 || void 0, children: [jsxRuntimeExports.jsx(ResourceIcon, { resource: row.resource, isErrored: level === "error", isCancelled: event.eventType === "run_cancelled" }), name2 ? jsxRuntimeExports.jsx("span", { className: cn$2("-mx-1 truncate rounded px-1", isRelated && "text-blue-900", isRelated && isTinted && "bg-blue-100"), children: name2 }) : null] }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.event), children: jsxRuntimeExports.jsx(EventNoticeTooltip, { notice, children: jsxRuntimeExports.jsx("span", { className: cn$2("truncate", notice && "line-through"), title: event.eventType, children: event.eventType }) }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, "min-w-0 flex-1 h-3.5 border-l", LEVEL_SEPARATOR_CLASS[level]), title: message2 || void 0, children: jsxRuntimeExports.jsx("span", { className: "truncate", children: message2 }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.duration, "tabular-nums"), children: row.durationMs !== void 0 ? formatDurationPrecise(row.durationMs) : "" })] });
68670
69109
  }
68671
69110
  const SKELETON_MESSAGE_WIDTHS = ["40%", "0%", "25%", "55%", "0%", "30%"];
68672
69111
  function EventRowsSkeleton() {
68673
- return jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-hidden pt-px", children: Array.from({ length: 18 }, (_2, i) => jsxRuntimeExports.jsxs("div", { className: cn$2("mx-1 mt-px flex h-6 items-center rounded-md", i % 2 === 1 && "bg-background-200"), children: [jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.level) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.time), children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3 w-[136px]" }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.since), children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3 w-12" }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.name), children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3 w-24" }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.event), children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3 w-[104px]" }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, "min-w-0 flex-1"), children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3", style: {
69112
+ return jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-hidden pt-px", children: Array.from({ length: 18 }, (_2, i) => jsxRuntimeExports.jsxs("div", { className: cn$2("mx-1 mt-px flex h-6 items-center rounded-md", i % 2 === 1 && "bg-background-200"), children: [jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.level) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.time), children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3 w-[136px]" }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.since), children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3 w-12" }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.name), children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3 w-24" }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.event), children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3 w-[104px]" }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, "min-w-0 flex-1"), children: jsxRuntimeExports.jsx(Skeleton$1, { className: "h-3", style: {
68674
69113
  width: SKELETON_MESSAGE_WIDTHS[i % SKELETON_MESSAGE_WIDTHS.length]
68675
- } }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL, COL.duration) })] }, i)) });
69114
+ } }) }), jsxRuntimeExports.jsx("div", { className: cn$2(CELL$1, COL.duration) })] }, i)) });
68676
69115
  }
68677
69116
  const WORKFLOW_ULID_BODY = "[0123456789ABCDEFGHJKMNPQRSTVWXYZ]{26}";
68678
69117
  const STEP_ID_PATTERN$1 = new RegExp(`^step_(${WORKFLOW_ULID_BODY})$`, "i");
@@ -87889,9 +88328,9 @@ function tokenizeCodeFenced(effects, ok2, nok) {
87889
88328
  effects.enter("chunkString", {
87890
88329
  contentType: "string"
87891
88330
  });
87892
- return meta(code2);
88331
+ return meta2(code2);
87893
88332
  }
87894
- function meta(code2) {
88333
+ function meta2(code2) {
87895
88334
  if (code2 === null || markdownLineEnding(code2)) {
87896
88335
  effects.exit("chunkString");
87897
88336
  effects.exit("codeFencedFenceMeta");
@@ -87901,7 +88340,7 @@ function tokenizeCodeFenced(effects, ok2, nok) {
87901
88340
  return nok(code2);
87902
88341
  }
87903
88342
  effects.consume(code2);
87904
- return meta;
88343
+ return meta2;
87905
88344
  }
87906
88345
  function atNonLazyBreak(code2) {
87907
88346
  return effects.attempt(closeStart, after, contentBefore)(code2);
@@ -101112,7 +101551,7 @@ var Ts = (e) => {
101112
101551
  for (; t > 0 && e[t - 1] === `
101113
101552
  `; ) t--;
101114
101553
  return e.slice(0, t);
101115
- }, Ps = reactExports.lazy(() => import("./highlighted-body-JLMTFACH-j-e-XD1V.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), At = ({ code: e, language: t, className: n, children: o, isIncomplete: r2 = false, startLine: s2, lineNumbers: a2, ...i }) => {
101554
+ }, Ps = reactExports.lazy(() => import("./highlighted-body-JLMTFACH-CF_5tt3-.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), At = ({ code: e, language: t, className: n, children: o, isIncomplete: r2 = false, startLine: s2, lineNumbers: a2, ...i }) => {
101116
101555
  let l = w(), { codeBlockMaxHeight: c2 } = reactExports.useContext(R), d2 = reactExports.useMemo(() => Ts(e), [e]), p2 = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: d2.split(`
101117
101556
  `).map((b2) => [{ content: b2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [d2]);
101118
101557
  return jsxRuntimeExports.jsx(Lt.Provider, { value: { code: e }, children: jsxRuntimeExports.jsxs(It, { dir: "ltr", isIncomplete: r2, language: t, children: [jsxRuntimeExports.jsx(Dt, { language: t }), o ? jsxRuntimeExports.jsx("div", { className: l("pointer-events-none absolute top-2 right-2 z-10 flex items-center"), children: jsxRuntimeExports.jsx("div", { className: l("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: o }) }) : null, jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: jsxRuntimeExports.jsx(In, { className: n, language: t, lineNumbers: a2, maxHeight: c2, result: p2, startLine: s2, ...i }), children: jsxRuntimeExports.jsx(Ps, { className: n, code: d2, isIncomplete: r2, language: t, lineNumbers: a2, maxHeight: c2, raw: p2, startLine: s2, ...i }) })] }) });
@@ -101547,7 +101986,7 @@ var Co = ({ children: e, className: t, maxHeight: n, showControls: o, showCopy:
101547
101986
  let l = w(), { isAnimating: c2 } = reactExports.useContext(R), d2 = rt(n), p2 = st(c2, !!d2, e), b2 = o && r2, f2 = o && s2, u = o && a2, g2 = b2 || f2 || u;
101548
101987
  return jsxRuntimeExports.jsxs("div", { className: l("my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2"), "data-streamdown": "table-wrapper", children: [g2 ? jsxRuntimeExports.jsxs("div", { className: l("flex items-center justify-end gap-1"), children: [b2 ? jsxRuntimeExports.jsx(Ze, {}) : null, f2 ? jsxRuntimeExports.jsx(Ge, {}) : null, u ? jsxRuntimeExports.jsx(ho, { showCopy: b2, showDownload: f2, children: e }) : null] }) : null, jsxRuntimeExports.jsx("div", { className: l("border-collapse overflow-x-auto overflow-y-auto rounded-md border border-border bg-background"), ref: p2, style: d2 ? { maxHeight: d2 } : void 0, children: jsxRuntimeExports.jsx("table", { className: l("w-full divide-y divide-border", t), "data-streamdown": "table", ...i, children: e }) })] });
101549
101988
  };
101550
- var Na = /startLine=(\d+)/, Ra = /\bnoLineNumbers\b/, Ia = reactExports.lazy(() => import("./mermaid-WFAXDIZX-B19UvP0H.js").then((e) => ({ default: e.Mermaid }))), La = /language-([^\s]+)/, Da = "node";
101989
+ var Na = /startLine=(\d+)/, Ra = /\bnoLineNumbers\b/, Ia = reactExports.lazy(() => import("./mermaid-WFAXDIZX-BHZz_uL6.js").then((e) => ({ default: e.Mermaid }))), La = /language-([^\s]+)/, Da = "node";
101551
101990
  function H(e, t) {
101552
101991
  let n = Object.keys(e);
101553
101992
  if (n.length !== Object.keys(t).length) return false;
@@ -103309,7 +103748,7 @@ function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, fetchSpanDeta
103309
103748
  run2.status,
103310
103749
  resolvedHookIds
103311
103750
  ]);
103312
- const hookToken = reactExports.useMemo(() => {
103751
+ const hookToken2 = reactExports.useMemo(() => {
103313
103752
  if (resource !== "hook" || !resourceId)
103314
103753
  return void 0;
103315
103754
  if (isHook(matchedSpanDetailData) && matchedSpanDetailData.token) {
@@ -103366,7 +103805,7 @@ function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, fetchSpanDeta
103366
103805
  });
103367
103806
  return;
103368
103807
  }
103369
- if (!hookToken) {
103808
+ if (!hookToken2) {
103370
103809
  toast2.error("Unable to resolve hook", {
103371
103810
  description: "Missing hook token. Try refreshing the run data and retry."
103372
103811
  });
@@ -103376,7 +103815,7 @@ function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, fetchSpanDeta
103376
103815
  setResolvingHook(true);
103377
103816
  const candidate = matchedSpanDetailData ?? data2;
103378
103817
  const hook = isHook(candidate) ? candidate : void 0;
103379
- await onResolveHook(hookToken, payload, hook);
103818
+ await onResolveHook(hookToken2, payload, hook);
103380
103819
  toast2.success("Hook resolved", {
103381
103820
  description: "The payload has been sent and the hook resolved."
103382
103821
  });
@@ -103392,7 +103831,7 @@ function EntityDetailPanel({ run: run2, onStreamClick, onRunClick, fetchSpanDeta
103392
103831
  } finally {
103393
103832
  setResolvingHook(false);
103394
103833
  }
103395
- }, [onResolveHook, hookToken, resolvingHook, matchedSpanDetailData, data2]);
103834
+ }, [onResolveHook, hookToken2, resolvingHook, matchedSpanDetailData, data2]);
103396
103835
  const moduleSpecifier = reactExports.useMemo(() => {
103397
103836
  const displayRecord = displayData;
103398
103837
  const displayStepName = displayRecord.stepName;
@@ -107239,6 +107678,9 @@ async function fetchRuns$1(worldEnv, params) {
107239
107678
  async function fetchRun$1(worldEnv, runId, resolveData = "all") {
107240
107679
  return rpc("fetchRun", { worldEnv, runId, resolveData });
107241
107680
  }
107681
+ async function fetchRunUsage$1(worldEnv, runId) {
107682
+ return rpc("fetchRunUsage", { worldEnv, runId });
107683
+ }
107242
107684
  async function fetchStep$1(worldEnv, runId, stepId, resolveData = "all") {
107243
107685
  return rpc("fetchStep", { worldEnv, runId, stepId, resolveData });
107244
107686
  }
@@ -107519,6 +107961,8 @@ function Logo({ className } = {}) {
107519
107961
  }
107520
107962
  );
107521
107963
  }
107964
+ const DEFAULT_TITLE = "Workflow Observability UI";
107965
+ const DEFAULT_META_DESCRIPTION = "Web interface for inspecting flow runs, steps, streams, and events";
107522
107966
  const RETRYABLE_WORLD_ERROR_CODES = /* @__PURE__ */ new Set([
107523
107967
  "TRANSPORT",
107524
107968
  "TIMEOUT",
@@ -110957,6 +111401,63 @@ async function getWorldLazy() {
110957
111401
  }
110958
111402
  throw new Error("Workflow world runtime was not initialized. Import from the host workflow entrypoints (`workflow`, `workflow/api`, or `workflow/runtime`) so @workflow/core/runtime/world-init can register getWorld before getWorldLazy() is used.");
110959
111403
  }
111404
+ const REGISTRY_KEY = Symbol.for("@workflow/core//localAbortDelivery");
111405
+ const PUBLISHED_TTL_MS = 6e4;
111406
+ const MAX_PUBLISHED = 256;
111407
+ function registry() {
111408
+ const holder = globalThis;
111409
+ holder[REGISTRY_KEY] ?? (holder[REGISTRY_KEY] = { listeners: /* @__PURE__ */ new Map(), published: /* @__PURE__ */ new Map() });
111410
+ return holder[REGISTRY_KEY];
111411
+ }
111412
+ function keyOf(runId, streamName) {
111413
+ return `${runId}\0${streamName}`;
111414
+ }
111415
+ function prune(published, now2) {
111416
+ for (const [key, entry2] of published) {
111417
+ if (now2 - entry2.at < PUBLISHED_TTL_MS && published.size <= MAX_PUBLISHED)
111418
+ break;
111419
+ published.delete(key);
111420
+ }
111421
+ }
111422
+ function publishLocalAbort(runId, streamName, packet) {
111423
+ const { listeners, published } = registry();
111424
+ const key = keyOf(runId, streamName);
111425
+ const now2 = Date.now();
111426
+ published.delete(key);
111427
+ published.set(key, { packet, at: now2 });
111428
+ prune(published, now2);
111429
+ for (const listener of listeners.get(key) ?? []) {
111430
+ try {
111431
+ listener(packet);
111432
+ } catch {
111433
+ }
111434
+ }
111435
+ }
111436
+ function onLocalAbort(runId, streamName, listener) {
111437
+ const { listeners, published } = registry();
111438
+ const key = keyOf(runId, streamName);
111439
+ prune(published, Date.now());
111440
+ const recent = published.get(key);
111441
+ if (recent) {
111442
+ listener(recent.packet);
111443
+ return () => {
111444
+ };
111445
+ }
111446
+ let set2 = listeners.get(key);
111447
+ if (!set2) {
111448
+ set2 = /* @__PURE__ */ new Set();
111449
+ listeners.set(key, set2);
111450
+ }
111451
+ set2.add(listener);
111452
+ return () => {
111453
+ const current2 = listeners.get(key);
111454
+ if (!current2)
111455
+ return;
111456
+ current2.delete(listener);
111457
+ if (current2.size === 0)
111458
+ listeners.delete(key);
111459
+ };
111460
+ }
110960
111461
  const HEADER_SIZE = 4;
110961
111462
  const MAX_PACKET_SIZE = 1e8;
110962
111463
  function frameAbortStreamPayload(payload) {
@@ -112406,7 +112907,7 @@ var EventConsumerResult;
112406
112907
  })(EventConsumerResult || (EventConsumerResult = {}));
112407
112908
  _g = ABORT_STREAM_NAME, _f = ABORT_HOOK_TOKEN;
112408
112909
  class WorkflowAbortSignal {
112409
- constructor(streamName, hookToken) {
112910
+ constructor(streamName, hookToken2) {
112410
112911
  __publicField(this, "aborted", false);
112411
112912
  __publicField(this, "reason");
112412
112913
  __publicField(this, _g);
@@ -112414,7 +112915,7 @@ class WorkflowAbortSignal {
112414
112915
  __privateAdd(this, _listeners, []);
112415
112916
  __privateAdd(this, _onabort, null);
112416
112917
  this[ABORT_STREAM_NAME] = streamName;
112417
- this[ABORT_HOOK_TOKEN] = hookToken;
112918
+ this[ABORT_HOOK_TOKEN] = hookToken2;
112418
112919
  }
112419
112920
  get onabort() {
112420
112921
  return __privateGet(this, _onabort);
@@ -113392,22 +113893,22 @@ function getAllBaseReducers(global2 = globalThis) {
113392
113893
  }
113393
113894
  function reduceAbortWithListener(signal, holder, global2, ops, runId, cryptoKey, framedAbortStreams) {
113394
113895
  let streamName = holder[ABORT_STREAM_NAME];
113395
- let hookToken = holder[ABORT_HOOK_TOKEN];
113896
+ let hookToken2 = holder[ABORT_HOOK_TOKEN];
113396
113897
  if (!streamName) {
113397
113898
  const id2 = (global2[STABLE_ULID] || defaultUlid)();
113398
113899
  streamName = getAbortStreamId(id2);
113399
- hookToken = `abrt_${id2}`;
113900
+ hookToken2 = `abrt_${id2}`;
113400
113901
  holder[ABORT_STREAM_NAME] = streamName;
113401
- holder[ABORT_HOOK_TOKEN] = hookToken;
113902
+ holder[ABORT_HOOK_TOKEN] = hookToken2;
113402
113903
  if (holder.signal) {
113403
113904
  holder.signal[ABORT_STREAM_NAME] = streamName;
113404
- holder.signal[ABORT_HOOK_TOKEN] = hookToken;
113905
+ holder.signal[ABORT_HOOK_TOKEN] = hookToken2;
113405
113906
  }
113406
113907
  }
113407
113908
  attachAbortListenerOnce(signal, streamName, runId, cryptoKey, ops, framedAbortStreams);
113408
113909
  return {
113409
113910
  streamName,
113410
- hookToken,
113911
+ hookToken: hookToken2,
113411
113912
  aborted: signal.aborted,
113412
113913
  reason: signal.aborted ? signal.reason : void 0
113413
113914
  };
@@ -113415,13 +113916,13 @@ function reduceAbortWithListener(signal, holder, global2, ops, runId, cryptoKey,
113415
113916
  function reduceAbortBySymbol(signal, holder) {
113416
113917
  var _a3, _b2;
113417
113918
  const streamName = holder[ABORT_STREAM_NAME] ?? ((_a3 = holder.signal) == null ? void 0 : _a3[ABORT_STREAM_NAME]);
113418
- const hookToken = holder[ABORT_HOOK_TOKEN] ?? ((_b2 = holder.signal) == null ? void 0 : _b2[ABORT_HOOK_TOKEN]);
113919
+ const hookToken2 = holder[ABORT_HOOK_TOKEN] ?? ((_b2 = holder.signal) == null ? void 0 : _b2[ABORT_HOOK_TOKEN]);
113419
113920
  if (!streamName) {
113420
113921
  throw new Error("AbortController/AbortSignal stream name is not set");
113421
113922
  }
113422
113923
  return {
113423
113924
  streamName,
113424
- hookToken,
113925
+ hookToken: hookToken2,
113425
113926
  aborted: signal.aborted,
113426
113927
  reason: signal.aborted ? signal.reason : void 0
113427
113928
  };
@@ -113437,6 +113938,7 @@ function attachAbortListenerOnce(signal, streamName, runId, cryptoKey, ops, fram
113437
113938
  try {
113438
113939
  const key = await resolveEncryptionKey(cryptoKey);
113439
113940
  const payload = await dehydrateStepArguments({ aborted: true, reason: signal.reason }, runId, key);
113941
+ publishLocalAbort(runId, streamName, payload);
113440
113942
  const writable = new WorkflowServerWritableStream(runId, streamName);
113441
113943
  const writer = writable.getWriter();
113442
113944
  await writer.write(framedAbortStreams ? frameAbortStreamPayload(payload) : payload);
@@ -113690,40 +114192,78 @@ function getStepReducers(global2 = globalThis, ops, runId, cryptoKey, framedByte
113690
114192
  }
113691
114193
  };
113692
114194
  }
113693
- function setupAbortStreamReader(controller, runId, streamName, ops, cryptoKey) {
114195
+ const LOCAL_ABORT_LISTEN_AFTER_STREAM_END_MS = 60 * 60 * 1e3;
114196
+ function setupAbortStreamReader(controller, runId, streamName, ops, cryptoKey, untilCancelled) {
113694
114197
  const readerCancel = new AbortController();
114198
+ let resolveLocal;
114199
+ const localPacket = new Promise((resolve2) => {
114200
+ resolveLocal = resolve2;
114201
+ });
114202
+ const stopLocal = onLocalAbort(runId, streamName, (packet) => resolveLocal == null ? void 0 : resolveLocal(packet));
113695
114203
  ops.push((async () => {
114204
+ var _a3;
113696
114205
  let reader;
114206
+ let keepListening = false;
113697
114207
  try {
113698
- const readable2 = new WorkflowServerReadableStream(runId, streamName);
113699
- reader = readable2.getReader();
113700
114208
  let keyPromise;
113701
114209
  let decoded;
113702
114210
  const decodePacket = async (packet) => {
113703
114211
  keyPromise ?? (keyPromise = resolveEncryptionKey(cryptoKey));
113704
114212
  decoded = await hydrateStepArguments(packet, runId, await keyPromise);
113705
114213
  };
113706
- const result = await Promise.race([
113707
- readAbortStreamPacket(reader, decodePacket),
113708
- new Promise((resolve2) => {
113709
- if (readerCancel.signal.aborted) {
113710
- resolve2(void 0);
113711
- return;
113712
- }
113713
- readerCancel.signal.addEventListener("abort", () => resolve2(void 0), { once: true });
113714
- })
113715
- ]);
113716
- if (result) {
114214
+ const abortWith = async (packet, already) => {
113717
114215
  try {
114216
+ decoded = already;
113718
114217
  if (decoded === void 0)
113719
- await decodePacket(result);
114218
+ await decodePacket(packet);
113720
114219
  controller.abort(decoded == null ? void 0 : decoded.reason);
113721
114220
  } catch {
113722
114221
  controller.abort();
113723
114222
  }
114223
+ };
114224
+ const cancelled = new Promise((resolve2) => {
114225
+ if (readerCancel.signal.aborted) {
114226
+ resolve2(void 0);
114227
+ return;
114228
+ }
114229
+ readerCancel.signal.addEventListener("abort", () => resolve2(void 0), { once: true });
114230
+ });
114231
+ let streamPacket;
114232
+ try {
114233
+ const readable2 = new WorkflowServerReadableStream(runId, streamName);
114234
+ reader = readable2.getReader();
114235
+ streamPacket = readAbortStreamPacket(reader, decodePacket);
114236
+ } catch {
114237
+ streamPacket = new Promise(() => {
114238
+ });
114239
+ }
114240
+ const local = localPacket.then((packet) => ({ packet, local: true }));
114241
+ const winner = await Promise.race([
114242
+ local,
114243
+ untilCancelled ? (
114244
+ // An empty or failed stream is not the end of the abort.
114245
+ streamPacket.then((packet) => packet ? { packet, local: false } : void 0, () => void 0)
114246
+ ) : streamPacket.then((packet) => packet ? { packet, local: false } : void 0),
114247
+ cancelled
114248
+ ]);
114249
+ if (winner) {
114250
+ await abortWith(winner.packet, winner.local ? void 0 : decoded);
114251
+ } else if (untilCancelled && !readerCancel.signal.aborted) {
114252
+ keepListening = true;
114253
+ const expiry = setTimeout(stopLocal, LOCAL_ABORT_LISTEN_AFTER_STREAM_END_MS);
114254
+ (_a3 = expiry.unref) == null ? void 0 : _a3.call(expiry);
114255
+ void Promise.race([local, cancelled]).then(async (late) => {
114256
+ clearTimeout(expiry);
114257
+ stopLocal();
114258
+ if (late)
114259
+ await abortWith(late.packet, void 0);
114260
+ }).catch(() => {
114261
+ });
113724
114262
  }
113725
114263
  } catch {
113726
114264
  } finally {
114265
+ if (!keepListening)
114266
+ stopLocal();
113727
114267
  void (reader == null ? void 0 : reader.cancel().catch(() => {
113728
114268
  }));
113729
114269
  }
@@ -113755,13 +114295,13 @@ function copyAbortInternals(src2, dest) {
113755
114295
  d2[ABORT_READER_CANCEL] = s2[ABORT_READER_CANCEL];
113756
114296
  }
113757
114297
  }
113758
- function reviveAbortController(value, ops, runId, cryptoKey) {
114298
+ function reviveAbortController(value, ops, runId, cryptoKey, untilCancelled = false) {
113759
114299
  const controller = new AbortController();
113760
114300
  if (value.aborted) {
113761
114301
  tagAbortPair(controller, value);
113762
114302
  controller.abort(value.reason);
113763
114303
  } else if (value.streamName) {
113764
- const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops, cryptoKey);
114304
+ const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops, cryptoKey, untilCancelled);
113765
114305
  tagAbortPair(controller, value, readerCancel);
113766
114306
  } else {
113767
114307
  tagAbortPair(controller, value);
@@ -113776,6 +114316,7 @@ function reviveAbortController(value, ops, runId, cryptoKey) {
113776
114316
  ctx.ops.push((async () => {
113777
114317
  try {
113778
114318
  const payload = await dehydrateStepArguments({ aborted: true, reason }, ctx.workflowMetadata.workflowRunId, ctx.encryptionKey);
114319
+ publishLocalAbort(ctx.workflowMetadata.workflowRunId, value.streamName, payload);
113779
114320
  const writable = new WorkflowServerWritableStream(ctx.workflowMetadata.workflowRunId, value.streamName);
113780
114321
  const writer = writable.getWriter();
113781
114322
  await writer.write(frameAbortStreamPayload(payload));
@@ -113800,13 +114341,13 @@ function reviveAbortController(value, ops, runId, cryptoKey) {
113800
114341
  };
113801
114342
  return controller;
113802
114343
  }
113803
- function reviveAbortSignal(value, ops, runId, cryptoKey) {
114344
+ function reviveAbortSignal(value, ops, runId, cryptoKey, untilCancelled = false) {
113804
114345
  const controller = new AbortController();
113805
114346
  if (value.aborted) {
113806
114347
  tagAbortPair(controller, value);
113807
114348
  controller.abort(value.reason);
113808
114349
  } else if (value.streamName) {
113809
- const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops, cryptoKey);
114350
+ const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops, cryptoKey, untilCancelled);
113810
114351
  tagAbortPair(controller, value, readerCancel);
113811
114352
  } else {
113812
114353
  tagAbortPair(controller, value);
@@ -114303,8 +114844,10 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deployment
114303
114844
  }
114304
114845
  return writable;
114305
114846
  },
114306
- AbortController: (value) => reviveAbortController(value, ops, runId, cryptoKey),
114307
- AbortSignal: (value) => reviveAbortSignal(value, ops, runId, cryptoKey)
114847
+ // A step's readers are cancelled when the step returns
114848
+ // (`cancelAbortReaders`), so they may outlive an empty stream.
114849
+ AbortController: (value) => reviveAbortController(value, ops, runId, cryptoKey, true),
114850
+ AbortSignal: (value) => reviveAbortSignal(value, ops, runId, cryptoKey, true)
114308
114851
  };
114309
114852
  }
114310
114853
  async function maybeEncrypt(data2, key) {
@@ -114670,7 +115213,7 @@ function getCompressionMode(capabilities) {
114670
115213
  }
114671
115214
  return capabilities.supportedFormats.has(SerializationFormat$1.ZSTD) ? true : "gzip";
114672
115215
  }
114673
- const version$2 = "5.7.0";
115216
+ const version$2 = "5.7.2";
114674
115217
  globalSingleton("@workflow/core//envWarnings", 1, () => ({
114675
115218
  replayTimeoutValues: /* @__PURE__ */ new Set(),
114676
115219
  maxInlineStepsValues: /* @__PURE__ */ new Set(),
@@ -121184,8 +121727,8 @@ function requireWebidl() {
121184
121727
  return new TypeError(`${message2.header}: ${message2.message}`);
121185
121728
  };
121186
121729
  webidl.errors.conversionFailed = function(opts) {
121187
- const plural = opts.types.length === 1 ? "" : " one of";
121188
- const message2 = `${opts.argument} could not be converted to${plural}: ${opts.types.join(", ")}.`;
121730
+ const plural2 = opts.types.length === 1 ? "" : " one of";
121731
+ const message2 = `${opts.argument} could not be converted to${plural2}: ${opts.types.join(", ")}.`;
121189
121732
  return webidl.errors.exception({
121190
121733
  header: opts.prefix,
121191
121734
  message: message2
@@ -132171,8 +132714,8 @@ function requireDns() {
132171
132714
  deleteRecords(origin) {
132172
132715
  this.storage.delete(origin.hostname);
132173
132716
  }
132174
- getHandler(meta, opts) {
132175
- return new DNSDispatchHandler(this, meta, opts);
132717
+ getHandler(meta2, opts) {
132718
+ return new DNSDispatchHandler(this, meta2, opts);
132176
132719
  }
132177
132720
  }
132178
132721
  _maxTTL = new WeakMap();
@@ -144513,6 +145056,105 @@ function backstopWakeDelaySeconds(resumeAt, now2) {
144513
145056
  return void 0;
144514
145057
  return Math.ceil(delayMs / 1e3);
144515
145058
  }
145059
+ const PAYLOAD_PATHS = {
145060
+ // A dynamic run's code is kept on the run, not on its events, so it is
145061
+ // not here.
145062
+ run_created: ["$.eventData.input", "$.eventData.startHook.metadata"],
145063
+ run_started: ["$.eventData.input", "$.eventData.startHook.metadata"],
145064
+ run_completed: ["$.eventData.output"],
145065
+ run_failed: ["$.eventData.error"],
145066
+ step_created: ["$.eventData.input"],
145067
+ step_started: ["$.eventData.input"],
145068
+ step_completed: ["$.eventData.result"],
145069
+ step_failed: ["$.eventData.error"],
145070
+ step_retrying: ["$.eventData.error"],
145071
+ hook_created: ["$.eventData.metadata"],
145072
+ hook_received: ["$.eventData.payload"]
145073
+ };
145074
+ function valueBytesSql(path2) {
145075
+ const data2 = `CAST(json_extract(doc, '${path2}.data') AS BLOB)`;
145076
+ return `CASE WHEN json_extract(doc, '${path2}.__type') = 'Uint8Array'
145077
+ THEN length(${data2}) / 4 * 3 - (CASE WHEN substr(${data2}, -2) = X'3D3D' THEN 2 WHEN substr(${data2}, -1) = X'3D' THEN 1 ELSE 0 END)
145078
+ ELSE coalesce(length(CAST(doc -> '${path2}' AS BLOB)), 0) END`;
145079
+ }
145080
+ const PAYLOAD_BYTES_SQL = `(CASE event_type ${Object.entries(PAYLOAD_PATHS).map(([eventType, paths]) => `WHEN '${eventType}' THEN ${paths.map((path2) => `(${valueBytesSql(path2)})`).join(" + ")}`).join(" ")} ELSE 0 END)`;
145081
+ const STREAM_BYTES_SQL = `
145082
+ SELECT COALESCE(SUM(length(data)), 0) AS bytes
145083
+ FROM stream_chunks
145084
+ WHERE run_id = ?
145085
+ `;
145086
+ function measureStreamBytes(db, runId) {
145087
+ var _a3;
145088
+ return Number(((_a3 = db.get(STREAM_BYTES_SQL, runId)) == null ? void 0 : _a3.bytes) ?? 0);
145089
+ }
145090
+ const TABLE = "run_usage_purged";
145091
+ const CREATE_TABLE_SQL = `
145092
+ CREATE TABLE IF NOT EXISTS ${TABLE} (
145093
+ run_id TEXT PRIMARY KEY,
145094
+ -- The last log position the sizes below cover.
145095
+ seq INTEGER NOT NULL,
145096
+ run_bytes INTEGER NOT NULL,
145097
+ step_bytes INTEGER NOT NULL,
145098
+ hook_bytes INTEGER NOT NULL,
145099
+ stream_bytes INTEGER NOT NULL
145100
+ )
145101
+ `;
145102
+ class EntityBytes {
145103
+ constructor() {
145104
+ __publicField(this, "byEntity", {
145105
+ run: 0,
145106
+ step: 0,
145107
+ hook: 0,
145108
+ stream: 0
145109
+ });
145110
+ }
145111
+ add(eventType, bytes) {
145112
+ const entity = usageEntityOfEventType(eventType);
145113
+ if (entity)
145114
+ this.byEntity[entity] += Number(bytes) || 0;
145115
+ }
145116
+ }
145117
+ function tableExists(db) {
145118
+ return db.get("SELECT 1 AS one FROM sqlite_master WHERE type = 'table' AND name = ?", TABLE) !== void 0;
145119
+ }
145120
+ function savePurgedUsage(db, runId, usage) {
145121
+ db.run(CREATE_TABLE_SQL);
145122
+ db.run(`INSERT INTO ${TABLE}
145123
+ (run_id, seq, run_bytes, step_bytes, hook_bytes, stream_bytes)
145124
+ VALUES (?, ?, ?, ?, ?, ?)
145125
+ ON CONFLICT (run_id) DO UPDATE SET
145126
+ seq = excluded.seq,
145127
+ run_bytes = excluded.run_bytes,
145128
+ step_bytes = excluded.step_bytes,
145129
+ hook_bytes = excluded.hook_bytes,
145130
+ stream_bytes = excluded.stream_bytes`, runId, usage.seq, usage.byEntity.run, usage.byEntity.step, usage.byEntity.hook, usage.byEntity.stream);
145131
+ }
145132
+ function readPurgedUsage(db, runId) {
145133
+ if (!tableExists(db))
145134
+ return null;
145135
+ const row = db.get(`SELECT seq, run_bytes, step_bytes, hook_bytes, stream_bytes
145136
+ FROM ${TABLE} WHERE run_id = ?`, runId);
145137
+ if (!row)
145138
+ return null;
145139
+ return {
145140
+ seq: Number(row.seq),
145141
+ byEntity: {
145142
+ run: Number(row.run_bytes),
145143
+ step: Number(row.step_bytes),
145144
+ hook: Number(row.hook_bytes),
145145
+ stream: Number(row.stream_bytes)
145146
+ }
145147
+ };
145148
+ }
145149
+ function deletePurgedUsage(db, where) {
145150
+ if (!tableExists(db))
145151
+ return;
145152
+ if (!where) {
145153
+ db.run(`DELETE FROM ${TABLE}`);
145154
+ return;
145155
+ }
145156
+ db.run(`DELETE FROM ${TABLE} WHERE run_id IN (${where.runIdsSql})`, ...where.params);
145157
+ }
144516
145158
  function truncateForError(value) {
144517
145159
  const s2 = typeof value === "string" ? value : String(value);
144518
145160
  const MAX = 48;
@@ -144547,11 +145189,31 @@ function ranPurge(run2) {
144547
145189
  return true;
144548
145190
  return run2.expiredAt !== void 0 && new Date(run2.expiredAt).getTime() <= Date.now();
144549
145191
  }
144550
- function purgeRunData(db, runId) {
145192
+ function purgeRunData(db, runId, { purgedBefore = false } = {}) {
144551
145193
  for (const row of db.all("SELECT step_id, doc FROM steps WHERE run_id = ?", runId)) {
144552
145194
  writeScrubbedStep(db, runId, row.step_id, row.doc);
144553
145195
  }
144554
- for (const row of db.all("SELECT seq, doc FROM events WHERE run_id = ?", runId)) {
145196
+ const saved = readPurgedUsage(db, runId);
145197
+ const written = new EntityBytes();
145198
+ let lastSeq = 0;
145199
+ const events2 = db.all(`SELECT seq, event_type, doc, ${PAYLOAD_BYTES_SQL} AS bytes
145200
+ FROM events WHERE run_id = ?`, runId);
145201
+ for (const row of events2) {
145202
+ lastSeq = Math.max(lastSeq, Number(row.seq));
145203
+ if (saved && Number(row.seq) <= saved.seq)
145204
+ continue;
145205
+ written.add(row.event_type, row.bytes);
145206
+ }
145207
+ written.byEntity.stream = measureStreamBytes(db, runId);
145208
+ if (saved) {
145209
+ savePurgedUsage(db, runId, {
145210
+ seq: lastSeq,
145211
+ byEntity: addBytes(saved.byEntity, written.byEntity)
145212
+ });
145213
+ } else if (!purgedBefore) {
145214
+ savePurgedUsage(db, runId, { seq: lastSeq, byEntity: written.byEntity });
145215
+ }
145216
+ for (const row of events2) {
144555
145217
  writeScrubbedEvent(db, runId, row.seq, row.doc);
144556
145218
  }
144557
145219
  for (const row of db.all("SELECT hook_id, doc FROM hooks WHERE run_id = ?", runId)) {
@@ -144571,8 +145233,29 @@ function purgeLateStepWrite(db, runId, stepId, seq) {
144571
145233
  db.run("UPDATE steps SET doc = ? WHERE run_id = ? AND step_id = ?", encode$1(step), runId, stepId);
144572
145234
  }
144573
145235
  const event = db.get("SELECT doc FROM events WHERE run_id = ? AND seq = ?", runId, seq);
144574
- if (event)
144575
- writeScrubbedEvent(db, runId, seq, event.doc);
145236
+ if (!event)
145237
+ return;
145238
+ const saved = readPurgedUsage(db, runId);
145239
+ if (saved && seq > saved.seq) {
145240
+ const written = new EntityBytes();
145241
+ for (const row of db.all(`SELECT event_type, ${PAYLOAD_BYTES_SQL} AS bytes
145242
+ FROM events WHERE run_id = ? AND seq > ? AND seq <= ?`, runId, saved.seq, seq)) {
145243
+ written.add(row.event_type, row.bytes);
145244
+ }
145245
+ savePurgedUsage(db, runId, {
145246
+ seq,
145247
+ byEntity: addBytes(saved.byEntity, written.byEntity)
145248
+ });
145249
+ }
145250
+ writeScrubbedEvent(db, runId, seq, event.doc);
145251
+ }
145252
+ function addBytes(a2, b2) {
145253
+ return {
145254
+ run: a2.run + b2.run,
145255
+ step: a2.step + b2.step,
145256
+ hook: a2.hook + b2.hook,
145257
+ stream: a2.stream + b2.stream
145258
+ };
144576
145259
  }
144577
145260
  function writeScrubbedStep(db, runId, stepId, doc) {
144578
145261
  const step = decode$1(doc);
@@ -144810,6 +145493,7 @@ class Store {
144810
145493
  eventsBetween(runId, afterSeq, beforeSeq) {
144811
145494
  return this.db.all("SELECT doc FROM events WHERE run_id = ? AND seq > ? AND seq < ? ORDER BY seq", runId, afterSeq, beforeSeq).map((row) => decode$1(row.doc));
144812
145495
  }
145496
+ // A caller that rewrites a live run's events makes the usage cache stale (see usage-storage.ts).
144813
145497
  rewriteEvent(event) {
144814
145498
  const seq = eventIdToSlot(event.eventId);
144815
145499
  if (seq === null)
@@ -145977,7 +146661,7 @@ function createRunsStorage(db, tag) {
145977
146661
  const alreadyDeleted = run2.expiredAt !== void 0 && run2.expiredAt.getTime() <= now2.getTime();
145978
146662
  if (!alreadyDeleted)
145979
146663
  store.updateRun(withRunPayloadsPurged(run2, now2));
145980
- purgeRunData(db, runId);
146664
+ purgeRunData(db, runId, { purgedBefore: alreadyDeleted });
145981
146665
  return { runId, outcome: alreadyDeleted ? "already_deleted" : "deleted" };
145982
146666
  }
145983
146667
  return {
@@ -146170,6 +146854,320 @@ function createStepsStorage(db, tag) {
146170
146854
  })
146171
146855
  };
146172
146856
  }
146857
+ const IS_STEP_EVENT = `event_type LIKE 'step\\_%' ESCAPE '\\'`;
146858
+ const EVENT_GROUPS_SQL = `
146859
+ SELECT event_type,
146860
+ COUNT(*) AS events,
146861
+ SUM(${PAYLOAD_BYTES_SQL}) AS bytes
146862
+ FROM events
146863
+ WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3 AND NOT (${IS_STEP_EVENT})
146864
+ GROUP BY event_type
146865
+ `;
146866
+ const STEP_GROUPS_SQL = `
146867
+ SELECT correlation_id,
146868
+ COUNT(*) AS events,
146869
+ SUM(event_type = 'step_created') AS created,
146870
+ SUM(event_type = 'step_started') AS started,
146871
+ SUM(event_type = 'step_completed') AS completed,
146872
+ SUM(event_type = 'step_failed') AS failed,
146873
+ SUM(event_type = 'step_retrying') AS retries,
146874
+ SUM(${PAYLOAD_BYTES_SQL}) AS bytes
146875
+ FROM events
146876
+ WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3 AND ${IS_STEP_EVENT}
146877
+ GROUP BY correlation_id
146878
+ `;
146879
+ const WAIT_IDS_SQL = `
146880
+ SELECT DISTINCT correlation_id
146881
+ FROM events
146882
+ WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3
146883
+ AND correlation_id IS NOT NULL AND substr(event_type, 1, 5) = 'wait_'
146884
+ `;
146885
+ const HOOK_GROUPS_SQL = `
146886
+ SELECT correlation_id, COUNT(*) AS events
146887
+ FROM events
146888
+ WHERE run_id = ?1 AND seq > ?2 AND seq <= ?3
146889
+ AND correlation_id IS NOT NULL AND substr(event_type, 1, 5) = 'hook_'
146890
+ GROUP BY correlation_id
146891
+ `;
146892
+ const HOOK_TOKEN_SQL = `
146893
+ SELECT json_extract(doc, '$.eventData.token') AS token
146894
+ FROM ${EVENTS_BY_CORRELATION}
146895
+ WHERE run_id = ? AND correlation_id = ?
146896
+ AND event_type IN ('hook_created', 'hook_conflict')
146897
+ ORDER BY seq LIMIT 1
146898
+ `;
146899
+ const HOOK_ROW_TOKEN_SQL = "SELECT token FROM hooks WHERE hook_id = ?";
146900
+ const START_HOOK_TOKEN_SQL = `
146901
+ SELECT json_extract(doc, '$.eventData.startHook.token') AS token
146902
+ FROM events
146903
+ WHERE run_id = ? AND event_type = 'run_created'
146904
+ LIMIT 1
146905
+ `;
146906
+ const STEP_NAME_SQL = `
146907
+ SELECT json_extract(doc, '$.stepName') AS step_name
146908
+ FROM steps WHERE run_id = ? AND step_id = ?
146909
+ `;
146910
+ const BATCH_END_SQL = `
146911
+ SELECT MAX(seq) AS seq FROM (
146912
+ SELECT seq FROM events WHERE run_id = ? AND seq > ? ORDER BY seq LIMIT ?
146913
+ )
146914
+ `;
146915
+ const EVENTS_AFTER_SQL = `
146916
+ SELECT event_type, SUM(${PAYLOAD_BYTES_SQL}) AS bytes
146917
+ FROM events
146918
+ WHERE run_id = ? AND seq > ?
146919
+ GROUP BY event_type
146920
+ `;
146921
+ const PURGED_RUN_SQL = `
146922
+ SELECT json_extract(doc, '$.expiredAt') IS NOT NULL AS purged
146923
+ FROM runs WHERE run_id = ?
146924
+ `;
146925
+ const newCounts = () => ({
146926
+ countedSeq: 0,
146927
+ finished: false,
146928
+ eventTypes: /* @__PURE__ */ new Map(),
146929
+ steps: /* @__PURE__ */ new Map(),
146930
+ hooks: /* @__PURE__ */ new Map(),
146931
+ waitIds: /* @__PURE__ */ new Set()
146932
+ });
146933
+ function countRange(db, runId, counts, from, to2) {
146934
+ var _a3;
146935
+ if (to2 <= from)
146936
+ return;
146937
+ for (const row of db.all(EVENT_GROUPS_SQL, runId, from, to2)) {
146938
+ const entry2 = counts.eventTypes.get(row.event_type) ?? {
146939
+ events: 0,
146940
+ bytes: 0
146941
+ };
146942
+ entry2.events += Number(row.events);
146943
+ entry2.bytes += Number(row.bytes ?? 0);
146944
+ counts.eventTypes.set(row.event_type, entry2);
146945
+ }
146946
+ for (const row of db.all(STEP_GROUPS_SQL, runId, from, to2)) {
146947
+ const stepId = row.correlation_id ?? "";
146948
+ let step = counts.steps.get(stepId);
146949
+ if (!step) {
146950
+ const name2 = row.correlation_id === null ? null : ((_a3 = db.get(STEP_NAME_SQL, runId, row.correlation_id)) == null ? void 0 : _a3.step_name) ?? null;
146951
+ step = {
146952
+ name: name2,
146953
+ events: 0,
146954
+ created: 0,
146955
+ started: 0,
146956
+ completed: 0,
146957
+ failed: 0,
146958
+ retries: 0,
146959
+ bytes: 0
146960
+ };
146961
+ counts.steps.set(stepId, step);
146962
+ }
146963
+ step.events += Number(row.events);
146964
+ step.created += Number(row.created);
146965
+ step.started += Number(row.started);
146966
+ step.completed += Number(row.completed);
146967
+ step.failed += Number(row.failed);
146968
+ step.retries += Number(row.retries);
146969
+ step.bytes += Number(row.bytes ?? 0);
146970
+ }
146971
+ for (const row of db.all(HOOK_GROUPS_SQL, runId, from, to2)) {
146972
+ let hook = counts.hooks.get(row.correlation_id);
146973
+ if (!hook) {
146974
+ hook = { token: hookToken(db, runId, row.correlation_id), events: 0 };
146975
+ counts.hooks.set(row.correlation_id, hook);
146976
+ }
146977
+ hook.events += Number(row.events);
146978
+ }
146979
+ for (const row of db.all(WAIT_IDS_SQL, runId, from, to2)) {
146980
+ counts.waitIds.add(row.correlation_id);
146981
+ }
146982
+ counts.countedSeq = to2;
146983
+ }
146984
+ function hookToken(db, runId, hookId) {
146985
+ const created = db.get(HOOK_TOKEN_SQL, runId, hookId);
146986
+ if (typeof (created == null ? void 0 : created.token) === "string" && created.token)
146987
+ return created.token;
146988
+ const row = db.get(HOOK_ROW_TOKEN_SQL, hookId);
146989
+ if (typeof (row == null ? void 0 : row.token) === "string" && row.token)
146990
+ return row.token;
146991
+ let startHook;
146992
+ try {
146993
+ startHook = startHookId(runId);
146994
+ } catch {
146995
+ return null;
146996
+ }
146997
+ if (hookId !== startHook)
146998
+ return null;
146999
+ const start2 = db.get(START_HOOK_TOKEN_SQL, runId);
147000
+ return typeof (start2 == null ? void 0 : start2.token) === "string" && start2.token ? start2.token : null;
147001
+ }
147002
+ function hookGroupsOf(counts) {
147003
+ return [...counts.hooks].map(([hookId, hook]) => ({
147004
+ hookId,
147005
+ token: hook.token,
147006
+ events: hook.events
147007
+ }));
147008
+ }
147009
+ function eventGroupsOf(counts) {
147010
+ return [...counts.eventTypes].map(([eventType, entry2]) => ({
147011
+ eventType,
147012
+ events: entry2.events,
147013
+ bytes: entry2.bytes
147014
+ }));
147015
+ }
147016
+ function stepGroupsOf(counts) {
147017
+ const byName = /* @__PURE__ */ new Map();
147018
+ for (const step of counts.steps.values()) {
147019
+ let group = byName.get(step.name);
147020
+ if (!group) {
147021
+ group = {
147022
+ stepName: step.name,
147023
+ steps: 0,
147024
+ events: 0,
147025
+ created: 0,
147026
+ started: 0,
147027
+ completed: 0,
147028
+ failed: 0,
147029
+ retries: 0,
147030
+ restarts: 0,
147031
+ bytes: 0
147032
+ };
147033
+ byName.set(step.name, group);
147034
+ }
147035
+ group.steps += 1;
147036
+ group.events += step.events;
147037
+ group.created += step.created;
147038
+ group.started += step.started;
147039
+ group.completed += step.completed;
147040
+ group.failed += step.failed;
147041
+ group.retries += step.retries;
147042
+ group.restarts += Math.min(step.retries, Math.max(0, step.started - 1));
147043
+ group.bytes += step.bytes;
147044
+ }
147045
+ return [...byName.values()];
147046
+ }
147047
+ function purgedDataWritten(db, runId, streamBytes) {
147048
+ const saved = readPurgedUsage(db, runId);
147049
+ if (!saved)
147050
+ return null;
147051
+ const late = new EntityBytes();
147052
+ for (const row of db.all(EVENTS_AFTER_SQL, runId, saved.seq)) {
147053
+ late.add(row.event_type, Number(row.bytes ?? 0));
147054
+ }
147055
+ return {
147056
+ run: saved.byEntity.run + late.byEntity.run,
147057
+ step: saved.byEntity.step + late.byEntity.step,
147058
+ hook: saved.byEntity.hook + late.byEntity.hook,
147059
+ stream: saved.byEntity.stream + streamBytes
147060
+ };
147061
+ }
147062
+ const yieldToEventLoop = () => new Promise((resolve2) => setImmediate(resolve2));
147063
+ function createUsageStorage(db, tag, options = {}) {
147064
+ const maxRuns = options.maxRuns ?? 64;
147065
+ const batchTargetMs = options.batchTargetMs ?? 10;
147066
+ const maxBatchRows = options.maxBatchRows ?? 4096;
147067
+ const initialBatchRows = options.initialBatchRows ?? 4;
147068
+ const cache2 = /* @__PURE__ */ new Map();
147069
+ const inFlight = /* @__PURE__ */ new Map();
147070
+ const remember = (runId, counts) => {
147071
+ cache2.delete(runId);
147072
+ cache2.set(runId, counts);
147073
+ while (cache2.size > maxRuns) {
147074
+ cache2.delete(cache2.keys().next().value);
147075
+ }
147076
+ };
147077
+ const runRow = (runId) => db.get(`SELECT status, workflow_name, seq FROM runs WHERE run_id = ? AND ${tagClause("tag", tag)}`, runId, ...tagParams(tag));
147078
+ async function countInBatches(runId, counts, target2) {
147079
+ var _a3, _b2;
147080
+ let batchRows = initialBatchRows;
147081
+ while (counts.countedSeq < target2) {
147082
+ const end = Number(((_a3 = db.get(BATCH_END_SQL, runId, counts.countedSeq, batchRows)) == null ? void 0 : _a3.seq) ?? target2);
147083
+ const started = performance.now();
147084
+ countRange(db, runId, counts, counts.countedSeq, Math.min(end, target2));
147085
+ const took = performance.now() - started;
147086
+ batchRows = Math.max(1, Math.min(maxBatchRows, batchRows * 2, Math.round(batchRows * batchTargetMs / Math.max(took, 0.1))));
147087
+ if (counts.countedSeq < target2) {
147088
+ await ((_b2 = options.onBatch) == null ? void 0 : _b2.call(options, runId, counts.countedSeq));
147089
+ await yieldToEventLoop();
147090
+ }
147091
+ }
147092
+ }
147093
+ async function read2(runId) {
147094
+ const first = runRow(runId);
147095
+ if (!first) {
147096
+ cache2.delete(runId);
147097
+ throw new WorkflowRunNotFoundError(runId);
147098
+ }
147099
+ let counts = cache2.get(runId) ?? newCounts();
147100
+ if (Number(first.seq) < counts.countedSeq)
147101
+ counts = newCounts();
147102
+ let readBeforeFinish = !isTerminalWorkflowRunStatus(first.status) || counts.countedSeq > 0 && !counts.finished;
147103
+ await countInBatches(runId, counts, Number(first.seq));
147104
+ const snapshot = db.snapshot(() => {
147105
+ var _a3, _b2;
147106
+ const run2 = runRow(runId);
147107
+ if (!run2)
147108
+ return null;
147109
+ const seq = Number(run2.seq);
147110
+ const finished = isTerminalWorkflowRunStatus(run2.status);
147111
+ if (seq < counts.countedSeq) {
147112
+ counts = newCounts();
147113
+ readBeforeFinish = !finished;
147114
+ }
147115
+ countRange(db, runId, counts, counts.countedSeq, seq);
147116
+ const streamBytes = measureStreamBytes(db, runId);
147117
+ const savedDataWritten = purgedDataWritten(db, runId, streamBytes) ?? void 0;
147118
+ const dataPurged = savedDataWritten !== void 0 || finished && Number((_a3 = db.get(PURGED_RUN_SQL, runId)) == null ? void 0 : _a3.purged) === 1;
147119
+ if (dataPurged && readBeforeFinish && counts.countedSeq > 0) {
147120
+ (_b2 = options.onRecount) == null ? void 0 : _b2.call(options, runId);
147121
+ counts = newCounts();
147122
+ countRange(db, runId, counts, 0, seq);
147123
+ }
147124
+ counts.finished = finished;
147125
+ return {
147126
+ run: run2,
147127
+ streamBytes,
147128
+ dataPurged,
147129
+ savedDataWritten
147130
+ };
147131
+ });
147132
+ if (!snapshot) {
147133
+ cache2.delete(runId);
147134
+ throw new WorkflowRunNotFoundError(runId);
147135
+ }
147136
+ remember(runId, counts);
147137
+ return buildRunUsage({
147138
+ runId,
147139
+ status: snapshot.run.status,
147140
+ workflowName: snapshot.run.workflow_name,
147141
+ eventGroups: eventGroupsOf(counts),
147142
+ stepGroups: stepGroupsOf(counts),
147143
+ streamBytes: snapshot.streamBytes,
147144
+ dataPurged: snapshot.dataPurged,
147145
+ savedDataWritten: snapshot.savedDataWritten,
147146
+ hookGroups: hookGroupsOf(counts),
147147
+ calls: { wait: counts.waitIds.size },
147148
+ // Local runs are not billed.
147149
+ billed: false,
147150
+ // world-local has no plan retention, so there is no Data Retained to
147151
+ // report: the UI and CLI hide it.
147152
+ dataRetained: null
147153
+ });
147154
+ }
147155
+ return {
147156
+ async getRun(runId) {
147157
+ assertSafeEntityId("runId", runId);
147158
+ const previous2 = inFlight.get(runId) ?? Promise.resolve();
147159
+ const current2 = previous2.catch(() => {
147160
+ }).then(() => read2(runId));
147161
+ inFlight.set(runId, current2);
147162
+ try {
147163
+ return await current2;
147164
+ } finally {
147165
+ if (inFlight.get(runId) === current2)
147166
+ inFlight.delete(runId);
147167
+ }
147168
+ }
147169
+ };
147170
+ }
146173
147171
  function createStorage$1(basedir, tag) {
146174
147172
  const db = databaseFor(basedir);
146175
147173
  const runs = createRunsStorage(db, tag);
@@ -146177,12 +147175,14 @@ function createStorage$1(basedir, tag) {
146177
147175
  const events2 = createEventsStorage(db, tag);
146178
147176
  const hooks = createHooksStorage(db, tag);
146179
147177
  const snapshots = createSnapshotsStorage$1(db);
147178
+ const usage = createUsageStorage(db, tag);
146180
147179
  return {
146181
147180
  runs: instrumentObject$1("world.runs", runs),
146182
147181
  steps: instrumentObject$1("world.steps", steps),
146183
147182
  events: instrumentObject$1("world.events", events2),
146184
147183
  hooks: instrumentObject$1("world.hooks", hooks),
146185
147184
  experimental_snapshots: instrumentObject$1("world.experimental_snapshots", snapshots),
147185
+ experimental_usage: instrumentObject$1("world.experimental_usage", usage),
146186
147186
  clearCache: () => {
146187
147187
  }
146188
147188
  };
@@ -146558,9 +147558,11 @@ function createWorld$2(args) {
146558
147558
  ]) {
146559
147559
  db.run(`DELETE FROM ${table2}`);
146560
147560
  }
147561
+ deletePurgedUsage(db);
146561
147562
  return;
146562
147563
  }
146563
147564
  const runs = "SELECT run_id FROM runs WHERE tag = ?";
147565
+ deletePurgedUsage(db, { runIdsSql: runs, params: [tag] });
146564
147566
  for (const table2 of [
146565
147567
  "events",
146566
147568
  "steps",
@@ -146703,8 +147705,8 @@ function requireGetVercelOidcToken() {
146703
147705
  }
146704
147706
  try {
146705
147707
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
146706
- await import("./token-util-D91uzxKb.js").then((n) => n.t),
146707
- await import("./token-CPc7to8F.js").then((n) => n.t)
147708
+ await import("./token-util-DgTmPzWb.js").then((n) => n.t),
147709
+ await import("./token-B94O3LuJ.js").then((n) => n.t)
146708
147710
  ]);
146709
147711
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
146710
147712
  await refreshToken(options);
@@ -147268,7 +148270,7 @@ function requireDist() {
147268
148270
  }
147269
148271
  var distExports = requireDist();
147270
148272
  const QUEUE_REQUEST_DEADLINE_CODE = "WORKFLOW_QUEUE_REQUEST_DEADLINE";
147271
- const version$1 = "5.7.0";
148273
+ const version$1 = "5.7.2";
147272
148274
  const pools = globalSingleton("@workflow/world-vercel//httpPools", 1, () => ({
147273
148275
  dispatcher: void 0,
147274
148276
  queueDispatcher: void 0,
@@ -147636,7 +148638,7 @@ function getDefaultStreamCloseDispatcher() {
147636
148638
  return pools.streamCloseDispatcher;
147637
148639
  }
147638
148640
  async function getDeadline() {
147639
- const { getDeadline: getDeadline2 } = await import("./index-BZ4PHwlc.js").then((n) => n.i);
148641
+ const { getDeadline: getDeadline2 } = await import("./index-BrYeW--s.js").then((n) => n.i);
147640
148642
  return getDeadline2();
147641
148643
  }
147642
148644
  class ReplayEventObserverError extends Error {
@@ -155988,8 +156990,8 @@ const V4_FRAME_CONTENT_TYPE = "application/vnd.workflow.v4-frames";
155988
156990
  class IncompleteFrameError extends Error {
155989
156991
  }
155990
156992
  const CborObjectSchema = record(string$2(), unknown$1());
155991
- function encodeFrame(meta, body2) {
155992
- const metaBytes = new Uint8Array(encode$2(meta));
156993
+ function encodeFrame(meta2, body2) {
156994
+ const metaBytes = new Uint8Array(encode$2(meta2));
155993
156995
  const out = new Uint8Array(4 + metaBytes.byteLength + 4 + body2.byteLength);
155994
156996
  const view = new DataView(out.buffer);
155995
156997
  view.setUint32(0, metaBytes.byteLength, false);
@@ -156007,8 +157009,8 @@ function decodeFrame(raw2) {
156007
157009
  if (raw2.byteLength < metaEnd + 4) {
156008
157010
  throw new Error("ws frame too short for meta + body length prefix");
156009
157011
  }
156010
- const meta = decode$2(raw2.subarray(4, metaEnd));
156011
- if (meta === null || typeof meta !== "object" || Array.isArray(meta)) {
157012
+ const meta2 = decode$2(raw2.subarray(4, metaEnd));
157013
+ if (meta2 === null || typeof meta2 !== "object" || Array.isArray(meta2)) {
156012
157014
  throw new Error("ws frame meta must be a CBOR map");
156013
157015
  }
156014
157016
  const bodyStart = metaEnd + 4;
@@ -156017,7 +157019,7 @@ function decodeFrame(raw2) {
156017
157019
  throw new Error(raw2.byteLength < bodyEnd ? "ws frame shorter than its declared body length" : `ws frame has ${raw2.byteLength - bodyEnd} trailing bytes`);
156018
157020
  }
156019
157021
  return {
156020
- meta,
157022
+ meta: meta2,
156021
157023
  body: raw2.subarray(bodyStart, bodyEnd)
156022
157024
  };
156023
157025
  }
@@ -156067,7 +157069,7 @@ async function* decodeFrames(source) {
156067
157069
  if (!await refill(metaLen)) {
156068
157070
  throw new IncompleteFrameError("decodeFrames: truncated meta block");
156069
157071
  }
156070
- const meta = CborObjectSchema.parse(decode$2(take(metaLen)));
157072
+ const meta2 = CborObjectSchema.parse(decode$2(take(metaLen)));
156071
157073
  if (!await refill(4)) {
156072
157074
  throw new IncompleteFrameError("decodeFrames: truncated body length");
156073
157075
  }
@@ -156076,9 +157078,9 @@ async function* decodeFrames(source) {
156076
157078
  if (bodyLen > 0 && !await refill(bodyLen)) {
156077
157079
  throw new IncompleteFrameError("decodeFrames: truncated body bytes");
156078
157080
  }
156079
- yield { meta, body: buffer2.slice(0, bodyLen) };
157081
+ yield { meta: meta2, body: buffer2.slice(0, bodyLen) };
156080
157082
  take(bodyLen);
156081
- if (meta._end === 1)
157083
+ if (meta2._end === 1)
156082
157084
  return;
156083
157085
  }
156084
157086
  } finally {
@@ -156495,146 +157497,146 @@ function decodeLegacyStructuredError(payload) {
156495
157497
  return payload;
156496
157498
  }
156497
157499
  }
156498
- function decodeEventFrame({ meta, body: body2 }) {
156499
- const eventType = EventTypeSchema.parse(meta.eventType);
157500
+ function decodeEventFrame({ meta: meta2, body: body2 }) {
157501
+ const eventType = EventTypeSchema.parse(meta2.eventType);
156500
157502
  if (body2.byteLength === 0)
156501
- return VercelEventWireSchema.parse(meta);
157503
+ return VercelEventWireSchema.parse(meta2);
156502
157504
  const payloadField = getEventDataPayloadField(eventType);
156503
157505
  assert$1(payloadField, `Event type ${eventType} cannot carry a payload body`);
156504
- assert$1(meta.eventData && typeof meta.eventData === "object");
157506
+ assert$1(meta2.eventData && typeof meta2.eventData === "object");
156505
157507
  return VercelEventWireSchema.parse({
156506
- ...meta,
157508
+ ...meta2,
156507
157509
  eventData: {
156508
- ...meta.eventData,
157510
+ ...meta2.eventData,
156509
157511
  [payloadField]: legacyStructuredErrorEventTypes.has(eventType) ? decodeLegacyStructuredError(body2) : body2
156510
157512
  }
156511
157513
  });
156512
157514
  }
156513
157515
  function buildPostFrameMeta(input) {
156514
- const meta = {
157516
+ const meta2 = {
156515
157517
  eventType: input.eventType,
156516
157518
  specVersion: input.specVersion
156517
157519
  };
156518
157520
  if (input.executorSpecVersion !== void 0) {
156519
- meta.executorSpecVersion = input.executorSpecVersion;
157521
+ meta2.executorSpecVersion = input.executorSpecVersion;
156520
157522
  }
156521
157523
  if (input.correlationId !== void 0)
156522
- meta.correlationId = input.correlationId;
157524
+ meta2.correlationId = input.correlationId;
156523
157525
  if (input.vercelId !== void 0)
156524
- meta.vercelId = input.vercelId;
157526
+ meta2.vercelId = input.vercelId;
156525
157527
  if (input.computeInstanceId !== void 0)
156526
- meta.computeInstanceId = input.computeInstanceId;
157528
+ meta2.computeInstanceId = input.computeInstanceId;
156527
157529
  if (input.stepCreatedAt !== void 0) {
156528
- meta.stepCreatedAt = input.stepCreatedAt;
157530
+ meta2.stepCreatedAt = input.stepCreatedAt;
156529
157531
  }
156530
157532
  if (input.occurredAt !== void 0)
156531
- meta.occurredAt = input.occurredAt;
157533
+ meta2.occurredAt = input.occurredAt;
156532
157534
  if (input.remoteRefBehavior !== void 0) {
156533
- meta.remoteRefBehavior = input.remoteRefBehavior;
157535
+ meta2.remoteRefBehavior = input.remoteRefBehavior;
156534
157536
  }
156535
157537
  if (input.eventsRemoteRefBehavior !== void 0) {
156536
- meta.eventsRemoteRefBehavior = input.eventsRemoteRefBehavior;
157538
+ meta2.eventsRemoteRefBehavior = input.eventsRemoteRefBehavior;
156537
157539
  }
156538
157540
  if (input.deploymentId !== void 0)
156539
- meta.deploymentId = input.deploymentId;
157541
+ meta2.deploymentId = input.deploymentId;
156540
157542
  if (input.workflowName !== void 0)
156541
- meta.workflowName = input.workflowName;
157543
+ meta2.workflowName = input.workflowName;
156542
157544
  if (input.stepName !== void 0)
156543
- meta.stepName = input.stepName;
157545
+ meta2.stepName = input.stepName;
156544
157546
  if (input.attempt !== void 0)
156545
- meta.attempt = input.attempt;
157547
+ meta2.attempt = input.attempt;
156546
157548
  if (input.resumeAt !== void 0)
156547
- meta.resumeAt = input.resumeAt;
157549
+ meta2.resumeAt = input.resumeAt;
156548
157550
  if (input.retryAfter !== void 0)
156549
- meta.retryAfter = input.retryAfter;
157551
+ meta2.retryAfter = input.retryAfter;
156550
157552
  if (input.hookToken !== void 0)
156551
- meta.hookToken = input.hookToken;
157553
+ meta2.hookToken = input.hookToken;
156552
157554
  if (input.hookTokenRetentionUntil !== void 0) {
156553
- meta.hookTokenRetentionUntil = input.hookTokenRetentionUntil;
157555
+ meta2.hookTokenRetentionUntil = input.hookTokenRetentionUntil;
156554
157556
  }
156555
157557
  if (input.hookIsWebhook !== void 0)
156556
- meta.hookIsWebhook = input.hookIsWebhook;
157558
+ meta2.hookIsWebhook = input.hookIsWebhook;
156557
157559
  if (input.hookIsSystem !== void 0)
156558
- meta.hookIsSystem = input.hookIsSystem;
157560
+ meta2.hookIsSystem = input.hookIsSystem;
156559
157561
  if (input.hookForce !== void 0)
156560
- meta.hookForce = input.hookForce;
157562
+ meta2.hookForce = input.hookForce;
156561
157563
  if (input.resumeId !== void 0)
156562
- meta.resumeId = input.resumeId;
157564
+ meta2.resumeId = input.resumeId;
156563
157565
  if (input.errorCode !== void 0)
156564
- meta.errorCode = input.errorCode;
157566
+ meta2.errorCode = input.errorCode;
156565
157567
  if (input.cancelReason !== void 0)
156566
- meta.cancelReason = input.cancelReason;
157568
+ meta2.cancelReason = input.cancelReason;
156567
157569
  if (input.ownerMessageId !== void 0) {
156568
- meta.ownerMessageId = input.ownerMessageId;
157570
+ meta2.ownerMessageId = input.ownerMessageId;
156569
157571
  }
156570
157572
  if (input.executionContext !== void 0) {
156571
- meta.executionContext = input.executionContext;
157573
+ meta2.executionContext = input.executionContext;
156572
157574
  }
156573
157575
  if (input.attributes !== void 0)
156574
- meta.attributes = input.attributes;
157576
+ meta2.attributes = input.attributes;
156575
157577
  if (input.startHook !== void 0)
156576
- meta.startHook = input.startHook;
157578
+ meta2.startHook = input.startHook;
156577
157579
  if (input.changes !== void 0)
156578
- meta.changes = input.changes;
157580
+ meta2.changes = input.changes;
156579
157581
  if (input.writer !== void 0)
156580
- meta.writer = input.writer;
157582
+ meta2.writer = input.writer;
156581
157583
  if (input.allowReservedAttributes !== void 0) {
156582
- meta.allowReservedAttributes = input.allowReservedAttributes;
157584
+ meta2.allowReservedAttributes = input.allowReservedAttributes;
156583
157585
  }
156584
157586
  if (input.encryptionPublicKey !== void 0) {
156585
- meta.encryptionPublicKey = input.encryptionPublicKey;
157587
+ meta2.encryptionPublicKey = input.encryptionPublicKey;
156586
157588
  }
156587
157589
  if (input.dynamicWorkflowCode !== void 0) {
156588
- meta.dynamicWorkflowCode = input.dynamicWorkflowCode;
157590
+ meta2.dynamicWorkflowCode = input.dynamicWorkflowCode;
156589
157591
  }
156590
157592
  if (input.dynamicWorkflowCodeRef !== void 0) {
156591
- meta.dynamicWorkflowCodeRef = input.dynamicWorkflowCodeRef;
157593
+ meta2.dynamicWorkflowCodeRef = input.dynamicWorkflowCodeRef;
156592
157594
  }
156593
157595
  if (input.ttfs !== void 0)
156594
- meta.ttfs = input.ttfs;
157596
+ meta2.ttfs = input.ttfs;
156595
157597
  if (input.stso !== void 0)
156596
- meta.stso = input.stso;
157598
+ meta2.stso = input.stso;
156597
157599
  if (input.stepCount !== void 0)
156598
- meta.stepCount = input.stepCount;
157600
+ meta2.stepCount = input.stepCount;
156599
157601
  if (input.eventCount !== void 0)
156600
- meta.eventCount = input.eventCount;
157602
+ meta2.eventCount = input.eventCount;
156601
157603
  if (input.rsfs !== void 0)
156602
- meta.rsfs = input.rsfs;
157604
+ meta2.rsfs = input.rsfs;
156603
157605
  if (input.finalSchedulingReplay !== void 0) {
156604
- meta.finalSchedulingReplay = input.finalSchedulingReplay;
157606
+ meta2.finalSchedulingReplay = input.finalSchedulingReplay;
156605
157607
  }
156606
157608
  if (input.optimizations !== void 0) {
156607
- meta.optimizations = input.optimizations;
157609
+ meta2.optimizations = input.optimizations;
156608
157610
  }
156609
157611
  if (input.sinceCursor !== void 0)
156610
- meta.sinceCursor = input.sinceCursor;
157612
+ meta2.sinceCursor = input.sinceCursor;
156611
157613
  if (input.skipPreload)
156612
- meta.skipPreload = true;
157614
+ meta2.skipPreload = true;
156613
157615
  if (input.maxSlot !== void 0)
156614
- meta.maxSlot = input.maxSlot;
157616
+ meta2.maxSlot = input.maxSlot;
156615
157617
  if (input.replayDivergenceCount !== void 0) {
156616
- meta.replayDivergenceCount = input.replayDivergenceCount;
157618
+ meta2.replayDivergenceCount = input.replayDivergenceCount;
156617
157619
  }
156618
157620
  if (input.replayDivergenceEventIds !== void 0) {
156619
- meta.replayDivergenceEventIds = input.replayDivergenceEventIds;
157621
+ meta2.replayDivergenceEventIds = input.replayDivergenceEventIds;
156620
157622
  }
156621
157623
  if (input.resumePayloadDigest !== void 0) {
156622
- meta.resumePayloadDigest = input.resumePayloadDigest;
157624
+ meta2.resumePayloadDigest = input.resumePayloadDigest;
156623
157625
  }
156624
157626
  if (input.viaStepDispatch !== void 0) {
156625
- meta.viaStepDispatch = input.viaStepDispatch;
157627
+ meta2.viaStepDispatch = input.viaStepDispatch;
156626
157628
  }
156627
157629
  if (input.inBand !== void 0)
156628
- meta.inBand = input.inBand;
157630
+ meta2.inBand = input.inBand;
156629
157631
  if (input.expectedSeqInBand !== void 0) {
156630
- meta.expectedSeqInBand = input.expectedSeqInBand;
157632
+ meta2.expectedSeqInBand = input.expectedSeqInBand;
156631
157633
  }
156632
157634
  if (input.inline !== void 0)
156633
- meta.inline = input.inline;
157635
+ meta2.inline = input.inline;
156634
157636
  if (input.creatorMessageId !== void 0) {
156635
- meta.creatorMessageId = input.creatorMessageId;
157637
+ meta2.creatorMessageId = input.creatorMessageId;
156636
157638
  }
156637
- return meta;
157639
+ return meta2;
156638
157640
  }
156639
157641
  function inBandFenceAttributes(input) {
156640
157642
  return {
@@ -156964,14 +157966,14 @@ async function createWorkflowRunEventsBatchV4(input, config2) {
156964
157966
  ...allocated !== void 0 ? { allocated } : {}
156965
157967
  };
156966
157968
  }
156967
- function replyMetaToHeaderRecord(meta) {
157969
+ function replyMetaToHeaderRecord(meta2) {
156968
157970
  const out = {};
156969
- if (typeof meta.eventId === "string")
156970
- out[EVENT_ID_HEADER] = meta.eventId;
156971
- if (typeof meta.retryAfter === "string")
156972
- out["retry-after"] = meta.retryAfter;
156973
- if (typeof meta.mitigated === "string")
156974
- out["x-vercel-mitigated"] = meta.mitigated;
157971
+ if (typeof meta2.eventId === "string")
157972
+ out[EVENT_ID_HEADER] = meta2.eventId;
157973
+ if (typeof meta2.retryAfter === "string")
157974
+ out["retry-after"] = meta2.retryAfter;
157975
+ if (typeof meta2.mitigated === "string")
157976
+ out["x-vercel-mitigated"] = meta2.mitigated;
156975
157977
  return out;
156976
157978
  }
156977
157979
  function recordWsReplyParts(span, reply) {
@@ -157185,8 +158187,8 @@ async function getEventV4(runId, eventId, remoteRefBehavior, config2, specVersio
157185
158187
  }
157186
158188
  throw new Error(`v4 getEvent: empty frame stream for ${eventId}`);
157187
158189
  }
157188
- function streamErrorFrameToError(meta, opName) {
157189
- const parsed = EventStreamErrorSchema.safeParse(meta);
158190
+ function streamErrorFrameToError(meta2, opName) {
158191
+ const parsed = EventStreamErrorSchema.safeParse(meta2);
157190
158192
  if (!parsed.success) {
157191
158193
  return new WorkflowWorldError(`v4 ${opName}: malformed terminal error frame`, { code: "SCHEMA_VALIDATION", cause: parsed.error });
157192
158194
  }
@@ -157743,84 +158745,84 @@ function splitEventDataForV4(data2) {
157743
158745
  }
157744
158746
  const eventData = data2.eventData ?? {};
157745
158747
  const payloadField = getEventDataPayloadField(data2.eventType);
157746
- const meta = {};
158748
+ const meta2 = {};
157747
158749
  if (typeof eventData.deploymentId === "string") {
157748
- meta.deploymentId = eventData.deploymentId;
158750
+ meta2.deploymentId = eventData.deploymentId;
157749
158751
  }
157750
158752
  if (typeof eventData.workflowName === "string") {
157751
- meta.workflowName = eventData.workflowName;
158753
+ meta2.workflowName = eventData.workflowName;
157752
158754
  }
157753
158755
  if (typeof eventData.stepName === "string") {
157754
- meta.stepName = eventData.stepName;
158756
+ meta2.stepName = eventData.stepName;
157755
158757
  }
157756
158758
  if (typeof eventData.attempt === "number") {
157757
- meta.attempt = eventData.attempt;
158759
+ meta2.attempt = eventData.attempt;
157758
158760
  }
157759
158761
  if (eventData.resumeAt instanceof Date) {
157760
- meta.resumeAt = eventData.resumeAt;
158762
+ meta2.resumeAt = eventData.resumeAt;
157761
158763
  } else if (typeof eventData.resumeAt === "string") {
157762
158764
  const parsed = new Date(eventData.resumeAt);
157763
158765
  if (!Number.isNaN(parsed.getTime()))
157764
- meta.resumeAt = parsed;
158766
+ meta2.resumeAt = parsed;
157765
158767
  }
157766
158768
  if (eventData.retryAfter instanceof Date) {
157767
- meta.retryAfter = eventData.retryAfter;
158769
+ meta2.retryAfter = eventData.retryAfter;
157768
158770
  } else if (typeof eventData.retryAfter === "string") {
157769
158771
  const parsed = new Date(eventData.retryAfter);
157770
158772
  if (!Number.isNaN(parsed.getTime()))
157771
- meta.retryAfter = parsed;
158773
+ meta2.retryAfter = parsed;
157772
158774
  }
157773
158775
  if (typeof eventData.token === "string") {
157774
- meta.hookToken = eventData.token;
158776
+ meta2.hookToken = eventData.token;
157775
158777
  }
157776
158778
  if (eventData.tokenRetentionUntil instanceof Date) {
157777
- meta.hookTokenRetentionUntil = eventData.tokenRetentionUntil;
158779
+ meta2.hookTokenRetentionUntil = eventData.tokenRetentionUntil;
157778
158780
  }
157779
158781
  if (typeof eventData.isWebhook === "boolean") {
157780
- meta.hookIsWebhook = eventData.isWebhook;
158782
+ meta2.hookIsWebhook = eventData.isWebhook;
157781
158783
  }
157782
158784
  if (typeof eventData.isSystem === "boolean") {
157783
- meta.hookIsSystem = eventData.isSystem;
158785
+ meta2.hookIsSystem = eventData.isSystem;
157784
158786
  }
157785
158787
  if (eventData.force === true) {
157786
- meta.hookForce = true;
158788
+ meta2.hookForce = true;
157787
158789
  }
157788
158790
  if (typeof eventData.errorCode === "string") {
157789
- meta.errorCode = eventData.errorCode;
158791
+ meta2.errorCode = eventData.errorCode;
157790
158792
  }
157791
158793
  if (typeof eventData.cancelReason === "string") {
157792
- meta.cancelReason = eventData.cancelReason;
158794
+ meta2.cancelReason = eventData.cancelReason;
157793
158795
  }
157794
158796
  if (typeof eventData.ownerMessageId === "string") {
157795
- meta.ownerMessageId = eventData.ownerMessageId;
158797
+ meta2.ownerMessageId = eventData.ownerMessageId;
157796
158798
  }
157797
158799
  if (eventData.executionContext !== void 0 && eventData.executionContext !== null && typeof eventData.executionContext === "object") {
157798
- meta.executionContext = eventData.executionContext;
158800
+ meta2.executionContext = eventData.executionContext;
157799
158801
  }
157800
158802
  if (eventData.attributes !== void 0 && eventData.attributes !== null && typeof eventData.attributes === "object") {
157801
- meta.attributes = eventData.attributes;
158803
+ meta2.attributes = eventData.attributes;
157802
158804
  }
157803
158805
  if (Array.isArray(eventData.changes)) {
157804
- meta.changes = eventData.changes;
158806
+ meta2.changes = eventData.changes;
157805
158807
  }
157806
158808
  if (eventData.writer !== void 0 && eventData.writer !== null && typeof eventData.writer === "object") {
157807
- meta.writer = eventData.writer;
158809
+ meta2.writer = eventData.writer;
157808
158810
  }
157809
158811
  if (typeof eventData.allowReservedAttributes === "boolean") {
157810
- meta.allowReservedAttributes = eventData.allowReservedAttributes;
158812
+ meta2.allowReservedAttributes = eventData.allowReservedAttributes;
157811
158813
  }
157812
158814
  if (typeof eventData.encryptionPublicKey === "string") {
157813
- meta.encryptionPublicKey = eventData.encryptionPublicKey;
158815
+ meta2.encryptionPublicKey = eventData.encryptionPublicKey;
157814
158816
  }
157815
158817
  if (eventData.dynamicWorkflowCode instanceof Uint8Array) {
157816
- meta.dynamicWorkflowCode = eventData.dynamicWorkflowCode;
158818
+ meta2.dynamicWorkflowCode = eventData.dynamicWorkflowCode;
157817
158819
  }
157818
158820
  if (typeof eventData.dynamicWorkflowCodeRef === "string") {
157819
- meta.dynamicWorkflowCodeRef = eventData.dynamicWorkflowCodeRef;
158821
+ meta2.dynamicWorkflowCodeRef = eventData.dynamicWorkflowCodeRef;
157820
158822
  }
157821
158823
  if (eventData.startHook !== void 0 && eventData.startHook !== null && typeof eventData.startHook === "object") {
157822
158824
  const startHook = eventData.startHook;
157823
- meta.startHook = {
158825
+ meta2.startHook = {
157824
158826
  token: startHook.token,
157825
158827
  ...startHook.tokenRetentionUntil instanceof Date ? { tokenRetentionUntil: startHook.tokenRetentionUntil } : {},
157826
158828
  // The serialized metadata bytes, exactly what `hook_created` would
@@ -157829,31 +158831,31 @@ function splitEventDataForV4(data2) {
157829
158831
  };
157830
158832
  }
157831
158833
  if (typeof eventData.ttfs === "number") {
157832
- meta.ttfs = eventData.ttfs;
158834
+ meta2.ttfs = eventData.ttfs;
157833
158835
  }
157834
158836
  if (typeof eventData.stso === "number") {
157835
- meta.stso = eventData.stso;
158837
+ meta2.stso = eventData.stso;
157836
158838
  }
157837
158839
  if (typeof eventData.stepCount === "number" && Number.isSafeInteger(eventData.stepCount) && eventData.stepCount > 0) {
157838
- meta.stepCount = eventData.stepCount;
158840
+ meta2.stepCount = eventData.stepCount;
157839
158841
  }
157840
158842
  if (typeof eventData.eventCount === "number" && Number.isSafeInteger(eventData.eventCount) && eventData.eventCount > 0) {
157841
- meta.eventCount = eventData.eventCount;
158843
+ meta2.eventCount = eventData.eventCount;
157842
158844
  }
157843
158845
  if (typeof eventData.rsfs === "number") {
157844
- meta.rsfs = eventData.rsfs;
158846
+ meta2.rsfs = eventData.rsfs;
157845
158847
  }
157846
158848
  if (typeof eventData.finalSchedulingReplay === "number") {
157847
- meta.finalSchedulingReplay = eventData.finalSchedulingReplay;
158849
+ meta2.finalSchedulingReplay = eventData.finalSchedulingReplay;
157848
158850
  }
157849
158851
  if (Array.isArray(eventData.optimizations) && eventData.optimizations.every((o) => typeof o === "string")) {
157850
- meta.optimizations = eventData.optimizations;
158852
+ meta2.optimizations = eventData.optimizations;
157851
158853
  }
157852
158854
  if (typeof eventData.inline === "boolean") {
157853
- meta.inline = eventData.inline;
158855
+ meta2.inline = eventData.inline;
157854
158856
  }
157855
158857
  if (typeof eventData.creatorMessageId === "string") {
157856
- meta.creatorMessageId = eventData.creatorMessageId;
158858
+ meta2.creatorMessageId = eventData.creatorMessageId;
157857
158859
  }
157858
158860
  let payload;
157859
158861
  if (payloadField && payloadField in eventData) {
@@ -157865,7 +158867,7 @@ function splitEventDataForV4(data2) {
157865
158867
  payload = value;
157866
158868
  }
157867
158869
  }
157868
- return { payload, meta };
158870
+ return { payload, meta: meta2 };
157869
158871
  }
157870
158872
  async function getEvent(runId, eventId, params, config2) {
157871
158873
  return getEventV4(runId, eventId, (params == null ? void 0 : params.resolveData) === "none" ? "lazy" : "resolve", config2, params == null ? void 0 : params.specVersion);
@@ -157915,7 +158917,7 @@ async function createWorkflowRunEventBatch(runId, events2, params, config2) {
157915
158917
  throw new WorkflowWorldError("world-vercel: hook_received cannot be batched (it has no entity condition, so a batch retry would append the delivery twice); send it through the single-event path", { status: 400 });
157916
158918
  }
157917
158919
  const inputs = events2.map(({ event, occurredAt, computeInstanceId, stepCreatedAt }) => {
157918
- const { payload, meta } = splitEventDataForV4(event);
158920
+ const { payload, meta: meta2 } = splitEventDataForV4(event);
157919
158921
  return {
157920
158922
  runId,
157921
158923
  eventType: event.eventType,
@@ -157940,7 +158942,7 @@ async function createWorkflowRunEventBatch(runId, events2, params, config2) {
157940
158942
  ...(fence == null ? void 0 : fence.expectedSeqInBand) !== void 0 ? { expectedSeqInBand: fence.expectedSeqInBand } : {},
157941
158943
  ...(fence == null ? void 0 : fence.eventCount) !== void 0 ? { maxSlot: fence.eventCount } : {},
157942
158944
  payload,
157943
- ...meta,
158945
+ ...meta2,
157944
158946
  // The batch is one fenced allocation: the backend requires every frame
157945
158947
  // to carry the same fence. Spread after `meta` so nothing derived from
157946
158948
  // the event data can override it.
@@ -158062,7 +159064,7 @@ async function createWorkflowRunEventInner(id2, data2, params, config2) {
158062
159064
  // Honor its explicit request for replay-ready metadata; other mutation
158063
159065
  // responses keep their existing lightweight entity-only behavior.
158064
159066
  data2.eventType === "hook_created" && (params == null ? void 0 : params.resolveData) === "all" ? "resolve" : "lazy";
158065
- const { payload, meta } = splitEventDataForV4(data2);
159067
+ const { payload, meta: meta2 } = splitEventDataForV4(data2);
158066
159068
  const input = {
158067
159069
  runId: id2,
158068
159070
  specVersion: data2.specVersion ?? 2,
@@ -158110,7 +159112,7 @@ async function createWorkflowRunEventInner(id2, data2, params, config2) {
158110
159112
  ...(params == null ? void 0 : params.resolveData) === "skip-step-inputs" ? { eventsRemoteRefBehavior: "skip-step-inputs" } : {},
158111
159113
  remoteRefBehavior,
158112
159114
  payload,
158113
- ...meta
159115
+ ...meta2
158114
159116
  };
158115
159117
  if (data2.eventType === "run_started" && !(params == null ? void 0 : params.skipPreload) && (params == null ? void 0 : params.inBand) === void 0) {
158116
159118
  const result2 = await createWorkflowRunStartedEventV4(input, config2, params == null ? void 0 : params.replayEventObserver);
@@ -158199,8 +159201,8 @@ const GAP_FILL_PAGE_SIZE = 100;
158199
159201
  function cursorAfterSlot(slot) {
158200
159202
  return `eid:${slotToEventId(slot)}`;
158201
159203
  }
158202
- function ackedHeartbeatMs(meta) {
158203
- const value = meta.heartbeatMs;
159204
+ function ackedHeartbeatMs(meta2) {
159205
+ const value = meta2.heartbeatMs;
158204
159206
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
158205
159207
  }
158206
159208
  class LiveFeedError extends Error {
@@ -158735,8 +159737,8 @@ function getStreamWsProtocolV1Url(baseUrl, runId, streamId, writerId) {
158735
159737
  url.search = new URLSearchParams({ writerId: parsedWriterId }).toString();
158736
159738
  return url;
158737
159739
  }
158738
- function encodeStreamWsWriteRequest(meta, chunks) {
158739
- const parsed = StreamWsWriteRequestMetaSchema.parse(meta);
159740
+ function encodeStreamWsWriteRequest(meta2, chunks) {
159741
+ const parsed = StreamWsWriteRequestMetaSchema.parse(meta2);
158740
159742
  if (parsed.numChunks !== chunks.length) {
158741
159743
  throw new Error(`stream WebSocket write declares ${parsed.numChunks} chunks but received ${chunks.length}`);
158742
159744
  }
@@ -158761,14 +159763,14 @@ function streamWsWriteBatchEnd(chunks, start2, maxMessageBytes) {
158761
159763
  }
158762
159764
  return end;
158763
159765
  }
158764
- function encodeStreamWsCloseRequest(meta) {
158765
- return encodeFrame(StreamWsCloseRequestMetaSchema.parse(meta), new Uint8Array());
159766
+ function encodeStreamWsCloseRequest(meta2) {
159767
+ return encodeFrame(StreamWsCloseRequestMetaSchema.parse(meta2), new Uint8Array());
158766
159768
  }
158767
- function parseStreamWsReply(meta, body2) {
159769
+ function parseStreamWsReply(meta2, body2) {
158768
159770
  if (body2.byteLength !== 0) {
158769
159771
  throw new Error("stream WebSocket reply body must be empty");
158770
159772
  }
158771
- return StreamWsReplyMetaSchema.parse(meta);
159773
+ return StreamWsReplyMetaSchema.parse(meta2);
158772
159774
  }
158773
159775
  const WS_FLAGS_HEADER = "x-workflow-ws-flags";
158774
159776
  const WS_FLAG_FRAME_PARTS = "frame-parts";
@@ -158788,19 +159790,19 @@ function wsMaxMessageBytes() {
158788
159790
  integer: true
158789
159791
  });
158790
159792
  }
158791
- function encodeWsFrameMessages(meta, body2, maxMessageBytes) {
158792
- const whole = encodeFrame(meta, body2);
159793
+ function encodeWsFrameMessages(meta2, body2, maxMessageBytes) {
159794
+ const whole = encodeFrame(meta2, body2);
158793
159795
  if (whole.byteLength <= maxMessageBytes)
158794
159796
  return [whole];
158795
159797
  if (body2.byteLength > WS_MAX_FRAME_BYTES) {
158796
159798
  throw new WsFrameTooLargeError(`ws frame body of ${body2.byteLength} bytes is over the ${WS_MAX_FRAME_BYTES}-byte limit for a split frame`);
158797
159799
  }
158798
- const reqId = meta.reqId;
159800
+ const reqId = meta2.reqId;
158799
159801
  if (!isClientReqId(reqId)) {
158800
159802
  throw new Error(`ws frame of ${whole.byteLength} bytes exceeds the ${maxMessageBytes}-byte message limit and has no reqId to split it under`);
158801
159803
  }
158802
159804
  const bound = body2.byteLength + 1;
158803
- const firstHeaderBytes = encodeFrame({ ...meta, partIndex: 0, partCount: bound }, EMPTY).byteLength;
159805
+ const firstHeaderBytes = encodeFrame({ ...meta2, partIndex: 0, partCount: bound }, EMPTY).byteLength;
158804
159806
  const continuationHeaderBytes = encodeFrame(continuationMeta(reqId, bound, bound), EMPTY).byteLength;
158805
159807
  const firstSlice = maxMessageBytes - firstHeaderBytes;
158806
159808
  const continuationSlice = maxMessageBytes - continuationHeaderBytes;
@@ -158813,7 +159815,7 @@ function encodeWsFrameMessages(meta, body2, maxMessageBytes) {
158813
159815
  throw new Error(`ws frame of ${whole.byteLength} bytes needs ${partCount} parts at a ${maxMessageBytes}-byte message limit; at most ${WS_MAX_PART_COUNT} are allowed`);
158814
159816
  }
158815
159817
  const messages = [
158816
- encodeFrame({ ...meta, partIndex: 0, partCount }, body2.subarray(0, firstSlice))
159818
+ encodeFrame({ ...meta2, partIndex: 0, partCount }, body2.subarray(0, firstSlice))
158817
159819
  ];
158818
159820
  for (let index2 = 1; index2 < partCount; index2++) {
158819
159821
  const start2 = firstSlice + (index2 - 1) * continuationSlice;
@@ -158825,8 +159827,8 @@ const EMPTY = new Uint8Array(0);
158825
159827
  function splitEncodedFrame(frame2, maxMessageBytes) {
158826
159828
  if (frame2.byteLength <= maxMessageBytes)
158827
159829
  return [frame2];
158828
- const { meta, body: body2 } = decodeFrame(frame2);
158829
- return encodeWsFrameMessages(meta, body2, maxMessageBytes);
159830
+ const { meta: meta2, body: body2 } = decodeFrame(frame2);
159831
+ return encodeWsFrameMessages(meta2, body2, maxMessageBytes);
158830
159832
  }
158831
159833
  function continuationMeta(reqId, partIndex, partCount) {
158832
159834
  return { type: WS_PART_TYPE, reqId, partIndex, partCount };
@@ -158867,11 +159869,11 @@ class WsPartAssembler {
158867
159869
  });
158868
159870
  }
158869
159871
  accept(frame2) {
158870
- const { meta, body: body2 } = frame2;
158871
- if (meta.type === WS_PART_TYPE)
158872
- return this.continue(meta, body2);
158873
- const { reqId, partIndex, partCount } = meta;
158874
- if (!("partIndex" in meta) && !("partCount" in meta)) {
159872
+ const { meta: meta2, body: body2 } = frame2;
159873
+ if (meta2.type === WS_PART_TYPE)
159874
+ return this.continue(meta2, body2);
159875
+ const { reqId, partIndex, partCount } = meta2;
159876
+ if (!("partIndex" in meta2) && !("partCount" in meta2)) {
158875
159877
  if (isClientReqId(reqId) && this.open.has(reqId)) {
158876
159878
  throw new WsPartProtocolError(`whole frame for reqId ${reqId} while its split frame is open`);
158877
159879
  }
@@ -158892,7 +159894,7 @@ class WsPartAssembler {
158892
159894
  if (this.open.size >= this.maxOpenFrames) {
158893
159895
  throw new WsPartProtocolError(`more than ${this.maxOpenFrames} split frames open at once`);
158894
159896
  }
158895
- const { partIndex: _index, partCount: _count, ...frameMeta } = meta;
159897
+ const { partIndex: _index, partCount: _count, ...frameMeta } = meta2;
158896
159898
  const entry2 = {
158897
159899
  meta: frameMeta,
158898
159900
  partCount,
@@ -158910,12 +159912,12 @@ class WsPartAssembler {
158910
159912
  get openFrames() {
158911
159913
  return this.open.size;
158912
159914
  }
158913
- continue(meta, body2) {
158914
- const keys2 = Object.keys(meta);
158915
- if (keys2.length !== 4 || !("reqId" in meta) || !("partIndex" in meta) || !("partCount" in meta)) {
159915
+ continue(meta2, body2) {
159916
+ const keys2 = Object.keys(meta2);
159917
+ if (keys2.length !== 4 || !("reqId" in meta2) || !("partIndex" in meta2) || !("partCount" in meta2)) {
158916
159918
  throw new WsPartProtocolError(`continuation part must have exactly type, reqId, partIndex and partCount, got ${keys2.join(", ")}`);
158917
159919
  }
158918
- const { reqId, partIndex, partCount } = meta;
159920
+ const { reqId, partIndex, partCount } = meta2;
158919
159921
  if (!isClientReqId(reqId)) {
158920
159922
  throw new WsPartProtocolError("continuation part has no valid reqId");
158921
159923
  }
@@ -159005,7 +160007,7 @@ function beginNormalWsClose(ws, reason) {
159005
160007
  await observed;
159006
160008
  span == null ? void 0 : span.setAttribute("workflow.stream.ws.close_cleanup_timeout", timedOut);
159007
160009
  });
159008
- void import("./index-BZ4PHwlc.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => waitUntil2(cleanup)).catch(() => {
160010
+ void import("./index-BrYeW--s.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => waitUntil2(cleanup)).catch(() => {
159009
160011
  });
159010
160012
  void cleanup.catch(() => {
159011
160013
  });
@@ -159390,7 +160392,7 @@ class VercelStreamWriteSession {
159390
160392
  return http3;
159391
160393
  });
159392
160394
  const [{ WebSocket: WebSocketImpl }, http2] = await Promise.all([
159393
- import("./wrapper-BKFP-Nku.js"),
160395
+ import("./wrapper-BEqyNEir.js"),
159394
160396
  httpPromise
159395
160397
  ]);
159396
160398
  if (this.mode !== "connecting")
@@ -164828,7 +165830,7 @@ const VERCEL_REQUEST_CONTEXT = Symbol.for("@vercel/request-context");
164828
165830
  function waitUntil(promise2) {
164829
165831
  if (!(VERCEL_REQUEST_CONTEXT in globalThis))
164830
165832
  return;
164831
- void import("./index-BZ4PHwlc.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
165833
+ void import("./index-BrYeW--s.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
164832
165834
  waitUntil2(promise2);
164833
165835
  });
164834
165836
  }
@@ -168156,9 +169158,9 @@ pp$5.parseExprImport = function(forNew) {
168156
169158
  if (this.type === types$1.parenL && !forNew) {
168157
169159
  return this.parseDynamicImport(node2);
168158
169160
  } else if (this.type === types$1.dot) {
168159
- var meta = this.startNodeAt(node2.start, node2.loc && node2.loc.start);
168160
- meta.name = "import";
168161
- node2.meta = this.finishNode(meta, "Identifier");
169161
+ var meta2 = this.startNodeAt(node2.start, node2.loc && node2.loc.start);
169162
+ meta2.name = "import";
169163
+ node2.meta = this.finishNode(meta2, "Identifier");
168162
169164
  return this.parseImportMeta(node2);
168163
169165
  } else {
168164
169166
  this.unexpected();
@@ -168308,9 +169310,9 @@ pp$5.parseNew = function() {
168308
169310
  var node2 = this.startNode();
168309
169311
  this.next();
168310
169312
  if (this.options.ecmaVersion >= 6 && this.type === types$1.dot) {
168311
- var meta = this.startNodeAt(node2.start, node2.loc && node2.loc.start);
168312
- meta.name = "new";
168313
- node2.meta = this.finishNode(meta, "Identifier");
169313
+ var meta2 = this.startNodeAt(node2.start, node2.loc && node2.loc.start);
169314
+ meta2.name = "new";
169315
+ node2.meta = this.finishNode(meta2, "Identifier");
168314
169316
  this.next();
168315
169317
  var containsEsc = this.containsEsc;
168316
169318
  node2.property = this.parseIdent(true);
@@ -171566,7 +172568,7 @@ function isPermanentWorldError(error2) {
171566
172568
  }
171567
172569
  function assertDynamicWorkflowsEnabled() {
171568
172570
  if (!isDynamicWorkflowsEnabled()) {
171569
- throw dynamicStartRefusal(`Dynamic workflows are disabled on this deployment, so no run was created. Set ${DYNAMIC_WORKFLOWS_ENV}=1 on the deployment to enable them.`);
172571
+ throw new DynamicWorkflowsNotEnabledError("Dynamic workflows are not enabled for this project, so start() did not create a run for the given workflow source.");
171570
172572
  }
171571
172573
  }
171572
172574
  async function start$1(workflow, argsOrOptions, options) {
@@ -174095,6 +175097,19 @@ async function fetchRun(worldEnv, runId, resolveData = "all") {
174095
175097
  });
174096
175098
  }
174097
175099
  }
175100
+ async function fetchRunUsage(worldEnv, runId) {
175101
+ try {
175102
+ const world = await getWorldFromEnv(worldEnv);
175103
+ if (!world.experimental_usage) return createResponse(null);
175104
+ return createResponse(await world.experimental_usage.getRun(runId));
175105
+ } catch (error2) {
175106
+ return createServerActionError(
175107
+ error2,
175108
+ "world.experimental_usage.getRun",
175109
+ { runId }
175110
+ );
175111
+ }
175112
+ }
174098
175113
  async function fetchStep(worldEnv, runId, stepId, resolveData = "all") {
174099
175114
  try {
174100
175115
  const world = await getWorldFromEnv(worldEnv);
@@ -174492,6 +175507,14 @@ async function action$1({
174492
175507
  Body: ${body2.slice(0, 500) || "(empty)"}`);
174493
175508
  return null;
174494
175509
  }
175510
+ function meta$1() {
175511
+ return [{
175512
+ title: DEFAULT_TITLE
175513
+ }, {
175514
+ name: "description",
175515
+ content: DEFAULT_META_DESCRIPTION
175516
+ }];
175517
+ }
174495
175518
  function Layout({
174496
175519
  children: children2
174497
175520
  }) {
@@ -174507,11 +175530,6 @@ function Layout({
174507
175530
  }), /* @__PURE__ */ jsxRuntimeExports.jsx("link", {
174508
175531
  rel: "icon",
174509
175532
  href: "/favicon.ico"
174510
- }), /* @__PURE__ */ jsxRuntimeExports.jsx("title", {
174511
- children: "Workflow Observability UI"
174512
- }), /* @__PURE__ */ jsxRuntimeExports.jsx("meta", {
174513
- name: "description",
174514
- content: "Web interface for inspecting flow runs, steps, streams, and events"
174515
175533
  }), /* @__PURE__ */ jsxRuntimeExports.jsx(Meta, {}), /* @__PURE__ */ jsxRuntimeExports.jsx(Links, {})]
174516
175534
  }), /* @__PURE__ */ jsxRuntimeExports.jsxs("body", {
174517
175535
  className: "antialiased",
@@ -174692,6 +175710,7 @@ const route0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
174692
175710
  action: action$1,
174693
175711
  default: root$1,
174694
175712
  loader: loader$2,
175713
+ meta: meta$1,
174695
175714
  shouldRevalidate
174696
175715
  }, Symbol.toStringTag, { value: "Module" }));
174697
175716
  const alertVariants = cva(
@@ -183547,6 +184566,8 @@ function makeContentId(baseId, value) {
183547
184566
  return `${baseId}-content-${value}`;
183548
184567
  }
183549
184568
  __name$2(makeContentId, "makeContentId");
184569
+ const tabsListClassName = "bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg border border-input p-[3px]";
184570
+ const tabsTriggerClassName = "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow aria-[current=page]:bg-background aria-[current=page]:text-foreground aria-[current=page]:shadow";
183550
184571
  function Tabs({
183551
184572
  className,
183552
184573
  ...props
@@ -183568,10 +184589,7 @@ function TabsList({
183568
184589
  TabsList$1,
183569
184590
  {
183570
184591
  "data-slot": "tabs-list",
183571
- className: cn$2(
183572
- "bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg border border-input p-[3px]",
183573
- className
183574
- ),
184592
+ className: cn$2(tabsListClassName, className),
183575
184593
  ...props
183576
184594
  }
183577
184595
  );
@@ -183584,10 +184602,7 @@ function TabsTrigger({
183584
184602
  TabsTrigger$1,
183585
184603
  {
183586
184604
  "data-slot": "tabs-trigger",
183587
- className: cn$2(
183588
- "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
183589
- className
183590
- ),
184605
+ className: cn$2(tabsTriggerClassName, className),
183591
184606
  ...props
183592
184607
  }
183593
184608
  );
@@ -194707,6 +195722,88 @@ function useCancellationReason(env2, runId, status, events2) {
194707
195722
  }, [env2, runId, status, loadedReason]);
194708
195723
  return loadedReason ?? terminalReason;
194709
195724
  }
195725
+ const RUN_USAGE_REFRESH_INTERVAL_MS = 5e3;
195726
+ const SLOW_READ_BACKOFF = 10;
195727
+ function useRunUsage(env2, runId, {
195728
+ enabled = true,
195729
+ live = false,
195730
+ refreshInterval = RUN_USAGE_REFRESH_INTERVAL_MS
195731
+ } = {}) {
195732
+ const [usage, setUsage] = reactExports.useState(void 0);
195733
+ const [loading, setLoading] = reactExports.useState(false);
195734
+ const [error2, setError] = reactExports.useState(null);
195735
+ const latestRef = reactExports.useRef(0);
195736
+ const lastReadMsRef = reactExports.useRef(0);
195737
+ const inFlightRef = reactExports.useRef(0);
195738
+ const mountedRef = reactExports.useRef(true);
195739
+ reactExports.useEffect(() => {
195740
+ mountedRef.current = true;
195741
+ return () => {
195742
+ mountedRef.current = false;
195743
+ };
195744
+ }, []);
195745
+ const read2 = reactExports.useCallback(async () => {
195746
+ const seq = ++latestRef.current;
195747
+ const startedAt = Date.now();
195748
+ const isCurrent = () => mountedRef.current && seq === latestRef.current;
195749
+ inFlightRef.current++;
195750
+ setLoading(true);
195751
+ try {
195752
+ const result = await unwrapOrThrow(fetchRunUsage$1(env2, runId));
195753
+ if (isCurrent()) {
195754
+ setUsage(result);
195755
+ setError(null);
195756
+ }
195757
+ } catch (err) {
195758
+ if (isCurrent()) {
195759
+ setError(err instanceof Error ? err : new Error(String(err)));
195760
+ }
195761
+ } finally {
195762
+ lastReadMsRef.current = Date.now() - startedAt;
195763
+ inFlightRef.current--;
195764
+ if (isCurrent()) setLoading(false);
195765
+ }
195766
+ }, [env2, runId]);
195767
+ reactExports.useEffect(() => {
195768
+ setUsage(void 0);
195769
+ setError(null);
195770
+ }, [runId]);
195771
+ reactExports.useEffect(() => {
195772
+ if (!enabled) return;
195773
+ void read2();
195774
+ }, [enabled, read2]);
195775
+ const wasLiveRef = reactExports.useRef(live);
195776
+ reactExports.useEffect(() => {
195777
+ const wasLive = wasLiveRef.current;
195778
+ wasLiveRef.current = live;
195779
+ if (enabled && wasLive && !live) void read2();
195780
+ }, [enabled, live, read2]);
195781
+ const unsupported = usage === null;
195782
+ const polling = live || (usage == null ? void 0 : usage.inProgress) === true;
195783
+ reactExports.useEffect(() => {
195784
+ if (!enabled || !polling || unsupported) return;
195785
+ if (!refreshInterval || refreshInterval <= 0) return;
195786
+ let cancelled = false;
195787
+ let timer2;
195788
+ const schedule2 = () => {
195789
+ const delay = Math.max(
195790
+ refreshInterval,
195791
+ SLOW_READ_BACKOFF * lastReadMsRef.current
195792
+ );
195793
+ timer2 = setTimeout(async () => {
195794
+ if (cancelled) return;
195795
+ if (inFlightRef.current === 0) await read2();
195796
+ if (!cancelled) schedule2();
195797
+ }, delay);
195798
+ };
195799
+ schedule2();
195800
+ return () => {
195801
+ cancelled = true;
195802
+ clearTimeout(timer2);
195803
+ };
195804
+ }, [enabled, polling, unsupported, refreshInterval, read2]);
195805
+ return { usage, loading, error: error2, refresh: read2 };
195806
+ }
194710
195807
  const FRAME_HEADER_SIZE = 4;
194711
195808
  const ENCRYPTED_PLACEHOLDER = "[Encrypted]";
194712
195809
  const POLL_INTERVAL_MS = 3e3;
@@ -195077,6 +196174,696 @@ function LiveStatus({ hasError, errorMessage }) {
195077
196174
  ({
195078
196175
  ...LAYOUT$1
195079
196176
  });
196177
+ const STORAGE_DOCS_URL = `${USAGE_DOCS_URL}#storage`;
196178
+ function NewTabLink({
196179
+ href,
196180
+ className,
196181
+ children: children2,
196182
+ label,
196183
+ testId,
196184
+ ...rest
196185
+ }) {
196186
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
196187
+ "a",
196188
+ {
196189
+ ...rest,
196190
+ href,
196191
+ target: "_blank",
196192
+ rel: "noopener noreferrer",
196193
+ className,
196194
+ "aria-label": label ? `${label} (opens in a new tab)` : void 0,
196195
+ "data-testid": testId,
196196
+ children: [
196197
+ children2,
196198
+ !label && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
196199
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
196200
+ ArrowUpRight,
196201
+ {
196202
+ className: "ml-0.5 inline h-3.5 w-3.5 align-[-2px]",
196203
+ "aria-hidden": "true"
196204
+ }
196205
+ ),
196206
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: " (opens in a new tab)" })
196207
+ ] })
196208
+ ]
196209
+ }
196210
+ );
196211
+ }
196212
+ function runUsagePath(runId) {
196213
+ return `/run/${encodeURIComponent(runId)}/usage`;
196214
+ }
196215
+ function runPath(runId) {
196216
+ return `/run/${encodeURIComponent(runId)}`;
196217
+ }
196218
+ const ENTITY_LABELS = {
196219
+ run: "Run",
196220
+ step: "Steps",
196221
+ hook: "Hooks",
196222
+ stream: "Streams"
196223
+ };
196224
+ const ROW_RESOURCE = {
196225
+ steps: "step",
196226
+ hooks: "hook",
196227
+ attributes: "run",
196228
+ sleeps: "sleep",
196229
+ run: "run",
196230
+ other: "event"
196231
+ };
196232
+ function RowIcon({ type }) {
196233
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex h-[18px] shrink-0 items-center", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResourceIcon, { resource: ROW_RESOURCE[type] }) });
196234
+ }
196235
+ function RetryBadge({
196236
+ retries,
196237
+ testId = "run-usage-retries"
196238
+ }) {
196239
+ if (retries <= 0) return null;
196240
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
196241
+ "span",
196242
+ {
196243
+ className: "inline-flex items-center whitespace-nowrap rounded-full border border-amber-400 bg-amber-100 px-2 text-label-12 leading-4 text-amber-900",
196244
+ "data-testid": testId,
196245
+ children: formatCount(retries, "retry", "retries")
196246
+ }
196247
+ );
196248
+ }
196249
+ function RowDetail({
196250
+ children: children2,
196251
+ testId
196252
+ }) {
196253
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
196254
+ "span",
196255
+ {
196256
+ className: "whitespace-nowrap font-sans text-label-12 text-gray-700",
196257
+ "data-testid": testId,
196258
+ children: children2
196259
+ }
196260
+ );
196261
+ }
196262
+ function InlineRetryBadge({
196263
+ retries,
196264
+ className
196265
+ }) {
196266
+ if (retries <= 0) return null;
196267
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: cn$2("mt-1 block @min-[520px]:hidden", className), children: /* @__PURE__ */ jsxRuntimeExports.jsx(RetryBadge, { retries, testId: "run-usage-retries-inline" }) });
196268
+ }
196269
+ function ShareBar({
196270
+ share,
196271
+ muted = false
196272
+ }) {
196273
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
196274
+ "div",
196275
+ {
196276
+ className: "h-1.5 w-full min-w-16 rounded-full bg-gray-alpha-200",
196277
+ "aria-hidden": "true",
196278
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
196279
+ "div",
196280
+ {
196281
+ className: cn$2(
196282
+ "h-1.5 rounded-full",
196283
+ muted ? "bg-gray-500" : "bg-blue-700"
196284
+ ),
196285
+ style: { width: `${Math.max(0, Math.min(1, share)) * 100}%` }
196286
+ }
196287
+ )
196288
+ }
196289
+ );
196290
+ }
196291
+ function usageVisible(usage, isLocalBackend) {
196292
+ return usage != null || usage === void 0 && isLocalBackend;
196293
+ }
196294
+ const UNAVAILABLE = "—";
196295
+ function dataWrittenLabel(usage, isLocalBackend) {
196296
+ if (usage) return formatDataWrittenHeading(usage);
196297
+ return isLocalBackend ? "Storage (local)" : "Storage";
196298
+ }
196299
+ const failedMessage = (error2) => `Failed to read this run’s usage: ${error2.message}`;
196300
+ function HeaderFigure({
196301
+ to: to2,
196302
+ onUsagePage,
196303
+ label,
196304
+ title,
196305
+ testId,
196306
+ children: children2
196307
+ }) {
196308
+ if (onUsagePage) {
196309
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", "data-testid": testId, title, children: children2 });
196310
+ }
196311
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
196312
+ Link,
196313
+ {
196314
+ to: to2,
196315
+ className: "-my-1 inline-block min-w-6 rounded-sm py-1 text-left text-xs underline decoration-dotted underline-offset-2 text-gray-1000 hover:text-blue-900 focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]",
196316
+ "aria-label": label,
196317
+ title,
196318
+ "data-testid": testId,
196319
+ children: children2
196320
+ }
196321
+ );
196322
+ }
196323
+ function RunUsageHeaderStats({
196324
+ runId,
196325
+ usage,
196326
+ error: error2,
196327
+ isLocalBackend,
196328
+ onUsagePage = false
196329
+ }) {
196330
+ const failed = !usage && error2 !== null;
196331
+ const failedTitle = failed ? failedMessage(error2) : void 0;
196332
+ const localNote = usage ? formatLocalDataWrittenNote(usage) : null;
196333
+ const to2 = runUsagePath(runId);
196334
+ const label = dataWrittenLabel(usage, isLocalBackend);
196335
+ const events2 = usage ? usage.events.toLocaleString("en-US") : UNAVAILABLE;
196336
+ const bytes = usage ? formatUsageBytes(usage.dataWritten.bytes) : UNAVAILABLE;
196337
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
196338
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
196339
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Events" }),
196340
+ usage || failed ? /* @__PURE__ */ jsxRuntimeExports.jsx(
196341
+ HeaderFigure,
196342
+ {
196343
+ to: to2,
196344
+ onUsagePage,
196345
+ label: usage ? `${formatCount(usage.events, "event", "events")}, open usage` : "Events unavailable, open usage",
196346
+ title: failedTitle,
196347
+ testId: "run-usage-events",
196348
+ children: events2
196349
+ }
196350
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[40px] h-[20px]" })
196351
+ ] }),
196352
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
196353
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
196354
+ "div",
196355
+ {
196356
+ className: "text-xs text-muted-foreground flex items-center gap-1",
196357
+ "data-testid": "run-usage-data-label",
196358
+ children: [
196359
+ label,
196360
+ localNote && /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
196361
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
196362
+ NewTabLink,
196363
+ {
196364
+ href: STORAGE_DOCS_URL,
196365
+ className: "-m-1.5 inline-flex rounded-sm p-1.5 text-muted-foreground hover:text-gray-1000 focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]",
196366
+ label: `How ${label} is counted`,
196367
+ testId: "run-usage-data-help",
196368
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(CircleQuestionMark, { className: "w-3 h-3", "aria-hidden": "true" })
196369
+ }
196370
+ ) }),
196371
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "max-w-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: localNote }) })
196372
+ ] })
196373
+ ]
196374
+ }
196375
+ ),
196376
+ usage || failed ? /* @__PURE__ */ jsxRuntimeExports.jsx(
196377
+ HeaderFigure,
196378
+ {
196379
+ to: to2,
196380
+ onUsagePage,
196381
+ label: usage ? `${bytes} ${label.toLowerCase()}, open usage` : `${label} unavailable, open usage`,
196382
+ title: failedTitle,
196383
+ testId: "run-usage-data-written",
196384
+ children: bytes
196385
+ }
196386
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[50px] h-[20px]" })
196387
+ ] })
196388
+ ] });
196389
+ }
196390
+ function formatRunEventTypes(usage) {
196391
+ const { events: events2, byType } = usage.runEvents;
196392
+ if (events2 <= 0) return null;
196393
+ const parts = RUN_USAGE_RUN_EVENT_TYPES.flatMap(
196394
+ (type) => byType[type] > 0 ? [`${byType[type].toLocaleString("en-US")} ${type}`] : []
196395
+ );
196396
+ const known = RUN_USAGE_RUN_EVENT_TYPES.reduce((n, t) => n + byType[t], 0);
196397
+ if (events2 > known) {
196398
+ parts.push(`${(events2 - known).toLocaleString("en-US")} other`);
196399
+ }
196400
+ return parts.join(", ");
196401
+ }
196402
+ const CELL = "py-2 pr-2 sm:pr-4";
196403
+ const SHARE_CELL = "py-2 pr-0 @min-[520px]:pr-4";
196404
+ const TABLE_HEAD_ROW = "text-label-12 text-gray-900 border-b border-gray-alpha-400";
196405
+ function groupDetail(group) {
196406
+ switch (group.type) {
196407
+ case "steps":
196408
+ return formatCount(group.calls, "call", "calls");
196409
+ case "hooks":
196410
+ return formatCount(group.calls, "hook", "hooks");
196411
+ case "attributes":
196412
+ return formatCount(group.calls, "write", "writes");
196413
+ case "sleeps":
196414
+ return formatCount(group.calls, "sleep", "sleeps");
196415
+ default:
196416
+ return null;
196417
+ }
196418
+ }
196419
+ function BreakableLabel({ label }) {
196420
+ const parts = label.split(new RegExp("(?<=[:/._-])"));
196421
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: parts.map((part, i) => (
196422
+ // biome-ignore lint/suspicious/noArrayIndexKey: parts of one fixed label
196423
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(reactExports.Fragment, { children: [
196424
+ i > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("wbr", {}),
196425
+ part
196426
+ ] }, i)
196427
+ )) });
196428
+ }
196429
+ function CountCells({
196430
+ row,
196431
+ emphasis: emphasis2 = false
196432
+ }) {
196433
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
196434
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
196435
+ "td",
196436
+ {
196437
+ className: cn$2(
196438
+ CELL,
196439
+ "text-right tabular-nums",
196440
+ emphasis2 && "font-medium"
196441
+ ),
196442
+ children: row.events.toLocaleString("en-US")
196443
+ }
196444
+ ),
196445
+ /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: cn$2(CELL, "hidden @min-[520px]:table-cell"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(ShareBar, { share: row.share }) }),
196446
+ /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: cn$2(SHARE_CELL, "text-right tabular-nums text-gray-900"), children: formatUsageShare(row.share) }),
196447
+ /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "hidden py-2 @min-[520px]:table-cell", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RetryBadge, { retries: row.retries }) })
196448
+ ] });
196449
+ }
196450
+ const TOGGLE = "-my-[3px] -ml-1 flex min-w-0 items-start gap-2 rounded-sm py-[3px] pl-1 pr-1 text-left focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]";
196451
+ function UsageGroup({
196452
+ group,
196453
+ usage,
196454
+ idPrefix
196455
+ }) {
196456
+ const expandable = group.type === "steps" || group.type === "hooks";
196457
+ const [expanded, setExpanded] = reactExports.useState(true);
196458
+ const [showAll, setShowAll] = reactExports.useState(false);
196459
+ const label = USAGE_ROW_TYPE_LABELS[group.type];
196460
+ const detail = groupDetail(group);
196461
+ const runEventTypes = group.type === "run" ? formatRunEventTypes(usage) : null;
196462
+ const childrenId = `${idPrefix}-${group.type}`;
196463
+ const shown = expandable && showAll ? usageRows(usage, Number.POSITIVE_INFINITY).find(
196464
+ (g2) => g2.type === group.type
196465
+ ) ?? group : group;
196466
+ const name2 = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
196467
+ /* @__PURE__ */ jsxRuntimeExports.jsx(RowIcon, { type: group.type }),
196468
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex min-w-0 flex-wrap items-baseline gap-x-2", children: [
196469
+ runEventTypes ? (
196470
+ // Just "Run"; its event types are its tooltip, on hover or focus.
196471
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
196472
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
196473
+ "span",
196474
+ {
196475
+ tabIndex: 0,
196476
+ className: "rounded-sm font-medium text-gray-1000 underline decoration-dotted underline-offset-2 focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]",
196477
+ "data-testid": "run-usage-type-label",
196478
+ children: label
196479
+ }
196480
+ ) }),
196481
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { "data-testid": "run-usage-run-events", children: runEventTypes })
196482
+ ] })
196483
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
196484
+ "span",
196485
+ {
196486
+ className: "font-medium text-gray-1000",
196487
+ "data-testid": "run-usage-type-label",
196488
+ children: label
196489
+ }
196490
+ ),
196491
+ detail && /* @__PURE__ */ jsxRuntimeExports.jsx(RowDetail, { testId: "run-usage-group-detail", children: detail })
196492
+ ] })
196493
+ ] });
196494
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
196495
+ /* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
196496
+ "tr",
196497
+ {
196498
+ className: "border-b border-gray-alpha-200",
196499
+ "data-testid": "run-usage-group",
196500
+ "data-type": group.type,
196501
+ children: [
196502
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("td", { className: CELL, children: [
196503
+ expandable ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
196504
+ "button",
196505
+ {
196506
+ type: "button",
196507
+ className: TOGGLE,
196508
+ "aria-expanded": expanded,
196509
+ "aria-controls": childrenId,
196510
+ onClick: () => setExpanded((value) => !value),
196511
+ "data-testid": "run-usage-toggle",
196512
+ children: [
196513
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex h-[18px] shrink-0 items-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
196514
+ ChevronRight,
196515
+ {
196516
+ className: cn$2(
196517
+ "h-4 w-4 text-gray-900 motion-safe:transition-transform",
196518
+ expanded && "rotate-90"
196519
+ ),
196520
+ "aria-hidden": "true"
196521
+ }
196522
+ ) }),
196523
+ name2
196524
+ ]
196525
+ }
196526
+ ) : (
196527
+ // Lines up with the toggles' labels: a chevron's width in.
196528
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex min-w-0 items-start gap-2 pl-6", children: name2 })
196529
+ ),
196530
+ /* @__PURE__ */ jsxRuntimeExports.jsx(InlineRetryBadge, { retries: group.retries, className: "pl-12" })
196531
+ ] }),
196532
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CountCells, { row: group, emphasis: true })
196533
+ ]
196534
+ }
196535
+ ) }),
196536
+ expandable && /* @__PURE__ */ jsxRuntimeExports.jsxs(
196537
+ "tbody",
196538
+ {
196539
+ id: childrenId,
196540
+ hidden: !expanded,
196541
+ "data-testid": "run-usage-children",
196542
+ "data-type": group.type,
196543
+ children: [
196544
+ shown.children.map((child) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
196545
+ "tr",
196546
+ {
196547
+ className: "border-b border-gray-alpha-200",
196548
+ "data-testid": "run-usage-child",
196549
+ "data-key": child.key,
196550
+ children: [
196551
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("td", { className: cn$2(CELL, "pl-12"), children: [
196552
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex min-w-0 flex-wrap items-baseline gap-x-2", children: [
196553
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
196554
+ "span",
196555
+ {
196556
+ className: "min-w-0 font-mono text-gray-1000",
196557
+ title: child.label,
196558
+ "data-testid": "run-usage-child-label",
196559
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(BreakableLabel, { label: child.label })
196560
+ }
196561
+ ),
196562
+ group.type === "steps" && /* @__PURE__ */ jsxRuntimeExports.jsx(RowDetail, { testId: "run-usage-calls", children: formatCount(child.calls, "call", "calls") })
196563
+ ] }),
196564
+ /* @__PURE__ */ jsxRuntimeExports.jsx(InlineRetryBadge, { retries: child.retries })
196565
+ ] }),
196566
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CountCells, { row: child })
196567
+ ]
196568
+ },
196569
+ child.key
196570
+ )),
196571
+ shown.otherChildren && /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: "border-b border-gray-alpha-200", children: [
196572
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("td", { className: cn$2(CELL, "pl-12"), children: [
196573
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
196574
+ "button",
196575
+ {
196576
+ type: "button",
196577
+ className: "-my-[3px] rounded-sm py-[3px] text-gray-900 hover:text-gray-1000 underline decoration-dotted underline-offset-2 focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]",
196578
+ onClick: () => setShowAll(true),
196579
+ children: shown.otherChildren.label
196580
+ }
196581
+ ),
196582
+ /* @__PURE__ */ jsxRuntimeExports.jsx(InlineRetryBadge, { retries: shown.otherChildren.retries })
196583
+ ] }),
196584
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CountCells, { row: shown.otherChildren })
196585
+ ] })
196586
+ ]
196587
+ }
196588
+ )
196589
+ ] });
196590
+ }
196591
+ function UsageTable({ usage }) {
196592
+ const idPrefix = reactExports.useId();
196593
+ return (
196594
+ // A size container: its width, not the viewport's, decides whether the
196595
+ // bars and the retries column fit (side by side with the storage table
196596
+ // from lg, the table is narrower than the screen).
196597
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "@container overflow-x-auto", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "w-full text-copy-13", "data-testid": "run-usage-types", children: [
196598
+ /* @__PURE__ */ jsxRuntimeExports.jsx("thead", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: TABLE_HEAD_ROW, children: [
196599
+ /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: cn$2(CELL, "text-left font-medium"), children: "Type" }),
196600
+ /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: cn$2(CELL, "text-right font-medium"), children: "Events" }),
196601
+ /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: cn$2(CELL, "hidden w-1/4 @min-[520px]:table-cell"), children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Share of Events" }) }),
196602
+ /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: cn$2(SHARE_CELL, "text-right font-medium"), children: "Share" }),
196603
+ /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "hidden py-2 text-left font-medium @min-[520px]:table-cell", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Retries" }) })
196604
+ ] }) }),
196605
+ usageRows(usage).map((group) => /* @__PURE__ */ jsxRuntimeExports.jsx(
196606
+ UsageGroup,
196607
+ {
196608
+ group,
196609
+ usage,
196610
+ idPrefix
196611
+ },
196612
+ group.key
196613
+ ))
196614
+ ] }) })
196615
+ );
196616
+ }
196617
+ function DataWrittenTable({ usage }) {
196618
+ const purgedNote = formatDataPurgedNote(usage);
196619
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-3", children: [
196620
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { className: "w-full text-copy-13", "data-testid": "run-usage-data", children: [
196621
+ /* @__PURE__ */ jsxRuntimeExports.jsx("thead", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: TABLE_HEAD_ROW, children: [
196622
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
196623
+ "th",
196624
+ {
196625
+ className: cn$2(CELL, "text-left font-medium"),
196626
+ "data-testid": "run-usage-data-heading",
196627
+ children: formatDataWrittenHeading(usage)
196628
+ }
196629
+ ),
196630
+ /* @__PURE__ */ jsxRuntimeExports.jsx("th", { className: "py-2 text-right font-medium", children: "Size" })
196631
+ ] }) }),
196632
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("tbody", { children: [
196633
+ RUN_USAGE_ENTITIES.filter(
196634
+ // Like the CLI: only the entities that wrote something.
196635
+ (entity) => usage.dataWritten.byEntity[entity] > 0
196636
+ ).map((entity) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
196637
+ "tr",
196638
+ {
196639
+ className: "border-b border-gray-alpha-200",
196640
+ "data-testid": "run-usage-entity",
196641
+ children: [
196642
+ /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: cn$2(CELL, "text-gray-1000"), children: ENTITY_LABELS[entity] }),
196643
+ /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: "py-2 text-right tabular-nums", children: formatUsageBytes(usage.dataWritten.byEntity[entity]) })
196644
+ ]
196645
+ },
196646
+ entity
196647
+ )),
196648
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("tr", { className: "font-medium", children: [
196649
+ /* @__PURE__ */ jsxRuntimeExports.jsx("td", { className: cn$2(CELL, "text-gray-1000"), children: "Total" }),
196650
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
196651
+ "td",
196652
+ {
196653
+ className: "py-2 text-right tabular-nums",
196654
+ "data-testid": "run-usage-total",
196655
+ children: formatUsageBytes(usage.dataWritten.bytes)
196656
+ }
196657
+ )
196658
+ ] })
196659
+ ] })
196660
+ ] }),
196661
+ purgedNote && /* @__PURE__ */ jsxRuntimeExports.jsx(
196662
+ "p",
196663
+ {
196664
+ className: "text-copy-13 text-gray-900",
196665
+ "data-testid": "run-usage-purged-note",
196666
+ children: purgedNote
196667
+ }
196668
+ ),
196669
+ usage.dataRetained && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { "data-testid": "run-usage-retained", children: [
196670
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-12 text-gray-900", children: "Data retained" }),
196671
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-copy-14 text-gray-1000", children: [
196672
+ formatUsageBytes(usage.dataRetained.byteMonths),
196673
+ "-months"
196674
+ ] }),
196675
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-copy-13 text-gray-900", children: [
196676
+ "Storage × ",
196677
+ usage.dataRetained.retentionMonths,
196678
+ " month retention"
196679
+ ] })
196680
+ ] })
196681
+ ] });
196682
+ }
196683
+ const USAGE_TABLES_LAYOUT = "grid grid-cols-1 gap-8 lg:grid-cols-[minmax(0,3fr)_minmax(0,2fr)] lg:gap-10";
196684
+ function UsageTables({ spans, data: data2 }) {
196685
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: USAGE_TABLES_LAYOUT, "data-testid": "run-usage-tables", children: [
196686
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { "aria-labelledby": "run-usage-spans-heading", className: "min-w-0", children: [
196687
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { id: "run-usage-spans-heading", className: "sr-only", children: "Events by type" }),
196688
+ spans
196689
+ ] }),
196690
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { "aria-labelledby": "run-usage-data-section", className: "min-w-0", children: [
196691
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { id: "run-usage-data-section", className: "sr-only", children: "Storage" }),
196692
+ data2
196693
+ ] })
196694
+ ] });
196695
+ }
196696
+ const skeletonRow = (key, widths) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
196697
+ "div",
196698
+ {
196699
+ className: "flex h-[37px] items-center justify-between border-b border-gray-alpha-200",
196700
+ children: [
196701
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: cn$2("h-4", widths[0]) }),
196702
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: cn$2("h-4", widths[1]) })
196703
+ ]
196704
+ },
196705
+ key
196706
+ );
196707
+ function RunUsagePageSkeleton() {
196708
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-6 pb-6 pt-2", "data-testid": "run-usage-skeleton", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
196709
+ UsageTables,
196710
+ {
196711
+ spans: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
196712
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-[33px] items-center border-b border-gray-alpha-400", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-12" }) }),
196713
+ skeletonRow(0, ["w-28 ml-6", "w-10"]),
196714
+ [1, 2, 3].map((i) => skeletonRow(i, ["w-40 ml-12", "w-10"])),
196715
+ skeletonRow(4, ["w-28 ml-6", "w-10"]),
196716
+ skeletonRow(5, ["w-40 ml-12", "w-10"]),
196717
+ [6, 7, 8].map((i) => skeletonRow(i, ["w-24 ml-6", "w-10"]))
196718
+ ] }),
196719
+ data: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
196720
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-[33px] items-center border-b border-gray-alpha-400", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3 w-32" }) }),
196721
+ [0, 1, 2, 3, 4].map((i) => skeletonRow(i, ["w-16", "w-12"]))
196722
+ ] })
196723
+ }
196724
+ ) });
196725
+ }
196726
+ const FOOTER_LINK = "whitespace-nowrap rounded-sm py-1 text-blue-900 hover:underline focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]";
196727
+ function UsageFooter({ usage }) {
196728
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("footer", { className: "text-copy-13 text-gray-900", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { "data-testid": "run-usage-footer-line", children: [
196729
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { "data-testid": "run-usage-footer", children: usage.billed ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium text-gray-1000", children: formatUsageFooter(usage) }) : formatUsageFooter(usage) }),
196730
+ " ",
196731
+ /* @__PURE__ */ jsxRuntimeExports.jsx(NewTabLink, { href: USAGE_DOCS_URL, className: FOOTER_LINK, children: "How usage is counted" })
196732
+ ] }) });
196733
+ }
196734
+ function RunUsagePage({
196735
+ runId,
196736
+ usage,
196737
+ error: error2,
196738
+ onRetry,
196739
+ retrying = false
196740
+ }) {
196741
+ if (usage === null) {
196742
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
196743
+ "div",
196744
+ {
196745
+ className: "flex flex-col items-start gap-3 pb-6 pt-2",
196746
+ "data-testid": "run-usage-unsupported",
196747
+ children: [
196748
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-copy-14 text-gray-1000", children: "This page isn’t available for this backend." }),
196749
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
196750
+ Link,
196751
+ {
196752
+ to: runPath(runId),
196753
+ className: "-my-[3px] inline-block rounded-sm py-[3px] text-copy-13 text-blue-900 hover:underline focus-visible:outline-none focus-visible:shadow-[var(--ds-focus-ring)]",
196754
+ children: "Back to run"
196755
+ }
196756
+ )
196757
+ ]
196758
+ }
196759
+ );
196760
+ }
196761
+ if (!usage) {
196762
+ if (!error2) return /* @__PURE__ */ jsxRuntimeExports.jsx(RunUsagePageSkeleton, {});
196763
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
196764
+ "div",
196765
+ {
196766
+ className: "flex flex-col items-start gap-3 pb-6 pt-2",
196767
+ "data-testid": "run-usage-error",
196768
+ children: [
196769
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-copy-13 text-red-800", children: [
196770
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CircleAlert, { className: "h-4 w-4 shrink-0" }),
196771
+ failedMessage(error2)
196772
+ ] }),
196773
+ onRetry && /* @__PURE__ */ jsxRuntimeExports.jsx(
196774
+ Button,
196775
+ {
196776
+ variant: "secondary",
196777
+ size: "small",
196778
+ onClick: onRetry,
196779
+ loading: retrying,
196780
+ prefix: /* @__PURE__ */ jsxRuntimeExports.jsx(RotateCw, {}),
196781
+ children: "Try again"
196782
+ }
196783
+ )
196784
+ ]
196785
+ }
196786
+ );
196787
+ }
196788
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-8 pb-6 pt-2", "data-testid": "run-usage-page", children: [
196789
+ error2 && /* @__PURE__ */ jsxRuntimeExports.jsxs("output", { className: "block text-copy-13 text-amber-800", children: [
196790
+ "Showing the last numbers read. Failed to refresh: ",
196791
+ error2.message
196792
+ ] }),
196793
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
196794
+ UsageTables,
196795
+ {
196796
+ spans: usage.eventsBySpan.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(UsageTable, { usage }) : /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-copy-13 text-gray-900", children: "This run has no events yet." }),
196797
+ data: /* @__PURE__ */ jsxRuntimeExports.jsx(DataWrittenTable, { usage })
196798
+ }
196799
+ ),
196800
+ /* @__PURE__ */ jsxRuntimeExports.jsx(UsageFooter, { usage })
196801
+ ] });
196802
+ }
196803
+ const RUN_TABS = [
196804
+ { value: "trace", label: "Trace" },
196805
+ { value: "events", label: "Events" },
196806
+ { value: "streams", label: "Streams" }
196807
+ ];
196808
+ function focusRunViewItem(root2, item) {
196809
+ const target2 = root2 == null ? void 0 : root2.querySelector(
196810
+ `[data-run-view-item="${item}"]:is([aria-current="page"], [data-state="active"])`
196811
+ );
196812
+ if (!(target2 instanceof HTMLElement)) return false;
196813
+ target2.focus();
196814
+ return true;
196815
+ }
196816
+ function runTabPath(runId, tab2) {
196817
+ return `${runPath(runId)}?tab=${tab2}`;
196818
+ }
196819
+ function UsageNavLink({
196820
+ runId,
196821
+ current: current2 = false,
196822
+ onNavigate
196823
+ }) {
196824
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(
196825
+ Link,
196826
+ {
196827
+ to: runUsagePath(runId),
196828
+ className: cn$2(tabsTriggerClassName, "gap-2"),
196829
+ "aria-current": current2 ? "page" : void 0,
196830
+ "data-testid": "run-usage-nav-link",
196831
+ "data-run-view-item": "usage",
196832
+ onClick: () => onNavigate == null ? void 0 : onNavigate("usage"),
196833
+ children: [
196834
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ChartColumn, { className: "h-4 w-4", "aria-hidden": "true" }),
196835
+ "Usage"
196836
+ ]
196837
+ }
196838
+ );
196839
+ }
196840
+ const RUN_VIEW_ROW_CLASS = cn$2(
196841
+ tabsListClassName,
196842
+ "mb-4 max-w-full flex-none max-sm:[&_svg]:hidden"
196843
+ );
196844
+ function RunViewNav({
196845
+ runId,
196846
+ showUsage,
196847
+ onNavigate
196848
+ }) {
196849
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("nav", { "aria-label": "Run views", className: RUN_VIEW_ROW_CLASS, children: [
196850
+ RUN_TABS.map((tab2) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
196851
+ Link,
196852
+ {
196853
+ to: runTabPath(runId, tab2.value),
196854
+ className: cn$2(tabsTriggerClassName, "gap-2"),
196855
+ "data-run-view-item": tab2.value,
196856
+ onClick: () => onNavigate == null ? void 0 : onNavigate(tab2.value),
196857
+ children: [
196858
+ /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4", "aria-hidden": "true" }),
196859
+ tab2.label
196860
+ ]
196861
+ },
196862
+ tab2.value
196863
+ )),
196864
+ showUsage && /* @__PURE__ */ jsxRuntimeExports.jsx(UsageNavLink, { runId, current: true, onNavigate })
196865
+ ] });
196866
+ }
195080
196867
  function RunDetailView({
195081
196868
  runId,
195082
196869
  selectedId: _selectedId
@@ -195090,8 +196877,8 @@ function RunDetailView({
195090
196877
  const [showCancelDialog, setShowCancelDialog] = reactExports.useState(false);
195091
196878
  const [showRerunDialog, setShowRerunDialog] = reactExports.useState(false);
195092
196879
  const env2 = reactExports.useMemo(() => ({}), []);
195093
- const rawTab = searchParams.get("tab") || "trace";
195094
- const activeTab = rawTab === "graph" ? "trace" : rawTab;
196880
+ const rawTab = searchParams.get("tab");
196881
+ const activeTab = rawTab === "events" || rawTab === "streams" ? rawTab : "trace";
195095
196882
  const selectedStreamId = searchParams.get("streamId");
195096
196883
  const initialSelectedSpanId = searchParams.get("spanId") ?? void 0;
195097
196884
  const setActiveTab = reactExports.useCallback(
@@ -195130,8 +196917,8 @@ function RunDetailView({
195130
196917
  );
195131
196918
  const encryptionKeyRef = reactExports.useRef(null);
195132
196919
  const handleResolveHook = reactExports.useCallback(
195133
- async (hookToken, payload) => {
195134
- await resumeHook(env2, hookToken, payload);
196920
+ async (hookToken2, payload) => {
196921
+ await resumeHook(env2, hookToken2, payload);
195135
196922
  },
195136
196923
  [env2]
195137
196924
  );
@@ -195158,7 +196945,7 @@ function RunDetailView({
195158
196945
  },
195159
196946
  [env2, stateHydrator]
195160
196947
  );
195161
- serverConfig.backendId === "local" || serverConfig.backendId === "@workflow/world-local";
196948
+ const isLocalBackend = serverConfig.backendId === "local" || serverConfig.backendId === "@workflow/world-local";
195162
196949
  const {
195163
196950
  run: runData,
195164
196951
  events: allEvents,
@@ -195233,6 +197020,23 @@ function RunDetailView({
195233
197020
  hasEncryptedData
195234
197021
  ]
195235
197022
  );
197023
+ const runIsLive = Boolean(run2.status) && !isTerminalWorkflowRunStatus(run2.status);
197024
+ const runUsageState = useRunUsage(env2, runId, { live: runIsLive });
197025
+ const { usage: runUsage2, error: runUsageError } = runUsageState;
197026
+ const showUsage = usageVisible(runUsage2, isLocalBackend);
197027
+ const usageContext = { runId, usage: runUsageState };
197028
+ const usagePage = useOutlet(usageContext);
197029
+ const viewRootRef = reactExports.useRef(null);
197030
+ const pendingRowFocus = reactExports.useRef(null);
197031
+ const focusRowItemAfterNavigation = reactExports.useCallback((item) => {
197032
+ pendingRowFocus.current = item;
197033
+ }, []);
197034
+ reactExports.useEffect(() => {
197035
+ const item = pendingRowFocus.current;
197036
+ if (item && focusRunViewItem(viewRootRef.current, item)) {
197037
+ pendingRowFocus.current = null;
197038
+ }
197039
+ });
195236
197040
  const {
195237
197041
  streams,
195238
197042
  loading: streamsLoading,
@@ -195327,196 +197131,260 @@ function RunDetailView({
195327
197131
  /* @__PURE__ */ jsxRuntimeExports.jsx(AlertDialogAction, { onClick: handleConfirmRerun, children: "Replay Run" })
195328
197132
  ] })
195329
197133
  ] }) }),
195330
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col h-[calc(100vh-97px)]", children: [
195331
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-none space-y-4", children: [
195332
- /* @__PURE__ */ jsxRuntimeExports.jsx(Breadcrumb, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(BreadcrumbList, { children: [
195333
- /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbLink, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/", children: "Runs" }) }) }),
195334
- /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbSeparator, {}),
195335
- /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbPage, { className: "font-mono text-xs", children: runId }) })
195336
- ] }) }),
195337
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4 p-6 border rounded-lg", children: [
195338
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start justify-between", children: [
195339
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "text-xl font-semibold", children: workflowName ? workflowName : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[260px] h-[28px]" }) }) }),
195340
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
195341
- /* @__PURE__ */ jsxRuntimeExports.jsx(LiveStatus, { hasError, errorMessage }),
195342
- /* @__PURE__ */ jsxRuntimeExports.jsx(
195343
- RunActionsButtons,
195344
- {
195345
- env: env2,
195346
- runId,
195347
- runStatus: run2.status,
195348
- events: allEvents,
195349
- eventsLoading: loading,
195350
- loading,
195351
- replayDisabledReason: isDynamicRun ? "Dynamic runs cannot be replayed as a new run." : void 0,
195352
- onRerunClick: handleRerunClick,
195353
- onCancelClick: handleCancelClick,
195354
- callbacks: { onSuccess: update }
195355
- }
195356
- )
195357
- ] })
195358
- ] }),
195359
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start gap-8", children: [
195360
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
195361
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Status" }),
195362
- run2.status ? /* @__PURE__ */ jsxRuntimeExports.jsx(
195363
- StatusBadge,
195364
- {
195365
- status: run2.status,
195366
- context: { error: run2.error, cancelReason }
195367
- }
195368
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[55px] h-[24px]" })
195369
- ] }),
195370
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
195371
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Duration" }),
195372
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run2.runId ? run2.startedAt ? (() => {
195373
- const ms2 = (run2.completedAt ? new Date(run2.completedAt).getTime() : Date.now()) - new Date(run2.startedAt).getTime();
195374
- const seconds = Math.floor(ms2 / 1e3);
195375
- if (seconds < 60) return `${seconds}s`;
195376
- const minutes = Math.floor(seconds / 60);
195377
- const remainingSeconds = seconds % 60;
195378
- if (minutes < 60) {
195379
- return remainingSeconds > 0 ? `${minutes}m ${remainingSeconds}s` : `${minutes}m`;
195380
- }
195381
- const hours = Math.floor(minutes / 60);
195382
- const remainingMinutes = minutes % 60;
195383
- return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
195384
- })() : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[60px] h-[20px]" }) })
195385
- ] }),
195386
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
195387
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Run ID" }),
195388
- run2.runId ? /* @__PURE__ */ jsxRuntimeExports.jsx(CopyableText, { text: run2.runId, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs mt-0.5 font-mono", children: run2.runId }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[280px] h-[20px]" })
195389
- ] }),
195390
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
195391
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Queued" }),
195392
- run2.createdAt ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run2.createdAt }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[110px] h-[20px]" })
195393
- ] }),
195394
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
195395
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Started" }),
195396
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run2.runId ? run2.startedAt ? /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run2.startedAt }) : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[110px] h-[20px]" }) })
195397
- ] }),
195398
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
195399
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Completed" }),
195400
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run2.runId ? run2.completedAt ? /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run2.completedAt }) : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[110px] h-[20px]" }) })
195401
- ] }),
195402
- run2.expiredAt != null && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
195403
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
195404
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-muted-foreground cursor-help flex items-center gap-1", children: [
195405
- "Expired",
195406
- /* @__PURE__ */ jsxRuntimeExports.jsx(CircleQuestionMark, { className: "w-3 h-3" })
195407
- ] }) }),
195408
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "The storage data for this run has expired and is no longer available." }) })
195409
- ] }),
195410
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run2.expiredAt }) })
195411
- ] })
195412
- ] })
195413
- ] }),
195414
- /* @__PURE__ */ jsxRuntimeExports.jsx(RunLimitGuidanceAlert, { run: runData })
195415
- ] }),
195416
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 flex-1 flex flex-col min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
195417
- Tabs,
195418
- {
195419
- value: activeTab,
195420
- onValueChange: (v2) => setActiveTab(v2),
195421
- className: "flex-1 flex flex-col min-h-0",
195422
- children: [
195423
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "mb-4 flex-none", children: [
195424
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "trace", className: "gap-2", children: [
195425
- /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
195426
- "Trace"
195427
- ] }),
195428
- false,
195429
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "events", className: "gap-2", children: [
195430
- /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
195431
- "Events"
197134
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
197135
+ "div",
197136
+ {
197137
+ ref: viewRootRef,
197138
+ className: usagePage ? "flex flex-col" : "flex flex-col h-[calc(100vh-97px)]",
197139
+ children: [
197140
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-none space-y-4", children: [
197141
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Breadcrumb, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(BreadcrumbList, { children: [
197142
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbLink, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: "/", children: "Runs" }) }) }),
197143
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbSeparator, {}),
197144
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbItem, { children: usagePage ? /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbLink, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { to: runPath(runId), className: "font-mono text-xs", children: runId }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbPage, { className: "font-mono text-xs", children: runId }) }),
197145
+ usagePage && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
197146
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbSeparator, {}),
197147
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(BreadcrumbPage, { children: "Usage" }) })
197148
+ ] })
197149
+ ] }) }),
197150
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4 p-6 border rounded-lg", children: [
197151
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-start justify-between gap-x-4 gap-y-2", children: [
197152
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "text-xl font-semibold", children: workflowName ? workflowName : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[260px] h-[28px]" }) }) }),
197153
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
197154
+ /* @__PURE__ */ jsxRuntimeExports.jsx(LiveStatus, { hasError, errorMessage }),
197155
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
197156
+ RunActionsButtons,
197157
+ {
197158
+ env: env2,
197159
+ runId,
197160
+ runStatus: run2.status,
197161
+ events: allEvents,
197162
+ eventsLoading: loading,
197163
+ loading,
197164
+ replayDisabledReason: isDynamicRun ? "Dynamic runs cannot be replayed as a new run." : void 0,
197165
+ onRerunClick: handleRerunClick,
197166
+ onCancelClick: handleCancelClick,
197167
+ callbacks: { onSuccess: update }
197168
+ }
197169
+ )
197170
+ ] })
195432
197171
  ] }),
195433
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "streams", className: "gap-2", children: [
195434
- /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
195435
- "Streams"
197172
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap items-start gap-x-8 gap-y-4", children: [
197173
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
197174
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Status" }),
197175
+ run2.status ? /* @__PURE__ */ jsxRuntimeExports.jsx(
197176
+ StatusBadge,
197177
+ {
197178
+ status: run2.status,
197179
+ context: { error: run2.error, cancelReason }
197180
+ }
197181
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[55px] h-[24px]" })
197182
+ ] }),
197183
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
197184
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Duration" }),
197185
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run2.runId ? run2.startedAt ? (() => {
197186
+ const ms2 = (run2.completedAt ? new Date(run2.completedAt).getTime() : Date.now()) - new Date(run2.startedAt).getTime();
197187
+ const seconds = Math.floor(ms2 / 1e3);
197188
+ if (seconds < 60) return `${seconds}s`;
197189
+ const minutes = Math.floor(seconds / 60);
197190
+ const remainingSeconds = seconds % 60;
197191
+ if (minutes < 60) {
197192
+ return remainingSeconds > 0 ? `${minutes}m ${remainingSeconds}s` : `${minutes}m`;
197193
+ }
197194
+ const hours = Math.floor(minutes / 60);
197195
+ const remainingMinutes = minutes % 60;
197196
+ return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
197197
+ })() : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[60px] h-[20px]" }) })
197198
+ ] }),
197199
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
197200
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Run ID" }),
197201
+ run2.runId ? /* @__PURE__ */ jsxRuntimeExports.jsx(CopyableText, { text: run2.runId, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs mt-0.5 font-mono", children: run2.runId }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[280px] h-[20px]" })
197202
+ ] }),
197203
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
197204
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Queued" }),
197205
+ run2.createdAt ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run2.createdAt }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[110px] h-[20px]" })
197206
+ ] }),
197207
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
197208
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Started" }),
197209
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run2.runId ? run2.startedAt ? /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run2.startedAt }) : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[110px] h-[20px]" }) })
197210
+ ] }),
197211
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
197212
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs text-muted-foreground", children: "Completed" }),
197213
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: run2.runId ? run2.completedAt ? /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run2.completedAt }) : "-" : /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "w-[110px] h-[20px]" }) })
197214
+ ] }),
197215
+ showUsage && /* @__PURE__ */ jsxRuntimeExports.jsx(
197216
+ RunUsageHeaderStats,
197217
+ {
197218
+ runId,
197219
+ usage: runUsage2 ?? void 0,
197220
+ error: runUsageError,
197221
+ isLocalBackend,
197222
+ onUsagePage: usagePage != null
197223
+ }
197224
+ ),
197225
+ run2.expiredAt != null && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1", children: [
197226
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
197227
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-xs text-muted-foreground cursor-help flex items-center gap-1", children: [
197228
+ "Expired",
197229
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CircleQuestionMark, { className: "w-3 h-3" })
197230
+ ] }) }),
197231
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "The storage data for this run has expired and is no longer available." }) })
197232
+ ] }),
197233
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(RelativeTime, { date: run2.expiredAt }) })
197234
+ ] })
195436
197235
  ] })
195437
197236
  ] }),
195438
- /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "trace", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary$1, { title: "Failed to load trace viewer", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative h-full -mx-6 bg-background-100 border-t border-gray-alpha-400 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
195439
- TraceViewer,
195440
- {
195441
- run: run2,
195442
- events: allEvents ?? [],
195443
- loading,
195444
- sidebarData,
195445
- onLoadMore: loadMoreTraceData,
195446
- hasMore: hasMoreTraceData,
195447
- isLoadingMore: isLoadingMoreTraceData,
195448
- initialSelectedSpanId
195449
- }
195450
- ) }) }) }),
195451
- /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "events", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary$1, { title: "Failed to load events list", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative h-full -mx-6 bg-background-100 border-t border-gray-alpha-400 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
195452
- RunEventsTab,
197237
+ /* @__PURE__ */ jsxRuntimeExports.jsx(RunLimitGuidanceAlert, { run: runData })
197238
+ ] }),
197239
+ usagePage ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4", children: [
197240
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
197241
+ RunViewNav,
195453
197242
  {
195454
- env: env2,
195455
197243
  runId,
195456
- run: run2,
195457
- onLoadEventData: handleLoadEventData,
195458
- encryptionKey: encryptionKey ?? void 0,
195459
- sortOrder: eventsSortOrder,
195460
- onSortOrderChange: setEventsSortOrder,
195461
- onDecrypt: handleDecrypt,
195462
- isDecrypting,
195463
- onViewInTrace: (spanId) => updateSearchParams({ tab: "trace", spanId })
197244
+ showUsage,
197245
+ onNavigate: focusRowItemAfterNavigation
195464
197246
  }
195465
- ) }) }) }),
195466
- /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "streams", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary$1, { title: "Failed to load stream data", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative -mx-6 flex h-full min-h-0 overflow-hidden border-t border-gray-alpha-400 bg-background-100", children: [
195467
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-[340px] shrink-0 flex-col border-r border-gray-alpha-400 bg-background-100", children: [
195468
- /* @__PURE__ */ jsxRuntimeExports.jsx(
195469
- "div",
197247
+ ),
197248
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary$1, { title: "Failed to load run usage", children: usagePage })
197249
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 flex-1 flex flex-col min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
197250
+ Tabs,
197251
+ {
197252
+ value: activeTab,
197253
+ onValueChange: (v2) => setActiveTab(v2),
197254
+ className: "flex-1 flex flex-col min-h-0",
197255
+ children: [
197256
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: RUN_VIEW_ROW_CLASS, children: [
197257
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "h-auto border-0 bg-transparent p-0", children: [
197258
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
197259
+ TabsTrigger,
197260
+ {
197261
+ value: "trace",
197262
+ className: "gap-2",
197263
+ "data-run-view-item": "trace",
197264
+ children: [
197265
+ /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
197266
+ "Trace"
197267
+ ]
197268
+ }
197269
+ ),
197270
+ false,
197271
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
197272
+ TabsTrigger,
197273
+ {
197274
+ value: "events",
197275
+ className: "gap-2",
197276
+ "data-run-view-item": "events",
197277
+ children: [
197278
+ /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
197279
+ "Events"
197280
+ ]
197281
+ }
197282
+ ),
197283
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
197284
+ TabsTrigger,
197285
+ {
197286
+ value: "streams",
197287
+ className: "gap-2",
197288
+ "data-run-view-item": "streams",
197289
+ children: [
197290
+ /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-4 w-4" }),
197291
+ "Streams"
197292
+ ]
197293
+ }
197294
+ )
197295
+ ] }),
197296
+ showUsage && /* @__PURE__ */ jsxRuntimeExports.jsx(
197297
+ UsageNavLink,
197298
+ {
197299
+ runId,
197300
+ onNavigate: focusRowItemAfterNavigation
197301
+ }
197302
+ )
197303
+ ] }),
197304
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "trace", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary$1, { title: "Failed to load trace viewer", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative h-full -mx-6 bg-background-100 border-t border-gray-alpha-400 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
197305
+ TraceViewer,
195470
197306
  {
195471
- "aria-hidden": "true",
195472
- className: "h-10 min-h-10 border-b border-gray-alpha-400"
197307
+ run: run2,
197308
+ events: allEvents ?? [],
197309
+ loading,
197310
+ sidebarData,
197311
+ onLoadMore: loadMoreTraceData,
197312
+ hasMore: hasMoreTraceData,
197313
+ isLoadingMore: isLoadingMoreTraceData,
197314
+ initialSelectedSpanId
195473
197315
  }
195474
- ),
195475
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1 divide-y divide-gray-400 overflow-y-auto", children: streamsLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col divide-y divide-gray-400", children: [
195476
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3.5 w-24" }) }),
195477
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3.5 w-32" }) }),
195478
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3.5 w-20" }) })
195479
- ] }) : streamsError ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-2 text-label-12 text-red-900", children: streamsError.message }) : streams.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center px-4 text-label-12 text-gray-900", children: "No streams found for this run" }) : streams.map((streamId) => /* @__PURE__ */ jsxRuntimeExports.jsx(
195480
- "button",
195481
- {
195482
- type: "button",
195483
- onClick: () => setSelectedStreamId(streamId),
195484
- className: `flex h-10 min-h-10 w-full min-w-0 items-center truncate pl-4 pr-2 text-left text-label-14 transition-colors ${selectedStreamId === streamId ? "bg-gray-100 text-gray-1000 hover:bg-gray-200 active:bg-gray-200" : "bg-transparent text-gray-900 hover:bg-gray-100 hover:text-gray-1000 focus-visible:bg-gray-100 focus-visible:text-gray-1000"}`,
195485
- title: streamId,
195486
- children: streamId
195487
- },
195488
- streamId
195489
- )) })
195490
- ] }),
195491
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex min-w-0 flex-1 flex-col overflow-hidden bg-background-100", children: streamsLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(StreamViewerSkeleton, {}) }) : selectedStreamId ? (streamError == null ? void 0 : streamError.includes("encrypted")) && !encryptionKey ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-3 text-center", children: [
195492
- /* @__PURE__ */ jsxRuntimeExports.jsx(Lock, { className: "h-8 w-8 text-gray-700" }),
195493
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [
195494
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-14 font-medium text-gray-1000", children: "Encrypted Stream" }),
195495
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-12 text-gray-900", children: "Decrypt this stream to view its chunks." })
195496
- ] }),
195497
- /* @__PURE__ */ jsxRuntimeExports.jsx(
195498
- DecryptButton,
197316
+ ) }) }) }),
197317
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "events", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary$1, { title: "Failed to load events list", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative h-full -mx-6 bg-background-100 border-t border-gray-alpha-400 overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
197318
+ RunEventsTab,
195499
197319
  {
195500
- onClick: handleDecrypt,
195501
- loading: isDecrypting
197320
+ env: env2,
197321
+ runId,
197322
+ run: run2,
197323
+ onLoadEventData: handleLoadEventData,
197324
+ encryptionKey: encryptionKey ?? void 0,
197325
+ sortOrder: eventsSortOrder,
197326
+ onSortOrderChange: setEventsSortOrder,
197327
+ onDecrypt: handleDecrypt,
197328
+ isDecrypting,
197329
+ onViewInTrace: (spanId) => updateSearchParams({ tab: "trace", spanId })
195502
197330
  }
195503
- )
195504
- ] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
195505
- StreamViewer,
195506
- {
195507
- streamId: selectedStreamId,
195508
- chunks: streamChunks,
195509
- isLive: streamIsLive,
195510
- isLoading: streamIsInitialLoading,
195511
- error: (streamError == null ? void 0 : streamError.includes("encrypted")) ? null : streamError
195512
- }
195513
- ) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-14 text-gray-600", children: streams.length > 0 ? "Select a stream to view its data" : "No streams available" }) }) })
195514
- ] }) }) }),
195515
- false
195516
- ]
195517
- }
195518
- ) })
195519
- ] })
197331
+ ) }) }) }),
197332
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "streams", className: "mt-0 flex-1 min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary$1, { title: "Failed to load stream data", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative -mx-6 flex h-full min-h-0 overflow-hidden border-t border-gray-alpha-400 bg-background-100", children: [
197333
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-[340px] shrink-0 flex-col border-r border-gray-alpha-400 bg-background-100", children: [
197334
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
197335
+ "div",
197336
+ {
197337
+ "aria-hidden": "true",
197338
+ className: "h-10 min-h-10 border-b border-gray-alpha-400"
197339
+ }
197340
+ ),
197341
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1 divide-y divide-gray-400 overflow-y-auto", children: streamsLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col divide-y divide-gray-400", children: [
197342
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3.5 w-24" }) }),
197343
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3.5 w-32" }) }),
197344
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center pl-4 pr-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-3.5 w-20" }) })
197345
+ ] }) : streamsError ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "px-4 py-2 text-label-12 text-red-900", children: streamsError.message }) : streams.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-10 min-h-10 items-center px-4 text-label-12 text-gray-900", children: "No streams found for this run" }) : streams.map((streamId) => /* @__PURE__ */ jsxRuntimeExports.jsx(
197346
+ "button",
197347
+ {
197348
+ type: "button",
197349
+ onClick: () => setSelectedStreamId(streamId),
197350
+ className: `flex h-10 min-h-10 w-full min-w-0 items-center truncate pl-4 pr-2 text-left text-label-14 transition-colors ${selectedStreamId === streamId ? "bg-gray-100 text-gray-1000 hover:bg-gray-200 active:bg-gray-200" : "bg-transparent text-gray-900 hover:bg-gray-100 hover:text-gray-1000 focus-visible:bg-gray-100 focus-visible:text-gray-1000"}`,
197351
+ title: streamId,
197352
+ children: streamId
197353
+ },
197354
+ streamId
197355
+ )) })
197356
+ ] }),
197357
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex min-w-0 flex-1 flex-col overflow-hidden bg-background-100", children: streamsLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(StreamViewerSkeleton, {}) }) : selectedStreamId ? (streamError == null ? void 0 : streamError.includes("encrypted")) && !encryptionKey ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center gap-3 text-center", children: [
197358
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Lock, { className: "h-8 w-8 text-gray-700" }),
197359
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [
197360
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-14 font-medium text-gray-1000", children: "Encrypted Stream" }),
197361
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-12 text-gray-900", children: "Decrypt this stream to view its chunks." })
197362
+ ] }),
197363
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
197364
+ DecryptButton,
197365
+ {
197366
+ onClick: handleDecrypt,
197367
+ loading: isDecrypting
197368
+ }
197369
+ )
197370
+ ] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
197371
+ StreamViewer,
197372
+ {
197373
+ streamId: selectedStreamId,
197374
+ chunks: streamChunks,
197375
+ isLive: streamIsLive,
197376
+ isLoading: streamIsInitialLoading,
197377
+ error: (streamError == null ? void 0 : streamError.includes("encrypted")) ? null : streamError
197378
+ }
197379
+ ) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-label-14 text-gray-600", children: streams.length > 0 ? "Select a stream to view its data" : "No streams available" }) }) })
197380
+ ] }) }) }),
197381
+ false
197382
+ ]
197383
+ }
197384
+ ) })
197385
+ ]
197386
+ }
197387
+ )
195520
197388
  ] });
195521
197389
  }
195522
197390
  const runDetail = withComponentProps(function RunDetailPage() {
@@ -195539,9 +197407,38 @@ const route2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
195539
197407
  __proto__: null,
195540
197408
  default: runDetail
195541
197409
  }, Symbol.toStringTag, { value: "Module" }));
197410
+ function meta({
197411
+ params
197412
+ }) {
197413
+ return [{
197414
+ title: `Usage · ${params.runId ?? "Run"} · ${DEFAULT_TITLE}`
197415
+ }, {
197416
+ name: "description",
197417
+ content: DEFAULT_META_DESCRIPTION
197418
+ }];
197419
+ }
197420
+ const runUsage = withComponentProps(function RunUsageRoute() {
197421
+ const {
197422
+ runId,
197423
+ usage
197424
+ } = useOutletContext();
197425
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(RunUsagePage, {
197426
+ runId,
197427
+ usage: usage.usage,
197428
+ error: usage.error,
197429
+ onRetry: usage.refresh,
197430
+ retrying: usage.loading
197431
+ });
197432
+ });
197433
+ const route3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
197434
+ __proto__: null,
197435
+ default: runUsage,
197436
+ meta
197437
+ }, Symbol.toStringTag, { value: "Module" }));
195542
197438
  const handlers = {
195543
197439
  fetchRuns: (p2) => fetchRuns(p2.worldEnv ?? {}, p2.params ?? {}),
195544
197440
  fetchRun: (p2) => fetchRun(p2.worldEnv ?? {}, p2.runId, p2.resolveData),
197441
+ fetchRunUsage: (p2) => fetchRunUsage(p2.worldEnv ?? {}, p2.runId),
195545
197442
  fetchStep: (p2) => fetchStep(p2.worldEnv ?? {}, p2.runId, p2.stepId, p2.resolveData),
195546
197443
  fetchEvents: (p2) => fetchEvents(p2.worldEnv ?? {}, p2.runId, p2.params ?? {}),
195547
197444
  fetchEvent: (p2) => fetchEvent(p2.worldEnv ?? {}, p2.runId, p2.eventId, p2.resolveData),
@@ -195633,7 +197530,7 @@ async function loader$1({
195633
197530
  status: 405
195634
197531
  });
195635
197532
  }
195636
- const route3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
197533
+ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
195637
197534
  __proto__: null,
195638
197535
  action,
195639
197536
  loader: loader$1
@@ -195691,11 +197588,11 @@ async function loader({
195691
197588
  });
195692
197589
  }
195693
197590
  }
195694
- const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
197591
+ const route5 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
195695
197592
  __proto__: null,
195696
197593
  loader
195697
197594
  }, Symbol.toStringTag, { value: "Module" }));
195698
- const serverManifest = { "entry": { "module": "/assets/entry.client-DDsh88VE.js", "imports": ["/assets/index-BS6T0Zjc.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-wdKzRZGT.js", "imports": ["/assets/index-BS6T0Zjc.js", "/assets/mermaid-WFAXDIZX-BLO7Z8RE.js", "/assets/arrow-up-right-CNHh1bh2.js"], "css": ["/assets/root-BBptRWmF.css", "/assets/mermaid-WFAXDIZX-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/home": { "id": "routes/home", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/home-DZqYMSiD.js", "imports": ["/assets/index-BS6T0Zjc.js", "/assets/url-state-DhOv2zv0.js", "/assets/mermaid-WFAXDIZX-BLO7Z8RE.js"], "css": ["/assets/url-state-C9ccOmbh.css", "/assets/mermaid-WFAXDIZX-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-detail": { "id": "routes/run-detail", "parentId": "root", "path": "run/:runId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-detail-DyXpnv9C.js", "imports": ["/assets/index-BS6T0Zjc.js", "/assets/url-state-DhOv2zv0.js", "/assets/mermaid-WFAXDIZX-BLO7Z8RE.js", "/assets/arrow-up-right-CNHh1bh2.js"], "css": ["/assets/run-detail-CWoGxu_0.css", "/assets/url-state-C9ccOmbh.css", "/assets/mermaid-WFAXDIZX-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.rpc": { "id": "routes/api.rpc", "parentId": "root", "path": "api/rpc", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.rpc-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.stream.$streamId": { "id": "routes/api.stream.$streamId", "parentId": "root", "path": "api/stream/:streamId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.stream._streamId-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 } }, "url": "/assets/manifest-f2e93220.js", "version": "f2e93220", "sri": void 0 };
197595
+ const serverManifest = { "entry": { "module": "/assets/entry.client-xzxVCL3o.js", "imports": ["/assets/index-wl5l5E8H.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-C1XwTNUK.js", "imports": ["/assets/index-wl5l5E8H.js", "/assets/mermaid-WFAXDIZX-CB__BxYb.js", "/assets/rpc-client-SbyXJdFV.js", "/assets/arrow-up-right-DyaB_ak4.js", "/assets/meta-9cjJ0pVb.js"], "css": ["/assets/root-C3ED6Dwc.css", "/assets/mermaid-WFAXDIZX-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/home": { "id": "routes/home", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/home--wf0CrF6.js", "imports": ["/assets/index-wl5l5E8H.js", "/assets/url-state-JAVaNZ_m.js", "/assets/mermaid-WFAXDIZX-CB__BxYb.js", "/assets/rpc-client-SbyXJdFV.js", "/assets/skeleton-DMLgjvZZ.js"], "css": ["/assets/url-state-C9ccOmbh.css", "/assets/mermaid-WFAXDIZX-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-detail": { "id": "routes/run-detail", "parentId": "root", "path": "run/:runId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-detail-2CnpdXm1.js", "imports": ["/assets/index-wl5l5E8H.js", "/assets/url-state-JAVaNZ_m.js", "/assets/mermaid-WFAXDIZX-CB__BxYb.js", "/assets/skeleton-DMLgjvZZ.js", "/assets/run-usage-DRV6lopZ.js", "/assets/arrow-up-right-DyaB_ak4.js", "/assets/rpc-client-SbyXJdFV.js"], "css": ["/assets/run-detail-CWoGxu_0.css", "/assets/url-state-C9ccOmbh.css", "/assets/mermaid-WFAXDIZX-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-usage": { "id": "routes/run-usage", "parentId": "routes/run-detail", "path": "usage", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-usage-C3aywyqa.js", "imports": ["/assets/index-wl5l5E8H.js", "/assets/run-usage-DRV6lopZ.js", "/assets/meta-9cjJ0pVb.js", "/assets/mermaid-WFAXDIZX-CB__BxYb.js", "/assets/skeleton-DMLgjvZZ.js", "/assets/arrow-up-right-DyaB_ak4.js"], "css": ["/assets/mermaid-WFAXDIZX-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.rpc": { "id": "routes/api.rpc", "parentId": "root", "path": "api/rpc", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.rpc-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.stream.$streamId": { "id": "routes/api.stream.$streamId", "parentId": "root", "path": "api/stream/:streamId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.stream._streamId-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 } }, "url": "/assets/manifest-7b81d8d4.js", "version": "7b81d8d4", "sri": void 0 };
195699
197596
  const assetsBuildDirectory = "build/client";
195700
197597
  const basename = "/";
195701
197598
  const future = { "unstable_optimizeDeps": false, "v8_passThroughRequests": false, "v8_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };
@@ -195730,13 +197627,21 @@ const routes = {
195730
197627
  caseSensitive: void 0,
195731
197628
  module: route2
195732
197629
  },
197630
+ "routes/run-usage": {
197631
+ id: "routes/run-usage",
197632
+ parentId: "routes/run-detail",
197633
+ path: "usage",
197634
+ index: void 0,
197635
+ caseSensitive: void 0,
197636
+ module: route3
197637
+ },
195733
197638
  "routes/api.rpc": {
195734
197639
  id: "routes/api.rpc",
195735
197640
  parentId: "root",
195736
197641
  path: "api/rpc",
195737
197642
  index: void 0,
195738
197643
  caseSensitive: void 0,
195739
- module: route3
197644
+ module: route4
195740
197645
  },
195741
197646
  "routes/api.stream.$streamId": {
195742
197647
  id: "routes/api.stream.$streamId",
@@ -195744,7 +197649,7 @@ const routes = {
195744
197649
  path: "api/stream/:streamId",
195745
197650
  index: void 0,
195746
197651
  caseSensitive: void 0,
195747
- module: route4
197652
+ module: route5
195748
197653
  }
195749
197654
  };
195750
197655
  const allowedActionOrigins = false;