@mnemonik/cli 7.109.2 → 7.110.0

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 (104) hide show
  1. package/dist/auth/credentials.js +297 -36
  2. package/dist/auth/index.d.ts +2 -0
  3. package/dist/auth/index.d.ts.map +1 -1
  4. package/dist/auth/index.js +1914 -19
  5. package/dist/auth/index.js.map +1 -1
  6. package/dist/auth/machineName.d.ts +8 -0
  7. package/dist/auth/machineName.d.ts.map +1 -0
  8. package/dist/auth/machineName.js +23 -0
  9. package/dist/auth/machineName.js.map +1 -0
  10. package/dist/consent.d.ts +29 -0
  11. package/dist/consent.d.ts.map +1 -0
  12. package/dist/consent.js +87 -0
  13. package/dist/consent.js.map +1 -0
  14. package/dist/diagnostics.js +301 -40
  15. package/dist/digests.json +102 -90
  16. package/dist/help.d.ts.map +1 -1
  17. package/dist/help.js +59 -44
  18. package/dist/help.js.map +1 -1
  19. package/dist/humanReason.d.ts +8 -0
  20. package/dist/humanReason.d.ts.map +1 -1
  21. package/dist/humanReason.js +44 -16
  22. package/dist/humanReason.js.map +1 -1
  23. package/dist/identity/migrate.js +1835 -44
  24. package/dist/install/hosts.d.ts +2 -0
  25. package/dist/install/hosts.d.ts.map +1 -1
  26. package/dist/install/hosts.js +23 -14
  27. package/dist/install/hosts.js.map +1 -1
  28. package/dist/install/journal.js +124 -11
  29. package/dist/install/journey.d.ts +20 -0
  30. package/dist/install/journey.d.ts.map +1 -1
  31. package/dist/install/journey.js +1913 -82
  32. package/dist/install/journey.js.map +1 -1
  33. package/dist/install/ownership.d.ts.map +1 -1
  34. package/dist/install/ownership.js +1818 -10
  35. package/dist/install/ownership.js.map +1 -1
  36. package/dist/install/transaction.js +1913 -19
  37. package/dist/install/ui.js +1910 -15
  38. package/dist/installation.js +133 -10
  39. package/dist/launcher.js +108 -4
  40. package/dist/output.d.ts +3 -0
  41. package/dist/output.d.ts.map +1 -1
  42. package/dist/output.js +11 -1
  43. package/dist/output.js.map +1 -1
  44. package/dist/preflight.d.ts +5 -0
  45. package/dist/preflight.d.ts.map +1 -1
  46. package/dist/preflight.js +14 -12
  47. package/dist/preflight.js.map +1 -1
  48. package/dist/project/eligibility.js +1917 -22
  49. package/dist/project/records.js +121 -8
  50. package/dist/project.d.ts +15 -0
  51. package/dist/project.d.ts.map +1 -1
  52. package/dist/project.js +229 -15
  53. package/dist/project.js.map +1 -1
  54. package/dist/router.d.ts +2 -0
  55. package/dist/router.d.ts.map +1 -1
  56. package/dist/router.js +2164 -122
  57. package/dist/router.js.map +1 -1
  58. package/dist/runtime/releaseSource.d.ts +6 -0
  59. package/dist/runtime/releaseSource.d.ts.map +1 -1
  60. package/dist/runtime/releaseSource.js +1933 -32
  61. package/dist/runtime/releaseSource.js.map +1 -1
  62. package/dist/runtime/selfUpdate.js +1809 -8
  63. package/dist/runtime/signers.js +28 -9
  64. package/dist/runtime/store.js +18 -6
  65. package/dist/runtime/updateCheck.d.ts +4 -0
  66. package/dist/runtime/updateCheck.d.ts.map +1 -0
  67. package/dist/runtime/updateCheck.js +6695 -0
  68. package/dist/runtime/updateCheck.js.map +1 -0
  69. package/dist/sbom.json +21 -21
  70. package/dist/scanner/control.d.ts +27 -1
  71. package/dist/scanner/control.d.ts.map +1 -1
  72. package/dist/scanner/control.js +207 -36
  73. package/dist/scanner/control.js.map +1 -1
  74. package/dist/scanner/discover.d.ts +5 -0
  75. package/dist/scanner/discover.d.ts.map +1 -1
  76. package/dist/scanner/discover.js +16 -6
  77. package/dist/scanner/discover.js.map +1 -1
  78. package/dist/scanner/enable.d.ts +2 -0
  79. package/dist/scanner/enable.d.ts.map +1 -1
  80. package/dist/scanner/enable.js +152 -14
  81. package/dist/scanner/enable.js.map +1 -1
  82. package/dist/scanner/picker.d.ts.map +1 -1
  83. package/dist/scanner/picker.js +5 -6
  84. package/dist/scanner/picker.js.map +1 -1
  85. package/dist/scanner/service.d.ts +2 -0
  86. package/dist/scanner/service.d.ts.map +1 -1
  87. package/dist/scanner/service.js +279 -54
  88. package/dist/scanner/service.js.map +1 -1
  89. package/dist/scanner/update.d.ts +8 -0
  90. package/dist/scanner/update.d.ts.map +1 -1
  91. package/dist/scanner/update.js +254 -20
  92. package/dist/scanner/update.js.map +1 -1
  93. package/dist/scanner-release.json +35 -30
  94. package/dist/screens/journey.d.ts +6 -1
  95. package/dist/screens/journey.d.ts.map +1 -1
  96. package/dist/screens/journey.js +29 -8
  97. package/dist/screens/journey.js.map +1 -1
  98. package/dist/status.d.ts +21 -0
  99. package/dist/status.d.ts.map +1 -1
  100. package/dist/status.js +1993 -39
  101. package/dist/status.js.map +1 -1
  102. package/dist/vendor/local-setup.js +256 -29
  103. package/dist/vendor/shared/runtimeSigners.js +38 -11
  104. package/package.json +31 -31
