@workflow/web 4.1.28 → 4.1.30

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 (22) hide show
  1. package/build/client/assets/{encryption-CVDhlDp_.js → encryption-Cu4jq70Y.js} +2 -2
  2. package/build/client/assets/{entry.client-C_C46bD6.js → entry.client-C7XgFTHI.js} +7 -205
  3. package/build/client/assets/{highlighted-body-B3W2YXNL-DNE7dweN.js → highlighted-body-B3W2YXNL-B6-MkXV1.js} +2 -2
  4. package/build/client/assets/{home-BcCTbe4i.js → home-Yy5gk_jJ.js} +4 -4
  5. package/build/client/assets/{index-BsV8i_Jn.js → index-BQ-Xa8kF.js} +769 -330
  6. package/build/client/assets/{index-DhdkuKp5.js → index-CXBr7N7m.js} +1 -1
  7. package/build/client/assets/{manifest-f88c7f34.js → manifest-e13ef35a.js} +1 -1
  8. package/build/client/assets/{mermaid-3ZIDBTTL-B1-N6W83.js → mermaid-3ZIDBTTL-DV4S4pTo.js} +7 -7
  9. package/build/client/assets/{root-C2Eu3fUP.js → root-DQQlQnXn.js} +2 -2
  10. package/build/client/assets/{run-detail-CyImB2zR.js → run-detail-rocfw9Z5.js} +5 -5
  11. package/build/client/assets/{workflow-graph-viewer-lj3vdGSs.js → workflow-graph-viewer-De_-9tJh.js} +3 -3
  12. package/build/server/assets/{app-BAmhYum_.js → app-juehGONX.js} +891 -613
  13. package/build/server/assets/{highlighted-body-B3W2YXNL-D2bE_zLh.js → highlighted-body-B3W2YXNL-DgD9LFQJ.js} +4 -2
  14. package/build/server/assets/index-BUlN7QFn.js +1164 -0
  15. package/build/server/assets/{index-Tv6_4f6I.js → index-C1by_z-e.js} +5 -3
  16. package/build/server/assets/{mermaid-3ZIDBTTL-Dn3iLq1N.js → mermaid-3ZIDBTTL-DBfS-ZH8.js} +4 -2
  17. package/build/server/assets/{server-build-D38evYCr.js → server-build-CgjoLYPd.js} +1797 -68
  18. package/build/server/assets/{token-lgwgo3i8.js → token-CP9u68ZL.js} +2 -2
  19. package/build/server/assets/{token-util-BzAlruRH.js → token-util-BrBJCxub.js} +2 -2
  20. package/build/server/index.js +2 -2
  21. package/package.json +9 -9
  22. package/build/server/assets/index-hBO56emR.js +0 -1286
@@ -18,7 +18,7 @@ import { createRequire as __wkfCreateRequire } from "node:module";
18
18
  if (typeof globalThis.require === "undefined") {
19
19
  globalThis.require = __wkfCreateRequire(import.meta.url);
20
20
  }
21
- import { a as requireReact, S as ServerRouter, c as createReadableStreamFromReadable, r as reactExports, g as getDefaultExportFromCjs, R as React, b as ReactExports, w as withComponentProps, d as withErrorBoundaryProps, M as Meta, L as Links, e as ScrollRestoration, f as Scripts, O as Outlet, u as useNavigate, h as useSearchParams, i as Link$1, j as useRouteError, k as isRouteErrorResponse, l as useLocation, m as useParams } from "./app-BAmhYum_.js";
21
+ import { a as requireReact, S as ServerRouter, c as createReadableStreamFromReadable, r as reactExports, g as getDefaultExportFromCjs, R as React, b as ReactExports, d as commonjsGlobal, w as withComponentProps, e as withErrorBoundaryProps, M as Meta, L as Links, f as ScrollRestoration, h as Scripts, O as Outlet, u as useNavigate, i as useSearchParams, j as Link$1, k as useRouteError, l as isRouteErrorResponse, m as useLocation, n as useParams } from "./app-juehGONX.js";
22
22
  import require$$0$5, { PassThrough, Transform as Transform$1 } from "node:stream";
23
23
  import require$$0 from "util";
24
24
  import require$$1 from "crypto";
@@ -60,6 +60,8 @@ import * as path$2 from "path";
60
60
  import path__default from "path";
61
61
  import * as fs from "fs";
62
62
  import fs__default from "fs";
63
+ import require$$0$9 from "constants";
64
+ import require$$5$3 from "assert";
63
65
  import * as net from "net";
64
66
  import os, { homedir } from "node:os";
65
67
  var jsxRuntime = { exports: {} };
@@ -49121,7 +49123,7 @@ const WorkflowRunSchema = discriminatedUnion("status", [
49121
49123
  // Completed state - output can be v1 or v2 format
49122
49124
  WorkflowRunBaseSchema.extend({
49123
49125
  status: literal("completed"),
49124
- output: SerializedDataSchema,
49126
+ output: SerializedDataSchema.optional(),
49125
49127
  error: _undefined().optional(),
49126
49128
  completedAt: date$2()
49127
49129
  }),
@@ -49129,7 +49131,7 @@ const WorkflowRunSchema = discriminatedUnion("status", [
49129
49131
  WorkflowRunBaseSchema.extend({
49130
49132
  status: literal("failed"),
49131
49133
  output: _undefined().optional(),
49132
- error: StructuredErrorSchema,
49134
+ error: StructuredErrorSchema.optional(),
49133
49135
  completedAt: date$2()
49134
49136
  })
49135
49137
  ]);
@@ -81973,7 +81975,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
81973
81975
  var et = ({ className: e, language: t, style: o, isIncomplete: n, ...s2 }) => jsxRuntimeExports.jsx("div", { className: f("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2", e), "data-incomplete": n || void 0, "data-language": t, "data-streamdown": "code-block", style: { contentVisibility: "auto", containIntrinsicSize: "auto 200px", ...o }, ...s2 });
81974
81976
  var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
81975
81977
  var ot = ({ language: e }) => jsxRuntimeExports.jsx("div", { className: "flex h-8 items-center text-muted-foreground text-xs", "data-language": e, "data-streamdown": "code-block-header", children: jsxRuntimeExports.jsx("span", { className: "ml-1 font-mono lowercase", children: e }) });
81976
- var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-D2bE_zLh.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
81978
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-DgD9LFQJ.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
81977
81979
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
81978
81980
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
81979
81981
  return jsxRuntimeExports.jsx(Se.Provider, { value: { code: e }, children: jsxRuntimeExports.jsxs(et, { isIncomplete: s2, language: t, children: [jsxRuntimeExports.jsx(ot, { language: t }), n ? jsxRuntimeExports.jsx("div", { className: "pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end", children: jsxRuntimeExports.jsx("div", { className: "pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur", "data-streamdown": "code-block-actions", children: n }) }) : null, jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: jsxRuntimeExports.jsx(Qe, { className: o, language: t, result: c, ...r2 }), children: jsxRuntimeExports.jsx(dn, { className: o, code: i, language: t, raw: c, ...r2 }) })] }) });
@@ -82295,7 +82297,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
82295
82297
  }, []), jsxRuntimeExports.jsxs("div", { className: "relative", ref: i, children: [jsxRuntimeExports.jsx("button", { className: f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", t), disabled: c, onClick: () => r2(!s2), title: "Download table", type: "button", children: e != null ? e : jsxRuntimeExports.jsx(Z, { size: 14 }) }), s2 ? jsxRuntimeExports.jsxs("div", { className: "absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg", children: [jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("csv"), title: "Download table as CSV", type: "button", children: "CSV" }), jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("markdown"), title: "Download table as Markdown", type: "button", children: "Markdown" })] }) : null] });
82296
82298
  };
82297
82299
  var Vt = ({ children: e, className: t, showControls: o, ...n }) => jsxRuntimeExports.jsxs("div", { className: "my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2", "data-streamdown": "table-wrapper", children: [o ? jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-end gap-1", children: [jsxRuntimeExports.jsx(Ht, {}), jsxRuntimeExports.jsx(Dt, {})] }) : null, jsxRuntimeExports.jsx("div", { className: "border-collapse overflow-x-auto overscroll-y-auto rounded-md border border-border bg-background", children: jsxRuntimeExports.jsx("table", { className: f("w-full divide-y divide-border", t), "data-streamdown": "table", ...n, children: e }) })] });
82298
- var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-Dn3iLq1N.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
82300
+ var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-DBfS-ZH8.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
82299
82301
  function ke(e, t) {
82300
82302
  if (!(e != null && e.position || t != null && t.position)) return true;
82301
82303
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -92059,7 +92061,7 @@ async function withTraceContext(traceCarrier, fn2) {
92059
92061
  }
92060
92062
  const OtelApi = once$1(async () => {
92061
92063
  try {
92062
- return await import("./index-hBO56emR.js");
92064
+ return await import("./index-BUlN7QFn.js");
92063
92065
  } catch {
92064
92066
  runtimeLogger.info("OpenTelemetry not available, tracing will be disabled");
92065
92067
  return null;
@@ -92204,7 +92206,7 @@ createLogger("build", {
92204
92206
  debugNamespace: "workflow:build"
92205
92207
  });
92206
92208
  const MAX_QUEUE_DELIVERIES = 48;
92207
- const version$1 = "4.8.12";
92209
+ const version$1 = "4.8.14";
92208
92210
  const execFileAsync = promisify(execFile);
92209
92211
  function parsePort$1(value, radix = 10) {
92210
92212
  const port = parseInt(value, radix);
@@ -92441,6 +92443,25 @@ function once(fn2) {
92441
92443
  };
92442
92444
  return result;
92443
92445
  }
92446
+ function withInProcessLock(locks, key, fn2) {
92447
+ const prev = locks.get(key);
92448
+ const taskBox = {};
92449
+ const task = (async () => {
92450
+ if (prev) {
92451
+ await prev.catch(() => void 0);
92452
+ }
92453
+ try {
92454
+ return await fn2();
92455
+ } finally {
92456
+ if (locks.get(key) === taskBox.task) {
92457
+ locks.delete(key);
92458
+ }
92459
+ }
92460
+ })();
92461
+ taskBox.task = task;
92462
+ locks.set(key, task);
92463
+ return task;
92464
+ }
92444
92465
  const getDataDirFromEnv = () => {
92445
92466
  return process.env.WORKFLOW_LOCAL_DATA_DIR || ".workflow-data";
92446
92467
  };
@@ -93000,7 +93021,7 @@ async function initDataDir(dataDir) {
93000
93021
  let otelApiPromise$1 = null;
93001
93022
  async function getOtelApi$1() {
93002
93023
  if (!otelApiPromise$1) {
93003
- otelApiPromise$1 = import("./index-hBO56emR.js").catch(() => null);
93024
+ otelApiPromise$1 = import("./index-BUlN7QFn.js").catch(() => null);
93004
93025
  }
93005
93026
  return otelApiPromise$1;
93006
93027
  }
@@ -108648,13 +108669,13 @@ function requireResponseError() {
108648
108669
  };
108649
108670
  return responseError;
108650
108671
  }
108651
- var retry;
108652
- var hasRequiredRetry;
108653
- function requireRetry() {
108654
- if (hasRequiredRetry) return retry;
108655
- hasRequiredRetry = 1;
108672
+ var retry$2;
108673
+ var hasRequiredRetry$2;
108674
+ function requireRetry$2() {
108675
+ if (hasRequiredRetry$2) return retry$2;
108676
+ hasRequiredRetry$2 = 1;
108656
108677
  const RetryHandler = requireRetryHandler();
108657
- retry = (globalOpts) => {
108678
+ retry$2 = (globalOpts) => {
108658
108679
  return (dispatch2) => {
108659
108680
  return function retryInterceptor(opts, handler) {
108660
108681
  return dispatch2(
@@ -108670,7 +108691,7 @@ function requireRetry() {
108670
108691
  };
108671
108692
  };
108672
108693
  };
108673
- return retry;
108694
+ return retry$2;
108674
108695
  }
108675
108696
  var dump;
108676
108697
  var hasRequiredDump;
@@ -119925,7 +119946,7 @@ function requireUndici() {
119925
119946
  module.exports.interceptors = {
119926
119947
  redirect: requireRedirect(),
119927
119948
  responseError: requireResponseError(),
119928
- retry: requireRetry(),
119949
+ retry: requireRetry$2(),
119929
119950
  dump: requireDump(),
119930
119951
  dns: requireDns(),
119931
119952
  cache: requireCache$1(),
@@ -120692,25 +120713,6 @@ async function pinCanonicalEventIdForLegacyClaim(basedir, token, runId, hookId,
120692
120713
  const existing = await readHookRecoveryMarker(markerPath);
120693
120714
  return (existing == null ? void 0 : existing.eventId) ?? null;
120694
120715
  }
120695
- function withInProcessLock(locks, key, fn2) {
120696
- const prev = locks.get(key);
120697
- const taskBox = {};
120698
- const task = (async () => {
120699
- if (prev) {
120700
- await prev.catch(() => void 0);
120701
- }
120702
- try {
120703
- return await fn2();
120704
- } finally {
120705
- if (locks.get(key) === taskBox.task) {
120706
- locks.delete(key);
120707
- }
120708
- }
120709
- })();
120710
- taskBox.task = task;
120711
- locks.set(key, task);
120712
- return task;
120713
- }
120714
120716
  async function deleteAllWaitsForRun(basedir, runId) {
120715
120717
  const waitsDir = path$3.join(basedir, "waits");
120716
120718
  const files = await listJSONFiles(waitsDir);
@@ -121547,10 +121549,1590 @@ function createStorage$1(basedir, tag) {
121547
121549
  clearCache: () => events2.clearCache()
121548
121550
  };
121549
121551
  }
121552
+ var properLockfile = { exports: {} };
121553
+ var lockfile = {};
121554
+ var polyfills;
121555
+ var hasRequiredPolyfills;
121556
+ function requirePolyfills() {
121557
+ if (hasRequiredPolyfills) return polyfills;
121558
+ hasRequiredPolyfills = 1;
121559
+ var constants2 = require$$0$9;
121560
+ var origCwd = process.cwd;
121561
+ var cwd = null;
121562
+ var platform2 = process.env.GRACEFUL_FS_PLATFORM || process.platform;
121563
+ process.cwd = function() {
121564
+ if (!cwd)
121565
+ cwd = origCwd.call(process);
121566
+ return cwd;
121567
+ };
121568
+ try {
121569
+ process.cwd();
121570
+ } catch (er2) {
121571
+ }
121572
+ if (typeof process.chdir === "function") {
121573
+ var chdir = process.chdir;
121574
+ process.chdir = function(d2) {
121575
+ cwd = null;
121576
+ chdir.call(process, d2);
121577
+ };
121578
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
121579
+ }
121580
+ polyfills = patch2;
121581
+ function patch2(fs2) {
121582
+ if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
121583
+ patchLchmod(fs2);
121584
+ }
121585
+ if (!fs2.lutimes) {
121586
+ patchLutimes(fs2);
121587
+ }
121588
+ fs2.chown = chownFix(fs2.chown);
121589
+ fs2.fchown = chownFix(fs2.fchown);
121590
+ fs2.lchown = chownFix(fs2.lchown);
121591
+ fs2.chmod = chmodFix(fs2.chmod);
121592
+ fs2.fchmod = chmodFix(fs2.fchmod);
121593
+ fs2.lchmod = chmodFix(fs2.lchmod);
121594
+ fs2.chownSync = chownFixSync(fs2.chownSync);
121595
+ fs2.fchownSync = chownFixSync(fs2.fchownSync);
121596
+ fs2.lchownSync = chownFixSync(fs2.lchownSync);
121597
+ fs2.chmodSync = chmodFixSync(fs2.chmodSync);
121598
+ fs2.fchmodSync = chmodFixSync(fs2.fchmodSync);
121599
+ fs2.lchmodSync = chmodFixSync(fs2.lchmodSync);
121600
+ fs2.stat = statFix(fs2.stat);
121601
+ fs2.fstat = statFix(fs2.fstat);
121602
+ fs2.lstat = statFix(fs2.lstat);
121603
+ fs2.statSync = statFixSync(fs2.statSync);
121604
+ fs2.fstatSync = statFixSync(fs2.fstatSync);
121605
+ fs2.lstatSync = statFixSync(fs2.lstatSync);
121606
+ if (fs2.chmod && !fs2.lchmod) {
121607
+ fs2.lchmod = function(path2, mode, cb) {
121608
+ if (cb) process.nextTick(cb);
121609
+ };
121610
+ fs2.lchmodSync = function() {
121611
+ };
121612
+ }
121613
+ if (fs2.chown && !fs2.lchown) {
121614
+ fs2.lchown = function(path2, uid, gid, cb) {
121615
+ if (cb) process.nextTick(cb);
121616
+ };
121617
+ fs2.lchownSync = function() {
121618
+ };
121619
+ }
121620
+ if (platform2 === "win32") {
121621
+ fs2.rename = typeof fs2.rename !== "function" ? fs2.rename : (function(fs$rename) {
121622
+ function rename(from, to2, cb) {
121623
+ var start2 = Date.now();
121624
+ var backoff = 0;
121625
+ fs$rename(from, to2, function CB(er2) {
121626
+ if (er2 && (er2.code === "EACCES" || er2.code === "EPERM" || er2.code === "EBUSY") && Date.now() - start2 < 6e4) {
121627
+ setTimeout(function() {
121628
+ fs2.stat(to2, function(stater, st2) {
121629
+ if (stater && stater.code === "ENOENT")
121630
+ fs$rename(from, to2, CB);
121631
+ else
121632
+ cb(er2);
121633
+ });
121634
+ }, backoff);
121635
+ if (backoff < 100)
121636
+ backoff += 10;
121637
+ return;
121638
+ }
121639
+ if (cb) cb(er2);
121640
+ });
121641
+ }
121642
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
121643
+ return rename;
121644
+ })(fs2.rename);
121645
+ }
121646
+ fs2.read = typeof fs2.read !== "function" ? fs2.read : (function(fs$read) {
121647
+ function read2(fd, buffer2, offset2, length, position2, callback_) {
121648
+ var callback;
121649
+ if (callback_ && typeof callback_ === "function") {
121650
+ var eagCounter = 0;
121651
+ callback = function(er2, _2, __) {
121652
+ if (er2 && er2.code === "EAGAIN" && eagCounter < 10) {
121653
+ eagCounter++;
121654
+ return fs$read.call(fs2, fd, buffer2, offset2, length, position2, callback);
121655
+ }
121656
+ callback_.apply(this, arguments);
121657
+ };
121658
+ }
121659
+ return fs$read.call(fs2, fd, buffer2, offset2, length, position2, callback);
121660
+ }
121661
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read2, fs$read);
121662
+ return read2;
121663
+ })(fs2.read);
121664
+ fs2.readSync = typeof fs2.readSync !== "function" ? fs2.readSync : /* @__PURE__ */ (function(fs$readSync) {
121665
+ return function(fd, buffer2, offset2, length, position2) {
121666
+ var eagCounter = 0;
121667
+ while (true) {
121668
+ try {
121669
+ return fs$readSync.call(fs2, fd, buffer2, offset2, length, position2);
121670
+ } catch (er2) {
121671
+ if (er2.code === "EAGAIN" && eagCounter < 10) {
121672
+ eagCounter++;
121673
+ continue;
121674
+ }
121675
+ throw er2;
121676
+ }
121677
+ }
121678
+ };
121679
+ })(fs2.readSync);
121680
+ function patchLchmod(fs3) {
121681
+ fs3.lchmod = function(path2, mode, callback) {
121682
+ fs3.open(
121683
+ path2,
121684
+ constants2.O_WRONLY | constants2.O_SYMLINK,
121685
+ mode,
121686
+ function(err, fd) {
121687
+ if (err) {
121688
+ if (callback) callback(err);
121689
+ return;
121690
+ }
121691
+ fs3.fchmod(fd, mode, function(err2) {
121692
+ fs3.close(fd, function(err22) {
121693
+ if (callback) callback(err2 || err22);
121694
+ });
121695
+ });
121696
+ }
121697
+ );
121698
+ };
121699
+ fs3.lchmodSync = function(path2, mode) {
121700
+ var fd = fs3.openSync(path2, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
121701
+ var threw = true;
121702
+ var ret;
121703
+ try {
121704
+ ret = fs3.fchmodSync(fd, mode);
121705
+ threw = false;
121706
+ } finally {
121707
+ if (threw) {
121708
+ try {
121709
+ fs3.closeSync(fd);
121710
+ } catch (er2) {
121711
+ }
121712
+ } else {
121713
+ fs3.closeSync(fd);
121714
+ }
121715
+ }
121716
+ return ret;
121717
+ };
121718
+ }
121719
+ function patchLutimes(fs3) {
121720
+ if (constants2.hasOwnProperty("O_SYMLINK") && fs3.futimes) {
121721
+ fs3.lutimes = function(path2, at2, mt2, cb) {
121722
+ fs3.open(path2, constants2.O_SYMLINK, function(er2, fd) {
121723
+ if (er2) {
121724
+ if (cb) cb(er2);
121725
+ return;
121726
+ }
121727
+ fs3.futimes(fd, at2, mt2, function(er3) {
121728
+ fs3.close(fd, function(er22) {
121729
+ if (cb) cb(er3 || er22);
121730
+ });
121731
+ });
121732
+ });
121733
+ };
121734
+ fs3.lutimesSync = function(path2, at2, mt2) {
121735
+ var fd = fs3.openSync(path2, constants2.O_SYMLINK);
121736
+ var ret;
121737
+ var threw = true;
121738
+ try {
121739
+ ret = fs3.futimesSync(fd, at2, mt2);
121740
+ threw = false;
121741
+ } finally {
121742
+ if (threw) {
121743
+ try {
121744
+ fs3.closeSync(fd);
121745
+ } catch (er2) {
121746
+ }
121747
+ } else {
121748
+ fs3.closeSync(fd);
121749
+ }
121750
+ }
121751
+ return ret;
121752
+ };
121753
+ } else if (fs3.futimes) {
121754
+ fs3.lutimes = function(_a3, _b2, _c, cb) {
121755
+ if (cb) process.nextTick(cb);
121756
+ };
121757
+ fs3.lutimesSync = function() {
121758
+ };
121759
+ }
121760
+ }
121761
+ function chmodFix(orig) {
121762
+ if (!orig) return orig;
121763
+ return function(target2, mode, cb) {
121764
+ return orig.call(fs2, target2, mode, function(er2) {
121765
+ if (chownErOk(er2)) er2 = null;
121766
+ if (cb) cb.apply(this, arguments);
121767
+ });
121768
+ };
121769
+ }
121770
+ function chmodFixSync(orig) {
121771
+ if (!orig) return orig;
121772
+ return function(target2, mode) {
121773
+ try {
121774
+ return orig.call(fs2, target2, mode);
121775
+ } catch (er2) {
121776
+ if (!chownErOk(er2)) throw er2;
121777
+ }
121778
+ };
121779
+ }
121780
+ function chownFix(orig) {
121781
+ if (!orig) return orig;
121782
+ return function(target2, uid, gid, cb) {
121783
+ return orig.call(fs2, target2, uid, gid, function(er2) {
121784
+ if (chownErOk(er2)) er2 = null;
121785
+ if (cb) cb.apply(this, arguments);
121786
+ });
121787
+ };
121788
+ }
121789
+ function chownFixSync(orig) {
121790
+ if (!orig) return orig;
121791
+ return function(target2, uid, gid) {
121792
+ try {
121793
+ return orig.call(fs2, target2, uid, gid);
121794
+ } catch (er2) {
121795
+ if (!chownErOk(er2)) throw er2;
121796
+ }
121797
+ };
121798
+ }
121799
+ function statFix(orig) {
121800
+ if (!orig) return orig;
121801
+ return function(target2, options, cb) {
121802
+ if (typeof options === "function") {
121803
+ cb = options;
121804
+ options = null;
121805
+ }
121806
+ function callback(er2, stats2) {
121807
+ if (stats2) {
121808
+ if (stats2.uid < 0) stats2.uid += 4294967296;
121809
+ if (stats2.gid < 0) stats2.gid += 4294967296;
121810
+ }
121811
+ if (cb) cb.apply(this, arguments);
121812
+ }
121813
+ return options ? orig.call(fs2, target2, options, callback) : orig.call(fs2, target2, callback);
121814
+ };
121815
+ }
121816
+ function statFixSync(orig) {
121817
+ if (!orig) return orig;
121818
+ return function(target2, options) {
121819
+ var stats2 = options ? orig.call(fs2, target2, options) : orig.call(fs2, target2);
121820
+ if (stats2) {
121821
+ if (stats2.uid < 0) stats2.uid += 4294967296;
121822
+ if (stats2.gid < 0) stats2.gid += 4294967296;
121823
+ }
121824
+ return stats2;
121825
+ };
121826
+ }
121827
+ function chownErOk(er2) {
121828
+ if (!er2)
121829
+ return true;
121830
+ if (er2.code === "ENOSYS")
121831
+ return true;
121832
+ var nonroot = !process.getuid || process.getuid() !== 0;
121833
+ if (nonroot) {
121834
+ if (er2.code === "EINVAL" || er2.code === "EPERM")
121835
+ return true;
121836
+ }
121837
+ return false;
121838
+ }
121839
+ }
121840
+ return polyfills;
121841
+ }
121842
+ var legacyStreams;
121843
+ var hasRequiredLegacyStreams;
121844
+ function requireLegacyStreams() {
121845
+ if (hasRequiredLegacyStreams) return legacyStreams;
121846
+ hasRequiredLegacyStreams = 1;
121847
+ var Stream = require$$5.Stream;
121848
+ legacyStreams = legacy;
121849
+ function legacy(fs2) {
121850
+ return {
121851
+ ReadStream,
121852
+ WriteStream
121853
+ };
121854
+ function ReadStream(path2, options) {
121855
+ if (!(this instanceof ReadStream)) return new ReadStream(path2, options);
121856
+ Stream.call(this);
121857
+ var self2 = this;
121858
+ this.path = path2;
121859
+ this.fd = null;
121860
+ this.readable = true;
121861
+ this.paused = false;
121862
+ this.flags = "r";
121863
+ this.mode = 438;
121864
+ this.bufferSize = 64 * 1024;
121865
+ options = options || {};
121866
+ var keys2 = Object.keys(options);
121867
+ for (var index2 = 0, length = keys2.length; index2 < length; index2++) {
121868
+ var key = keys2[index2];
121869
+ this[key] = options[key];
121870
+ }
121871
+ if (this.encoding) this.setEncoding(this.encoding);
121872
+ if (this.start !== void 0) {
121873
+ if ("number" !== typeof this.start) {
121874
+ throw TypeError("start must be a Number");
121875
+ }
121876
+ if (this.end === void 0) {
121877
+ this.end = Infinity;
121878
+ } else if ("number" !== typeof this.end) {
121879
+ throw TypeError("end must be a Number");
121880
+ }
121881
+ if (this.start > this.end) {
121882
+ throw new Error("start must be <= end");
121883
+ }
121884
+ this.pos = this.start;
121885
+ }
121886
+ if (this.fd !== null) {
121887
+ process.nextTick(function() {
121888
+ self2._read();
121889
+ });
121890
+ return;
121891
+ }
121892
+ fs2.open(this.path, this.flags, this.mode, function(err, fd) {
121893
+ if (err) {
121894
+ self2.emit("error", err);
121895
+ self2.readable = false;
121896
+ return;
121897
+ }
121898
+ self2.fd = fd;
121899
+ self2.emit("open", fd);
121900
+ self2._read();
121901
+ });
121902
+ }
121903
+ function WriteStream(path2, options) {
121904
+ if (!(this instanceof WriteStream)) return new WriteStream(path2, options);
121905
+ Stream.call(this);
121906
+ this.path = path2;
121907
+ this.fd = null;
121908
+ this.writable = true;
121909
+ this.flags = "w";
121910
+ this.encoding = "binary";
121911
+ this.mode = 438;
121912
+ this.bytesWritten = 0;
121913
+ options = options || {};
121914
+ var keys2 = Object.keys(options);
121915
+ for (var index2 = 0, length = keys2.length; index2 < length; index2++) {
121916
+ var key = keys2[index2];
121917
+ this[key] = options[key];
121918
+ }
121919
+ if (this.start !== void 0) {
121920
+ if ("number" !== typeof this.start) {
121921
+ throw TypeError("start must be a Number");
121922
+ }
121923
+ if (this.start < 0) {
121924
+ throw new Error("start must be >= zero");
121925
+ }
121926
+ this.pos = this.start;
121927
+ }
121928
+ this.busy = false;
121929
+ this._queue = [];
121930
+ if (this.fd === null) {
121931
+ this._open = fs2.open;
121932
+ this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
121933
+ this.flush();
121934
+ }
121935
+ }
121936
+ }
121937
+ return legacyStreams;
121938
+ }
121939
+ var clone_1;
121940
+ var hasRequiredClone;
121941
+ function requireClone() {
121942
+ if (hasRequiredClone) return clone_1;
121943
+ hasRequiredClone = 1;
121944
+ clone_1 = clone2;
121945
+ var getPrototypeOf = Object.getPrototypeOf || function(obj) {
121946
+ return obj.__proto__;
121947
+ };
121948
+ function clone2(obj) {
121949
+ if (obj === null || typeof obj !== "object")
121950
+ return obj;
121951
+ if (obj instanceof Object)
121952
+ var copy = { __proto__: getPrototypeOf(obj) };
121953
+ else
121954
+ var copy = /* @__PURE__ */ Object.create(null);
121955
+ Object.getOwnPropertyNames(obj).forEach(function(key) {
121956
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
121957
+ });
121958
+ return copy;
121959
+ }
121960
+ return clone_1;
121961
+ }
121962
+ var gracefulFs;
121963
+ var hasRequiredGracefulFs;
121964
+ function requireGracefulFs() {
121965
+ if (hasRequiredGracefulFs) return gracefulFs;
121966
+ hasRequiredGracefulFs = 1;
121967
+ var fs2 = fs__default;
121968
+ var polyfills2 = requirePolyfills();
121969
+ var legacy = requireLegacyStreams();
121970
+ var clone2 = requireClone();
121971
+ var util2 = require$$0;
121972
+ var gracefulQueue;
121973
+ var previousSymbol;
121974
+ if (typeof Symbol === "function" && typeof Symbol.for === "function") {
121975
+ gracefulQueue = Symbol.for("graceful-fs.queue");
121976
+ previousSymbol = Symbol.for("graceful-fs.previous");
121977
+ } else {
121978
+ gracefulQueue = "___graceful-fs.queue";
121979
+ previousSymbol = "___graceful-fs.previous";
121980
+ }
121981
+ function noop3() {
121982
+ }
121983
+ function publishQueue(context, queue2) {
121984
+ Object.defineProperty(context, gracefulQueue, {
121985
+ get: function() {
121986
+ return queue2;
121987
+ }
121988
+ });
121989
+ }
121990
+ var debug2 = noop3;
121991
+ if (util2.debuglog)
121992
+ debug2 = util2.debuglog("gfs4");
121993
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
121994
+ debug2 = function() {
121995
+ var m2 = util2.format.apply(util2, arguments);
121996
+ m2 = "GFS4: " + m2.split(/\n/).join("\nGFS4: ");
121997
+ console.error(m2);
121998
+ };
121999
+ if (!fs2[gracefulQueue]) {
122000
+ var queue = commonjsGlobal[gracefulQueue] || [];
122001
+ publishQueue(fs2, queue);
122002
+ fs2.close = (function(fs$close) {
122003
+ function close(fd, cb) {
122004
+ return fs$close.call(fs2, fd, function(err) {
122005
+ if (!err) {
122006
+ resetQueue();
122007
+ }
122008
+ if (typeof cb === "function")
122009
+ cb.apply(this, arguments);
122010
+ });
122011
+ }
122012
+ Object.defineProperty(close, previousSymbol, {
122013
+ value: fs$close
122014
+ });
122015
+ return close;
122016
+ })(fs2.close);
122017
+ fs2.closeSync = (function(fs$closeSync) {
122018
+ function closeSync(fd) {
122019
+ fs$closeSync.apply(fs2, arguments);
122020
+ resetQueue();
122021
+ }
122022
+ Object.defineProperty(closeSync, previousSymbol, {
122023
+ value: fs$closeSync
122024
+ });
122025
+ return closeSync;
122026
+ })(fs2.closeSync);
122027
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
122028
+ process.on("exit", function() {
122029
+ debug2(fs2[gracefulQueue]);
122030
+ require$$5$3.equal(fs2[gracefulQueue].length, 0);
122031
+ });
122032
+ }
122033
+ }
122034
+ if (!commonjsGlobal[gracefulQueue]) {
122035
+ publishQueue(commonjsGlobal, fs2[gracefulQueue]);
122036
+ }
122037
+ gracefulFs = patch2(clone2(fs2));
122038
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs2.__patched) {
122039
+ gracefulFs = patch2(fs2);
122040
+ fs2.__patched = true;
122041
+ }
122042
+ function patch2(fs3) {
122043
+ polyfills2(fs3);
122044
+ fs3.gracefulify = patch2;
122045
+ fs3.createReadStream = createReadStream;
122046
+ fs3.createWriteStream = createWriteStream;
122047
+ var fs$readFile = fs3.readFile;
122048
+ fs3.readFile = readFile2;
122049
+ function readFile2(path2, options, cb) {
122050
+ if (typeof options === "function")
122051
+ cb = options, options = null;
122052
+ return go$readFile(path2, options, cb);
122053
+ function go$readFile(path3, options2, cb2, startTime) {
122054
+ return fs$readFile(path3, options2, function(err) {
122055
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
122056
+ enqueue([go$readFile, [path3, options2, cb2], err, startTime || Date.now(), Date.now()]);
122057
+ else {
122058
+ if (typeof cb2 === "function")
122059
+ cb2.apply(this, arguments);
122060
+ }
122061
+ });
122062
+ }
122063
+ }
122064
+ var fs$writeFile = fs3.writeFile;
122065
+ fs3.writeFile = writeFile2;
122066
+ function writeFile2(path2, data, options, cb) {
122067
+ if (typeof options === "function")
122068
+ cb = options, options = null;
122069
+ return go$writeFile(path2, data, options, cb);
122070
+ function go$writeFile(path3, data2, options2, cb2, startTime) {
122071
+ return fs$writeFile(path3, data2, options2, function(err) {
122072
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
122073
+ enqueue([go$writeFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
122074
+ else {
122075
+ if (typeof cb2 === "function")
122076
+ cb2.apply(this, arguments);
122077
+ }
122078
+ });
122079
+ }
122080
+ }
122081
+ var fs$appendFile = fs3.appendFile;
122082
+ if (fs$appendFile)
122083
+ fs3.appendFile = appendFile;
122084
+ function appendFile(path2, data, options, cb) {
122085
+ if (typeof options === "function")
122086
+ cb = options, options = null;
122087
+ return go$appendFile(path2, data, options, cb);
122088
+ function go$appendFile(path3, data2, options2, cb2, startTime) {
122089
+ return fs$appendFile(path3, data2, options2, function(err) {
122090
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
122091
+ enqueue([go$appendFile, [path3, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
122092
+ else {
122093
+ if (typeof cb2 === "function")
122094
+ cb2.apply(this, arguments);
122095
+ }
122096
+ });
122097
+ }
122098
+ }
122099
+ var fs$copyFile = fs3.copyFile;
122100
+ if (fs$copyFile)
122101
+ fs3.copyFile = copyFile;
122102
+ function copyFile(src2, dest, flags, cb) {
122103
+ if (typeof flags === "function") {
122104
+ cb = flags;
122105
+ flags = 0;
122106
+ }
122107
+ return go$copyFile(src2, dest, flags, cb);
122108
+ function go$copyFile(src3, dest2, flags2, cb2, startTime) {
122109
+ return fs$copyFile(src3, dest2, flags2, function(err) {
122110
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
122111
+ enqueue([go$copyFile, [src3, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
122112
+ else {
122113
+ if (typeof cb2 === "function")
122114
+ cb2.apply(this, arguments);
122115
+ }
122116
+ });
122117
+ }
122118
+ }
122119
+ var fs$readdir = fs3.readdir;
122120
+ fs3.readdir = readdir2;
122121
+ var noReaddirOptionVersions = /^v[0-5]\./;
122122
+ function readdir2(path2, options, cb) {
122123
+ if (typeof options === "function")
122124
+ cb = options, options = null;
122125
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path3, options2, cb2, startTime) {
122126
+ return fs$readdir(path3, fs$readdirCallback(
122127
+ path3,
122128
+ options2,
122129
+ cb2,
122130
+ startTime
122131
+ ));
122132
+ } : function go$readdir2(path3, options2, cb2, startTime) {
122133
+ return fs$readdir(path3, options2, fs$readdirCallback(
122134
+ path3,
122135
+ options2,
122136
+ cb2,
122137
+ startTime
122138
+ ));
122139
+ };
122140
+ return go$readdir(path2, options, cb);
122141
+ function fs$readdirCallback(path3, options2, cb2, startTime) {
122142
+ return function(err, files) {
122143
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
122144
+ enqueue([
122145
+ go$readdir,
122146
+ [path3, options2, cb2],
122147
+ err,
122148
+ startTime || Date.now(),
122149
+ Date.now()
122150
+ ]);
122151
+ else {
122152
+ if (files && files.sort)
122153
+ files.sort();
122154
+ if (typeof cb2 === "function")
122155
+ cb2.call(this, err, files);
122156
+ }
122157
+ };
122158
+ }
122159
+ }
122160
+ if (process.version.substr(0, 4) === "v0.8") {
122161
+ var legStreams = legacy(fs3);
122162
+ ReadStream = legStreams.ReadStream;
122163
+ WriteStream = legStreams.WriteStream;
122164
+ }
122165
+ var fs$ReadStream = fs3.ReadStream;
122166
+ if (fs$ReadStream) {
122167
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
122168
+ ReadStream.prototype.open = ReadStream$open;
122169
+ }
122170
+ var fs$WriteStream = fs3.WriteStream;
122171
+ if (fs$WriteStream) {
122172
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
122173
+ WriteStream.prototype.open = WriteStream$open;
122174
+ }
122175
+ Object.defineProperty(fs3, "ReadStream", {
122176
+ get: function() {
122177
+ return ReadStream;
122178
+ },
122179
+ set: function(val) {
122180
+ ReadStream = val;
122181
+ },
122182
+ enumerable: true,
122183
+ configurable: true
122184
+ });
122185
+ Object.defineProperty(fs3, "WriteStream", {
122186
+ get: function() {
122187
+ return WriteStream;
122188
+ },
122189
+ set: function(val) {
122190
+ WriteStream = val;
122191
+ },
122192
+ enumerable: true,
122193
+ configurable: true
122194
+ });
122195
+ var FileReadStream = ReadStream;
122196
+ Object.defineProperty(fs3, "FileReadStream", {
122197
+ get: function() {
122198
+ return FileReadStream;
122199
+ },
122200
+ set: function(val) {
122201
+ FileReadStream = val;
122202
+ },
122203
+ enumerable: true,
122204
+ configurable: true
122205
+ });
122206
+ var FileWriteStream = WriteStream;
122207
+ Object.defineProperty(fs3, "FileWriteStream", {
122208
+ get: function() {
122209
+ return FileWriteStream;
122210
+ },
122211
+ set: function(val) {
122212
+ FileWriteStream = val;
122213
+ },
122214
+ enumerable: true,
122215
+ configurable: true
122216
+ });
122217
+ function ReadStream(path2, options) {
122218
+ if (this instanceof ReadStream)
122219
+ return fs$ReadStream.apply(this, arguments), this;
122220
+ else
122221
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
122222
+ }
122223
+ function ReadStream$open() {
122224
+ var that = this;
122225
+ open(that.path, that.flags, that.mode, function(err, fd) {
122226
+ if (err) {
122227
+ if (that.autoClose)
122228
+ that.destroy();
122229
+ that.emit("error", err);
122230
+ } else {
122231
+ that.fd = fd;
122232
+ that.emit("open", fd);
122233
+ that.read();
122234
+ }
122235
+ });
122236
+ }
122237
+ function WriteStream(path2, options) {
122238
+ if (this instanceof WriteStream)
122239
+ return fs$WriteStream.apply(this, arguments), this;
122240
+ else
122241
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
122242
+ }
122243
+ function WriteStream$open() {
122244
+ var that = this;
122245
+ open(that.path, that.flags, that.mode, function(err, fd) {
122246
+ if (err) {
122247
+ that.destroy();
122248
+ that.emit("error", err);
122249
+ } else {
122250
+ that.fd = fd;
122251
+ that.emit("open", fd);
122252
+ }
122253
+ });
122254
+ }
122255
+ function createReadStream(path2, options) {
122256
+ return new fs3.ReadStream(path2, options);
122257
+ }
122258
+ function createWriteStream(path2, options) {
122259
+ return new fs3.WriteStream(path2, options);
122260
+ }
122261
+ var fs$open = fs3.open;
122262
+ fs3.open = open;
122263
+ function open(path2, flags, mode, cb) {
122264
+ if (typeof mode === "function")
122265
+ cb = mode, mode = null;
122266
+ return go$open(path2, flags, mode, cb);
122267
+ function go$open(path3, flags2, mode2, cb2, startTime) {
122268
+ return fs$open(path3, flags2, mode2, function(err, fd) {
122269
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
122270
+ enqueue([go$open, [path3, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
122271
+ else {
122272
+ if (typeof cb2 === "function")
122273
+ cb2.apply(this, arguments);
122274
+ }
122275
+ });
122276
+ }
122277
+ }
122278
+ return fs3;
122279
+ }
122280
+ function enqueue(elem) {
122281
+ debug2("ENQUEUE", elem[0].name, elem[1]);
122282
+ fs2[gracefulQueue].push(elem);
122283
+ retry2();
122284
+ }
122285
+ var retryTimer;
122286
+ function resetQueue() {
122287
+ var now2 = Date.now();
122288
+ for (var i = 0; i < fs2[gracefulQueue].length; ++i) {
122289
+ if (fs2[gracefulQueue][i].length > 2) {
122290
+ fs2[gracefulQueue][i][3] = now2;
122291
+ fs2[gracefulQueue][i][4] = now2;
122292
+ }
122293
+ }
122294
+ retry2();
122295
+ }
122296
+ function retry2() {
122297
+ clearTimeout(retryTimer);
122298
+ retryTimer = void 0;
122299
+ if (fs2[gracefulQueue].length === 0)
122300
+ return;
122301
+ var elem = fs2[gracefulQueue].shift();
122302
+ var fn2 = elem[0];
122303
+ var args = elem[1];
122304
+ var err = elem[2];
122305
+ var startTime = elem[3];
122306
+ var lastTime = elem[4];
122307
+ if (startTime === void 0) {
122308
+ debug2("RETRY", fn2.name, args);
122309
+ fn2.apply(null, args);
122310
+ } else if (Date.now() - startTime >= 6e4) {
122311
+ debug2("TIMEOUT", fn2.name, args);
122312
+ var cb = args.pop();
122313
+ if (typeof cb === "function")
122314
+ cb.call(null, err);
122315
+ } else {
122316
+ var sinceAttempt = Date.now() - lastTime;
122317
+ var sinceStart = Math.max(lastTime - startTime, 1);
122318
+ var desiredDelay = Math.min(sinceStart * 1.2, 100);
122319
+ if (sinceAttempt >= desiredDelay) {
122320
+ debug2("RETRY", fn2.name, args);
122321
+ fn2.apply(null, args.concat([startTime]));
122322
+ } else {
122323
+ fs2[gracefulQueue].push(elem);
122324
+ }
122325
+ }
122326
+ if (retryTimer === void 0) {
122327
+ retryTimer = setTimeout(retry2, 0);
122328
+ }
122329
+ }
122330
+ return gracefulFs;
122331
+ }
122332
+ var retry$1 = {};
122333
+ var retry_operation;
122334
+ var hasRequiredRetry_operation;
122335
+ function requireRetry_operation() {
122336
+ if (hasRequiredRetry_operation) return retry_operation;
122337
+ hasRequiredRetry_operation = 1;
122338
+ function RetryOperation(timeouts, options) {
122339
+ if (typeof options === "boolean") {
122340
+ options = { forever: options };
122341
+ }
122342
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
122343
+ this._timeouts = timeouts;
122344
+ this._options = options || {};
122345
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
122346
+ this._fn = null;
122347
+ this._errors = [];
122348
+ this._attempts = 1;
122349
+ this._operationTimeout = null;
122350
+ this._operationTimeoutCb = null;
122351
+ this._timeout = null;
122352
+ this._operationStart = null;
122353
+ if (this._options.forever) {
122354
+ this._cachedTimeouts = this._timeouts.slice(0);
122355
+ }
122356
+ }
122357
+ retry_operation = RetryOperation;
122358
+ RetryOperation.prototype.reset = function() {
122359
+ this._attempts = 1;
122360
+ this._timeouts = this._originalTimeouts;
122361
+ };
122362
+ RetryOperation.prototype.stop = function() {
122363
+ if (this._timeout) {
122364
+ clearTimeout(this._timeout);
122365
+ }
122366
+ this._timeouts = [];
122367
+ this._cachedTimeouts = null;
122368
+ };
122369
+ RetryOperation.prototype.retry = function(err) {
122370
+ if (this._timeout) {
122371
+ clearTimeout(this._timeout);
122372
+ }
122373
+ if (!err) {
122374
+ return false;
122375
+ }
122376
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
122377
+ if (err && currentTime - this._operationStart >= this._maxRetryTime) {
122378
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
122379
+ return false;
122380
+ }
122381
+ this._errors.push(err);
122382
+ var timeout2 = this._timeouts.shift();
122383
+ if (timeout2 === void 0) {
122384
+ if (this._cachedTimeouts) {
122385
+ this._errors.splice(this._errors.length - 1, this._errors.length);
122386
+ this._timeouts = this._cachedTimeouts.slice(0);
122387
+ timeout2 = this._timeouts.shift();
122388
+ } else {
122389
+ return false;
122390
+ }
122391
+ }
122392
+ var self2 = this;
122393
+ var timer2 = setTimeout(function() {
122394
+ self2._attempts++;
122395
+ if (self2._operationTimeoutCb) {
122396
+ self2._timeout = setTimeout(function() {
122397
+ self2._operationTimeoutCb(self2._attempts);
122398
+ }, self2._operationTimeout);
122399
+ if (self2._options.unref) {
122400
+ self2._timeout.unref();
122401
+ }
122402
+ }
122403
+ self2._fn(self2._attempts);
122404
+ }, timeout2);
122405
+ if (this._options.unref) {
122406
+ timer2.unref();
122407
+ }
122408
+ return true;
122409
+ };
122410
+ RetryOperation.prototype.attempt = function(fn2, timeoutOps) {
122411
+ this._fn = fn2;
122412
+ if (timeoutOps) {
122413
+ if (timeoutOps.timeout) {
122414
+ this._operationTimeout = timeoutOps.timeout;
122415
+ }
122416
+ if (timeoutOps.cb) {
122417
+ this._operationTimeoutCb = timeoutOps.cb;
122418
+ }
122419
+ }
122420
+ var self2 = this;
122421
+ if (this._operationTimeoutCb) {
122422
+ this._timeout = setTimeout(function() {
122423
+ self2._operationTimeoutCb();
122424
+ }, self2._operationTimeout);
122425
+ }
122426
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
122427
+ this._fn(this._attempts);
122428
+ };
122429
+ RetryOperation.prototype.try = function(fn2) {
122430
+ console.log("Using RetryOperation.try() is deprecated");
122431
+ this.attempt(fn2);
122432
+ };
122433
+ RetryOperation.prototype.start = function(fn2) {
122434
+ console.log("Using RetryOperation.start() is deprecated");
122435
+ this.attempt(fn2);
122436
+ };
122437
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
122438
+ RetryOperation.prototype.errors = function() {
122439
+ return this._errors;
122440
+ };
122441
+ RetryOperation.prototype.attempts = function() {
122442
+ return this._attempts;
122443
+ };
122444
+ RetryOperation.prototype.mainError = function() {
122445
+ if (this._errors.length === 0) {
122446
+ return null;
122447
+ }
122448
+ var counts = {};
122449
+ var mainError = null;
122450
+ var mainErrorCount = 0;
122451
+ for (var i = 0; i < this._errors.length; i++) {
122452
+ var error2 = this._errors[i];
122453
+ var message2 = error2.message;
122454
+ var count2 = (counts[message2] || 0) + 1;
122455
+ counts[message2] = count2;
122456
+ if (count2 >= mainErrorCount) {
122457
+ mainError = error2;
122458
+ mainErrorCount = count2;
122459
+ }
122460
+ }
122461
+ return mainError;
122462
+ };
122463
+ return retry_operation;
122464
+ }
122465
+ var hasRequiredRetry$1;
122466
+ function requireRetry$1() {
122467
+ if (hasRequiredRetry$1) return retry$1;
122468
+ hasRequiredRetry$1 = 1;
122469
+ (function(exports) {
122470
+ var RetryOperation = requireRetry_operation();
122471
+ exports.operation = function(options) {
122472
+ var timeouts = exports.timeouts(options);
122473
+ return new RetryOperation(timeouts, {
122474
+ forever: options && options.forever,
122475
+ unref: options && options.unref,
122476
+ maxRetryTime: options && options.maxRetryTime
122477
+ });
122478
+ };
122479
+ exports.timeouts = function(options) {
122480
+ if (options instanceof Array) {
122481
+ return [].concat(options);
122482
+ }
122483
+ var opts = {
122484
+ retries: 10,
122485
+ factor: 2,
122486
+ minTimeout: 1 * 1e3,
122487
+ maxTimeout: Infinity,
122488
+ randomize: false
122489
+ };
122490
+ for (var key in options) {
122491
+ opts[key] = options[key];
122492
+ }
122493
+ if (opts.minTimeout > opts.maxTimeout) {
122494
+ throw new Error("minTimeout is greater than maxTimeout");
122495
+ }
122496
+ var timeouts = [];
122497
+ for (var i = 0; i < opts.retries; i++) {
122498
+ timeouts.push(this.createTimeout(i, opts));
122499
+ }
122500
+ if (options && options.forever && !timeouts.length) {
122501
+ timeouts.push(this.createTimeout(i, opts));
122502
+ }
122503
+ timeouts.sort(function(a2, b2) {
122504
+ return a2 - b2;
122505
+ });
122506
+ return timeouts;
122507
+ };
122508
+ exports.createTimeout = function(attempt, opts) {
122509
+ var random = opts.randomize ? Math.random() + 1 : 1;
122510
+ var timeout2 = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
122511
+ timeout2 = Math.min(timeout2, opts.maxTimeout);
122512
+ return timeout2;
122513
+ };
122514
+ exports.wrap = function(obj, options, methods) {
122515
+ if (options instanceof Array) {
122516
+ methods = options;
122517
+ options = null;
122518
+ }
122519
+ if (!methods) {
122520
+ methods = [];
122521
+ for (var key in obj) {
122522
+ if (typeof obj[key] === "function") {
122523
+ methods.push(key);
122524
+ }
122525
+ }
122526
+ }
122527
+ for (var i = 0; i < methods.length; i++) {
122528
+ var method = methods[i];
122529
+ var original = obj[method];
122530
+ obj[method] = (function retryWrapper(original2) {
122531
+ var op = exports.operation(options);
122532
+ var args = Array.prototype.slice.call(arguments, 1);
122533
+ var callback = args.pop();
122534
+ args.push(function(err) {
122535
+ if (op.retry(err)) {
122536
+ return;
122537
+ }
122538
+ if (err) {
122539
+ arguments[0] = op.mainError();
122540
+ }
122541
+ callback.apply(this, arguments);
122542
+ });
122543
+ op.attempt(function() {
122544
+ original2.apply(obj, args);
122545
+ });
122546
+ }).bind(obj, original);
122547
+ obj[method].options = options;
122548
+ }
122549
+ };
122550
+ })(retry$1);
122551
+ return retry$1;
122552
+ }
122553
+ var retry;
122554
+ var hasRequiredRetry;
122555
+ function requireRetry() {
122556
+ if (hasRequiredRetry) return retry;
122557
+ hasRequiredRetry = 1;
122558
+ retry = requireRetry$1();
122559
+ return retry;
122560
+ }
122561
+ var signalExit = { exports: {} };
122562
+ var signals = { exports: {} };
122563
+ var hasRequiredSignals;
122564
+ function requireSignals() {
122565
+ if (hasRequiredSignals) return signals.exports;
122566
+ hasRequiredSignals = 1;
122567
+ (function(module) {
122568
+ module.exports = [
122569
+ "SIGABRT",
122570
+ "SIGALRM",
122571
+ "SIGHUP",
122572
+ "SIGINT",
122573
+ "SIGTERM"
122574
+ ];
122575
+ if (process.platform !== "win32") {
122576
+ module.exports.push(
122577
+ "SIGVTALRM",
122578
+ "SIGXCPU",
122579
+ "SIGXFSZ",
122580
+ "SIGUSR2",
122581
+ "SIGTRAP",
122582
+ "SIGSYS",
122583
+ "SIGQUIT",
122584
+ "SIGIOT"
122585
+ // should detect profiler and enable/disable accordingly.
122586
+ // see #21
122587
+ // 'SIGPROF'
122588
+ );
122589
+ }
122590
+ if (process.platform === "linux") {
122591
+ module.exports.push(
122592
+ "SIGIO",
122593
+ "SIGPOLL",
122594
+ "SIGPWR",
122595
+ "SIGSTKFLT",
122596
+ "SIGUNUSED"
122597
+ );
122598
+ }
122599
+ })(signals);
122600
+ return signals.exports;
122601
+ }
122602
+ var hasRequiredSignalExit;
122603
+ function requireSignalExit() {
122604
+ if (hasRequiredSignalExit) return signalExit.exports;
122605
+ hasRequiredSignalExit = 1;
122606
+ var process2 = commonjsGlobal.process;
122607
+ const processOk = function(process3) {
122608
+ return process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
122609
+ };
122610
+ if (!processOk(process2)) {
122611
+ signalExit.exports = function() {
122612
+ return function() {
122613
+ };
122614
+ };
122615
+ } else {
122616
+ var assert2 = require$$5$3;
122617
+ var signals2 = requireSignals();
122618
+ var isWin = /^win/i.test(process2.platform);
122619
+ var EE = require$$0$2;
122620
+ if (typeof EE !== "function") {
122621
+ EE = EE.EventEmitter;
122622
+ }
122623
+ var emitter;
122624
+ if (process2.__signal_exit_emitter__) {
122625
+ emitter = process2.__signal_exit_emitter__;
122626
+ } else {
122627
+ emitter = process2.__signal_exit_emitter__ = new EE();
122628
+ emitter.count = 0;
122629
+ emitter.emitted = {};
122630
+ }
122631
+ if (!emitter.infinite) {
122632
+ emitter.setMaxListeners(Infinity);
122633
+ emitter.infinite = true;
122634
+ }
122635
+ signalExit.exports = function(cb, opts) {
122636
+ if (!processOk(commonjsGlobal.process)) {
122637
+ return function() {
122638
+ };
122639
+ }
122640
+ assert2.equal(typeof cb, "function", "a callback must be provided for exit handler");
122641
+ if (loaded === false) {
122642
+ load();
122643
+ }
122644
+ var ev = "exit";
122645
+ if (opts && opts.alwaysLast) {
122646
+ ev = "afterexit";
122647
+ }
122648
+ var remove2 = function() {
122649
+ emitter.removeListener(ev, cb);
122650
+ if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
122651
+ unload();
122652
+ }
122653
+ };
122654
+ emitter.on(ev, cb);
122655
+ return remove2;
122656
+ };
122657
+ var unload = function unload2() {
122658
+ if (!loaded || !processOk(commonjsGlobal.process)) {
122659
+ return;
122660
+ }
122661
+ loaded = false;
122662
+ signals2.forEach(function(sig) {
122663
+ try {
122664
+ process2.removeListener(sig, sigListeners[sig]);
122665
+ } catch (er2) {
122666
+ }
122667
+ });
122668
+ process2.emit = originalProcessEmit;
122669
+ process2.reallyExit = originalProcessReallyExit;
122670
+ emitter.count -= 1;
122671
+ };
122672
+ signalExit.exports.unload = unload;
122673
+ var emit = function emit2(event, code2, signal) {
122674
+ if (emitter.emitted[event]) {
122675
+ return;
122676
+ }
122677
+ emitter.emitted[event] = true;
122678
+ emitter.emit(event, code2, signal);
122679
+ };
122680
+ var sigListeners = {};
122681
+ signals2.forEach(function(sig) {
122682
+ sigListeners[sig] = function listener() {
122683
+ if (!processOk(commonjsGlobal.process)) {
122684
+ return;
122685
+ }
122686
+ var listeners = process2.listeners(sig);
122687
+ if (listeners.length === emitter.count) {
122688
+ unload();
122689
+ emit("exit", null, sig);
122690
+ emit("afterexit", null, sig);
122691
+ if (isWin && sig === "SIGHUP") {
122692
+ sig = "SIGINT";
122693
+ }
122694
+ process2.kill(process2.pid, sig);
122695
+ }
122696
+ };
122697
+ });
122698
+ signalExit.exports.signals = function() {
122699
+ return signals2;
122700
+ };
122701
+ var loaded = false;
122702
+ var load = function load2() {
122703
+ if (loaded || !processOk(commonjsGlobal.process)) {
122704
+ return;
122705
+ }
122706
+ loaded = true;
122707
+ emitter.count += 1;
122708
+ signals2 = signals2.filter(function(sig) {
122709
+ try {
122710
+ process2.on(sig, sigListeners[sig]);
122711
+ return true;
122712
+ } catch (er2) {
122713
+ return false;
122714
+ }
122715
+ });
122716
+ process2.emit = processEmit;
122717
+ process2.reallyExit = processReallyExit;
122718
+ };
122719
+ signalExit.exports.load = load;
122720
+ var originalProcessReallyExit = process2.reallyExit;
122721
+ var processReallyExit = function processReallyExit2(code2) {
122722
+ if (!processOk(commonjsGlobal.process)) {
122723
+ return;
122724
+ }
122725
+ process2.exitCode = code2 || /* istanbul ignore next */
122726
+ 0;
122727
+ emit("exit", process2.exitCode, null);
122728
+ emit("afterexit", process2.exitCode, null);
122729
+ originalProcessReallyExit.call(process2, process2.exitCode);
122730
+ };
122731
+ var originalProcessEmit = process2.emit;
122732
+ var processEmit = function processEmit2(ev, arg) {
122733
+ if (ev === "exit" && processOk(commonjsGlobal.process)) {
122734
+ if (arg !== void 0) {
122735
+ process2.exitCode = arg;
122736
+ }
122737
+ var ret = originalProcessEmit.apply(this, arguments);
122738
+ emit("exit", process2.exitCode, null);
122739
+ emit("afterexit", process2.exitCode, null);
122740
+ return ret;
122741
+ } else {
122742
+ return originalProcessEmit.apply(this, arguments);
122743
+ }
122744
+ };
122745
+ }
122746
+ return signalExit.exports;
122747
+ }
122748
+ var mtimePrecision = {};
122749
+ var hasRequiredMtimePrecision;
122750
+ function requireMtimePrecision() {
122751
+ if (hasRequiredMtimePrecision) return mtimePrecision;
122752
+ hasRequiredMtimePrecision = 1;
122753
+ const cacheSymbol = Symbol();
122754
+ function probe(file2, fs2, callback) {
122755
+ const cachedPrecision = fs2[cacheSymbol];
122756
+ if (cachedPrecision) {
122757
+ return fs2.stat(file2, (err, stat) => {
122758
+ if (err) {
122759
+ return callback(err);
122760
+ }
122761
+ callback(null, stat.mtime, cachedPrecision);
122762
+ });
122763
+ }
122764
+ const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
122765
+ fs2.utimes(file2, mtime, mtime, (err) => {
122766
+ if (err) {
122767
+ return callback(err);
122768
+ }
122769
+ fs2.stat(file2, (err2, stat) => {
122770
+ if (err2) {
122771
+ return callback(err2);
122772
+ }
122773
+ const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
122774
+ Object.defineProperty(fs2, cacheSymbol, { value: precision });
122775
+ callback(null, stat.mtime, precision);
122776
+ });
122777
+ });
122778
+ }
122779
+ function getMtime(precision) {
122780
+ let now2 = Date.now();
122781
+ if (precision === "s") {
122782
+ now2 = Math.ceil(now2 / 1e3) * 1e3;
122783
+ }
122784
+ return new Date(now2);
122785
+ }
122786
+ mtimePrecision.probe = probe;
122787
+ mtimePrecision.getMtime = getMtime;
122788
+ return mtimePrecision;
122789
+ }
122790
+ var hasRequiredLockfile;
122791
+ function requireLockfile() {
122792
+ if (hasRequiredLockfile) return lockfile;
122793
+ hasRequiredLockfile = 1;
122794
+ const path2 = path__default;
122795
+ const fs2 = requireGracefulFs();
122796
+ const retry2 = requireRetry();
122797
+ const onExit = requireSignalExit();
122798
+ const mtimePrecision2 = requireMtimePrecision();
122799
+ const locks = {};
122800
+ function getLockFile(file2, options) {
122801
+ return options.lockfilePath || `${file2}.lock`;
122802
+ }
122803
+ function resolveCanonicalPath(file2, options, callback) {
122804
+ if (!options.realpath) {
122805
+ return callback(null, path2.resolve(file2));
122806
+ }
122807
+ options.fs.realpath(file2, callback);
122808
+ }
122809
+ function acquireLock(file2, options, callback) {
122810
+ const lockfilePath = getLockFile(file2, options);
122811
+ options.fs.mkdir(lockfilePath, (err) => {
122812
+ if (!err) {
122813
+ return mtimePrecision2.probe(lockfilePath, options.fs, (err2, mtime, mtimePrecision3) => {
122814
+ if (err2) {
122815
+ options.fs.rmdir(lockfilePath, () => {
122816
+ });
122817
+ return callback(err2);
122818
+ }
122819
+ callback(null, mtime, mtimePrecision3);
122820
+ });
122821
+ }
122822
+ if (err.code !== "EEXIST") {
122823
+ return callback(err);
122824
+ }
122825
+ if (options.stale <= 0) {
122826
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file2 }));
122827
+ }
122828
+ options.fs.stat(lockfilePath, (err2, stat) => {
122829
+ if (err2) {
122830
+ if (err2.code === "ENOENT") {
122831
+ return acquireLock(file2, { ...options, stale: 0 }, callback);
122832
+ }
122833
+ return callback(err2);
122834
+ }
122835
+ if (!isLockStale(stat, options)) {
122836
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file2 }));
122837
+ }
122838
+ removeLock(file2, options, (err3) => {
122839
+ if (err3) {
122840
+ return callback(err3);
122841
+ }
122842
+ acquireLock(file2, { ...options, stale: 0 }, callback);
122843
+ });
122844
+ });
122845
+ });
122846
+ }
122847
+ function isLockStale(stat, options) {
122848
+ return stat.mtime.getTime() < Date.now() - options.stale;
122849
+ }
122850
+ function removeLock(file2, options, callback) {
122851
+ options.fs.rmdir(getLockFile(file2, options), (err) => {
122852
+ if (err && err.code !== "ENOENT") {
122853
+ return callback(err);
122854
+ }
122855
+ callback();
122856
+ });
122857
+ }
122858
+ function updateLock(file2, options) {
122859
+ const lock2 = locks[file2];
122860
+ if (lock2.updateTimeout) {
122861
+ return;
122862
+ }
122863
+ lock2.updateDelay = lock2.updateDelay || options.update;
122864
+ lock2.updateTimeout = setTimeout(() => {
122865
+ lock2.updateTimeout = null;
122866
+ options.fs.stat(lock2.lockfilePath, (err, stat) => {
122867
+ const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
122868
+ if (err) {
122869
+ if (err.code === "ENOENT" || isOverThreshold) {
122870
+ return setLockAsCompromised(file2, lock2, Object.assign(err, { code: "ECOMPROMISED" }));
122871
+ }
122872
+ lock2.updateDelay = 1e3;
122873
+ return updateLock(file2, options);
122874
+ }
122875
+ const isMtimeOurs = lock2.mtime.getTime() === stat.mtime.getTime();
122876
+ if (!isMtimeOurs) {
122877
+ return setLockAsCompromised(
122878
+ file2,
122879
+ lock2,
122880
+ Object.assign(
122881
+ new Error("Unable to update lock within the stale threshold"),
122882
+ { code: "ECOMPROMISED" }
122883
+ )
122884
+ );
122885
+ }
122886
+ const mtime = mtimePrecision2.getMtime(lock2.mtimePrecision);
122887
+ options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err2) => {
122888
+ const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
122889
+ if (lock2.released) {
122890
+ return;
122891
+ }
122892
+ if (err2) {
122893
+ if (err2.code === "ENOENT" || isOverThreshold2) {
122894
+ return setLockAsCompromised(file2, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
122895
+ }
122896
+ lock2.updateDelay = 1e3;
122897
+ return updateLock(file2, options);
122898
+ }
122899
+ lock2.mtime = mtime;
122900
+ lock2.lastUpdate = Date.now();
122901
+ lock2.updateDelay = null;
122902
+ updateLock(file2, options);
122903
+ });
122904
+ });
122905
+ }, lock2.updateDelay);
122906
+ if (lock2.updateTimeout.unref) {
122907
+ lock2.updateTimeout.unref();
122908
+ }
122909
+ }
122910
+ function setLockAsCompromised(file2, lock2, err) {
122911
+ lock2.released = true;
122912
+ if (lock2.updateTimeout) {
122913
+ clearTimeout(lock2.updateTimeout);
122914
+ }
122915
+ if (locks[file2] === lock2) {
122916
+ delete locks[file2];
122917
+ }
122918
+ lock2.options.onCompromised(err);
122919
+ }
122920
+ function lock(file2, options, callback) {
122921
+ options = {
122922
+ stale: 1e4,
122923
+ update: null,
122924
+ realpath: true,
122925
+ retries: 0,
122926
+ fs: fs2,
122927
+ onCompromised: (err) => {
122928
+ throw err;
122929
+ },
122930
+ ...options
122931
+ };
122932
+ options.retries = options.retries || 0;
122933
+ options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
122934
+ options.stale = Math.max(options.stale || 0, 2e3);
122935
+ options.update = options.update == null ? options.stale / 2 : options.update || 0;
122936
+ options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
122937
+ resolveCanonicalPath(file2, options, (err, file3) => {
122938
+ if (err) {
122939
+ return callback(err);
122940
+ }
122941
+ const operation = retry2.operation(options.retries);
122942
+ operation.attempt(() => {
122943
+ acquireLock(file3, options, (err2, mtime, mtimePrecision3) => {
122944
+ if (operation.retry(err2)) {
122945
+ return;
122946
+ }
122947
+ if (err2) {
122948
+ return callback(operation.mainError());
122949
+ }
122950
+ const lock2 = locks[file3] = {
122951
+ lockfilePath: getLockFile(file3, options),
122952
+ mtime,
122953
+ mtimePrecision: mtimePrecision3,
122954
+ options,
122955
+ lastUpdate: Date.now()
122956
+ };
122957
+ updateLock(file3, options);
122958
+ callback(null, (releasedCallback) => {
122959
+ if (lock2.released) {
122960
+ return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
122961
+ }
122962
+ unlock(file3, { ...options, realpath: false }, releasedCallback);
122963
+ });
122964
+ });
122965
+ });
122966
+ });
122967
+ }
122968
+ function unlock(file2, options, callback) {
122969
+ options = {
122970
+ fs: fs2,
122971
+ realpath: true,
122972
+ ...options
122973
+ };
122974
+ resolveCanonicalPath(file2, options, (err, file3) => {
122975
+ if (err) {
122976
+ return callback(err);
122977
+ }
122978
+ const lock2 = locks[file3];
122979
+ if (!lock2) {
122980
+ return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
122981
+ }
122982
+ lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
122983
+ lock2.released = true;
122984
+ delete locks[file3];
122985
+ removeLock(file3, options, callback);
122986
+ });
122987
+ }
122988
+ function check2(file2, options, callback) {
122989
+ options = {
122990
+ stale: 1e4,
122991
+ realpath: true,
122992
+ fs: fs2,
122993
+ ...options
122994
+ };
122995
+ options.stale = Math.max(options.stale || 0, 2e3);
122996
+ resolveCanonicalPath(file2, options, (err, file3) => {
122997
+ if (err) {
122998
+ return callback(err);
122999
+ }
123000
+ options.fs.stat(getLockFile(file3, options), (err2, stat) => {
123001
+ if (err2) {
123002
+ return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
123003
+ }
123004
+ return callback(null, !isLockStale(stat, options));
123005
+ });
123006
+ });
123007
+ }
123008
+ function getLocks() {
123009
+ return locks;
123010
+ }
123011
+ onExit(() => {
123012
+ for (const file2 in locks) {
123013
+ const options = locks[file2].options;
123014
+ try {
123015
+ options.fs.rmdirSync(getLockFile(file2, options));
123016
+ } catch (e) {
123017
+ }
123018
+ }
123019
+ });
123020
+ lockfile.lock = lock;
123021
+ lockfile.unlock = unlock;
123022
+ lockfile.check = check2;
123023
+ lockfile.getLocks = getLocks;
123024
+ return lockfile;
123025
+ }
123026
+ var adapter;
123027
+ var hasRequiredAdapter;
123028
+ function requireAdapter() {
123029
+ if (hasRequiredAdapter) return adapter;
123030
+ hasRequiredAdapter = 1;
123031
+ const fs2 = requireGracefulFs();
123032
+ function createSyncFs(fs3) {
123033
+ const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
123034
+ const newFs = { ...fs3 };
123035
+ methods.forEach((method) => {
123036
+ newFs[method] = (...args) => {
123037
+ const callback = args.pop();
123038
+ let ret;
123039
+ try {
123040
+ ret = fs3[`${method}Sync`](...args);
123041
+ } catch (err) {
123042
+ return callback(err);
123043
+ }
123044
+ callback(null, ret);
123045
+ };
123046
+ });
123047
+ return newFs;
123048
+ }
123049
+ function toPromise(method) {
123050
+ return (...args) => new Promise((resolve2, reject) => {
123051
+ args.push((err, result) => {
123052
+ if (err) {
123053
+ reject(err);
123054
+ } else {
123055
+ resolve2(result);
123056
+ }
123057
+ });
123058
+ method(...args);
123059
+ });
123060
+ }
123061
+ function toSync(method) {
123062
+ return (...args) => {
123063
+ let err;
123064
+ let result;
123065
+ args.push((_err, _result) => {
123066
+ err = _err;
123067
+ result = _result;
123068
+ });
123069
+ method(...args);
123070
+ if (err) {
123071
+ throw err;
123072
+ }
123073
+ return result;
123074
+ };
123075
+ }
123076
+ function toSyncOptions(options) {
123077
+ options = { ...options };
123078
+ options.fs = createSyncFs(options.fs || fs2);
123079
+ if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
123080
+ throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
123081
+ }
123082
+ return options;
123083
+ }
123084
+ adapter = {
123085
+ toPromise,
123086
+ toSync,
123087
+ toSyncOptions
123088
+ };
123089
+ return adapter;
123090
+ }
123091
+ var hasRequiredProperLockfile;
123092
+ function requireProperLockfile() {
123093
+ if (hasRequiredProperLockfile) return properLockfile.exports;
123094
+ hasRequiredProperLockfile = 1;
123095
+ const lockfile2 = requireLockfile();
123096
+ const { toPromise, toSync, toSyncOptions } = requireAdapter();
123097
+ async function lock(file2, options) {
123098
+ const release = await toPromise(lockfile2.lock)(file2, options);
123099
+ return toPromise(release);
123100
+ }
123101
+ function lockSync(file2, options) {
123102
+ const release = toSync(lockfile2.lock)(file2, toSyncOptions(options));
123103
+ return toSync(release);
123104
+ }
123105
+ function unlock(file2, options) {
123106
+ return toPromise(lockfile2.unlock)(file2, options);
123107
+ }
123108
+ function unlockSync(file2, options) {
123109
+ return toSync(lockfile2.unlock)(file2, toSyncOptions(options));
123110
+ }
123111
+ function check2(file2, options) {
123112
+ return toPromise(lockfile2.check)(file2, options);
123113
+ }
123114
+ function checkSync(file2, options) {
123115
+ return toSync(lockfile2.check)(file2, toSyncOptions(options));
123116
+ }
123117
+ properLockfile.exports = lock;
123118
+ properLockfile.exports.lock = lock;
123119
+ properLockfile.exports.unlock = unlock;
123120
+ properLockfile.exports.lockSync = lockSync;
123121
+ properLockfile.exports.unlockSync = unlockSync;
123122
+ properLockfile.exports.check = check2;
123123
+ properLockfile.exports.checkSync = checkSync;
123124
+ return properLockfile.exports;
123125
+ }
123126
+ var properLockfileExports = requireProperLockfile();
121550
123127
  const monotonicUlid = monotonicFactory(() => Math.random());
121551
123128
  const RunStreamsSchema = object$1({
121552
123129
  streams: array$1(string$3())
121553
123130
  });
123131
+ const RUN_STREAMS_LOCK_OPTIONS = {
123132
+ realpath: false,
123133
+ stale: 1e4,
123134
+ retries: { retries: 150, factor: 1, minTimeout: 100, maxTimeout: 100 }
123135
+ };
121554
123136
  const EOF_MARKER = 1;
121555
123137
  function isEofByte(byte) {
121556
123138
  return byte === EOF_MARKER;
@@ -121602,21 +123184,65 @@ function createStreamer$1(basedir, tag) {
121602
123184
  const tagSuffix = tag ? `.${tag}` : "";
121603
123185
  const streamEmitter = new EventEmitter();
121604
123186
  const registeredStreams = /* @__PURE__ */ new Set();
121605
- async function registerStreamForRun(runId, streamName) {
123187
+ const runStreamsLocks = /* @__PURE__ */ new Map();
123188
+ let warnedRunStreamsLockFailure = false;
123189
+ async function readRunStreams(runId) {
123190
+ const data = await readJSONWithFallback(basedir, "streams/runs", runId, RunStreamsSchema, tag);
123191
+ return (data == null ? void 0 : data.streams) ?? [];
123192
+ }
123193
+ async function registerStreamForRun(runId, streamName, { verify = false } = {}) {
121606
123194
  assertSafeEntityId("runId", runId);
121607
123195
  assertSafeEntityId("streamName", streamName);
121608
123196
  const cacheKey = `${runId}:${streamName}`;
121609
123197
  if (registeredStreams.has(cacheKey)) {
121610
- return;
123198
+ if (!verify)
123199
+ return;
123200
+ const listed = await readRunStreams(runId).catch(() => null);
123201
+ if (listed === null || listed.includes(streamName))
123202
+ return;
123203
+ registeredStreams.delete(cacheKey);
121611
123204
  }
121612
123205
  const runStreamsPath = taggedPath(basedir, "streams/runs", runId, tag);
121613
- const existing = await readJSONWithFallback(basedir, "streams/runs", runId, RunStreamsSchema, tag);
121614
- const streams = (existing == null ? void 0 : existing.streams) ?? [];
121615
- if (!streams.includes(streamName)) {
121616
- streams.push(streamName);
121617
- await writeJSON(runStreamsPath, { streams }, { overwrite: true });
123206
+ await withInProcessLock(runStreamsLocks, runStreamsPath, async () => {
123207
+ if (registeredStreams.has(cacheKey))
123208
+ return;
123209
+ if (await addToRunStreams(runStreamsPath, runId, streamName)) {
123210
+ registeredStreams.add(cacheKey);
123211
+ }
123212
+ });
123213
+ }
123214
+ async function addToRunStreams(runStreamsPath, runId, streamName) {
123215
+ await fs$1.mkdir(path$3.dirname(runStreamsPath), { recursive: true });
123216
+ let compromised = false;
123217
+ let release;
123218
+ try {
123219
+ release = await properLockfileExports.lock(runStreamsPath, {
123220
+ ...RUN_STREAMS_LOCK_OPTIONS,
123221
+ // The default handler throws from a timer, which would crash the
123222
+ // process.
123223
+ onCompromised: () => {
123224
+ compromised = true;
123225
+ }
123226
+ });
123227
+ } catch (error2) {
123228
+ if (!warnedRunStreamsLockFailure) {
123229
+ warnedRunStreamsLockFailure = true;
123230
+ console.warn(`[world-local] Could not lock the stream index of run ${runId}; updating it without the lock:`, error2 instanceof Error ? error2.message : error2);
123231
+ }
121618
123232
  }
121619
- registeredStreams.add(cacheKey);
123233
+ try {
123234
+ const streams = await readRunStreams(runId);
123235
+ if (!streams.includes(streamName)) {
123236
+ streams.push(streamName);
123237
+ await writeJSON(runStreamsPath, { streams }, { overwrite: true });
123238
+ }
123239
+ } finally {
123240
+ if (release && !compromised) {
123241
+ await release().catch(() => {
123242
+ });
123243
+ }
123244
+ }
123245
+ return !compromised;
121620
123246
  }
121621
123247
  function toBuffer(chunk) {
121622
123248
  if (typeof chunk === "string") {
@@ -121628,6 +123254,9 @@ function createStreamer$1(basedir, tag) {
121628
123254
  }
121629
123255
  }
121630
123256
  return {
123257
+ clearCache() {
123258
+ registeredStreams.clear();
123259
+ },
121631
123260
  async writeToStream(name2, _runId, chunk) {
121632
123261
  const chunkId = `chnk_${monotonicUlid()}`;
121633
123262
  const runId = await _runId;
@@ -121678,15 +123307,14 @@ function createStreamer$1(basedir, tag) {
121678
123307
  async closeStream(name2, _runId) {
121679
123308
  const chunkId = `chnk_${monotonicUlid()}`;
121680
123309
  const runId = await _runId;
121681
- await registerStreamForRun(runId, name2);
123310
+ await registerStreamForRun(runId, name2, { verify: true });
121682
123311
  const chunkPath = path$3.join(basedir, "streams", "chunks", `${name2}-${chunkId}${tagSuffix}.bin`);
121683
123312
  await write(chunkPath, serializeChunk({ chunk: Buffer.from([]), eof: true }));
121684
123313
  streamEmitter.emit(`close:${name2}`, { streamName: name2 });
121685
123314
  },
121686
123315
  async listStreamsByRunId(runId) {
121687
123316
  assertSafeEntityId("runId", runId);
121688
- const data = await readJSONWithFallback(basedir, "streams/runs", runId, RunStreamsSchema, tag);
121689
- return (data == null ? void 0 : data.streams) ?? [];
123317
+ return readRunStreams(runId);
121690
123318
  },
121691
123319
  async getStreamChunks(name2, _runId, options) {
121692
123320
  const limit = (options == null ? void 0 : options.limit) ?? 100;
@@ -121919,19 +123547,40 @@ function createStreamer$1(basedir, tag) {
121919
123547
  }
121920
123548
  };
121921
123549
  }
123550
+ async function clearTaggedLocks(basedir, tag) {
123551
+ const locksDir = path$3.join(basedir, ".locks");
123552
+ let lockKindEntries;
123553
+ try {
123554
+ lockKindEntries = await promises.readdir(locksDir, { withFileTypes: true });
123555
+ } catch {
123556
+ lockKindEntries = [];
123557
+ }
123558
+ await Promise.all(lockKindEntries.filter((entry2) => entry2.isDirectory()).map(async (entry2) => {
123559
+ const lockKindDir = path$3.join(locksDir, entry2.name);
123560
+ const lockNames = await promises.readdir(lockKindDir).catch(() => []);
123561
+ await Promise.all(lockNames.filter((name2) => name2.endsWith(`.${tag}`)).map((name2) => (
123562
+ // Recursive: a run's staged hook events are a directory.
123563
+ promises.rm(path$3.join(lockKindDir, name2), {
123564
+ recursive: true,
123565
+ force: true
123566
+ })
123567
+ )));
123568
+ }));
123569
+ }
121922
123570
  function createLocalWorld(args) {
121923
123571
  const definedArgs = args ? Object.fromEntries(Object.entries(args).filter(([, value]) => value !== void 0)) : {};
121924
123572
  const mergedConfig = { ...config.value, ...definedArgs };
121925
123573
  const tag = mergedConfig.tag;
121926
123574
  const queue = createQueue$2(mergedConfig);
121927
123575
  const { clearCache: clearStorageCache, ...storage } = createStorage$1(mergedConfig.dataDir, tag);
123576
+ const { clearCache: clearStreamerCache, ...streamer } = createStreamer$1(mergedConfig.dataDir, tag);
121928
123577
  const recoverActiveRuns = resolveRecoverActiveRuns(mergedConfig);
121929
123578
  return {
121930
123579
  specVersion: SPEC_VERSION_CURRENT,
121931
123580
  ...queue,
121932
123581
  ...storage,
121933
123582
  ...instrumentObject$1("world.streams", {
121934
- ...createStreamer$1(mergedConfig.dataDir, tag),
123583
+ ...streamer,
121935
123584
  ...mergedConfig.streamFlushIntervalMs !== void 0 && {
121936
123585
  streamFlushIntervalMs: mergedConfig.streamFlushIntervalMs
121937
123586
  }
@@ -121961,7 +123610,7 @@ function createLocalWorld(args) {
121961
123610
  const basedir = mergedConfig.dataDir;
121962
123611
  const hooksDir = path$3.join(basedir, "hooks");
121963
123612
  const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
121964
- const { HookSchema: HookSchema2 } = await import("./index-Tv6_4f6I.js");
123613
+ const { HookSchema: HookSchema2 } = await import("./index-C1by_z-e.js");
121965
123614
  await Promise.all(taggedHookFiles.map(async (hookFile) => {
121966
123615
  const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
121967
123616
  if (hook == null ? void 0 : hook.token) {
@@ -121982,8 +123631,7 @@ function createLocalWorld(args) {
121982
123631
  const files = await listTaggedFiles(fullDir, tag);
121983
123632
  await Promise.all(files.map((f2) => deleteJSON(path$3.join(fullDir, f2))));
121984
123633
  }));
121985
- await promises.rm(path$3.join(basedir, ".locks"), { recursive: true, force: true }).catch(() => {
121986
- });
123634
+ await clearTaggedLocks(basedir, tag);
121987
123635
  const chunksDir = path$3.join(basedir, "streams", "chunks");
121988
123636
  const taggedBinFiles = await listTaggedFilesByExtension(chunksDir, tag, ".bin");
121989
123637
  await Promise.all(taggedBinFiles.map((f2) => promises.unlink(path$3.join(chunksDir, f2)).catch(() => {
@@ -121994,6 +123642,7 @@ function createLocalWorld(args) {
121994
123642
  await rm(mergedConfig.dataDir, { recursive: true, force: true });
121995
123643
  await initDataDir(mergedConfig.dataDir);
121996
123644
  }
123645
+ clearStreamerCache();
121997
123646
  }
121998
123647
  };
121999
123648
  }
@@ -122155,9 +123804,10 @@ function getEventsRetryAgentOptions() {
122155
123804
  };
122156
123805
  }
122157
123806
  const STREAM_RETRY_OPTIONS = {
122158
- retryAfter: true,
123807
+ maxRetries: 0,
122159
123808
  methods: ["PUT"],
122160
- statusCodes: [429]
123809
+ statusCodes: [],
123810
+ errorCodes: []
122161
123811
  };
122162
123812
  const STREAM_CLOSE_RETRY_OPTIONS = {
122163
123813
  retryAfter: true,
@@ -122487,8 +124137,8 @@ function requireGetVercelOidcToken() {
122487
124137
  }
122488
124138
  try {
122489
124139
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
122490
- await import("./token-util-BzAlruRH.js").then((n) => n.t),
122491
- await import("./token-lgwgo3i8.js").then((n) => n.t)
124140
+ await import("./token-util-BrBJCxub.js").then((n) => n.t),
124141
+ await import("./token-CP9u68ZL.js").then((n) => n.t)
122492
124142
  ]);
122493
124143
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
122494
124144
  await refreshToken(options);
@@ -123054,7 +124704,7 @@ var distExports = requireDist();
123054
124704
  let otelApiPromise = null;
123055
124705
  async function getOtelApi() {
123056
124706
  if (!otelApiPromise) {
123057
- otelApiPromise = import("./index-hBO56emR.js").catch(() => null);
124707
+ otelApiPromise = import("./index-BUlN7QFn.js").catch(() => null);
123058
124708
  }
123059
124709
  return otelApiPromise;
123060
124710
  }
@@ -123113,6 +124763,7 @@ const UrlFull = SemanticConvention("url.full");
123113
124763
  const ServerAddress = SemanticConvention("server.address");
123114
124764
  const ServerPort = SemanticConvention("server.port");
123115
124765
  const HttpResponseStatusCode = SemanticConvention("http.response.status_code");
124766
+ const HttpRequestResendCount = SemanticConvention("http.request.resend_count");
123116
124767
  const ErrorType = SemanticConvention("error.type");
123117
124768
  const WorldParseFormat = SemanticConvention("workflow.world.parse.format");
123118
124769
  const PeerService = SemanticConvention("peer.service");
@@ -123231,7 +124882,10 @@ function parseRetryAfter(value) {
123231
124882
  if (!value)
123232
124883
  return void 0;
123233
124884
  const parsed = parseInt(value, 10);
123234
- return Number.isNaN(parsed) ? void 0 : parsed;
124885
+ if (!Number.isNaN(parsed))
124886
+ return parsed;
124887
+ const date2 = Date.parse(value);
124888
+ return Number.isNaN(date2) ? void 0 : Math.max(0, Math.ceil((date2 - Date.now()) / 1e3));
123235
124889
  }
123236
124890
  function errorForResponse(status, message2, opts = {}) {
123237
124891
  const { retryAfter, code: code2, url: url2, mitigated } = opts;
@@ -123286,17 +124940,80 @@ function httpClientSpanAttributes(args) {
123286
124940
  ...RpcService(peerService)
123287
124941
  };
123288
124942
  }
124943
+ const STREAM_APPEND_MAX_RETRIES = 5;
124944
+ const STREAM_APPEND_CONNECT_ERROR_CODES = /* @__PURE__ */ new Set([
124945
+ "ECONNREFUSED",
124946
+ "ENOTFOUND",
124947
+ "EAI_AGAIN",
124948
+ "UND_ERR_CONNECT_TIMEOUT"
124949
+ ]);
124950
+ const STREAM_APPEND_THROTTLE_BUDGET_MS = 3e4;
124951
+ const STREAM_APPEND_MIN_THROTTLE_WAIT_MS = 1e3;
124952
+ const STREAM_APPEND_DEADLINE_RESERVE_MS = 1e4;
124953
+ function streamAppendDeadlineReserveMs(timeoutMs) {
124954
+ return Math.min(STREAM_APPEND_DEADLINE_RESERVE_MS, timeoutMs / 2);
124955
+ }
124956
+ const sleep$2 = (ms2, signal) => new Promise((resolve2, reject) => {
124957
+ if (signal == null ? void 0 : signal.aborted) {
124958
+ reject(signal.reason);
124959
+ return;
124960
+ }
124961
+ const onAbort = () => {
124962
+ clearTimeout(timer2);
124963
+ reject(signal == null ? void 0 : signal.reason);
124964
+ };
124965
+ const timer2 = setTimeout(() => {
124966
+ signal == null ? void 0 : signal.removeEventListener("abort", onAbort);
124967
+ resolve2();
124968
+ }, ms2);
124969
+ signal == null ? void 0 : signal.addEventListener("abort", onAbort, { once: true });
124970
+ });
124971
+ async function fetchStreamAppend(request2, { signal, deadlineMs, reserveMs = 0, onResend } = {}) {
124972
+ var _a3;
124973
+ const resendFits = (waitMs) => deadlineMs === void 0 || deadlineMs - (Date.now() + waitMs) >= reserveMs;
124974
+ let throttledMs = 0;
124975
+ for (let retry2 = 0; ; retry2++) {
124976
+ if (retry2 > 0)
124977
+ onResend == null ? void 0 : onResend(retry2);
124978
+ let response2;
124979
+ try {
124980
+ response2 = await request2();
124981
+ } catch (error2) {
124982
+ const code2 = getTransientTransportCode(error2);
124983
+ const backoffMs = 500 * 2 ** retry2;
124984
+ if (retry2 === STREAM_APPEND_MAX_RETRIES || !code2 || !STREAM_APPEND_CONNECT_ERROR_CODES.has(code2) || !resendFits(backoffMs)) {
124985
+ throw error2;
124986
+ }
124987
+ console.warn(`[workflow] Stream append connection failed (${code2}); retrying in-process in ${backoffMs / 1e3}s`);
124988
+ await sleep$2(backoffMs, signal);
124989
+ continue;
124990
+ }
124991
+ if (response2.status !== 429 || isFirewallChallenge429(response2.status, response2.headers.get("x-vercel-mitigated")) || retry2 === STREAM_APPEND_MAX_RETRIES) {
124992
+ return response2;
124993
+ }
124994
+ const retryAfter = parseRetryAfter(response2.headers.get("Retry-After"));
124995
+ const waitMs = Math.max(STREAM_APPEND_MIN_THROTTLE_WAIT_MS, (retryAfter ?? 0) * 1e3);
124996
+ if (throttledMs + waitMs > STREAM_APPEND_THROTTLE_BUDGET_MS || !resendFits(waitMs)) {
124997
+ return response2;
124998
+ }
124999
+ throttledMs += waitMs;
125000
+ console.warn(`[workflow] Throttled (429) appending stream chunks; retrying in-process in ${waitMs / 1e3}s${formatVercelDiagnostics(response2.headers)}`);
125001
+ await ((_a3 = response2.body) == null ? void 0 : _a3.cancel().catch(() => {
125002
+ }));
125003
+ await sleep$2(waitMs, signal);
125004
+ }
125005
+ }
123289
125006
  async function instrumentedFetch(opts) {
123290
- const { method, url: url2, headers: headers2, body: body2, dispatcher: dispatcher2, peerService = "workflow-server", timeoutMs = REQUEST_TIMEOUT_MS, signal: callerSignal, injectTraceContext = true, cacheBust = true, logLabel, buildError, onTransportOutcome, deferTransportSuccessUntilBody = false } = opts;
125007
+ const { method, url: url2, headers: headers2, body: body2, dispatcher: dispatcher2, peerService = "workflow-server", timeoutMs = REQUEST_TIMEOUT_MS, signal: callerSignal, retryStreamAppend = false, injectTraceContext = true, cacheBust = true, logLabel, buildError, onTransportOutcome, deferTransportSuccessUntilBody = false } = opts;
123291
125008
  const label = logLabel ?? url2;
123292
125009
  validateHttpUrl(url2);
125010
+ const retryAppend = retryStreamAppend && method === "PUT" && !!dispatcher2;
125011
+ const requestBody = retryAppend && body2 instanceof Uint8Array ? Uint8Array.from(body2) : body2;
123293
125012
  return trace(`http ${method}`, { kind: await getSpanKind("CLIENT") }, async (span) => {
123294
125013
  var _a3, _b2, _c, _d, _e2;
123295
125014
  span == null ? void 0 : span.setAttributes(httpClientSpanAttributes({ method, url: url2, peerService }));
123296
125015
  if (injectTraceContext)
123297
125016
  await injectTraceContextIntoHeaders(headers2);
123298
- if (cacheBust)
123299
- headers2.set("X-Request-Time", Date.now().toString());
123300
125017
  const timeoutSignal = timeoutMs != null ? AbortSignal.timeout(timeoutMs) : void 0;
123301
125018
  const signal = callerSignal && timeoutSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : callerSignal ?? timeoutSignal;
123302
125019
  const nodeAgents = dispatcher2 ? void 0 : getNodeHttpAgents();
@@ -123305,11 +125022,14 @@ async function instrumentedFetch(opts) {
123305
125022
  });
123306
125023
  const start2 = Date.now();
123307
125024
  let response2;
123308
- try {
123309
- response2 = nodeAgents ? await nodeHttpFetch(url2, {
125025
+ const request2 = () => {
125026
+ signal == null ? void 0 : signal.throwIfAborted();
125027
+ if (cacheBust)
125028
+ headers2.set("X-Request-Time", Date.now().toString());
125029
+ return nodeAgents ? nodeHttpFetch(url2, {
123310
125030
  method,
123311
125031
  headers: headers2,
123312
- body: body2,
125032
+ body: requestBody,
123313
125033
  signal,
123314
125034
  agents: nodeAgents,
123315
125035
  // Same per-phase deadlines the undici agents are configured
@@ -123317,14 +125037,22 @@ async function instrumentedFetch(opts) {
123317
125037
  // deadline, and a `timeoutMs: null` caller would have no deadline
123318
125038
  // at all.
123319
125039
  ...getNodeHttpPhaseTimeouts()
123320
- }) : await fetch(url2, {
125040
+ }) : fetch(url2, {
123321
125041
  method,
123322
125042
  headers: headers2,
123323
- body: body2,
125043
+ body: requestBody,
123324
125044
  signal,
123325
125045
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- undici dispatcher type doesn't match @types/node's RequestInit
123326
125046
  dispatcher: dispatcher2
123327
125047
  });
125048
+ };
125049
+ try {
125050
+ response2 = await (retryAppend ? fetchStreamAppend(request2, {
125051
+ signal,
125052
+ deadlineMs: timeoutMs != null ? start2 + timeoutMs : void 0,
125053
+ reserveMs: timeoutMs != null ? streamAppendDeadlineReserveMs(timeoutMs) : void 0,
125054
+ onResend: (count2) => span == null ? void 0 : span.setAttributes({ ...HttpRequestResendCount(count2) })
125055
+ }) : request2());
123328
125056
  } catch (error2) {
123329
125057
  const elapsed = Date.now() - start2;
123330
125058
  onTransportOutcome == null ? void 0 : onTransportOutcome(error2);
@@ -128080,7 +129808,7 @@ var QueueClient = class {
128080
129808
  setApi(this, new ApiClient({ ...options, region }));
128081
129809
  }
128082
129810
  };
128083
- const version = "4.7.6";
129811
+ const version = "4.7.8";
128084
129812
  const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
128085
129813
  const MAX_BODY_PARSE_RETRIES = 2;
128086
129814
  const BODY_PARSE_RETRY_BASE_MS = 100;
@@ -129681,6 +131409,7 @@ async function fetchStreamMutation(url2, init2, operation, config2) {
129681
131409
  // idempotent (unlike chunk appends), so it gets the dispatcher that
129682
131410
  // retries 5xx, which the server's close-barrier protocol depends on.
129683
131411
  dispatcher: operation === "close" ? getStreamCloseDispatcher(config2) : getStreamDispatcher(config2),
131412
+ retryStreamAppend: operation === "write" && !(config2 == null ? void 0 : config2.dispatcher),
129684
131413
  timeoutMs: getStreamMutationTimeoutMs(),
129685
131414
  logLabel: url2.pathname,
129686
131415
  buildError: async (res) => createStreamRequestError(operation, url2, res, await res.text())
@@ -135015,7 +136744,7 @@ class Run {
135015
136744
  throw new WorkflowRunCancelledError(this.runId);
135016
136745
  }
135017
136746
  if (run2.status === "failed") {
135018
- throw new WorkflowRunFailedError(this.runId, run2.error);
136747
+ throw new WorkflowRunFailedError(this.runId, run2.error ?? { message: "Workflow run failed" });
135019
136748
  }
135020
136749
  throw new WorkflowRunNotCompletedError(this.runId, run2.status);
135021
136750
  } catch (error2) {
@@ -157355,10 +159084,10 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
157355
159084
  __proto__: null,
157356
159085
  loader
157357
159086
  }, Symbol.toStringTag, { value: "Module" }));
157358
- const serverManifest = { "entry": { "module": "/assets/entry.client-C_C46bD6.js", "imports": ["/assets/index-BsV8i_Jn.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": true, "module": "/assets/root-C2Eu3fUP.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/mermaid-3ZIDBTTL-B1-N6W83.js"], "css": ["/assets/root-BOS11TzD.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/home": { "id": "routes/home", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/home-BcCTbe4i.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/workflow-graph-viewer-lj3vdGSs.js", "/assets/mermaid-3ZIDBTTL-B1-N6W83.js", "/assets/index-DhdkuKp5.js"], "css": ["/assets/workflow-graph-viewer-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-detail": { "id": "routes/run-detail", "parentId": "root", "path": "run/:runId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-detail-CyImB2zR.js", "imports": ["/assets/index-BsV8i_Jn.js", "/assets/workflow-graph-viewer-lj3vdGSs.js", "/assets/mermaid-3ZIDBTTL-B1-N6W83.js", "/assets/encryption-CVDhlDp_.js", "/assets/index-DhdkuKp5.js"], "css": ["/assets/workflow-graph-viewer-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.rpc": { "id": "routes/api.rpc", "parentId": "root", "path": "api/rpc", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.rpc-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.stream.$streamId": { "id": "routes/api.stream.$streamId", "parentId": "root", "path": "api/stream/:streamId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.stream._streamId-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 } }, "url": "/assets/manifest-f88c7f34.js", "version": "f88c7f34", "sri": void 0 };
159087
+ const serverManifest = { "entry": { "module": "/assets/entry.client-C7XgFTHI.js", "imports": ["/assets/index-BQ-Xa8kF.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-DQQlQnXn.js", "imports": ["/assets/index-BQ-Xa8kF.js", "/assets/mermaid-3ZIDBTTL-DV4S4pTo.js"], "css": ["/assets/root-BOS11TzD.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/home": { "id": "routes/home", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/home-Yy5gk_jJ.js", "imports": ["/assets/index-BQ-Xa8kF.js", "/assets/workflow-graph-viewer-De_-9tJh.js", "/assets/mermaid-3ZIDBTTL-DV4S4pTo.js", "/assets/index-CXBr7N7m.js"], "css": ["/assets/workflow-graph-viewer-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-detail": { "id": "routes/run-detail", "parentId": "root", "path": "run/:runId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-detail-rocfw9Z5.js", "imports": ["/assets/index-BQ-Xa8kF.js", "/assets/workflow-graph-viewer-De_-9tJh.js", "/assets/mermaid-3ZIDBTTL-DV4S4pTo.js", "/assets/encryption-Cu4jq70Y.js", "/assets/index-CXBr7N7m.js"], "css": ["/assets/workflow-graph-viewer-yls6qlc0.css", "/assets/mermaid-3ZIDBTTL-yyHEMZs4.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.rpc": { "id": "routes/api.rpc", "parentId": "root", "path": "api/rpc", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.rpc-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.stream.$streamId": { "id": "routes/api.stream.$streamId", "parentId": "root", "path": "api/stream/:streamId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.stream._streamId-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 } }, "url": "/assets/manifest-e13ef35a.js", "version": "e13ef35a", "sri": void 0 };
157359
159088
  const assetsBuildDirectory = "build/client";
157360
159089
  const basename = "/";
157361
- const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };
159090
+ const future = { "unstable_optimizeDeps": false, "v8_passThroughRequests": false, "v8_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };
157362
159091
  const ssr = true;
157363
159092
  const isSpaMode = false;
157364
159093
  const prerender = [];