package/dist/status.js CHANGED
@@ -5,6 +5,12 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
8
14
  var __esm = (fn, res, err2) => function __init() {
9
15
  if (err2) throw err2[0];
10
16
  try {
@@ -13,7 +19,7 @@ var __esm = (fn, res, err2) => function __init() {
13
19
  throw err2 = [e], e;
14
20
  }
15
21
  };
16
- var __commonJS = (cb, mod) => function __require() {
22
+ var __commonJS = (cb, mod) => function __require2() {
17
23
  try {
18
24
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
25
  } catch (e) {
@@ -496,11 +502,73 @@ var require_ignore = __commonJS({
496
502
  });
497
503
 
498
504
  // packages/shared/dist/runtimeSigners.js
499
- var ttl;
505
+ import { basename, dirname as dirname2, join as join2, resolve, sep, win32 } from "node:path";
506
+ import { execFile, execFileSync } from "node:child_process";
507
+ function windowsCommand(file) {
508
+ const root = process.env.SystemRoot;
509
+ if (!root || !win32.isAbsolute(root))
510
+ throw new Error("acl_system_root_unavailable");
511
+ return win32.join(root, "System32", file);
512
+ }
513
+ function readIdentity(stdout) {
514
+ const match = /^"([^"\r\n]+)","(S-1-(?:\d+-)+\d+)"$/.exec(stdout.trim());
515
+ if (!match?.[1] || !match[2] || stdout.includes("\uFFFD"))
516
+ throw new Error("acl_identity_unavailable");
517
+ return { name: match[1], sid: match[2] };
518
+ }
519
+ function* readWindowsIdentity() {
520
+ const user = readIdentity(yield [windowsCommand("whoami.exe"), identityArgs]);
521
+ if (!ADMINISTRATOR_RID.test(user.sid))
522
+ return user;
523
+ const groups = yield [windowsCommand("whoami.exe"), groupArgs];
524
+ const local = /^"[^"\r\n]*","[^"\r\n]*","S-1-5-113",/m.test(groups);
525
+ return {
526
+ ...user,
527
+ localAdministratorSid: local ? `${user.sid.slice(0, user.sid.lastIndexOf("-"))}-500` : null
528
+ };
529
+ }
530
+ function windowsCurrentAccountSync() {
531
+ if (currentIdentity)
532
+ return currentIdentity;
533
+ const commands = readWindowsIdentity();
534
+ let step = commands.next();
535
+ while (!step.done)
536
+ step = commands.next(hookExecuteSync(...step.value));
537
+ return currentIdentity = step.value;
538
+ }
539
+ function hookInvocation(file, args2) {
540
+ if (win32.basename(file) === "whoami.exe") {
541
+ if ([file, ...args2].some((arg) => /[%!"\r\n]/.test(arg)))
542
+ throw new Error("acl_path_unavailable");
543
+ const command = args2.map((arg) => /^(?:[a-z0-9]+|\/[a-z]+)$/i.test(arg) ? arg : `"${arg}"`).join(" ");
544
+ return [
545
+ windowsCommand("cmd.exe"),
546
+ ["/d", "/v:off", "/s", "/c", `"chcp 65001>nul & "${file}" ${command}"`]
547
+ ];
548
+ }
549
+ if (win32.basename(file) === "cmd.exe")
550
+ return [file, ["/u", ...args2]];
551
+ return [file, args2];
552
+ }
553
+ function hookExecuteSync(file, args2, input) {
554
+ [file, args2] = hookInvocation(file, args2);
555
+ return execFileSync(file, args2, { ...hookOptions(file, args2), input });
556
+ }
557
+ var identityArgs, groupArgs, ADMINISTRATOR_RID, currentIdentity, ttl, hookOptions;
500
558
  var init_runtimeSigners = __esm({
501
559
  "packages/shared/dist/runtimeSigners.js"() {
502
560
  "use strict";
561
+ identityArgs = ["/user", "/fo", "csv", "/nh"];
562
+ groupArgs = ["/groups", "/fo", "csv", "/nh"];
563
+ ADMINISTRATOR_RID = /^S-1-5-21-\d+-\d+-\d+-500$/;
503
564
  ttl = 10 * 6e4;
565
+ hookOptions = (file, args2) => ({
566
+ encoding: args2.includes("/u") ? "utf16le" : "utf8",
567
+ timeout: win32.basename(file) === "powershell.exe" ? 3e4 : 5e3,
568
+ windowsHide: true,
569
+ maxBuffer: 16 * 1024 * 1024,
570
+ windowsVerbatimArguments: win32.basename(file) === "cmd.exe"
571
+ });
504
572
  }
505
573
  });
506
574
 
@@ -533,12 +601,20 @@ var init_repositoryRoot = __esm({
533
601
 
534
602
  // packages/shared/dist/runtimeReader.js
535
603
  import { createHash } from "node:crypto";
536
- var hash;
604
+ var RuntimeError, hash;
537
605
  var init_runtimeReader = __esm({
538
606
  "packages/shared/dist/runtimeReader.js"() {
539
607
  "use strict";
540
608
  init_runtimeSigners();
541
609
  init_runtimeSigners();
610
+ RuntimeError = class extends Error {
611
+ reason;
612
+ constructor(reason) {
613
+ super(reason);
614
+ this.reason = reason;
615
+ this.name = "RuntimeError";
616
+ }
617
+ };
542
618
  hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
543
619
  }
544
620
  });
@@ -547,7 +623,7 @@ var init_runtimeReader = __esm({
547
623
  import { constants } from "node:fs";
548
624
  import { lstat, mkdir, open, readdir, realpath, rename, rm } from "node:fs/promises";
549
625
  import { tmpdir } from "node:os";
550
- import { dirname as dirname2, join as join2, relative } from "node:path";
626
+ import { dirname as dirname3, join as join3, relative } from "node:path";
551
627
  async function readPrivate(path) {
552
628
  const file = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
553
629
  try {
@@ -564,7 +640,7 @@ async function pendingProjectSetup(root) {
564
640
  const results = [];
565
641
  const uid = process.getuid?.() ?? "user";
566
642
  for (const host of ["credit", "cursor", "grok"]) {
567
- const directory = join2(tmpdir(), `mnemonik-${host}-${uid}`);
643
+ const directory = join3(tmpdir(), `mnemonik-${host}-${uid}`);
568
644
  try {
569
645
  const stat2 = await lstat(directory);
570
646
  if (stat2.isSymbolicLink() || !stat2.isDirectory())
@@ -573,9 +649,9 @@ async function pendingProjectSetup(root) {
573
649
  if (!/^[a-f0-9]{64}$/.test(name2))
574
650
  continue;
575
651
  try {
576
- if ((await lstat(join2(directory, name2))).isSymbolicLink())
652
+ if ((await lstat(join3(directory, name2))).isSymbolicLink())
577
653
  continue;
578
- const diagnostic = JSON.parse(await readPrivate(join2(directory, name2, "project-setup.json")));
654
+ const diagnostic = JSON.parse(await readPrivate(join3(directory, name2, "project-setup.json")));
579
655
  if ((diagnostic.rootHash === rootHash || diagnostic.rootHash === null) && ["done", "ACTION_REQUIRED", "failed"].includes(diagnostic.outcome) && typeof diagnostic.action === "string" && diagnostic.action.length < 2e3 && Date.now() - Date.parse(diagnostic.time) < 24 * 60 * 60 * 1e3)
580
656
  results.push(diagnostic);
581
657
  } catch {
@@ -607,12 +683,1593 @@ var init_hookRuntime = __esm({
607
683
  }
608
684
  });
609
685
 
686
+ // node_modules/graceful-fs/polyfills.js
687
+ var require_polyfills = __commonJS({
688
+ "node_modules/graceful-fs/polyfills.js"(exports, module2) {
689
+ var constants2 = __require("constants");
690
+ var origCwd = process.cwd;
691
+ var cwd = null;
692
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
693
+ process.cwd = function() {
694
+ if (!cwd)
695
+ cwd = origCwd.call(process);
696
+ return cwd;
697
+ };
698
+ try {
699
+ process.cwd();
700
+ } catch (er) {
701
+ }
702
+ if (typeof process.chdir === "function") {
703
+ chdir = process.chdir;
704
+ process.chdir = function(d) {
705
+ cwd = null;
706
+ chdir.call(process, d);
707
+ };
708
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
709
+ }
710
+ var chdir;
711
+ module2.exports = patch;
712
+ function patch(fs3) {
713
+ if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
714
+ patchLchmod(fs3);
715
+ }
716
+ if (!fs3.lutimes) {
717
+ patchLutimes(fs3);
718
+ }
719
+ fs3.chown = chownFix(fs3.chown);
720
+ fs3.fchown = chownFix(fs3.fchown);
721
+ fs3.lchown = chownFix(fs3.lchown);
722
+ fs3.chmod = chmodFix(fs3.chmod);
723
+ fs3.fchmod = chmodFix(fs3.fchmod);
724
+ fs3.lchmod = chmodFix(fs3.lchmod);
725
+ fs3.chownSync = chownFixSync(fs3.chownSync);
726
+ fs3.fchownSync = chownFixSync(fs3.fchownSync);
727
+ fs3.lchownSync = chownFixSync(fs3.lchownSync);
728
+ fs3.chmodSync = chmodFixSync(fs3.chmodSync);
729
+ fs3.fchmodSync = chmodFixSync(fs3.fchmodSync);
730
+ fs3.lchmodSync = chmodFixSync(fs3.lchmodSync);
731
+ fs3.stat = statFix(fs3.stat);
732
+ fs3.fstat = statFix(fs3.fstat);
733
+ fs3.lstat = statFix(fs3.lstat);
734
+ fs3.statSync = statFixSync(fs3.statSync);
735
+ fs3.fstatSync = statFixSync(fs3.fstatSync);
736
+ fs3.lstatSync = statFixSync(fs3.lstatSync);
737
+ if (fs3.chmod && !fs3.lchmod) {
738
+ fs3.lchmod = function(path, mode, cb) {
739
+ if (cb) process.nextTick(cb);
740
+ };
741
+ fs3.lchmodSync = function() {
742
+ };
743
+ }
744
+ if (fs3.chown && !fs3.lchown) {
745
+ fs3.lchown = function(path, uid, gid, cb) {
746
+ if (cb) process.nextTick(cb);
747
+ };
748
+ fs3.lchownSync = function() {
749
+ };
750
+ }
751
+ if (platform === "win32") {
752
+ fs3.rename = typeof fs3.rename !== "function" ? fs3.rename : (function(fs$rename) {
753
+ function rename3(from, to, cb) {
754
+ var start2 = Date.now();
755
+ var backoff = 0;
756
+ fs$rename(from, to, function CB(er) {
757
+ if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start2 < 6e4) {
758
+ setTimeout(function() {
759
+ fs3.stat(to, function(stater, st) {
760
+ if (stater && stater.code === "ENOENT")
761
+ fs$rename(from, to, CB);
762
+ else
763
+ cb(er);
764
+ });
765
+ }, backoff);
766
+ if (backoff < 100)
767
+ backoff += 10;
768
+ return;
769
+ }
770
+ if (cb) cb(er);
771
+ });
772
+ }
773
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename3, fs$rename);
774
+ return rename3;
775
+ })(fs3.rename);
776
+ }
777
+ fs3.read = typeof fs3.read !== "function" ? fs3.read : (function(fs$read) {
778
+ function read(fd, buffer, offset, length, position, callback_) {
779
+ var callback;
780
+ if (callback_ && typeof callback_ === "function") {
781
+ var eagCounter = 0;
782
+ callback = function(er, _, __) {
783
+ if (er && er.code === "EAGAIN" && eagCounter < 10) {
784
+ eagCounter++;
785
+ return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
786
+ }
787
+ callback_.apply(this, arguments);
788
+ };
789
+ }
790
+ return fs$read.call(fs3, fd, buffer, offset, length, position, callback);
791
+ }
792
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
793
+ return read;
794
+ })(fs3.read);
795
+ fs3.readSync = typeof fs3.readSync !== "function" ? fs3.readSync : /* @__PURE__ */ (function(fs$readSync) {
796
+ return function(fd, buffer, offset, length, position) {
797
+ var eagCounter = 0;
798
+ while (true) {
799
+ try {
800
+ return fs$readSync.call(fs3, fd, buffer, offset, length, position);
801
+ } catch (er) {
802
+ if (er.code === "EAGAIN" && eagCounter < 10) {
803
+ eagCounter++;
804
+ continue;
805
+ }
806
+ throw er;
807
+ }
808
+ }
809
+ };
810
+ })(fs3.readSync);
811
+ function patchLchmod(fs4) {
812
+ fs4.lchmod = function(path, mode, callback) {
813
+ fs4.open(
814
+ path,
815
+ constants2.O_WRONLY | constants2.O_SYMLINK,
816
+ mode,
817
+ function(err2, fd) {
818
+ if (err2) {
819
+ if (callback) callback(err2);
820
+ return;
821
+ }
822
+ fs4.fchmod(fd, mode, function(err3) {
823
+ fs4.close(fd, function(err22) {
824
+ if (callback) callback(err3 || err22);
825
+ });
826
+ });
827
+ }
828
+ );
829
+ };
830
+ fs4.lchmodSync = function(path, mode) {
831
+ var fd = fs4.openSync(path, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
832
+ var threw = true;
833
+ var ret;
834
+ try {
835
+ ret = fs4.fchmodSync(fd, mode);
836
+ threw = false;
837
+ } finally {
838
+ if (threw) {
839
+ try {
840
+ fs4.closeSync(fd);
841
+ } catch (er) {
842
+ }
843
+ } else {
844
+ fs4.closeSync(fd);
845
+ }
846
+ }
847
+ return ret;
848
+ };
849
+ }
850
+ function patchLutimes(fs4) {
851
+ if (constants2.hasOwnProperty("O_SYMLINK") && fs4.futimes) {
852
+ fs4.lutimes = function(path, at, mt, cb) {
853
+ fs4.open(path, constants2.O_SYMLINK, function(er, fd) {
854
+ if (er) {
855
+ if (cb) cb(er);
856
+ return;
857
+ }
858
+ fs4.futimes(fd, at, mt, function(er2) {
859
+ fs4.close(fd, function(er22) {
860
+ if (cb) cb(er2 || er22);
861
+ });
862
+ });
863
+ });
864
+ };
865
+ fs4.lutimesSync = function(path, at, mt) {
866
+ var fd = fs4.openSync(path, constants2.O_SYMLINK);
867
+ var ret;
868
+ var threw = true;
869
+ try {
870
+ ret = fs4.futimesSync(fd, at, mt);
871
+ threw = false;
872
+ } finally {
873
+ if (threw) {
874
+ try {
875
+ fs4.closeSync(fd);
876
+ } catch (er) {
877
+ }
878
+ } else {
879
+ fs4.closeSync(fd);
880
+ }
881
+ }
882
+ return ret;
883
+ };
884
+ } else if (fs4.futimes) {
885
+ fs4.lutimes = function(_a, _b, _c, cb) {
886
+ if (cb) process.nextTick(cb);
887
+ };
888
+ fs4.lutimesSync = function() {
889
+ };
890
+ }
891
+ }
892
+ function chmodFix(orig) {
893
+ if (!orig) return orig;
894
+ return function(target, mode, cb) {
895
+ return orig.call(fs3, target, mode, function(er) {
896
+ if (chownErOk(er)) er = null;
897
+ if (cb) cb.apply(this, arguments);
898
+ });
899
+ };
900
+ }
901
+ function chmodFixSync(orig) {
902
+ if (!orig) return orig;
903
+ return function(target, mode) {
904
+ try {
905
+ return orig.call(fs3, target, mode);
906
+ } catch (er) {
907
+ if (!chownErOk(er)) throw er;
908
+ }
909
+ };
910
+ }
911
+ function chownFix(orig) {
912
+ if (!orig) return orig;
913
+ return function(target, uid, gid, cb) {
914
+ return orig.call(fs3, target, uid, gid, function(er) {
915
+ if (chownErOk(er)) er = null;
916
+ if (cb) cb.apply(this, arguments);
917
+ });
918
+ };
919
+ }
920
+ function chownFixSync(orig) {
921
+ if (!orig) return orig;
922
+ return function(target, uid, gid) {
923
+ try {
924
+ return orig.call(fs3, target, uid, gid);
925
+ } catch (er) {
926
+ if (!chownErOk(er)) throw er;
927
+ }
928
+ };
929
+ }
930
+ function statFix(orig) {
931
+ if (!orig) return orig;
932
+ return function(target, options, cb) {
933
+ if (typeof options === "function") {
934
+ cb = options;
935
+ options = null;
936
+ }
937
+ function callback(er, stats) {
938
+ if (stats) {
939
+ if (stats.uid < 0) stats.uid += 4294967296;
940
+ if (stats.gid < 0) stats.gid += 4294967296;
941
+ }
942
+ if (cb) cb.apply(this, arguments);
943
+ }
944
+ return options ? orig.call(fs3, target, options, callback) : orig.call(fs3, target, callback);
945
+ };
946
+ }
947
+ function statFixSync(orig) {
948
+ if (!orig) return orig;
949
+ return function(target, options) {
950
+ var stats = options ? orig.call(fs3, target, options) : orig.call(fs3, target);
951
+ if (stats) {
952
+ if (stats.uid < 0) stats.uid += 4294967296;
953
+ if (stats.gid < 0) stats.gid += 4294967296;
954
+ }
955
+ return stats;
956
+ };
957
+ }
958
+ function chownErOk(er) {
959
+ if (!er)
960
+ return true;
961
+ if (er.code === "ENOSYS")
962
+ return true;
963
+ var nonroot = !process.getuid || process.getuid() !== 0;
964
+ if (nonroot) {
965
+ if (er.code === "EINVAL" || er.code === "EPERM")
966
+ return true;
967
+ }
968
+ return false;
969
+ }
970
+ }
971
+ }
972
+ });
973
+
974
+ // node_modules/graceful-fs/legacy-streams.js
975
+ var require_legacy_streams = __commonJS({
976
+ "node_modules/graceful-fs/legacy-streams.js"(exports, module2) {
977
+ var Stream = __require("stream").Stream;
978
+ module2.exports = legacy;
979
+ function legacy(fs3) {
980
+ return {
981
+ ReadStream,
982
+ WriteStream
983
+ };
984
+ function ReadStream(path, options) {
985
+ if (!(this instanceof ReadStream)) return new ReadStream(path, options);
986
+ Stream.call(this);
987
+ var self = this;
988
+ this.path = path;
989
+ this.fd = null;
990
+ this.readable = true;
991
+ this.paused = false;
992
+ this.flags = "r";
993
+ this.mode = 438;
994
+ this.bufferSize = 64 * 1024;
995
+ options = options || {};
996
+ var keys = Object.keys(options);
997
+ for (var index = 0, length = keys.length; index < length; index++) {
998
+ var key = keys[index];
999
+ this[key] = options[key];
1000
+ }
1001
+ if (this.encoding) this.setEncoding(this.encoding);
1002
+ if (this.start !== void 0) {
1003
+ if ("number" !== typeof this.start) {
1004
+ throw TypeError("start must be a Number");
1005
+ }
1006
+ if (this.end === void 0) {
1007
+ this.end = Infinity;
1008
+ } else if ("number" !== typeof this.end) {
1009
+ throw TypeError("end must be a Number");
1010
+ }
1011
+ if (this.start > this.end) {
1012
+ throw new Error("start must be <= end");
1013
+ }
1014
+ this.pos = this.start;
1015
+ }
1016
+ if (this.fd !== null) {
1017
+ process.nextTick(function() {
1018
+ self._read();
1019
+ });
1020
+ return;
1021
+ }
1022
+ fs3.open(this.path, this.flags, this.mode, function(err2, fd) {
1023
+ if (err2) {
1024
+ self.emit("error", err2);
1025
+ self.readable = false;
1026
+ return;
1027
+ }
1028
+ self.fd = fd;
1029
+ self.emit("open", fd);
1030
+ self._read();
1031
+ });
1032
+ }
1033
+ function WriteStream(path, options) {
1034
+ if (!(this instanceof WriteStream)) return new WriteStream(path, options);
1035
+ Stream.call(this);
1036
+ this.path = path;
1037
+ this.fd = null;
1038
+ this.writable = true;
1039
+ this.flags = "w";
1040
+ this.encoding = "binary";
1041
+ this.mode = 438;
1042
+ this.bytesWritten = 0;
1043
+ options = options || {};
1044
+ var keys = Object.keys(options);
1045
+ for (var index = 0, length = keys.length; index < length; index++) {
1046
+ var key = keys[index];
1047
+ this[key] = options[key];
1048
+ }
1049
+ if (this.start !== void 0) {
1050
+ if ("number" !== typeof this.start) {
1051
+ throw TypeError("start must be a Number");
1052
+ }
1053
+ if (this.start < 0) {
1054
+ throw new Error("start must be >= zero");
1055
+ }
1056
+ this.pos = this.start;
1057
+ }
1058
+ this.busy = false;
1059
+ this._queue = [];
1060
+ if (this.fd === null) {
1061
+ this._open = fs3.open;
1062
+ this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
1063
+ this.flush();
1064
+ }
1065
+ }
1066
+ }
1067
+ }
1068
+ });
1069
+
1070
+ // node_modules/graceful-fs/clone.js
1071
+ var require_clone = __commonJS({
1072
+ "node_modules/graceful-fs/clone.js"(exports, module2) {
1073
+ "use strict";
1074
+ module2.exports = clone;
1075
+ var getPrototypeOf = Object.getPrototypeOf || function(obj) {
1076
+ return obj.__proto__;
1077
+ };
1078
+ function clone(obj) {
1079
+ if (obj === null || typeof obj !== "object")
1080
+ return obj;
1081
+ if (obj instanceof Object)
1082
+ var copy = { __proto__: getPrototypeOf(obj) };
1083
+ else
1084
+ var copy = /* @__PURE__ */ Object.create(null);
1085
+ Object.getOwnPropertyNames(obj).forEach(function(key) {
1086
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
1087
+ });
1088
+ return copy;
1089
+ }
1090
+ }
1091
+ });
1092
+
1093
+ // node_modules/graceful-fs/graceful-fs.js
1094
+ var require_graceful_fs = __commonJS({
1095
+ "node_modules/graceful-fs/graceful-fs.js"(exports, module2) {
1096
+ var fs3 = __require("fs");
1097
+ var polyfills = require_polyfills();
1098
+ var legacy = require_legacy_streams();
1099
+ var clone = require_clone();
1100
+ var util = __require("util");
1101
+ var gracefulQueue;
1102
+ var previousSymbol;
1103
+ if (typeof Symbol === "function" && typeof Symbol.for === "function") {
1104
+ gracefulQueue = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
1105
+ previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
1106
+ } else {
1107
+ gracefulQueue = "___graceful-fs.queue";
1108
+ previousSymbol = "___graceful-fs.previous";
1109
+ }
1110
+ function noop() {
1111
+ }
1112
+ function publishQueue(context, queue2) {
1113
+ Object.defineProperty(context, gracefulQueue, {
1114
+ get: function() {
1115
+ return queue2;
1116
+ }
1117
+ });
1118
+ }
1119
+ var debug2 = noop;
1120
+ if (util.debuglog)
1121
+ debug2 = util.debuglog("gfs4");
1122
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
1123
+ debug2 = function() {
1124
+ var m = util.format.apply(util, arguments);
1125
+ m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
1126
+ console.error(m);
1127
+ };
1128
+ if (!fs3[gracefulQueue]) {
1129
+ queue = global[gracefulQueue] || [];
1130
+ publishQueue(fs3, queue);
1131
+ fs3.close = (function(fs$close) {
1132
+ function close(fd, cb) {
1133
+ return fs$close.call(fs3, fd, function(err2) {
1134
+ if (!err2) {
1135
+ resetQueue();
1136
+ }
1137
+ if (typeof cb === "function")
1138
+ cb.apply(this, arguments);
1139
+ });
1140
+ }
1141
+ Object.defineProperty(close, previousSymbol, {
1142
+ value: fs$close
1143
+ });
1144
+ return close;
1145
+ })(fs3.close);
1146
+ fs3.closeSync = (function(fs$closeSync) {
1147
+ function closeSync(fd) {
1148
+ fs$closeSync.apply(fs3, arguments);
1149
+ resetQueue();
1150
+ }
1151
+ Object.defineProperty(closeSync, previousSymbol, {
1152
+ value: fs$closeSync
1153
+ });
1154
+ return closeSync;
1155
+ })(fs3.closeSync);
1156
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
1157
+ process.on("exit", function() {
1158
+ debug2(fs3[gracefulQueue]);
1159
+ __require("assert").equal(fs3[gracefulQueue].length, 0);
1160
+ });
1161
+ }
1162
+ }
1163
+ var queue;
1164
+ if (!global[gracefulQueue]) {
1165
+ publishQueue(global, fs3[gracefulQueue]);
1166
+ }
1167
+ module2.exports = patch(clone(fs3));
1168
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs3.__patched) {
1169
+ module2.exports = patch(fs3);
1170
+ fs3.__patched = true;
1171
+ }
1172
+ function patch(fs4) {
1173
+ polyfills(fs4);
1174
+ fs4.gracefulify = patch;
1175
+ fs4.createReadStream = createReadStream;
1176
+ fs4.createWriteStream = createWriteStream;
1177
+ var fs$readFile = fs4.readFile;
1178
+ fs4.readFile = readFile3;
1179
+ function readFile3(path, options, cb) {
1180
+ if (typeof options === "function")
1181
+ cb = options, options = null;
1182
+ return go$readFile(path, options, cb);
1183
+ function go$readFile(path2, options2, cb2, startTime) {
1184
+ return fs$readFile(path2, options2, function(err2) {
1185
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1186
+ enqueue([go$readFile, [path2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
1187
+ else {
1188
+ if (typeof cb2 === "function")
1189
+ cb2.apply(this, arguments);
1190
+ }
1191
+ });
1192
+ }
1193
+ }
1194
+ var fs$writeFile = fs4.writeFile;
1195
+ fs4.writeFile = writeFile2;
1196
+ function writeFile2(path, data, options, cb) {
1197
+ if (typeof options === "function")
1198
+ cb = options, options = null;
1199
+ return go$writeFile(path, data, options, cb);
1200
+ function go$writeFile(path2, data2, options2, cb2, startTime) {
1201
+ return fs$writeFile(path2, data2, options2, function(err2) {
1202
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1203
+ enqueue([go$writeFile, [path2, data2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
1204
+ else {
1205
+ if (typeof cb2 === "function")
1206
+ cb2.apply(this, arguments);
1207
+ }
1208
+ });
1209
+ }
1210
+ }
1211
+ var fs$appendFile = fs4.appendFile;
1212
+ if (fs$appendFile)
1213
+ fs4.appendFile = appendFile;
1214
+ function appendFile(path, data, options, cb) {
1215
+ if (typeof options === "function")
1216
+ cb = options, options = null;
1217
+ return go$appendFile(path, data, options, cb);
1218
+ function go$appendFile(path2, data2, options2, cb2, startTime) {
1219
+ return fs$appendFile(path2, data2, options2, function(err2) {
1220
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1221
+ enqueue([go$appendFile, [path2, data2, options2, cb2], err2, startTime || Date.now(), Date.now()]);
1222
+ else {
1223
+ if (typeof cb2 === "function")
1224
+ cb2.apply(this, arguments);
1225
+ }
1226
+ });
1227
+ }
1228
+ }
1229
+ var fs$copyFile = fs4.copyFile;
1230
+ if (fs$copyFile)
1231
+ fs4.copyFile = copyFile;
1232
+ function copyFile(src, dest, flags2, cb) {
1233
+ if (typeof flags2 === "function") {
1234
+ cb = flags2;
1235
+ flags2 = 0;
1236
+ }
1237
+ return go$copyFile(src, dest, flags2, cb);
1238
+ function go$copyFile(src2, dest2, flags3, cb2, startTime) {
1239
+ return fs$copyFile(src2, dest2, flags3, function(err2) {
1240
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1241
+ enqueue([go$copyFile, [src2, dest2, flags3, cb2], err2, startTime || Date.now(), Date.now()]);
1242
+ else {
1243
+ if (typeof cb2 === "function")
1244
+ cb2.apply(this, arguments);
1245
+ }
1246
+ });
1247
+ }
1248
+ }
1249
+ var fs$readdir = fs4.readdir;
1250
+ fs4.readdir = readdir2;
1251
+ var noReaddirOptionVersions = /^v[0-5]\./;
1252
+ function readdir2(path, options, cb) {
1253
+ if (typeof options === "function")
1254
+ cb = options, options = null;
1255
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path2, options2, cb2, startTime) {
1256
+ return fs$readdir(path2, fs$readdirCallback(
1257
+ path2,
1258
+ options2,
1259
+ cb2,
1260
+ startTime
1261
+ ));
1262
+ } : function go$readdir2(path2, options2, cb2, startTime) {
1263
+ return fs$readdir(path2, options2, fs$readdirCallback(
1264
+ path2,
1265
+ options2,
1266
+ cb2,
1267
+ startTime
1268
+ ));
1269
+ };
1270
+ return go$readdir(path, options, cb);
1271
+ function fs$readdirCallback(path2, options2, cb2, startTime) {
1272
+ return function(err2, files) {
1273
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1274
+ enqueue([
1275
+ go$readdir,
1276
+ [path2, options2, cb2],
1277
+ err2,
1278
+ startTime || Date.now(),
1279
+ Date.now()
1280
+ ]);
1281
+ else {
1282
+ if (files && files.sort)
1283
+ files.sort();
1284
+ if (typeof cb2 === "function")
1285
+ cb2.call(this, err2, files);
1286
+ }
1287
+ };
1288
+ }
1289
+ }
1290
+ if (process.version.substr(0, 4) === "v0.8") {
1291
+ var legStreams = legacy(fs4);
1292
+ ReadStream = legStreams.ReadStream;
1293
+ WriteStream = legStreams.WriteStream;
1294
+ }
1295
+ var fs$ReadStream = fs4.ReadStream;
1296
+ if (fs$ReadStream) {
1297
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
1298
+ ReadStream.prototype.open = ReadStream$open;
1299
+ }
1300
+ var fs$WriteStream = fs4.WriteStream;
1301
+ if (fs$WriteStream) {
1302
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
1303
+ WriteStream.prototype.open = WriteStream$open;
1304
+ }
1305
+ Object.defineProperty(fs4, "ReadStream", {
1306
+ get: function() {
1307
+ return ReadStream;
1308
+ },
1309
+ set: function(val) {
1310
+ ReadStream = val;
1311
+ },
1312
+ enumerable: true,
1313
+ configurable: true
1314
+ });
1315
+ Object.defineProperty(fs4, "WriteStream", {
1316
+ get: function() {
1317
+ return WriteStream;
1318
+ },
1319
+ set: function(val) {
1320
+ WriteStream = val;
1321
+ },
1322
+ enumerable: true,
1323
+ configurable: true
1324
+ });
1325
+ var FileReadStream = ReadStream;
1326
+ Object.defineProperty(fs4, "FileReadStream", {
1327
+ get: function() {
1328
+ return FileReadStream;
1329
+ },
1330
+ set: function(val) {
1331
+ FileReadStream = val;
1332
+ },
1333
+ enumerable: true,
1334
+ configurable: true
1335
+ });
1336
+ var FileWriteStream = WriteStream;
1337
+ Object.defineProperty(fs4, "FileWriteStream", {
1338
+ get: function() {
1339
+ return FileWriteStream;
1340
+ },
1341
+ set: function(val) {
1342
+ FileWriteStream = val;
1343
+ },
1344
+ enumerable: true,
1345
+ configurable: true
1346
+ });
1347
+ function ReadStream(path, options) {
1348
+ if (this instanceof ReadStream)
1349
+ return fs$ReadStream.apply(this, arguments), this;
1350
+ else
1351
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
1352
+ }
1353
+ function ReadStream$open() {
1354
+ var that = this;
1355
+ open3(that.path, that.flags, that.mode, function(err2, fd) {
1356
+ if (err2) {
1357
+ if (that.autoClose)
1358
+ that.destroy();
1359
+ that.emit("error", err2);
1360
+ } else {
1361
+ that.fd = fd;
1362
+ that.emit("open", fd);
1363
+ that.read();
1364
+ }
1365
+ });
1366
+ }
1367
+ function WriteStream(path, options) {
1368
+ if (this instanceof WriteStream)
1369
+ return fs$WriteStream.apply(this, arguments), this;
1370
+ else
1371
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
1372
+ }
1373
+ function WriteStream$open() {
1374
+ var that = this;
1375
+ open3(that.path, that.flags, that.mode, function(err2, fd) {
1376
+ if (err2) {
1377
+ that.destroy();
1378
+ that.emit("error", err2);
1379
+ } else {
1380
+ that.fd = fd;
1381
+ that.emit("open", fd);
1382
+ }
1383
+ });
1384
+ }
1385
+ function createReadStream(path, options) {
1386
+ return new fs4.ReadStream(path, options);
1387
+ }
1388
+ function createWriteStream(path, options) {
1389
+ return new fs4.WriteStream(path, options);
1390
+ }
1391
+ var fs$open = fs4.open;
1392
+ fs4.open = open3;
1393
+ function open3(path, flags2, mode, cb) {
1394
+ if (typeof mode === "function")
1395
+ cb = mode, mode = null;
1396
+ return go$open(path, flags2, mode, cb);
1397
+ function go$open(path2, flags3, mode2, cb2, startTime) {
1398
+ return fs$open(path2, flags3, mode2, function(err2, fd) {
1399
+ if (err2 && (err2.code === "EMFILE" || err2.code === "ENFILE"))
1400
+ enqueue([go$open, [path2, flags3, mode2, cb2], err2, startTime || Date.now(), Date.now()]);
1401
+ else {
1402
+ if (typeof cb2 === "function")
1403
+ cb2.apply(this, arguments);
1404
+ }
1405
+ });
1406
+ }
1407
+ }
1408
+ return fs4;
1409
+ }
1410
+ function enqueue(elem) {
1411
+ debug2("ENQUEUE", elem[0].name, elem[1]);
1412
+ fs3[gracefulQueue].push(elem);
1413
+ retry();
1414
+ }
1415
+ var retryTimer;
1416
+ function resetQueue() {
1417
+ var now = Date.now();
1418
+ for (var i2 = 0; i2 < fs3[gracefulQueue].length; ++i2) {
1419
+ if (fs3[gracefulQueue][i2].length > 2) {
1420
+ fs3[gracefulQueue][i2][3] = now;
1421
+ fs3[gracefulQueue][i2][4] = now;
1422
+ }
1423
+ }
1424
+ retry();
1425
+ }
1426
+ function retry() {
1427
+ clearTimeout(retryTimer);
1428
+ retryTimer = void 0;
1429
+ if (fs3[gracefulQueue].length === 0)
1430
+ return;
1431
+ var elem = fs3[gracefulQueue].shift();
1432
+ var fn = elem[0];
1433
+ var args2 = elem[1];
1434
+ var err2 = elem[2];
1435
+ var startTime = elem[3];
1436
+ var lastTime = elem[4];
1437
+ if (startTime === void 0) {
1438
+ debug2("RETRY", fn.name, args2);
1439
+ fn.apply(null, args2);
1440
+ } else if (Date.now() - startTime >= 6e4) {
1441
+ debug2("TIMEOUT", fn.name, args2);
1442
+ var cb = args2.pop();
1443
+ if (typeof cb === "function")
1444
+ cb.call(null, err2);
1445
+ } else {
1446
+ var sinceAttempt = Date.now() - lastTime;
1447
+ var sinceStart = Math.max(lastTime - startTime, 1);
1448
+ var desiredDelay = Math.min(sinceStart * 1.2, 100);
1449
+ if (sinceAttempt >= desiredDelay) {
1450
+ debug2("RETRY", fn.name, args2);
1451
+ fn.apply(null, args2.concat([startTime]));
1452
+ } else {
1453
+ fs3[gracefulQueue].push(elem);
1454
+ }
1455
+ }
1456
+ if (retryTimer === void 0) {
1457
+ retryTimer = setTimeout(retry, 0);
1458
+ }
1459
+ }
1460
+ }
1461
+ });
1462
+
1463
+ // node_modules/retry/lib/retry_operation.js
1464
+ var require_retry_operation = __commonJS({
1465
+ "node_modules/retry/lib/retry_operation.js"(exports, module2) {
1466
+ function RetryOperation(timeouts, options) {
1467
+ if (typeof options === "boolean") {
1468
+ options = { forever: options };
1469
+ }
1470
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
1471
+ this._timeouts = timeouts;
1472
+ this._options = options || {};
1473
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
1474
+ this._fn = null;
1475
+ this._errors = [];
1476
+ this._attempts = 1;
1477
+ this._operationTimeout = null;
1478
+ this._operationTimeoutCb = null;
1479
+ this._timeout = null;
1480
+ this._operationStart = null;
1481
+ if (this._options.forever) {
1482
+ this._cachedTimeouts = this._timeouts.slice(0);
1483
+ }
1484
+ }
1485
+ module2.exports = RetryOperation;
1486
+ RetryOperation.prototype.reset = function() {
1487
+ this._attempts = 1;
1488
+ this._timeouts = this._originalTimeouts;
1489
+ };
1490
+ RetryOperation.prototype.stop = function() {
1491
+ if (this._timeout) {
1492
+ clearTimeout(this._timeout);
1493
+ }
1494
+ this._timeouts = [];
1495
+ this._cachedTimeouts = null;
1496
+ };
1497
+ RetryOperation.prototype.retry = function(err2) {
1498
+ if (this._timeout) {
1499
+ clearTimeout(this._timeout);
1500
+ }
1501
+ if (!err2) {
1502
+ return false;
1503
+ }
1504
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
1505
+ if (err2 && currentTime - this._operationStart >= this._maxRetryTime) {
1506
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
1507
+ return false;
1508
+ }
1509
+ this._errors.push(err2);
1510
+ var timeout = this._timeouts.shift();
1511
+ if (timeout === void 0) {
1512
+ if (this._cachedTimeouts) {
1513
+ this._errors.splice(this._errors.length - 1, this._errors.length);
1514
+ this._timeouts = this._cachedTimeouts.slice(0);
1515
+ timeout = this._timeouts.shift();
1516
+ } else {
1517
+ return false;
1518
+ }
1519
+ }
1520
+ var self = this;
1521
+ var timer = setTimeout(function() {
1522
+ self._attempts++;
1523
+ if (self._operationTimeoutCb) {
1524
+ self._timeout = setTimeout(function() {
1525
+ self._operationTimeoutCb(self._attempts);
1526
+ }, self._operationTimeout);
1527
+ if (self._options.unref) {
1528
+ self._timeout.unref();
1529
+ }
1530
+ }
1531
+ self._fn(self._attempts);
1532
+ }, timeout);
1533
+ if (this._options.unref) {
1534
+ timer.unref();
1535
+ }
1536
+ return true;
1537
+ };
1538
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
1539
+ this._fn = fn;
1540
+ if (timeoutOps) {
1541
+ if (timeoutOps.timeout) {
1542
+ this._operationTimeout = timeoutOps.timeout;
1543
+ }
1544
+ if (timeoutOps.cb) {
1545
+ this._operationTimeoutCb = timeoutOps.cb;
1546
+ }
1547
+ }
1548
+ var self = this;
1549
+ if (this._operationTimeoutCb) {
1550
+ this._timeout = setTimeout(function() {
1551
+ self._operationTimeoutCb();
1552
+ }, self._operationTimeout);
1553
+ }
1554
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
1555
+ this._fn(this._attempts);
1556
+ };
1557
+ RetryOperation.prototype.try = function(fn) {
1558
+ console.log("Using RetryOperation.try() is deprecated");
1559
+ this.attempt(fn);
1560
+ };
1561
+ RetryOperation.prototype.start = function(fn) {
1562
+ console.log("Using RetryOperation.start() is deprecated");
1563
+ this.attempt(fn);
1564
+ };
1565
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
1566
+ RetryOperation.prototype.errors = function() {
1567
+ return this._errors;
1568
+ };
1569
+ RetryOperation.prototype.attempts = function() {
1570
+ return this._attempts;
1571
+ };
1572
+ RetryOperation.prototype.mainError = function() {
1573
+ if (this._errors.length === 0) {
1574
+ return null;
1575
+ }
1576
+ var counts2 = {};
1577
+ var mainError = null;
1578
+ var mainErrorCount = 0;
1579
+ for (var i2 = 0; i2 < this._errors.length; i2++) {
1580
+ var error = this._errors[i2];
1581
+ var message = error.message;
1582
+ var count = (counts2[message] || 0) + 1;
1583
+ counts2[message] = count;
1584
+ if (count >= mainErrorCount) {
1585
+ mainError = error;
1586
+ mainErrorCount = count;
1587
+ }
1588
+ }
1589
+ return mainError;
1590
+ };
1591
+ }
1592
+ });
1593
+
1594
+ // node_modules/retry/lib/retry.js
1595
+ var require_retry = __commonJS({
1596
+ "node_modules/retry/lib/retry.js"(exports) {
1597
+ var RetryOperation = require_retry_operation();
1598
+ exports.operation = function(options) {
1599
+ var timeouts = exports.timeouts(options);
1600
+ return new RetryOperation(timeouts, {
1601
+ forever: options && options.forever,
1602
+ unref: options && options.unref,
1603
+ maxRetryTime: options && options.maxRetryTime
1604
+ });
1605
+ };
1606
+ exports.timeouts = function(options) {
1607
+ if (options instanceof Array) {
1608
+ return [].concat(options);
1609
+ }
1610
+ var opts = {
1611
+ retries: 10,
1612
+ factor: 2,
1613
+ minTimeout: 1 * 1e3,
1614
+ maxTimeout: Infinity,
1615
+ randomize: false
1616
+ };
1617
+ for (var key in options) {
1618
+ opts[key] = options[key];
1619
+ }
1620
+ if (opts.minTimeout > opts.maxTimeout) {
1621
+ throw new Error("minTimeout is greater than maxTimeout");
1622
+ }
1623
+ var timeouts = [];
1624
+ for (var i2 = 0; i2 < opts.retries; i2++) {
1625
+ timeouts.push(this.createTimeout(i2, opts));
1626
+ }
1627
+ if (options && options.forever && !timeouts.length) {
1628
+ timeouts.push(this.createTimeout(i2, opts));
1629
+ }
1630
+ timeouts.sort(function(a, b) {
1631
+ return a - b;
1632
+ });
1633
+ return timeouts;
1634
+ };
1635
+ exports.createTimeout = function(attempt, opts) {
1636
+ var random = opts.randomize ? Math.random() + 1 : 1;
1637
+ var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
1638
+ timeout = Math.min(timeout, opts.maxTimeout);
1639
+ return timeout;
1640
+ };
1641
+ exports.wrap = function(obj, options, methods) {
1642
+ if (options instanceof Array) {
1643
+ methods = options;
1644
+ options = null;
1645
+ }
1646
+ if (!methods) {
1647
+ methods = [];
1648
+ for (var key in obj) {
1649
+ if (typeof obj[key] === "function") {
1650
+ methods.push(key);
1651
+ }
1652
+ }
1653
+ }
1654
+ for (var i2 = 0; i2 < methods.length; i2++) {
1655
+ var method = methods[i2];
1656
+ var original = obj[method];
1657
+ obj[method] = function retryWrapper(original2) {
1658
+ var op = exports.operation(options);
1659
+ var args2 = Array.prototype.slice.call(arguments, 1);
1660
+ var callback = args2.pop();
1661
+ args2.push(function(err2) {
1662
+ if (op.retry(err2)) {
1663
+ return;
1664
+ }
1665
+ if (err2) {
1666
+ arguments[0] = op.mainError();
1667
+ }
1668
+ callback.apply(this, arguments);
1669
+ });
1670
+ op.attempt(function() {
1671
+ original2.apply(obj, args2);
1672
+ });
1673
+ }.bind(obj, original);
1674
+ obj[method].options = options;
1675
+ }
1676
+ };
1677
+ }
1678
+ });
1679
+
1680
+ // node_modules/retry/index.js
1681
+ var require_retry2 = __commonJS({
1682
+ "node_modules/retry/index.js"(exports, module2) {
1683
+ module2.exports = require_retry();
1684
+ }
1685
+ });
1686
+
1687
+ // node_modules/proper-lockfile/node_modules/signal-exit/signals.js
1688
+ var require_signals = __commonJS({
1689
+ "node_modules/proper-lockfile/node_modules/signal-exit/signals.js"(exports, module2) {
1690
+ module2.exports = [
1691
+ "SIGABRT",
1692
+ "SIGALRM",
1693
+ "SIGHUP",
1694
+ "SIGINT",
1695
+ "SIGTERM"
1696
+ ];
1697
+ if (process.platform !== "win32") {
1698
+ module2.exports.push(
1699
+ "SIGVTALRM",
1700
+ "SIGXCPU",
1701
+ "SIGXFSZ",
1702
+ "SIGUSR2",
1703
+ "SIGTRAP",
1704
+ "SIGSYS",
1705
+ "SIGQUIT",
1706
+ "SIGIOT"
1707
+ // should detect profiler and enable/disable accordingly.
1708
+ // see #21
1709
+ // 'SIGPROF'
1710
+ );
1711
+ }
1712
+ if (process.platform === "linux") {
1713
+ module2.exports.push(
1714
+ "SIGIO",
1715
+ "SIGPOLL",
1716
+ "SIGPWR",
1717
+ "SIGSTKFLT",
1718
+ "SIGUNUSED"
1719
+ );
1720
+ }
1721
+ }
1722
+ });
1723
+
1724
+ // node_modules/proper-lockfile/node_modules/signal-exit/index.js
1725
+ var require_signal_exit = __commonJS({
1726
+ "node_modules/proper-lockfile/node_modules/signal-exit/index.js"(exports, module2) {
1727
+ var process2 = global.process;
1728
+ var processOk = function(process3) {
1729
+ 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";
1730
+ };
1731
+ if (!processOk(process2)) {
1732
+ module2.exports = function() {
1733
+ return function() {
1734
+ };
1735
+ };
1736
+ } else {
1737
+ assert = __require("assert");
1738
+ signals = require_signals();
1739
+ isWin = /^win/i.test(process2.platform);
1740
+ EE = __require("events");
1741
+ if (typeof EE !== "function") {
1742
+ EE = EE.EventEmitter;
1743
+ }
1744
+ if (process2.__signal_exit_emitter__) {
1745
+ emitter = process2.__signal_exit_emitter__;
1746
+ } else {
1747
+ emitter = process2.__signal_exit_emitter__ = new EE();
1748
+ emitter.count = 0;
1749
+ emitter.emitted = {};
1750
+ }
1751
+ if (!emitter.infinite) {
1752
+ emitter.setMaxListeners(Infinity);
1753
+ emitter.infinite = true;
1754
+ }
1755
+ module2.exports = function(cb, opts) {
1756
+ if (!processOk(global.process)) {
1757
+ return function() {
1758
+ };
1759
+ }
1760
+ assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
1761
+ if (loaded === false) {
1762
+ load();
1763
+ }
1764
+ var ev = "exit";
1765
+ if (opts && opts.alwaysLast) {
1766
+ ev = "afterexit";
1767
+ }
1768
+ var remove = function() {
1769
+ emitter.removeListener(ev, cb);
1770
+ if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
1771
+ unload();
1772
+ }
1773
+ };
1774
+ emitter.on(ev, cb);
1775
+ return remove;
1776
+ };
1777
+ unload = function unload2() {
1778
+ if (!loaded || !processOk(global.process)) {
1779
+ return;
1780
+ }
1781
+ loaded = false;
1782
+ signals.forEach(function(sig) {
1783
+ try {
1784
+ process2.removeListener(sig, sigListeners[sig]);
1785
+ } catch (er) {
1786
+ }
1787
+ });
1788
+ process2.emit = originalProcessEmit;
1789
+ process2.reallyExit = originalProcessReallyExit;
1790
+ emitter.count -= 1;
1791
+ };
1792
+ module2.exports.unload = unload;
1793
+ emit = function emit2(event, code, signal) {
1794
+ if (emitter.emitted[event]) {
1795
+ return;
1796
+ }
1797
+ emitter.emitted[event] = true;
1798
+ emitter.emit(event, code, signal);
1799
+ };
1800
+ sigListeners = {};
1801
+ signals.forEach(function(sig) {
1802
+ sigListeners[sig] = function listener() {
1803
+ if (!processOk(global.process)) {
1804
+ return;
1805
+ }
1806
+ var listeners = process2.listeners(sig);
1807
+ if (listeners.length === emitter.count) {
1808
+ unload();
1809
+ emit("exit", null, sig);
1810
+ emit("afterexit", null, sig);
1811
+ if (isWin && sig === "SIGHUP") {
1812
+ sig = "SIGINT";
1813
+ }
1814
+ process2.kill(process2.pid, sig);
1815
+ }
1816
+ };
1817
+ });
1818
+ module2.exports.signals = function() {
1819
+ return signals;
1820
+ };
1821
+ loaded = false;
1822
+ load = function load2() {
1823
+ if (loaded || !processOk(global.process)) {
1824
+ return;
1825
+ }
1826
+ loaded = true;
1827
+ emitter.count += 1;
1828
+ signals = signals.filter(function(sig) {
1829
+ try {
1830
+ process2.on(sig, sigListeners[sig]);
1831
+ return true;
1832
+ } catch (er) {
1833
+ return false;
1834
+ }
1835
+ });
1836
+ process2.emit = processEmit;
1837
+ process2.reallyExit = processReallyExit;
1838
+ };
1839
+ module2.exports.load = load;
1840
+ originalProcessReallyExit = process2.reallyExit;
1841
+ processReallyExit = function processReallyExit2(code) {
1842
+ if (!processOk(global.process)) {
1843
+ return;
1844
+ }
1845
+ process2.exitCode = code || /* istanbul ignore next */
1846
+ 0;
1847
+ emit("exit", process2.exitCode, null);
1848
+ emit("afterexit", process2.exitCode, null);
1849
+ originalProcessReallyExit.call(process2, process2.exitCode);
1850
+ };
1851
+ originalProcessEmit = process2.emit;
1852
+ processEmit = function processEmit2(ev, arg) {
1853
+ if (ev === "exit" && processOk(global.process)) {
1854
+ if (arg !== void 0) {
1855
+ process2.exitCode = arg;
1856
+ }
1857
+ var ret = originalProcessEmit.apply(this, arguments);
1858
+ emit("exit", process2.exitCode, null);
1859
+ emit("afterexit", process2.exitCode, null);
1860
+ return ret;
1861
+ } else {
1862
+ return originalProcessEmit.apply(this, arguments);
1863
+ }
1864
+ };
1865
+ }
1866
+ var assert;
1867
+ var signals;
1868
+ var isWin;
1869
+ var EE;
1870
+ var emitter;
1871
+ var unload;
1872
+ var emit;
1873
+ var sigListeners;
1874
+ var loaded;
1875
+ var load;
1876
+ var originalProcessReallyExit;
1877
+ var processReallyExit;
1878
+ var originalProcessEmit;
1879
+ var processEmit;
1880
+ }
1881
+ });
1882
+
1883
+ // node_modules/proper-lockfile/lib/mtime-precision.js
1884
+ var require_mtime_precision = __commonJS({
1885
+ "node_modules/proper-lockfile/lib/mtime-precision.js"(exports, module2) {
1886
+ "use strict";
1887
+ var cacheSymbol = /* @__PURE__ */ Symbol();
1888
+ function probe(file, fs3, callback) {
1889
+ const cachedPrecision = fs3[cacheSymbol];
1890
+ if (cachedPrecision) {
1891
+ return fs3.stat(file, (err2, stat2) => {
1892
+ if (err2) {
1893
+ return callback(err2);
1894
+ }
1895
+ callback(null, stat2.mtime, cachedPrecision);
1896
+ });
1897
+ }
1898
+ const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
1899
+ fs3.utimes(file, mtime, mtime, (err2) => {
1900
+ if (err2) {
1901
+ return callback(err2);
1902
+ }
1903
+ fs3.stat(file, (err3, stat2) => {
1904
+ if (err3) {
1905
+ return callback(err3);
1906
+ }
1907
+ const precision = stat2.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
1908
+ Object.defineProperty(fs3, cacheSymbol, { value: precision });
1909
+ callback(null, stat2.mtime, precision);
1910
+ });
1911
+ });
1912
+ }
1913
+ function getMtime(precision) {
1914
+ let now = Date.now();
1915
+ if (precision === "s") {
1916
+ now = Math.ceil(now / 1e3) * 1e3;
1917
+ }
1918
+ return new Date(now);
1919
+ }
1920
+ module2.exports.probe = probe;
1921
+ module2.exports.getMtime = getMtime;
1922
+ }
1923
+ });
1924
+
1925
+ // node_modules/proper-lockfile/lib/lockfile.js
1926
+ var require_lockfile = __commonJS({
1927
+ "node_modules/proper-lockfile/lib/lockfile.js"(exports, module2) {
1928
+ "use strict";
1929
+ var path = __require("path");
1930
+ var fs3 = require_graceful_fs();
1931
+ var retry = require_retry2();
1932
+ var onExit = require_signal_exit();
1933
+ var mtimePrecision = require_mtime_precision();
1934
+ var locks = {};
1935
+ function getLockFile(file, options) {
1936
+ return options.lockfilePath || `${file}.lock`;
1937
+ }
1938
+ function resolveCanonicalPath(file, options, callback) {
1939
+ if (!options.realpath) {
1940
+ return callback(null, path.resolve(file));
1941
+ }
1942
+ options.fs.realpath(file, callback);
1943
+ }
1944
+ function acquireLock(file, options, callback) {
1945
+ const lockfilePath = getLockFile(file, options);
1946
+ options.fs.mkdir(lockfilePath, (err2) => {
1947
+ if (!err2) {
1948
+ return mtimePrecision.probe(lockfilePath, options.fs, (err3, mtime, mtimePrecision2) => {
1949
+ if (err3) {
1950
+ options.fs.rmdir(lockfilePath, () => {
1951
+ });
1952
+ return callback(err3);
1953
+ }
1954
+ callback(null, mtime, mtimePrecision2);
1955
+ });
1956
+ }
1957
+ if (err2.code !== "EEXIST") {
1958
+ return callback(err2);
1959
+ }
1960
+ if (options.stale <= 0) {
1961
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
1962
+ }
1963
+ options.fs.stat(lockfilePath, (err3, stat2) => {
1964
+ if (err3) {
1965
+ if (err3.code === "ENOENT") {
1966
+ return acquireLock(file, { ...options, stale: 0 }, callback);
1967
+ }
1968
+ return callback(err3);
1969
+ }
1970
+ if (!isLockStale(stat2, options)) {
1971
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file }));
1972
+ }
1973
+ removeLock(file, options, (err4) => {
1974
+ if (err4) {
1975
+ return callback(err4);
1976
+ }
1977
+ acquireLock(file, { ...options, stale: 0 }, callback);
1978
+ });
1979
+ });
1980
+ });
1981
+ }
1982
+ function isLockStale(stat2, options) {
1983
+ return stat2.mtime.getTime() < Date.now() - options.stale;
1984
+ }
1985
+ function removeLock(file, options, callback) {
1986
+ options.fs.rmdir(getLockFile(file, options), (err2) => {
1987
+ if (err2 && err2.code !== "ENOENT") {
1988
+ return callback(err2);
1989
+ }
1990
+ callback();
1991
+ });
1992
+ }
1993
+ function updateLock(file, options) {
1994
+ const lock2 = locks[file];
1995
+ if (lock2.updateTimeout) {
1996
+ return;
1997
+ }
1998
+ lock2.updateDelay = lock2.updateDelay || options.update;
1999
+ lock2.updateTimeout = setTimeout(() => {
2000
+ lock2.updateTimeout = null;
2001
+ options.fs.stat(lock2.lockfilePath, (err2, stat2) => {
2002
+ const isOverThreshold = lock2.lastUpdate + options.stale < Date.now();
2003
+ if (err2) {
2004
+ if (err2.code === "ENOENT" || isOverThreshold) {
2005
+ return setLockAsCompromised(file, lock2, Object.assign(err2, { code: "ECOMPROMISED" }));
2006
+ }
2007
+ lock2.updateDelay = 1e3;
2008
+ return updateLock(file, options);
2009
+ }
2010
+ const isMtimeOurs = lock2.mtime.getTime() === stat2.mtime.getTime();
2011
+ if (!isMtimeOurs) {
2012
+ return setLockAsCompromised(
2013
+ file,
2014
+ lock2,
2015
+ Object.assign(
2016
+ new Error("Unable to update lock within the stale threshold"),
2017
+ { code: "ECOMPROMISED" }
2018
+ )
2019
+ );
2020
+ }
2021
+ const mtime = mtimePrecision.getMtime(lock2.mtimePrecision);
2022
+ options.fs.utimes(lock2.lockfilePath, mtime, mtime, (err3) => {
2023
+ const isOverThreshold2 = lock2.lastUpdate + options.stale < Date.now();
2024
+ if (lock2.released) {
2025
+ return;
2026
+ }
2027
+ if (err3) {
2028
+ if (err3.code === "ENOENT" || isOverThreshold2) {
2029
+ return setLockAsCompromised(file, lock2, Object.assign(err3, { code: "ECOMPROMISED" }));
2030
+ }
2031
+ lock2.updateDelay = 1e3;
2032
+ return updateLock(file, options);
2033
+ }
2034
+ lock2.mtime = mtime;
2035
+ lock2.lastUpdate = Date.now();
2036
+ lock2.updateDelay = null;
2037
+ updateLock(file, options);
2038
+ });
2039
+ });
2040
+ }, lock2.updateDelay);
2041
+ if (lock2.updateTimeout.unref) {
2042
+ lock2.updateTimeout.unref();
2043
+ }
2044
+ }
2045
+ function setLockAsCompromised(file, lock2, err2) {
2046
+ lock2.released = true;
2047
+ if (lock2.updateTimeout) {
2048
+ clearTimeout(lock2.updateTimeout);
2049
+ }
2050
+ if (locks[file] === lock2) {
2051
+ delete locks[file];
2052
+ }
2053
+ lock2.options.onCompromised(err2);
2054
+ }
2055
+ function lock(file, options, callback) {
2056
+ options = {
2057
+ stale: 1e4,
2058
+ update: null,
2059
+ realpath: true,
2060
+ retries: 0,
2061
+ fs: fs3,
2062
+ onCompromised: (err2) => {
2063
+ throw err2;
2064
+ },
2065
+ ...options
2066
+ };
2067
+ options.retries = options.retries || 0;
2068
+ options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
2069
+ options.stale = Math.max(options.stale || 0, 2e3);
2070
+ options.update = options.update == null ? options.stale / 2 : options.update || 0;
2071
+ options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
2072
+ resolveCanonicalPath(file, options, (err2, file2) => {
2073
+ if (err2) {
2074
+ return callback(err2);
2075
+ }
2076
+ const operation = retry.operation(options.retries);
2077
+ operation.attempt(() => {
2078
+ acquireLock(file2, options, (err3, mtime, mtimePrecision2) => {
2079
+ if (operation.retry(err3)) {
2080
+ return;
2081
+ }
2082
+ if (err3) {
2083
+ return callback(operation.mainError());
2084
+ }
2085
+ const lock2 = locks[file2] = {
2086
+ lockfilePath: getLockFile(file2, options),
2087
+ mtime,
2088
+ mtimePrecision: mtimePrecision2,
2089
+ options,
2090
+ lastUpdate: Date.now()
2091
+ };
2092
+ updateLock(file2, options);
2093
+ callback(null, (releasedCallback) => {
2094
+ if (lock2.released) {
2095
+ return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
2096
+ }
2097
+ unlock(file2, { ...options, realpath: false }, releasedCallback);
2098
+ });
2099
+ });
2100
+ });
2101
+ });
2102
+ }
2103
+ function unlock(file, options, callback) {
2104
+ options = {
2105
+ fs: fs3,
2106
+ realpath: true,
2107
+ ...options
2108
+ };
2109
+ resolveCanonicalPath(file, options, (err2, file2) => {
2110
+ if (err2) {
2111
+ return callback(err2);
2112
+ }
2113
+ const lock2 = locks[file2];
2114
+ if (!lock2) {
2115
+ return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
2116
+ }
2117
+ lock2.updateTimeout && clearTimeout(lock2.updateTimeout);
2118
+ lock2.released = true;
2119
+ delete locks[file2];
2120
+ removeLock(file2, options, callback);
2121
+ });
2122
+ }
2123
+ function check(file, options, callback) {
2124
+ options = {
2125
+ stale: 1e4,
2126
+ realpath: true,
2127
+ fs: fs3,
2128
+ ...options
2129
+ };
2130
+ options.stale = Math.max(options.stale || 0, 2e3);
2131
+ resolveCanonicalPath(file, options, (err2, file2) => {
2132
+ if (err2) {
2133
+ return callback(err2);
2134
+ }
2135
+ options.fs.stat(getLockFile(file2, options), (err3, stat2) => {
2136
+ if (err3) {
2137
+ return err3.code === "ENOENT" ? callback(null, false) : callback(err3);
2138
+ }
2139
+ return callback(null, !isLockStale(stat2, options));
2140
+ });
2141
+ });
2142
+ }
2143
+ function getLocks() {
2144
+ return locks;
2145
+ }
2146
+ onExit(() => {
2147
+ for (const file in locks) {
2148
+ const options = locks[file].options;
2149
+ try {
2150
+ options.fs.rmdirSync(getLockFile(file, options));
2151
+ } catch (e) {
2152
+ }
2153
+ }
2154
+ });
2155
+ module2.exports.lock = lock;
2156
+ module2.exports.unlock = unlock;
2157
+ module2.exports.check = check;
2158
+ module2.exports.getLocks = getLocks;
2159
+ }
2160
+ });
2161
+
2162
+ // node_modules/proper-lockfile/lib/adapter.js
2163
+ var require_adapter = __commonJS({
2164
+ "node_modules/proper-lockfile/lib/adapter.js"(exports, module2) {
2165
+ "use strict";
2166
+ var fs3 = require_graceful_fs();
2167
+ function createSyncFs(fs4) {
2168
+ const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
2169
+ const newFs = { ...fs4 };
2170
+ methods.forEach((method) => {
2171
+ newFs[method] = (...args2) => {
2172
+ const callback = args2.pop();
2173
+ let ret;
2174
+ try {
2175
+ ret = fs4[`${method}Sync`](...args2);
2176
+ } catch (err2) {
2177
+ return callback(err2);
2178
+ }
2179
+ callback(null, ret);
2180
+ };
2181
+ });
2182
+ return newFs;
2183
+ }
2184
+ function toPromise(method) {
2185
+ return (...args2) => new Promise((resolve3, reject) => {
2186
+ args2.push((err2, result) => {
2187
+ if (err2) {
2188
+ reject(err2);
2189
+ } else {
2190
+ resolve3(result);
2191
+ }
2192
+ });
2193
+ method(...args2);
2194
+ });
2195
+ }
2196
+ function toSync(method) {
2197
+ return (...args2) => {
2198
+ let err2;
2199
+ let result;
2200
+ args2.push((_err, _result) => {
2201
+ err2 = _err;
2202
+ result = _result;
2203
+ });
2204
+ method(...args2);
2205
+ if (err2) {
2206
+ throw err2;
2207
+ }
2208
+ return result;
2209
+ };
2210
+ }
2211
+ function toSyncOptions(options) {
2212
+ options = { ...options };
2213
+ options.fs = createSyncFs(options.fs || fs3);
2214
+ if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
2215
+ throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
2216
+ }
2217
+ return options;
2218
+ }
2219
+ module2.exports = {
2220
+ toPromise,
2221
+ toSync,
2222
+ toSyncOptions
2223
+ };
2224
+ }
2225
+ });
2226
+
2227
+ // node_modules/proper-lockfile/index.js
2228
+ var require_proper_lockfile = __commonJS({
2229
+ "node_modules/proper-lockfile/index.js"(exports, module2) {
2230
+ "use strict";
2231
+ var lockfile = require_lockfile();
2232
+ var { toPromise, toSync, toSyncOptions } = require_adapter();
2233
+ async function lock(file, options) {
2234
+ const release = await toPromise(lockfile.lock)(file, options);
2235
+ return toPromise(release);
2236
+ }
2237
+ function lockSync(file, options) {
2238
+ const release = toSync(lockfile.lock)(file, toSyncOptions(options));
2239
+ return toSync(release);
2240
+ }
2241
+ function unlock(file, options) {
2242
+ return toPromise(lockfile.unlock)(file, options);
2243
+ }
2244
+ function unlockSync(file, options) {
2245
+ return toSync(lockfile.unlock)(file, toSyncOptions(options));
2246
+ }
2247
+ function check(file, options) {
2248
+ return toPromise(lockfile.check)(file, options);
2249
+ }
2250
+ function checkSync(file, options) {
2251
+ return toSync(lockfile.check)(file, toSyncOptions(options));
2252
+ }
2253
+ module2.exports = lock;
2254
+ module2.exports.lock = lock;
2255
+ module2.exports.unlock = unlock;
2256
+ module2.exports.lockSync = lockSync;
2257
+ module2.exports.unlockSync = unlockSync;
2258
+ module2.exports.check = check;
2259
+ module2.exports.checkSync = checkSync;
2260
+ }
2261
+ });
2262
+
610
2263
  // packages/cli/src/status.ts
611
2264
  import { messageFor as humanMessageFor } from "./humanReason.js";
612
2265
  import { CODEX_TRUST_MESSAGE } from "./humanReason.js";
613
2266
  import { cliCredentialStatus } from "./auth/credentials.js";
614
2267
  import { readOwnership } from "./install/ownership.js";
615
- import { scannerReceipt } from "./scanner/control.js";
2268
+ import {
2269
+ pausedForConsent,
2270
+ resumeAbandonedPause,
2271
+ scannerReceipt
2272
+ } from "./scanner/control.js";
616
2273
  import {
617
2274
  scannerService,
618
2275
  ScannerServiceLimited,
@@ -2127,8 +3784,8 @@ var Language = class _Language {
2127
3784
  if (input instanceof Uint8Array) {
2128
3785
  binary2 = input;
2129
3786
  } else if (globalThis.process?.versions.node) {
2130
- const fs2 = await import("fs/promises");
2131
- binary2 = await fs2.readFile(input);
3787
+ const fs22 = await import("fs/promises");
3788
+ binary2 = await fs22.readFile(input);
2132
3789
  } else {
2133
3790
  const response = await fetch(input);
2134
3791
  if (!response.ok) {
@@ -2230,13 +3887,13 @@ async function Module2(moduleArg = {}) {
2230
3887
  }
2231
3888
  readAsync = /* @__PURE__ */ __name(async (url) => {
2232
3889
  if (isFileURI(url)) {
2233
- return new Promise((resolve2, reject) => {
3890
+ return new Promise((resolve3, reject) => {
2234
3891
  var xhr = new XMLHttpRequest();
2235
3892
  xhr.open("GET", url, true);
2236
3893
  xhr.responseType = "arraybuffer";
2237
3894
  xhr.onload = () => {
2238
3895
  if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
2239
- resolve2(xhr.response);
3896
+ resolve3(xhr.response);
2240
3897
  return;
2241
3898
  }
2242
3899
  reject(xhr.status);
@@ -2432,9 +4089,9 @@ async function Module2(moduleArg = {}) {
2432
4089
  __name(receiveInstantiationResult, "receiveInstantiationResult");
2433
4090
  var info22 = getWasmImports();
2434
4091
  if (Module["instantiateWasm"]) {
2435
- return new Promise((resolve2, reject) => {
4092
+ return new Promise((resolve3, reject) => {
2436
4093
  Module["instantiateWasm"](info22, (mod, inst) => {
2437
- resolve2(receiveInstance(mod, inst));
4094
+ resolve3(receiveInstance(mod, inst));
2438
4095
  });
2439
4096
  });
2440
4097
  }
@@ -3765,8 +5422,8 @@ async function Module2(moduleArg = {}) {
3765
5422
  if (runtimeInitialized) {
3766
5423
  moduleRtn = Module;
3767
5424
  } else {
3768
- moduleRtn = new Promise((resolve2, reject) => {
3769
- readyPromiseResolve = resolve2;
5425
+ moduleRtn = new Promise((resolve3, reject) => {
5426
+ readyPromiseResolve = resolve3;
3770
5427
  readyPromiseReject = reject;
3771
5428
  });
3772
5429
  }
@@ -4905,26 +6562,267 @@ function scannerAttemptHealthy(receipt, attempt, paused = false) {
4905
6562
 
4906
6563
  // packages/local-setup/dist/storage.js
4907
6564
  init_hookRuntime();
4908
- import { homedir } from "node:os";
4909
- import { dirname as dirname3, join as join3, win32, posix } from "node:path";
4910
6565
  init_hookRuntime();
6566
+ import { createHash as createHash2, randomUUID } from "node:crypto";
6567
+ import { execFile as nodeExecFile } from "node:child_process";
6568
+ import fs2 from "node:fs";
6569
+ import { open as open2, rename as rename2, readFile, mkdir as mkdir2, lstat as lstat2, chmod, writeFile, unlink, rmdir } from "node:fs/promises";
6570
+ import { homedir } from "node:os";
6571
+ import { dirname as dirname4, join as join4, win32 as win322, posix } from "node:path";
6572
+ import { setTimeout as delay } from "node:timers/promises";
6573
+ var lockfileKey = /* @__PURE__ */ Symbol.for("mnemonik.proper-lockfile");
6574
+ function sharedLockfile() {
6575
+ const shared = globalThis;
6576
+ return shared[lockfileKey] ??= Promise.resolve().then(() => __toESM(require_proper_lockfile(), 1)).then((module2) => module2.default);
6577
+ }
6578
+ var codeIs = (error, code) => error.code === code;
4911
6579
  function stateDirectory(platform = process.platform, env = process.env, home = homedir()) {
4912
6580
  if (env.MNEMONIK_STATE_DIR)
4913
6581
  return env.MNEMONIK_STATE_DIR;
4914
6582
  if (platform === "win32")
4915
- return win32.join(env.LOCALAPPDATA || win32.join(home, "AppData", "Local"), "Mnemonik");
6583
+ return win322.join(env.LOCALAPPDATA || win322.join(home, "AppData", "Local"), "Mnemonik");
4916
6584
  if (platform === "darwin")
4917
6585
  return posix.join(home, "Library", "Application Support", "Mnemonik");
4918
6586
  return posix.join(env.XDG_STATE_HOME || posix.join(home, ".local", "state"), "mnemonik");
4919
6587
  }
6588
+ async function readBytes(path) {
6589
+ try {
6590
+ if (!(await lstat2(path)).isFile())
6591
+ throw new Error("setup_requires_regular_file");
6592
+ return await readFile(path);
6593
+ } catch (error) {
6594
+ if (codeIs(error, "ENOENT"))
6595
+ return null;
6596
+ throw error;
6597
+ }
6598
+ }
6599
+ async function syncDirectory(path) {
6600
+ if (process.platform === "win32")
6601
+ return;
6602
+ const fd = await open2(path, "r");
6603
+ try {
6604
+ await fd.sync();
6605
+ } finally {
6606
+ await fd.close();
6607
+ }
6608
+ }
6609
+ var windowsCurrentAccount = windowsCurrentAccountSync;
6610
+ async function windowsCurrentUserAcl(path, directory = false, options = {}, created = false) {
6611
+ const username = options.username ?? `*${windowsCurrentAccount().sid}`;
6612
+ const grant = `${username}:${directory ? "(OI)(CI)F" : "F"}`;
6613
+ const execFile2 = options.execFile ?? nodeExecFile;
6614
+ await new Promise((resolve3, reject) => {
6615
+ execFile2("icacls.exe", [
6616
+ path,
6617
+ "/inheritance:r",
6618
+ "/grant:r",
6619
+ grant,
6620
+ ...created ? ["/remove:g", "*S-1-5-32-544", "*S-1-5-18"] : []
6621
+ ], (error) => {
6622
+ if (error)
6623
+ reject(error);
6624
+ else
6625
+ resolve3();
6626
+ });
6627
+ });
6628
+ }
6629
+ async function protectStateFile(path, platform = process.platform, aclOptions) {
6630
+ if (platform === "win32")
6631
+ await windowsCurrentUserAcl(path, false, aclOptions);
6632
+ else
6633
+ await chmod(path, 384);
6634
+ return "private";
6635
+ }
6636
+ async function atomicWrite(path, bytes, fault, assertOwned) {
6637
+ await assertOwned?.();
6638
+ const temp = `${path}.${randomUUID()}.tmp`;
6639
+ const fd = await open2(temp, "wx", 384);
6640
+ let permissionStatus;
6641
+ try {
6642
+ permissionStatus = await protectStateFile(temp);
6643
+ const split = Math.ceil(bytes.length / 2);
6644
+ await fd.writeFile(bytes.subarray(0, split));
6645
+ await fault?.("mid_write");
6646
+ await assertOwned?.();
6647
+ await fd.writeFile(bytes.subarray(split));
6648
+ await fd.sync();
6649
+ } finally {
6650
+ await fd.close();
6651
+ }
6652
+ await assertOwned?.();
6653
+ await rename2(temp, path);
6654
+ await syncDirectory(dirname4(path));
6655
+ return permissionStatus;
6656
+ }
6657
+ async function withLock(path, waitMs, work) {
6658
+ const lockfile = await sharedLockfile();
6659
+ await mkdir2(dirname4(path), { recursive: true, mode: 448 });
6660
+ const generation = randomUUID();
6661
+ const owner = join4(`${path}.lock`, "owner");
6662
+ let compromised = false;
6663
+ let acquired = false;
6664
+ const assertOwned = async () => {
6665
+ if (compromised || (await readBytes(owner).catch(() => null))?.toString() !== generation) {
6666
+ compromised = true;
6667
+ throw new Error("lock_lost");
6668
+ }
6669
+ };
6670
+ const leaseFs = {
6671
+ ...fs2,
6672
+ mkdir: (dir, callback) => {
6673
+ void mkdir2(dir).then(() => writeFile(owner, generation, { mode: 384, flag: "wx" })).then(() => callback(), callback);
6674
+ },
6675
+ rmdir: (dir, callback) => {
6676
+ void unlink(join4(dir, "owner")).catch((error) => {
6677
+ if (!codeIs(error, "ENOENT"))
6678
+ throw error;
6679
+ }).then(() => rmdir(dir)).then(() => callback(), callback);
6680
+ },
6681
+ rmdirSync: (dir) => {
6682
+ try {
6683
+ fs2.unlinkSync(join4(dir, "owner"));
6684
+ } catch (error) {
6685
+ if (!codeIs(error, "ENOENT"))
6686
+ throw error;
6687
+ }
6688
+ fs2.rmdirSync(dir);
6689
+ },
6690
+ stat: (file, callback) => {
6691
+ void (acquired ? assertOwned() : Promise.resolve()).then(() => fs2.stat(file, callback), () => callback(Object.assign(new Error("lock_lost"), { code: "ENOENT" })));
6692
+ }
6693
+ };
6694
+ const deadline = performance.now() + waitMs;
6695
+ let release;
6696
+ while (!release) {
6697
+ try {
6698
+ release = await lockfile.lock(path, {
6699
+ realpath: false,
6700
+ stale: 3e4,
6701
+ update: 5e3,
6702
+ retries: 0,
6703
+ fs: leaseFs,
6704
+ onCompromised: () => {
6705
+ compromised = true;
6706
+ }
6707
+ });
6708
+ } catch (error) {
6709
+ if (!codeIs(error, "ELOCKED"))
6710
+ throw error;
6711
+ if (performance.now() >= deadline)
6712
+ throw new RuntimeError("lock_held");
6713
+ await delay(Math.min(100, Math.max(1, deadline - performance.now())));
6714
+ }
6715
+ }
6716
+ acquired = true;
6717
+ try {
6718
+ return await work(assertOwned);
6719
+ } finally {
6720
+ if (await assertOwned().then(() => true, () => false))
6721
+ await release();
6722
+ }
6723
+ }
6724
+
6725
+ // packages/local-setup/dist/automaticUpdate.js
6726
+ import { spawn as nodeSpawn } from "node:child_process";
6727
+ import { realpathSync } from "node:fs";
6728
+ import { stat as nodeStat, utimes } from "node:fs/promises";
6729
+ import { homedir as homedir2 } from "node:os";
6730
+ import { join as join5 } from "node:path";
6731
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
6732
+ var DAY_MS = 864e5;
6733
+ var statePath = (stateDir) => join5(stateDir, "automatic-update.json");
6734
+ function cliLauncherPath(options = {}) {
6735
+ const platform = options.platform ?? process.platform;
6736
+ const home = options.home ?? homedir2();
6737
+ return platform === "win32" ? join5(options.env?.LOCALAPPDATA || join5(home, "AppData", "Local"), "Mnemonik", "bin", "mnemonik.cmd") : join5(home, ".local", "bin", "mnemonik");
6738
+ }
6739
+ async function readState(path) {
6740
+ const bytes = await readBytes(path);
6741
+ if (!bytes)
6742
+ return {};
6743
+ const value = JSON.parse(bytes.toString());
6744
+ if (!value || typeof value !== "object" || value.lastAttempt !== void 0 && (!Number.isFinite(value.lastAttempt) || value.lastAttempt < 0))
6745
+ throw new Error("automatic_update_state_invalid");
6746
+ return value.lastAttempt === void 0 ? {} : { lastAttempt: value.lastAttempt };
6747
+ }
6748
+ async function maybeStartAutomaticUpdate(options = {}) {
6749
+ const stateDir = options.stateDir ?? stateDirectory(options.platform, options.env, options.home);
6750
+ const path = statePath(stateDir);
6751
+ try {
6752
+ const now = (options.now ?? Date.now)();
6753
+ const stat2 = options.stat ?? nodeStat;
6754
+ try {
6755
+ if (now - (await stat2(path)).mtimeMs < DAY_MS)
6756
+ return false;
6757
+ } catch (error) {
6758
+ if (error.code !== "ENOENT")
6759
+ throw error;
6760
+ }
6761
+ if (!options.spawn && !(await stat2(cliLauncherPath(options))).isFile())
6762
+ return false;
6763
+ return await withLock(path, 0, async (assertOwned) => {
6764
+ const state = await readState(path);
6765
+ if (state.lastAttempt !== void 0 && now - state.lastAttempt < DAY_MS)
6766
+ return false;
6767
+ await atomicWrite(path, Buffer.from(`${JSON.stringify({ lastAttempt: now })}
6768
+ `), void 0, assertOwned);
6769
+ await utimes(path, now / 1e3, now / 1e3);
6770
+ const platform = options.platform ?? process.platform;
6771
+ const launcher = cliLauncherPath(options);
6772
+ const command = platform === "win32" ? {
6773
+ file: options.env?.ComSpec || "cmd.exe",
6774
+ args: ["/d", "/s", "/c", `""${launcher}" update --automatic"`],
6775
+ windowsVerbatimArguments: true
6776
+ } : platform === "linux" && (options.env ?? process.env).INVOCATION_ID ? {
6777
+ // detached creates a process group, not a new systemd cgroup. An
6778
+ // updater spawned by the scanner must survive stopping that service.
6779
+ file: "systemd-run",
6780
+ args: [
6781
+ "--user",
6782
+ "--collect",
6783
+ "--quiet",
6784
+ `--setenv=MNEMONIK_STATE_DIR=${stateDir}`,
6785
+ "--",
6786
+ launcher,
6787
+ "update",
6788
+ "--automatic"
6789
+ ]
6790
+ } : { file: launcher, args: ["update", "--automatic"] };
6791
+ const child = (options.spawn ?? nodeSpawn)(command.file, command.args, {
6792
+ detached: true,
6793
+ stdio: "ignore",
6794
+ windowsHide: true,
6795
+ ..."windowsVerbatimArguments" in command ? { windowsVerbatimArguments: command.windowsVerbatimArguments } : {}
6796
+ });
6797
+ child.once("error", () => {
6798
+ });
6799
+ child.unref();
6800
+ return true;
6801
+ });
6802
+ } catch {
6803
+ return false;
6804
+ }
6805
+ }
6806
+ var HELPER_FLAG = "--mnemonik-automatic-update";
6807
+ function isHelperInvocation() {
6808
+ if (process.argv[2] !== HELPER_FLAG || !process.argv[3] || !process.argv[1])
6809
+ return false;
6810
+ try {
6811
+ return realpathSync(process.argv[1]) === realpathSync(fileURLToPath2(import.meta.url));
6812
+ } catch {
6813
+ return false;
6814
+ }
6815
+ }
6816
+ if (isHelperInvocation())
6817
+ void maybeStartAutomaticUpdate({ stateDir: process.argv[3] });
4920
6818
 
4921
6819
  // packages/local-setup/dist/index.js
4922
6820
  var MAX_ORIGINAL_BYTES = 64 * 1024;
4923
6821
 
4924
6822
  // packages/cli/src/status.ts
4925
- import { readFile, stat } from "node:fs/promises";
4926
- import { join as join4 } from "node:path";
4927
- import { fileURLToPath as fileURLToPath2 } from "node:url";
6823
+ import { readFile as readFile2, stat } from "node:fs/promises";
6824
+ import { join as join6 } from "node:path";
6825
+ import { fileURLToPath as fileURLToPath3 } from "node:url";
4928
6826
 
4929
6827
  // node_modules/smol-toml/dist/date.js
4930
6828
  var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
@@ -5092,7 +6990,7 @@ function skipVoid(ctx, banNewLines, banComments) {
5092
6990
  skipComment(ctx);
5093
6991
  }
5094
6992
  }
5095
- function skipUntil(ctx, sep, end) {
6993
+ function skipUntil(ctx, sep2, end) {
5096
6994
  let ptr = ctx.p;
5097
6995
  if (!end) {
5098
6996
  ptr = indexOfNewline(ctx.s, ptr);
@@ -5103,7 +7001,7 @@ function skipUntil(ctx, sep, end) {
5103
7001
  let c = ctx.s.charCodeAt(ctx.p);
5104
7002
  if (c === 35) {
5105
7003
  skipComment(ctx);
5106
- } else if (c === end || c === sep) {
7004
+ } else if (c === end || c === sep2) {
5107
7005
  return;
5108
7006
  }
5109
7007
  }
@@ -5573,8 +7471,8 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
5573
7471
 
5574
7472
  // packages/cli/src/status.ts
5575
7473
  init_hookRuntime();
5576
- import { devReadiness } from "./runtime/releaseSource.js";
5577
- import { basename, isAbsolute, relative as relative2, resolve } from "node:path";
7474
+ import { devReadiness, expectedScannerDisclosureVersion } from "./runtime/releaseSource.js";
7475
+ import { basename as basename2, isAbsolute, relative as relative2, resolve as resolve2 } from "node:path";
5578
7476
  import { Output } from "./output.js";
5579
7477
  import {
5580
7478
  runProjectCommand
@@ -5604,7 +7502,7 @@ function hookTarget(command) {
5604
7502
  if (typeof parsed === "string") return parsed;
5605
7503
  }
5606
7504
  const token = /^node -e .* -- ([A-Za-z0-9_-]+)(?:\s|$)/u.exec(command)?.[1];
5607
- if (token) return fileURLToPath2(Buffer.from(token, "base64url").toString("utf8"));
7505
+ if (token) return fileURLToPath3(Buffer.from(token, "base64url").toString("utf8"));
5608
7506
  } catch {
5609
7507
  }
5610
7508
  return void 0;
@@ -5612,7 +7510,7 @@ function hookTarget(command) {
5612
7510
  async function localEditorStatus(home) {
5613
7511
  return Promise.all(
5614
7512
  editorFiles.map(async ([host, name2, hooksFile, mcpFile]) => {
5615
- const read = (file) => readFile(join4(home, file), "utf8").catch(
7513
+ const read = (file) => readFile2(join6(home, file), "utf8").catch(
5616
7514
  (error) => error.code === "ENOENT" ? null : ""
5617
7515
  );
5618
7516
  const [hooksRaw, mcpRaw] = await Promise.all([read(hooksFile), read(mcpFile)]);
@@ -5668,7 +7566,7 @@ async function localInstallationConditions(home, stateDir, launcherOptions) {
5668
7566
  (editor) => editor.marked || owned.includes(editor.host)
5669
7567
  );
5670
7568
  if (!editors.length)
5671
- issue("No editor connections were found.", "Run mnemonik install to set them up again.");
7569
+ issue("No coding tool connections were found.", "Run mnemonik install to set them up again.");
5672
7570
  for (const editor of editors) {
5673
7571
  if (!editor.hooks)
5674
7572
  issue(
@@ -5686,7 +7584,7 @@ async function localInstallationConditions(home, stateDir, launcherOptions) {
5686
7584
  return conditions;
5687
7585
  }
5688
7586
  var contains = (parent, child) => {
5689
- const path = relative2(resolve(parent), resolve(child));
7587
+ const path = relative2(resolve2(parent), resolve2(child));
5690
7588
  return path === "" || !path.startsWith("..") && !isAbsolute(path);
5691
7589
  };
5692
7590
  function scannerConditions(installationConditions, projectRoot, scanner) {
@@ -5761,7 +7659,7 @@ function buildStatusDocument(input) {
5761
7659
  kind: "hook_not_verified",
5762
7660
  component: host,
5763
7661
  reason: "hook_not_verified",
5764
- action: "Start a new session in that editor."
7662
+ action: "Start a new session in that coding tool."
5765
7663
  }));
5766
7664
  const installationConditions = [
5767
7665
  ...input.installationConditions,
@@ -5784,7 +7682,7 @@ function buildStatusDocument(input) {
5784
7682
  projects: [
5785
7683
  {
5786
7684
  projectId: project.projectId,
5787
- displayName: basename(project.resolvedRoot),
7685
+ displayName: basename2(project.resolvedRoot),
5788
7686
  repositoryMatch: project.identity,
5789
7687
  identityFile: null,
5790
7688
  summary: { conditions },
@@ -5837,6 +7735,10 @@ ${message.nextStep}`;
5837
7735
  output.line(`${label}: Needs attention.`);
5838
7736
  for (const line of lines) output.line(line);
5839
7737
  }
7738
+ var REPORT_NOT_SENT = {
7739
+ sentence: "The console has not heard from this machine because its sign-in no longer works.",
7740
+ nextStep: humanMessageFor("renew").nextStep
7741
+ };
5840
7742
  function renderStatusSummaries(document, output, options = {}) {
5841
7743
  if (options.diagnostics && document.cliCredential)
5842
7744
  output.line(
@@ -5858,7 +7760,7 @@ function renderStatusSummaries(document, output, options = {}) {
5858
7760
  if (document.installation.state === "READY") output.line("Mnemonik is installed and working.");
5859
7761
  else
5860
7762
  renderAttention("Installation", document.installation, output, rendered, document.conditions);
5861
- const connected = [...new Set(document.scanner?.roots?.map((root) => basename(root)) ?? [])].sort(
7763
+ const connected = [...new Set(document.scanner?.roots?.map((root) => basename2(root)) ?? [])].sort(
5862
7764
  (left, right) => left.toLocaleLowerCase().localeCompare(right.toLocaleLowerCase())
5863
7765
  );
5864
7766
  if (connected.length) {
@@ -5886,6 +7788,24 @@ function refusalLines(batches, withPaths = false) {
5886
7788
  ...withPaths ? [...issues].map((issue) => ` ${issue}`) : []
5887
7789
  ]);
5888
7790
  }
7791
+ function scannerFailureCause(failure) {
7792
+ switch (failure.kind) {
7793
+ case "credential_refused":
7794
+ return "The server refused this computer's indexing sign-in. Run mnemonik repair.";
7795
+ case "push_rejected":
7796
+ return `The server rejected an upload from this computer.${failure.reason ? ` The server said: ${failure.reason}.` : ""}`;
7797
+ case "watcher_error":
7798
+ return `A folder could not be watched.${failure.project ? ` Project: ${failure.project}.` : ""}`;
7799
+ default:
7800
+ return "Background indexing reported a problem.";
7801
+ }
7802
+ }
7803
+ async function renderScannerFailure(stateDir, output) {
7804
+ const failure = (await scannerReceipt(stateDir).catch(() => null))?.snapshot?.failure;
7805
+ if (!failure) return;
7806
+ output.line(scannerFailureCause(failure));
7807
+ output.line(` ${failure.cause}`);
7808
+ }
5889
7809
  async function renderRefusals(stateDir, output, withPaths = false) {
5890
7810
  const receipt = await scannerReceipt(stateDir).catch(() => null);
5891
7811
  for (const line of refusalLines(receipt?.snapshot?.refusedBatches, withPaths)) output.line(line);
@@ -5916,13 +7836,18 @@ async function collectStatusDocument(input) {
5916
7836
  let scannerStatus = await input.scannerStatus?.();
5917
7837
  let scannerHeartbeat;
5918
7838
  let scannerReason;
7839
+ let scannerFailing;
5919
7840
  const restarted = !input.scannerStatus && await scannerService({
5920
7841
  stateDir: statusStateDir,
5921
7842
  ...input.scannerRecovery
5922
7843
  }).recover().catch(() => false);
7844
+ if (!input.scannerStatus && input.abandonedPause && await resumeAbandonedPause({ ...input.abandonedPause, stateDir: statusStateDir }).catch(
7845
+ () => false
7846
+ ))
7847
+ input.abandonedPause.onAbandonedPauseResumed?.();
5923
7848
  const receipt = await scannerReceipt(statusStateDir);
5924
- const attempt = await readFile(
5925
- join4(statusStateDir, "scanner/service-replacement/result.json"),
7849
+ const attempt = await readFile2(
7850
+ join6(statusStateDir, "scanner/service-replacement/result.json"),
5926
7851
  "utf8"
5927
7852
  ).then(
5928
7853
  (text) => JSON.parse(text)
@@ -5937,7 +7862,7 @@ async function collectStatusDocument(input) {
5937
7862
  }
5938
7863
  if (!input.scannerStatus) {
5939
7864
  const state = JSON.parse(
5940
- await readFile(join4(statusStateDir, "scanner/state.json"), "utf8").catch(() => "null")
7865
+ await readFile2(join6(statusStateDir, "scanner/state.json"), "utf8").catch(() => "null")
5941
7866
  );
5942
7867
  const snapshot = receipt?.snapshot;
5943
7868
  const heartbeat = snapshot?.heartbeat.lastSuccess;
@@ -5946,8 +7871,16 @@ async function collectStatusDocument(input) {
5946
7871
  if (snapshot?.lifecycle.reason === "credential_revoked")
5947
7872
  scannerReason = {
5948
7873
  kind: "login_pending",
5949
- reason: "credential_revoked",
5950
- action: "mnemonik install"
7874
+ component: "scanner",
7875
+ reason: "scanner_signed_out",
7876
+ action: "mnemonik repair"
7877
+ };
7878
+ else if (pausedForConsent(receipt))
7879
+ scannerReason = {
7880
+ kind: "login_pending",
7881
+ component: "scanner",
7882
+ reason: "scanner_consent_required",
7883
+ action: "mnemonik scanner enable"
5951
7884
  };
5952
7885
  else if (snapshot?.lifecycle.state === "paused")
5953
7886
  scannerReason = {
@@ -5955,6 +7888,16 @@ async function collectStatusDocument(input) {
5955
7888
  reason: "scanner_paused",
5956
7889
  action: "mnemonik scanner resume"
5957
7890
  };
7891
+ else if (state?.consent && !scannerReason) {
7892
+ const expected = await (input.expectedDisclosureVersion ?? expectedScannerDisclosureVersion)().catch(() => void 0);
7893
+ if (expected && state.consent.disclosureVersion !== expected)
7894
+ scannerReason = {
7895
+ kind: "login_pending",
7896
+ component: "scanner",
7897
+ reason: "scanner_update_consent_required",
7898
+ action: "mnemonik scanner enable"
7899
+ };
7900
+ }
5958
7901
  if (state && alive && snapshot?.lifecycle.pid === pid && !restarted && (snapshot?.lifecycle.state === "running" || snapshot?.lifecycle.state === "starting") && heartbeat && Date.now() - heartbeat < SCANNER_RECEIPT_STALE_MS) {
5959
7902
  scannerStatus = {
5960
7903
  roots: state.config.roots,
@@ -5967,6 +7910,13 @@ async function collectStatusDocument(input) {
5967
7910
  disclosureVersion: state.consent?.disclosureVersion ?? null
5968
7911
  };
5969
7912
  }
7913
+ if (snapshot?.failure && snapshot.failure.kind !== "credential_refused" && alive && snapshot.lifecycle.pid === pid && (snapshot.lifecycle.state === "running" || snapshot.lifecycle.state === "starting"))
7914
+ scannerFailing = {
7915
+ kind: "selected_component_failed",
7916
+ component: "scanner",
7917
+ reason: "scanner_failing",
7918
+ action: "mnemonik doctor"
7919
+ };
5970
7920
  if (restarted)
5971
7921
  scannerReason = {
5972
7922
  kind: "scanner_not_verified",
@@ -5978,6 +7928,7 @@ async function collectStatusDocument(input) {
5978
7928
  const installationConditions = [
5979
7929
  ...input.installationConditions ?? [],
5980
7930
  ...scannerReason ? [scannerReason] : [],
7931
+ ...scannerFailing ? [scannerFailing] : [],
5981
7932
  ...input.preflight.status === "ready" ? [] : [
5982
7933
  // Name the check that failed, because the person can only fix that one.
5983
7934
  input.preflight.node.supported ? {
@@ -6019,7 +7970,7 @@ async function collectStatusDocument(input) {
6019
7970
  const owned = await readOwnership(statusStateDir);
6020
7971
  const details = { ...input.details };
6021
7972
  const resolved = input.preflight.project.root ? await readProjectStatus(input) : void 0;
6022
- const candidate = !!resolved && (resolved.identity !== "absent" || await stat(join4(resolved.resolvedRoot, ".git")).then(
7973
+ const candidate = !!resolved && (resolved.identity !== "absent" || await stat(join6(resolved.resolvedRoot, ".git")).then(
6023
7974
  () => true,
6024
7975
  () => false
6025
7976
  ) || (scannerStatus?.roots ?? []).some((root) => contains(root, resolved.resolvedRoot)));
@@ -6062,6 +8013,7 @@ async function collectStatusDocument(input) {
6062
8013
  var serializeReadiness2 = (input) => devReadiness(serializeReadiness(input));
6063
8014
  export {
6064
8015
  CODEX_TRUST_MESSAGE,
8016
+ REPORT_NOT_SENT,
6065
8017
  buildStatusDocument,
6066
8018
  collectStatusDocument,
6067
8019
  localEditorStatus,
@@ -6070,7 +8022,9 @@ export {
6070
8022
  readProjectStatus,
6071
8023
  refusalLines,
6072
8024
  renderRefusals,
8025
+ renderScannerFailure,
6073
8026
  renderStatusSummaries,
8027
+ scannerFailureCause,
6074
8028
  statusExitCode
6075
8029
  };
6076
8030
  /*! Bundled license information: