@mrrlin-dev/mcp 0.3.47 → 0.3.48

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.
package/dist/bin.cjs CHANGED
@@ -7703,54 +7703,54 @@ var require_polyfills = __commonJS({
7703
7703
  }
7704
7704
  var chdir;
7705
7705
  module2.exports = patch;
7706
- function patch(fs6) {
7706
+ function patch(fs7) {
7707
7707
  if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
7708
- patchLchmod(fs6);
7709
- }
7710
- if (!fs6.lutimes) {
7711
- patchLutimes(fs6);
7712
- }
7713
- fs6.chown = chownFix(fs6.chown);
7714
- fs6.fchown = chownFix(fs6.fchown);
7715
- fs6.lchown = chownFix(fs6.lchown);
7716
- fs6.chmod = chmodFix(fs6.chmod);
7717
- fs6.fchmod = chmodFix(fs6.fchmod);
7718
- fs6.lchmod = chmodFix(fs6.lchmod);
7719
- fs6.chownSync = chownFixSync(fs6.chownSync);
7720
- fs6.fchownSync = chownFixSync(fs6.fchownSync);
7721
- fs6.lchownSync = chownFixSync(fs6.lchownSync);
7722
- fs6.chmodSync = chmodFixSync(fs6.chmodSync);
7723
- fs6.fchmodSync = chmodFixSync(fs6.fchmodSync);
7724
- fs6.lchmodSync = chmodFixSync(fs6.lchmodSync);
7725
- fs6.stat = statFix(fs6.stat);
7726
- fs6.fstat = statFix(fs6.fstat);
7727
- fs6.lstat = statFix(fs6.lstat);
7728
- fs6.statSync = statFixSync(fs6.statSync);
7729
- fs6.fstatSync = statFixSync(fs6.fstatSync);
7730
- fs6.lstatSync = statFixSync(fs6.lstatSync);
7731
- if (fs6.chmod && !fs6.lchmod) {
7732
- fs6.lchmod = function(path16, mode, cb) {
7708
+ patchLchmod(fs7);
7709
+ }
7710
+ if (!fs7.lutimes) {
7711
+ patchLutimes(fs7);
7712
+ }
7713
+ fs7.chown = chownFix(fs7.chown);
7714
+ fs7.fchown = chownFix(fs7.fchown);
7715
+ fs7.lchown = chownFix(fs7.lchown);
7716
+ fs7.chmod = chmodFix(fs7.chmod);
7717
+ fs7.fchmod = chmodFix(fs7.fchmod);
7718
+ fs7.lchmod = chmodFix(fs7.lchmod);
7719
+ fs7.chownSync = chownFixSync(fs7.chownSync);
7720
+ fs7.fchownSync = chownFixSync(fs7.fchownSync);
7721
+ fs7.lchownSync = chownFixSync(fs7.lchownSync);
7722
+ fs7.chmodSync = chmodFixSync(fs7.chmodSync);
7723
+ fs7.fchmodSync = chmodFixSync(fs7.fchmodSync);
7724
+ fs7.lchmodSync = chmodFixSync(fs7.lchmodSync);
7725
+ fs7.stat = statFix(fs7.stat);
7726
+ fs7.fstat = statFix(fs7.fstat);
7727
+ fs7.lstat = statFix(fs7.lstat);
7728
+ fs7.statSync = statFixSync(fs7.statSync);
7729
+ fs7.fstatSync = statFixSync(fs7.fstatSync);
7730
+ fs7.lstatSync = statFixSync(fs7.lstatSync);
7731
+ if (fs7.chmod && !fs7.lchmod) {
7732
+ fs7.lchmod = function(path17, mode, cb) {
7733
7733
  if (cb) process.nextTick(cb);
7734
7734
  };
7735
- fs6.lchmodSync = function() {
7735
+ fs7.lchmodSync = function() {
7736
7736
  };
7737
7737
  }
7738
- if (fs6.chown && !fs6.lchown) {
7739
- fs6.lchown = function(path16, uid, gid, cb) {
7738
+ if (fs7.chown && !fs7.lchown) {
7739
+ fs7.lchown = function(path17, uid, gid, cb) {
7740
7740
  if (cb) process.nextTick(cb);
7741
7741
  };
7742
- fs6.lchownSync = function() {
7742
+ fs7.lchownSync = function() {
7743
7743
  };
7744
7744
  }
7745
7745
  if (platform === "win32") {
7746
- fs6.rename = typeof fs6.rename !== "function" ? fs6.rename : function(fs$rename) {
7746
+ fs7.rename = typeof fs7.rename !== "function" ? fs7.rename : function(fs$rename) {
7747
7747
  function rename(from, to, cb) {
7748
7748
  var start = Date.now();
7749
7749
  var backoff = 0;
7750
7750
  fs$rename(from, to, function CB(er) {
7751
7751
  if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
7752
7752
  setTimeout(function() {
7753
- fs6.stat(to, function(stater, st) {
7753
+ fs7.stat(to, function(stater, st) {
7754
7754
  if (stater && stater.code === "ENOENT")
7755
7755
  fs$rename(from, to, CB);
7756
7756
  else
@@ -7766,9 +7766,9 @@ var require_polyfills = __commonJS({
7766
7766
  }
7767
7767
  if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
7768
7768
  return rename;
7769
- }(fs6.rename);
7769
+ }(fs7.rename);
7770
7770
  }
7771
- fs6.read = typeof fs6.read !== "function" ? fs6.read : function(fs$read) {
7771
+ fs7.read = typeof fs7.read !== "function" ? fs7.read : function(fs$read) {
7772
7772
  function read(fd, buffer, offset, length, position, callback_) {
7773
7773
  var callback;
7774
7774
  if (callback_ && typeof callback_ === "function") {
@@ -7776,22 +7776,22 @@ var require_polyfills = __commonJS({
7776
7776
  callback = function(er, _, __) {
7777
7777
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
7778
7778
  eagCounter++;
7779
- return fs$read.call(fs6, fd, buffer, offset, length, position, callback);
7779
+ return fs$read.call(fs7, fd, buffer, offset, length, position, callback);
7780
7780
  }
7781
7781
  callback_.apply(this, arguments);
7782
7782
  };
7783
7783
  }
7784
- return fs$read.call(fs6, fd, buffer, offset, length, position, callback);
7784
+ return fs$read.call(fs7, fd, buffer, offset, length, position, callback);
7785
7785
  }
7786
7786
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
7787
7787
  return read;
7788
- }(fs6.read);
7789
- fs6.readSync = typeof fs6.readSync !== "function" ? fs6.readSync : /* @__PURE__ */ function(fs$readSync) {
7788
+ }(fs7.read);
7789
+ fs7.readSync = typeof fs7.readSync !== "function" ? fs7.readSync : /* @__PURE__ */ function(fs$readSync) {
7790
7790
  return function(fd, buffer, offset, length, position) {
7791
7791
  var eagCounter = 0;
7792
7792
  while (true) {
7793
7793
  try {
7794
- return fs$readSync.call(fs6, fd, buffer, offset, length, position);
7794
+ return fs$readSync.call(fs7, fd, buffer, offset, length, position);
7795
7795
  } catch (er) {
7796
7796
  if (er.code === "EAGAIN" && eagCounter < 10) {
7797
7797
  eagCounter++;
@@ -7801,11 +7801,11 @@ var require_polyfills = __commonJS({
7801
7801
  }
7802
7802
  }
7803
7803
  };
7804
- }(fs6.readSync);
7805
- function patchLchmod(fs7) {
7806
- fs7.lchmod = function(path16, mode, callback) {
7807
- fs7.open(
7808
- path16,
7804
+ }(fs7.readSync);
7805
+ function patchLchmod(fs8) {
7806
+ fs8.lchmod = function(path17, mode, callback) {
7807
+ fs8.open(
7808
+ path17,
7809
7809
  constants.O_WRONLY | constants.O_SYMLINK,
7810
7810
  mode,
7811
7811
  function(err, fd) {
@@ -7813,80 +7813,80 @@ var require_polyfills = __commonJS({
7813
7813
  if (callback) callback(err);
7814
7814
  return;
7815
7815
  }
7816
- fs7.fchmod(fd, mode, function(err2) {
7817
- fs7.close(fd, function(err22) {
7816
+ fs8.fchmod(fd, mode, function(err2) {
7817
+ fs8.close(fd, function(err22) {
7818
7818
  if (callback) callback(err2 || err22);
7819
7819
  });
7820
7820
  });
7821
7821
  }
7822
7822
  );
7823
7823
  };
7824
- fs7.lchmodSync = function(path16, mode) {
7825
- var fd = fs7.openSync(path16, constants.O_WRONLY | constants.O_SYMLINK, mode);
7824
+ fs8.lchmodSync = function(path17, mode) {
7825
+ var fd = fs8.openSync(path17, constants.O_WRONLY | constants.O_SYMLINK, mode);
7826
7826
  var threw = true;
7827
7827
  var ret;
7828
7828
  try {
7829
- ret = fs7.fchmodSync(fd, mode);
7829
+ ret = fs8.fchmodSync(fd, mode);
7830
7830
  threw = false;
7831
7831
  } finally {
7832
7832
  if (threw) {
7833
7833
  try {
7834
- fs7.closeSync(fd);
7834
+ fs8.closeSync(fd);
7835
7835
  } catch (er) {
7836
7836
  }
7837
7837
  } else {
7838
- fs7.closeSync(fd);
7838
+ fs8.closeSync(fd);
7839
7839
  }
7840
7840
  }
7841
7841
  return ret;
7842
7842
  };
7843
7843
  }
7844
- function patchLutimes(fs7) {
7845
- if (constants.hasOwnProperty("O_SYMLINK") && fs7.futimes) {
7846
- fs7.lutimes = function(path16, at, mt, cb) {
7847
- fs7.open(path16, constants.O_SYMLINK, function(er, fd) {
7844
+ function patchLutimes(fs8) {
7845
+ if (constants.hasOwnProperty("O_SYMLINK") && fs8.futimes) {
7846
+ fs8.lutimes = function(path17, at, mt, cb) {
7847
+ fs8.open(path17, constants.O_SYMLINK, function(er, fd) {
7848
7848
  if (er) {
7849
7849
  if (cb) cb(er);
7850
7850
  return;
7851
7851
  }
7852
- fs7.futimes(fd, at, mt, function(er2) {
7853
- fs7.close(fd, function(er22) {
7852
+ fs8.futimes(fd, at, mt, function(er2) {
7853
+ fs8.close(fd, function(er22) {
7854
7854
  if (cb) cb(er2 || er22);
7855
7855
  });
7856
7856
  });
7857
7857
  });
7858
7858
  };
7859
- fs7.lutimesSync = function(path16, at, mt) {
7860
- var fd = fs7.openSync(path16, constants.O_SYMLINK);
7859
+ fs8.lutimesSync = function(path17, at, mt) {
7860
+ var fd = fs8.openSync(path17, constants.O_SYMLINK);
7861
7861
  var ret;
7862
7862
  var threw = true;
7863
7863
  try {
7864
- ret = fs7.futimesSync(fd, at, mt);
7864
+ ret = fs8.futimesSync(fd, at, mt);
7865
7865
  threw = false;
7866
7866
  } finally {
7867
7867
  if (threw) {
7868
7868
  try {
7869
- fs7.closeSync(fd);
7869
+ fs8.closeSync(fd);
7870
7870
  } catch (er) {
7871
7871
  }
7872
7872
  } else {
7873
- fs7.closeSync(fd);
7873
+ fs8.closeSync(fd);
7874
7874
  }
7875
7875
  }
7876
7876
  return ret;
7877
7877
  };
7878
- } else if (fs7.futimes) {
7879
- fs7.lutimes = function(_a3, _b, _c, cb) {
7878
+ } else if (fs8.futimes) {
7879
+ fs8.lutimes = function(_a3, _b, _c, cb) {
7880
7880
  if (cb) process.nextTick(cb);
7881
7881
  };
7882
- fs7.lutimesSync = function() {
7882
+ fs8.lutimesSync = function() {
7883
7883
  };
7884
7884
  }
7885
7885
  }
7886
7886
  function chmodFix(orig) {
7887
7887
  if (!orig) return orig;
7888
7888
  return function(target, mode, cb) {
7889
- return orig.call(fs6, target, mode, function(er) {
7889
+ return orig.call(fs7, target, mode, function(er) {
7890
7890
  if (chownErOk(er)) er = null;
7891
7891
  if (cb) cb.apply(this, arguments);
7892
7892
  });
@@ -7896,7 +7896,7 @@ var require_polyfills = __commonJS({
7896
7896
  if (!orig) return orig;
7897
7897
  return function(target, mode) {
7898
7898
  try {
7899
- return orig.call(fs6, target, mode);
7899
+ return orig.call(fs7, target, mode);
7900
7900
  } catch (er) {
7901
7901
  if (!chownErOk(er)) throw er;
7902
7902
  }
@@ -7905,7 +7905,7 @@ var require_polyfills = __commonJS({
7905
7905
  function chownFix(orig) {
7906
7906
  if (!orig) return orig;
7907
7907
  return function(target, uid, gid, cb) {
7908
- return orig.call(fs6, target, uid, gid, function(er) {
7908
+ return orig.call(fs7, target, uid, gid, function(er) {
7909
7909
  if (chownErOk(er)) er = null;
7910
7910
  if (cb) cb.apply(this, arguments);
7911
7911
  });
@@ -7915,7 +7915,7 @@ var require_polyfills = __commonJS({
7915
7915
  if (!orig) return orig;
7916
7916
  return function(target, uid, gid) {
7917
7917
  try {
7918
- return orig.call(fs6, target, uid, gid);
7918
+ return orig.call(fs7, target, uid, gid);
7919
7919
  } catch (er) {
7920
7920
  if (!chownErOk(er)) throw er;
7921
7921
  }
@@ -7935,13 +7935,13 @@ var require_polyfills = __commonJS({
7935
7935
  }
7936
7936
  if (cb) cb.apply(this, arguments);
7937
7937
  }
7938
- return options ? orig.call(fs6, target, options, callback) : orig.call(fs6, target, callback);
7938
+ return options ? orig.call(fs7, target, options, callback) : orig.call(fs7, target, callback);
7939
7939
  };
7940
7940
  }
7941
7941
  function statFixSync(orig) {
7942
7942
  if (!orig) return orig;
7943
7943
  return function(target, options) {
7944
- var stats = options ? orig.call(fs6, target, options) : orig.call(fs6, target);
7944
+ var stats = options ? orig.call(fs7, target, options) : orig.call(fs7, target);
7945
7945
  if (stats) {
7946
7946
  if (stats.uid < 0) stats.uid += 4294967296;
7947
7947
  if (stats.gid < 0) stats.gid += 4294967296;
@@ -7970,16 +7970,16 @@ var require_legacy_streams = __commonJS({
7970
7970
  "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js"(exports2, module2) {
7971
7971
  var Stream = require("stream").Stream;
7972
7972
  module2.exports = legacy;
7973
- function legacy(fs6) {
7973
+ function legacy(fs7) {
7974
7974
  return {
7975
7975
  ReadStream,
7976
7976
  WriteStream
7977
7977
  };
7978
- function ReadStream(path16, options) {
7979
- if (!(this instanceof ReadStream)) return new ReadStream(path16, options);
7978
+ function ReadStream(path17, options) {
7979
+ if (!(this instanceof ReadStream)) return new ReadStream(path17, options);
7980
7980
  Stream.call(this);
7981
7981
  var self = this;
7982
- this.path = path16;
7982
+ this.path = path17;
7983
7983
  this.fd = null;
7984
7984
  this.readable = true;
7985
7985
  this.paused = false;
@@ -8013,7 +8013,7 @@ var require_legacy_streams = __commonJS({
8013
8013
  });
8014
8014
  return;
8015
8015
  }
8016
- fs6.open(this.path, this.flags, this.mode, function(err, fd) {
8016
+ fs7.open(this.path, this.flags, this.mode, function(err, fd) {
8017
8017
  if (err) {
8018
8018
  self.emit("error", err);
8019
8019
  self.readable = false;
@@ -8024,10 +8024,10 @@ var require_legacy_streams = __commonJS({
8024
8024
  self._read();
8025
8025
  });
8026
8026
  }
8027
- function WriteStream(path16, options) {
8028
- if (!(this instanceof WriteStream)) return new WriteStream(path16, options);
8027
+ function WriteStream(path17, options) {
8028
+ if (!(this instanceof WriteStream)) return new WriteStream(path17, options);
8029
8029
  Stream.call(this);
8030
- this.path = path16;
8030
+ this.path = path17;
8031
8031
  this.fd = null;
8032
8032
  this.writable = true;
8033
8033
  this.flags = "w";
@@ -8052,7 +8052,7 @@ var require_legacy_streams = __commonJS({
8052
8052
  this.busy = false;
8053
8053
  this._queue = [];
8054
8054
  if (this.fd === null) {
8055
- this._open = fs6.open;
8055
+ this._open = fs7.open;
8056
8056
  this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
8057
8057
  this.flush();
8058
8058
  }
@@ -8087,7 +8087,7 @@ var require_clone = __commonJS({
8087
8087
  // ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
8088
8088
  var require_graceful_fs = __commonJS({
8089
8089
  "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
8090
- var fs6 = require("fs");
8090
+ var fs7 = require("fs");
8091
8091
  var polyfills = require_polyfills();
8092
8092
  var legacy = require_legacy_streams();
8093
8093
  var clone2 = require_clone();
@@ -8119,12 +8119,12 @@ var require_graceful_fs = __commonJS({
8119
8119
  m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
8120
8120
  console.error(m);
8121
8121
  };
8122
- if (!fs6[gracefulQueue]) {
8122
+ if (!fs7[gracefulQueue]) {
8123
8123
  queue = global[gracefulQueue] || [];
8124
- publishQueue(fs6, queue);
8125
- fs6.close = function(fs$close) {
8124
+ publishQueue(fs7, queue);
8125
+ fs7.close = function(fs$close) {
8126
8126
  function close(fd, cb) {
8127
- return fs$close.call(fs6, fd, function(err) {
8127
+ return fs$close.call(fs7, fd, function(err) {
8128
8128
  if (!err) {
8129
8129
  resetQueue();
8130
8130
  }
@@ -8136,48 +8136,48 @@ var require_graceful_fs = __commonJS({
8136
8136
  value: fs$close
8137
8137
  });
8138
8138
  return close;
8139
- }(fs6.close);
8140
- fs6.closeSync = function(fs$closeSync) {
8139
+ }(fs7.close);
8140
+ fs7.closeSync = function(fs$closeSync) {
8141
8141
  function closeSync(fd) {
8142
- fs$closeSync.apply(fs6, arguments);
8142
+ fs$closeSync.apply(fs7, arguments);
8143
8143
  resetQueue();
8144
8144
  }
8145
8145
  Object.defineProperty(closeSync, previousSymbol, {
8146
8146
  value: fs$closeSync
8147
8147
  });
8148
8148
  return closeSync;
8149
- }(fs6.closeSync);
8149
+ }(fs7.closeSync);
8150
8150
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
8151
8151
  process.on("exit", function() {
8152
- debug(fs6[gracefulQueue]);
8153
- require("assert").equal(fs6[gracefulQueue].length, 0);
8152
+ debug(fs7[gracefulQueue]);
8153
+ require("assert").equal(fs7[gracefulQueue].length, 0);
8154
8154
  });
8155
8155
  }
8156
8156
  }
8157
8157
  var queue;
8158
8158
  if (!global[gracefulQueue]) {
8159
- publishQueue(global, fs6[gracefulQueue]);
8160
- }
8161
- module2.exports = patch(clone2(fs6));
8162
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs6.__patched) {
8163
- module2.exports = patch(fs6);
8164
- fs6.__patched = true;
8165
- }
8166
- function patch(fs7) {
8167
- polyfills(fs7);
8168
- fs7.gracefulify = patch;
8169
- fs7.createReadStream = createReadStream;
8170
- fs7.createWriteStream = createWriteStream;
8171
- var fs$readFile = fs7.readFile;
8172
- fs7.readFile = readFile2;
8173
- function readFile2(path16, options, cb) {
8159
+ publishQueue(global, fs7[gracefulQueue]);
8160
+ }
8161
+ module2.exports = patch(clone2(fs7));
8162
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs7.__patched) {
8163
+ module2.exports = patch(fs7);
8164
+ fs7.__patched = true;
8165
+ }
8166
+ function patch(fs8) {
8167
+ polyfills(fs8);
8168
+ fs8.gracefulify = patch;
8169
+ fs8.createReadStream = createReadStream;
8170
+ fs8.createWriteStream = createWriteStream;
8171
+ var fs$readFile = fs8.readFile;
8172
+ fs8.readFile = readFile2;
8173
+ function readFile2(path17, options, cb) {
8174
8174
  if (typeof options === "function")
8175
8175
  cb = options, options = null;
8176
- return go$readFile(path16, options, cb);
8177
- function go$readFile(path17, options2, cb2, startTime) {
8178
- return fs$readFile(path17, options2, function(err) {
8176
+ return go$readFile(path17, options, cb);
8177
+ function go$readFile(path18, options2, cb2, startTime) {
8178
+ return fs$readFile(path18, options2, function(err) {
8179
8179
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
8180
- enqueue([go$readFile, [path17, options2, cb2], err, startTime || Date.now(), Date.now()]);
8180
+ enqueue([go$readFile, [path18, options2, cb2], err, startTime || Date.now(), Date.now()]);
8181
8181
  else {
8182
8182
  if (typeof cb2 === "function")
8183
8183
  cb2.apply(this, arguments);
@@ -8185,16 +8185,16 @@ var require_graceful_fs = __commonJS({
8185
8185
  });
8186
8186
  }
8187
8187
  }
8188
- var fs$writeFile = fs7.writeFile;
8189
- fs7.writeFile = writeFile;
8190
- function writeFile(path16, data, options, cb) {
8188
+ var fs$writeFile = fs8.writeFile;
8189
+ fs8.writeFile = writeFile;
8190
+ function writeFile(path17, data, options, cb) {
8191
8191
  if (typeof options === "function")
8192
8192
  cb = options, options = null;
8193
- return go$writeFile(path16, data, options, cb);
8194
- function go$writeFile(path17, data2, options2, cb2, startTime) {
8195
- return fs$writeFile(path17, data2, options2, function(err) {
8193
+ return go$writeFile(path17, data, options, cb);
8194
+ function go$writeFile(path18, data2, options2, cb2, startTime) {
8195
+ return fs$writeFile(path18, data2, options2, function(err) {
8196
8196
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
8197
- enqueue([go$writeFile, [path17, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
8197
+ enqueue([go$writeFile, [path18, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
8198
8198
  else {
8199
8199
  if (typeof cb2 === "function")
8200
8200
  cb2.apply(this, arguments);
@@ -8202,17 +8202,17 @@ var require_graceful_fs = __commonJS({
8202
8202
  });
8203
8203
  }
8204
8204
  }
8205
- var fs$appendFile = fs7.appendFile;
8205
+ var fs$appendFile = fs8.appendFile;
8206
8206
  if (fs$appendFile)
8207
- fs7.appendFile = appendFile;
8208
- function appendFile(path16, data, options, cb) {
8207
+ fs8.appendFile = appendFile;
8208
+ function appendFile(path17, data, options, cb) {
8209
8209
  if (typeof options === "function")
8210
8210
  cb = options, options = null;
8211
- return go$appendFile(path16, data, options, cb);
8212
- function go$appendFile(path17, data2, options2, cb2, startTime) {
8213
- return fs$appendFile(path17, data2, options2, function(err) {
8211
+ return go$appendFile(path17, data, options, cb);
8212
+ function go$appendFile(path18, data2, options2, cb2, startTime) {
8213
+ return fs$appendFile(path18, data2, options2, function(err) {
8214
8214
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
8215
- enqueue([go$appendFile, [path17, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
8215
+ enqueue([go$appendFile, [path18, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
8216
8216
  else {
8217
8217
  if (typeof cb2 === "function")
8218
8218
  cb2.apply(this, arguments);
@@ -8220,9 +8220,9 @@ var require_graceful_fs = __commonJS({
8220
8220
  });
8221
8221
  }
8222
8222
  }
8223
- var fs$copyFile = fs7.copyFile;
8223
+ var fs$copyFile = fs8.copyFile;
8224
8224
  if (fs$copyFile)
8225
- fs7.copyFile = copyFile;
8225
+ fs8.copyFile = copyFile;
8226
8226
  function copyFile(src, dest, flags, cb) {
8227
8227
  if (typeof flags === "function") {
8228
8228
  cb = flags;
@@ -8240,34 +8240,34 @@ var require_graceful_fs = __commonJS({
8240
8240
  });
8241
8241
  }
8242
8242
  }
8243
- var fs$readdir = fs7.readdir;
8244
- fs7.readdir = readdir2;
8243
+ var fs$readdir = fs8.readdir;
8244
+ fs8.readdir = readdir2;
8245
8245
  var noReaddirOptionVersions = /^v[0-5]\./;
8246
- function readdir2(path16, options, cb) {
8246
+ function readdir2(path17, options, cb) {
8247
8247
  if (typeof options === "function")
8248
8248
  cb = options, options = null;
8249
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path17, options2, cb2, startTime) {
8250
- return fs$readdir(path17, fs$readdirCallback(
8251
- path17,
8249
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path18, options2, cb2, startTime) {
8250
+ return fs$readdir(path18, fs$readdirCallback(
8251
+ path18,
8252
8252
  options2,
8253
8253
  cb2,
8254
8254
  startTime
8255
8255
  ));
8256
- } : function go$readdir2(path17, options2, cb2, startTime) {
8257
- return fs$readdir(path17, options2, fs$readdirCallback(
8258
- path17,
8256
+ } : function go$readdir2(path18, options2, cb2, startTime) {
8257
+ return fs$readdir(path18, options2, fs$readdirCallback(
8258
+ path18,
8259
8259
  options2,
8260
8260
  cb2,
8261
8261
  startTime
8262
8262
  ));
8263
8263
  };
8264
- return go$readdir(path16, options, cb);
8265
- function fs$readdirCallback(path17, options2, cb2, startTime) {
8264
+ return go$readdir(path17, options, cb);
8265
+ function fs$readdirCallback(path18, options2, cb2, startTime) {
8266
8266
  return function(err, files) {
8267
8267
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
8268
8268
  enqueue([
8269
8269
  go$readdir,
8270
- [path17, options2, cb2],
8270
+ [path18, options2, cb2],
8271
8271
  err,
8272
8272
  startTime || Date.now(),
8273
8273
  Date.now()
@@ -8282,21 +8282,21 @@ var require_graceful_fs = __commonJS({
8282
8282
  }
8283
8283
  }
8284
8284
  if (process.version.substr(0, 4) === "v0.8") {
8285
- var legStreams = legacy(fs7);
8285
+ var legStreams = legacy(fs8);
8286
8286
  ReadStream = legStreams.ReadStream;
8287
8287
  WriteStream = legStreams.WriteStream;
8288
8288
  }
8289
- var fs$ReadStream = fs7.ReadStream;
8289
+ var fs$ReadStream = fs8.ReadStream;
8290
8290
  if (fs$ReadStream) {
8291
8291
  ReadStream.prototype = Object.create(fs$ReadStream.prototype);
8292
8292
  ReadStream.prototype.open = ReadStream$open;
8293
8293
  }
8294
- var fs$WriteStream = fs7.WriteStream;
8294
+ var fs$WriteStream = fs8.WriteStream;
8295
8295
  if (fs$WriteStream) {
8296
8296
  WriteStream.prototype = Object.create(fs$WriteStream.prototype);
8297
8297
  WriteStream.prototype.open = WriteStream$open;
8298
8298
  }
8299
- Object.defineProperty(fs7, "ReadStream", {
8299
+ Object.defineProperty(fs8, "ReadStream", {
8300
8300
  get: function() {
8301
8301
  return ReadStream;
8302
8302
  },
@@ -8306,7 +8306,7 @@ var require_graceful_fs = __commonJS({
8306
8306
  enumerable: true,
8307
8307
  configurable: true
8308
8308
  });
8309
- Object.defineProperty(fs7, "WriteStream", {
8309
+ Object.defineProperty(fs8, "WriteStream", {
8310
8310
  get: function() {
8311
8311
  return WriteStream;
8312
8312
  },
@@ -8317,7 +8317,7 @@ var require_graceful_fs = __commonJS({
8317
8317
  configurable: true
8318
8318
  });
8319
8319
  var FileReadStream = ReadStream;
8320
- Object.defineProperty(fs7, "FileReadStream", {
8320
+ Object.defineProperty(fs8, "FileReadStream", {
8321
8321
  get: function() {
8322
8322
  return FileReadStream;
8323
8323
  },
@@ -8328,7 +8328,7 @@ var require_graceful_fs = __commonJS({
8328
8328
  configurable: true
8329
8329
  });
8330
8330
  var FileWriteStream = WriteStream;
8331
- Object.defineProperty(fs7, "FileWriteStream", {
8331
+ Object.defineProperty(fs8, "FileWriteStream", {
8332
8332
  get: function() {
8333
8333
  return FileWriteStream;
8334
8334
  },
@@ -8338,7 +8338,7 @@ var require_graceful_fs = __commonJS({
8338
8338
  enumerable: true,
8339
8339
  configurable: true
8340
8340
  });
8341
- function ReadStream(path16, options) {
8341
+ function ReadStream(path17, options) {
8342
8342
  if (this instanceof ReadStream)
8343
8343
  return fs$ReadStream.apply(this, arguments), this;
8344
8344
  else
@@ -8358,7 +8358,7 @@ var require_graceful_fs = __commonJS({
8358
8358
  }
8359
8359
  });
8360
8360
  }
8361
- function WriteStream(path16, options) {
8361
+ function WriteStream(path17, options) {
8362
8362
  if (this instanceof WriteStream)
8363
8363
  return fs$WriteStream.apply(this, arguments), this;
8364
8364
  else
@@ -8376,22 +8376,22 @@ var require_graceful_fs = __commonJS({
8376
8376
  }
8377
8377
  });
8378
8378
  }
8379
- function createReadStream(path16, options) {
8380
- return new fs7.ReadStream(path16, options);
8379
+ function createReadStream(path17, options) {
8380
+ return new fs8.ReadStream(path17, options);
8381
8381
  }
8382
- function createWriteStream(path16, options) {
8383
- return new fs7.WriteStream(path16, options);
8382
+ function createWriteStream(path17, options) {
8383
+ return new fs8.WriteStream(path17, options);
8384
8384
  }
8385
- var fs$open = fs7.open;
8386
- fs7.open = open;
8387
- function open(path16, flags, mode, cb) {
8385
+ var fs$open = fs8.open;
8386
+ fs8.open = open;
8387
+ function open(path17, flags, mode, cb) {
8388
8388
  if (typeof mode === "function")
8389
8389
  cb = mode, mode = null;
8390
- return go$open(path16, flags, mode, cb);
8391
- function go$open(path17, flags2, mode2, cb2, startTime) {
8392
- return fs$open(path17, flags2, mode2, function(err, fd) {
8390
+ return go$open(path17, flags, mode, cb);
8391
+ function go$open(path18, flags2, mode2, cb2, startTime) {
8392
+ return fs$open(path18, flags2, mode2, function(err, fd) {
8393
8393
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
8394
- enqueue([go$open, [path17, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
8394
+ enqueue([go$open, [path18, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
8395
8395
  else {
8396
8396
  if (typeof cb2 === "function")
8397
8397
  cb2.apply(this, arguments);
@@ -8399,20 +8399,20 @@ var require_graceful_fs = __commonJS({
8399
8399
  });
8400
8400
  }
8401
8401
  }
8402
- return fs7;
8402
+ return fs8;
8403
8403
  }
8404
8404
  function enqueue(elem) {
8405
8405
  debug("ENQUEUE", elem[0].name, elem[1]);
8406
- fs6[gracefulQueue].push(elem);
8406
+ fs7[gracefulQueue].push(elem);
8407
8407
  retry();
8408
8408
  }
8409
8409
  var retryTimer;
8410
8410
  function resetQueue() {
8411
8411
  var now = Date.now();
8412
- for (var i = 0; i < fs6[gracefulQueue].length; ++i) {
8413
- if (fs6[gracefulQueue][i].length > 2) {
8414
- fs6[gracefulQueue][i][3] = now;
8415
- fs6[gracefulQueue][i][4] = now;
8412
+ for (var i = 0; i < fs7[gracefulQueue].length; ++i) {
8413
+ if (fs7[gracefulQueue][i].length > 2) {
8414
+ fs7[gracefulQueue][i][3] = now;
8415
+ fs7[gracefulQueue][i][4] = now;
8416
8416
  }
8417
8417
  }
8418
8418
  retry();
@@ -8420,9 +8420,9 @@ var require_graceful_fs = __commonJS({
8420
8420
  function retry() {
8421
8421
  clearTimeout(retryTimer);
8422
8422
  retryTimer = void 0;
8423
- if (fs6[gracefulQueue].length === 0)
8423
+ if (fs7[gracefulQueue].length === 0)
8424
8424
  return;
8425
- var elem = fs6[gracefulQueue].shift();
8425
+ var elem = fs7[gracefulQueue].shift();
8426
8426
  var fn = elem[0];
8427
8427
  var args = elem[1];
8428
8428
  var err = elem[2];
@@ -8444,7 +8444,7 @@ var require_graceful_fs = __commonJS({
8444
8444
  debug("RETRY", fn.name, args);
8445
8445
  fn.apply(null, args.concat([startTime]));
8446
8446
  } else {
8447
- fs6[gracefulQueue].push(elem);
8447
+ fs7[gracefulQueue].push(elem);
8448
8448
  }
8449
8449
  }
8450
8450
  if (retryTimer === void 0) {
@@ -8879,10 +8879,10 @@ var require_mtime_precision = __commonJS({
8879
8879
  "../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/mtime-precision.js"(exports2, module2) {
8880
8880
  "use strict";
8881
8881
  var cacheSymbol = Symbol();
8882
- function probe(file2, fs6, callback) {
8883
- const cachedPrecision = fs6[cacheSymbol];
8882
+ function probe(file2, fs7, callback) {
8883
+ const cachedPrecision = fs7[cacheSymbol];
8884
8884
  if (cachedPrecision) {
8885
- return fs6.stat(file2, (err, stat2) => {
8885
+ return fs7.stat(file2, (err, stat2) => {
8886
8886
  if (err) {
8887
8887
  return callback(err);
8888
8888
  }
@@ -8890,16 +8890,16 @@ var require_mtime_precision = __commonJS({
8890
8890
  });
8891
8891
  }
8892
8892
  const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
8893
- fs6.utimes(file2, mtime, mtime, (err) => {
8893
+ fs7.utimes(file2, mtime, mtime, (err) => {
8894
8894
  if (err) {
8895
8895
  return callback(err);
8896
8896
  }
8897
- fs6.stat(file2, (err2, stat2) => {
8897
+ fs7.stat(file2, (err2, stat2) => {
8898
8898
  if (err2) {
8899
8899
  return callback(err2);
8900
8900
  }
8901
8901
  const precision = stat2.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
8902
- Object.defineProperty(fs6, cacheSymbol, { value: precision });
8902
+ Object.defineProperty(fs7, cacheSymbol, { value: precision });
8903
8903
  callback(null, stat2.mtime, precision);
8904
8904
  });
8905
8905
  });
@@ -8920,8 +8920,8 @@ var require_mtime_precision = __commonJS({
8920
8920
  var require_lockfile = __commonJS({
8921
8921
  "../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/lockfile.js"(exports2, module2) {
8922
8922
  "use strict";
8923
- var path16 = require("path");
8924
- var fs6 = require_graceful_fs();
8923
+ var path17 = require("path");
8924
+ var fs7 = require_graceful_fs();
8925
8925
  var retry = require_retry2();
8926
8926
  var onExit = require_signal_exit();
8927
8927
  var mtimePrecision = require_mtime_precision();
@@ -8931,7 +8931,7 @@ var require_lockfile = __commonJS({
8931
8931
  }
8932
8932
  function resolveCanonicalPath(file2, options, callback) {
8933
8933
  if (!options.realpath) {
8934
- return callback(null, path16.resolve(file2));
8934
+ return callback(null, path17.resolve(file2));
8935
8935
  }
8936
8936
  options.fs.realpath(file2, callback);
8937
8937
  }
@@ -9052,7 +9052,7 @@ var require_lockfile = __commonJS({
9052
9052
  update: null,
9053
9053
  realpath: true,
9054
9054
  retries: 0,
9055
- fs: fs6,
9055
+ fs: fs7,
9056
9056
  onCompromised: (err) => {
9057
9057
  throw err;
9058
9058
  },
@@ -9096,7 +9096,7 @@ var require_lockfile = __commonJS({
9096
9096
  }
9097
9097
  function unlock(file2, options, callback) {
9098
9098
  options = {
9099
- fs: fs6,
9099
+ fs: fs7,
9100
9100
  realpath: true,
9101
9101
  ...options
9102
9102
  };
@@ -9118,7 +9118,7 @@ var require_lockfile = __commonJS({
9118
9118
  options = {
9119
9119
  stale: 1e4,
9120
9120
  realpath: true,
9121
- fs: fs6,
9121
+ fs: fs7,
9122
9122
  ...options
9123
9123
  };
9124
9124
  options.stale = Math.max(options.stale || 0, 2e3);
@@ -9157,16 +9157,16 @@ var require_lockfile = __commonJS({
9157
9157
  var require_adapter = __commonJS({
9158
9158
  "../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/adapter.js"(exports2, module2) {
9159
9159
  "use strict";
9160
- var fs6 = require_graceful_fs();
9161
- function createSyncFs(fs7) {
9160
+ var fs7 = require_graceful_fs();
9161
+ function createSyncFs(fs8) {
9162
9162
  const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
9163
- const newFs = { ...fs7 };
9163
+ const newFs = { ...fs8 };
9164
9164
  methods.forEach((method) => {
9165
9165
  newFs[method] = (...args) => {
9166
9166
  const callback = args.pop();
9167
9167
  let ret;
9168
9168
  try {
9169
- ret = fs7[`${method}Sync`](...args);
9169
+ ret = fs8[`${method}Sync`](...args);
9170
9170
  } catch (err) {
9171
9171
  return callback(err);
9172
9172
  }
@@ -9204,7 +9204,7 @@ var require_adapter = __commonJS({
9204
9204
  }
9205
9205
  function toSyncOptions(options) {
9206
9206
  options = { ...options };
9207
- options.fs = createSyncFs(options.fs || fs6);
9207
+ options.fs = createSyncFs(options.fs || fs7);
9208
9208
  if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
9209
9209
  throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
9210
9210
  }
@@ -10795,10 +10795,10 @@ var require_segments = __commonJS({
10795
10795
  const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
10796
10796
  const nodes = buildNodes(segs);
10797
10797
  const graph = buildGraph(nodes, version2);
10798
- const path16 = dijkstra.find_path(graph.map, "start", "end");
10798
+ const path17 = dijkstra.find_path(graph.map, "start", "end");
10799
10799
  const optimizedSegs = [];
10800
- for (let i = 1; i < path16.length - 1; i++) {
10801
- optimizedSegs.push(graph.table[path16[i]].node);
10800
+ for (let i = 1; i < path17.length - 1; i++) {
10801
+ optimizedSegs.push(graph.table[path17[i]].node);
10802
10802
  }
10803
10803
  return exports2.fromArray(mergeSegments(optimizedSegs));
10804
10804
  };
@@ -13234,7 +13234,7 @@ var require_utils2 = __commonJS({
13234
13234
  // ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js
13235
13235
  var require_png2 = __commonJS({
13236
13236
  "../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js"(exports2) {
13237
- var fs6 = require("fs");
13237
+ var fs7 = require("fs");
13238
13238
  var PNG = require_png().PNG;
13239
13239
  var Utils = require_utils2();
13240
13240
  exports2.render = function render(qrData, options) {
@@ -13275,7 +13275,7 @@ var require_png2 = __commonJS({
13275
13275
  });
13276
13276
  png.pack();
13277
13277
  };
13278
- exports2.renderToFile = function renderToFile(path16, qrData, options, cb) {
13278
+ exports2.renderToFile = function renderToFile(path17, qrData, options, cb) {
13279
13279
  if (typeof cb === "undefined") {
13280
13280
  cb = options;
13281
13281
  options = void 0;
@@ -13286,7 +13286,7 @@ var require_png2 = __commonJS({
13286
13286
  called = true;
13287
13287
  cb.apply(null, args);
13288
13288
  };
13289
- const stream = fs6.createWriteStream(path16);
13289
+ const stream = fs7.createWriteStream(path17);
13290
13290
  stream.on("error", done);
13291
13291
  stream.on("close", done);
13292
13292
  exports2.renderToFileStream(stream, qrData, options);
@@ -13348,14 +13348,14 @@ var require_utf8 = __commonJS({
13348
13348
  }
13349
13349
  return output3;
13350
13350
  };
13351
- exports2.renderToFile = function renderToFile(path16, qrData, options, cb) {
13351
+ exports2.renderToFile = function renderToFile(path17, qrData, options, cb) {
13352
13352
  if (typeof cb === "undefined") {
13353
13353
  cb = options;
13354
13354
  options = void 0;
13355
13355
  }
13356
- const fs6 = require("fs");
13356
+ const fs7 = require("fs");
13357
13357
  const utf8 = exports2.render(qrData, options);
13358
- fs6.writeFile(path16, utf8, cb);
13358
+ fs7.writeFile(path17, utf8, cb);
13359
13359
  };
13360
13360
  }
13361
13361
  });
@@ -13476,7 +13476,7 @@ var require_svg_tag = __commonJS({
13476
13476
  return str;
13477
13477
  }
13478
13478
  function qrToPath(data, size, margin) {
13479
- let path16 = "";
13479
+ let path17 = "";
13480
13480
  let moveBy = 0;
13481
13481
  let newRow = false;
13482
13482
  let lineLength = 0;
@@ -13487,19 +13487,19 @@ var require_svg_tag = __commonJS({
13487
13487
  if (data[i]) {
13488
13488
  lineLength++;
13489
13489
  if (!(i > 0 && col > 0 && data[i - 1])) {
13490
- path16 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
13490
+ path17 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
13491
13491
  moveBy = 0;
13492
13492
  newRow = false;
13493
13493
  }
13494
13494
  if (!(col + 1 < size && data[i + 1])) {
13495
- path16 += svgCmd("h", lineLength);
13495
+ path17 += svgCmd("h", lineLength);
13496
13496
  lineLength = 0;
13497
13497
  }
13498
13498
  } else {
13499
13499
  moveBy++;
13500
13500
  }
13501
13501
  }
13502
- return path16;
13502
+ return path17;
13503
13503
  }
13504
13504
  exports2.render = function render(qrData, options, cb) {
13505
13505
  const opts = Utils.getOptions(options);
@@ -13507,10 +13507,10 @@ var require_svg_tag = __commonJS({
13507
13507
  const data = qrData.modules.data;
13508
13508
  const qrcodesize = size + opts.margin * 2;
13509
13509
  const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>';
13510
- const path16 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
13510
+ const path17 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
13511
13511
  const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"';
13512
13512
  const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" ';
13513
- const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path16 + "</svg>\n";
13513
+ const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path17 + "</svg>\n";
13514
13514
  if (typeof cb === "function") {
13515
13515
  cb(null, svgTag);
13516
13516
  }
@@ -13524,15 +13524,15 @@ var require_svg = __commonJS({
13524
13524
  "../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"(exports2) {
13525
13525
  var svgTagRenderer = require_svg_tag();
13526
13526
  exports2.render = svgTagRenderer.render;
13527
- exports2.renderToFile = function renderToFile(path16, qrData, options, cb) {
13527
+ exports2.renderToFile = function renderToFile(path17, qrData, options, cb) {
13528
13528
  if (typeof cb === "undefined") {
13529
13529
  cb = options;
13530
13530
  options = void 0;
13531
13531
  }
13532
- const fs6 = require("fs");
13532
+ const fs7 = require("fs");
13533
13533
  const svgTag = exports2.render(qrData, options);
13534
13534
  const xmlStr = '<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' + svgTag;
13535
- fs6.writeFile(path16, xmlStr, cb);
13535
+ fs7.writeFile(path17, xmlStr, cb);
13536
13536
  };
13537
13537
  }
13538
13538
  });
@@ -13690,8 +13690,8 @@ var require_server = __commonJS({
13690
13690
  cb
13691
13691
  };
13692
13692
  }
13693
- function getTypeFromFilename(path16) {
13694
- return path16.slice((path16.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
13693
+ function getTypeFromFilename(path17) {
13694
+ return path17.slice((path17.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
13695
13695
  }
13696
13696
  function getRendererFromType(type) {
13697
13697
  switch (type) {
@@ -13755,17 +13755,17 @@ var require_server = __commonJS({
13755
13755
  const renderer = getRendererFromType(params.opts.type);
13756
13756
  return render(renderer.renderToBuffer, text, params);
13757
13757
  };
13758
- exports2.toFile = function toFile(path16, text, opts, cb) {
13759
- if (typeof path16 !== "string" || !(typeof text === "string" || typeof text === "object")) {
13758
+ exports2.toFile = function toFile(path17, text, opts, cb) {
13759
+ if (typeof path17 !== "string" || !(typeof text === "string" || typeof text === "object")) {
13760
13760
  throw new Error("Invalid argument");
13761
13761
  }
13762
13762
  if (arguments.length < 3 && !canPromise()) {
13763
13763
  throw new Error("Too few arguments provided");
13764
13764
  }
13765
13765
  const params = checkParams(text, opts, cb);
13766
- const type = params.opts.type || getTypeFromFilename(path16);
13766
+ const type = params.opts.type || getTypeFromFilename(path17);
13767
13767
  const renderer = getRendererFromType(type);
13768
- const renderToFile = renderer.renderToFile.bind(null, path16);
13768
+ const renderToFile = renderer.renderToFile.bind(null, path17);
13769
13769
  return render(renderToFile, text, params);
13770
13770
  };
13771
13771
  exports2.toFileStream = function toFileStream(stream, text, opts) {
@@ -16983,8 +16983,8 @@ var require_utils3 = __commonJS({
16983
16983
  }
16984
16984
  return ind;
16985
16985
  }
16986
- function removeDotSegments(path16) {
16987
- let input = path16;
16986
+ function removeDotSegments(path17) {
16987
+ let input = path17;
16988
16988
  const output3 = [];
16989
16989
  let nextSlash = -1;
16990
16990
  let len = 0;
@@ -17236,8 +17236,8 @@ var require_schemes = __commonJS({
17236
17236
  wsComponent.secure = void 0;
17237
17237
  }
17238
17238
  if (wsComponent.resourceName) {
17239
- const [path16, query] = wsComponent.resourceName.split("?");
17240
- wsComponent.path = path16 && path16 !== "/" ? path16 : void 0;
17239
+ const [path17, query] = wsComponent.resourceName.split("?");
17240
+ wsComponent.path = path17 && path17 !== "/" ? path17 : void 0;
17241
17241
  wsComponent.query = query;
17242
17242
  wsComponent.resourceName = void 0;
17243
17243
  }
@@ -20630,12 +20630,12 @@ var require_dist = __commonJS({
20630
20630
  throw new Error(`Unknown format "${name}"`);
20631
20631
  return f;
20632
20632
  };
20633
- function addFormats(ajv, list, fs6, exportName) {
20633
+ function addFormats(ajv, list, fs7, exportName) {
20634
20634
  var _a3;
20635
20635
  var _b;
20636
20636
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
20637
20637
  for (const f of list)
20638
- ajv.addFormat(f, fs6[f]);
20638
+ ajv.addFormat(f, fs7[f]);
20639
20639
  }
20640
20640
  module2.exports = exports2 = formatsPlugin;
20641
20641
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -20644,11 +20644,11 @@ var require_dist = __commonJS({
20644
20644
  });
20645
20645
 
20646
20646
  // src/bin.ts
20647
- var import_node_path20 = __toESM(require("node:path"), 1);
20647
+ var import_node_path21 = __toESM(require("node:path"), 1);
20648
20648
  var import_node_child_process13 = require("node:child_process");
20649
- var import_node_fs13 = require("node:fs");
20649
+ var import_node_fs14 = require("node:fs");
20650
20650
  var import_node_os11 = require("node:os");
20651
- var import_node_path21 = __toESM(require("node:path"), 1);
20651
+ var import_node_path22 = __toESM(require("node:path"), 1);
20652
20652
 
20653
20653
  // src/install-codex.ts
20654
20654
  var import_promises = __toESM(require("node:fs/promises"), 1);
@@ -21020,10 +21020,10 @@ ${block}`;
21020
21020
  }
21021
21021
 
21022
21022
  // src/director-bridge.ts
21023
- var import_node_fs11 = __toESM(require("node:fs"), 1);
21023
+ var import_node_fs12 = __toESM(require("node:fs"), 1);
21024
21024
  var import_node_http = __toESM(require("node:http"), 1);
21025
21025
  var import_node_os7 = __toESM(require("node:os"), 1);
21026
- var import_node_path14 = __toESM(require("node:path"), 1);
21026
+ var import_node_path15 = __toESM(require("node:path"), 1);
21027
21027
  var import_node_child_process10 = require("node:child_process");
21028
21028
  var import_node_crypto7 = __toESM(require("node:crypto"), 1);
21029
21029
 
@@ -22580,10 +22580,10 @@ function mergeDefs(...defs) {
22580
22580
  function cloneDef(schema) {
22581
22581
  return mergeDefs(schema._zod.def);
22582
22582
  }
22583
- function getElementAtPath(obj, path16) {
22584
- if (!path16)
22583
+ function getElementAtPath(obj, path17) {
22584
+ if (!path17)
22585
22585
  return obj;
22586
- return path16.reduce((acc, key) => acc?.[key], obj);
22586
+ return path17.reduce((acc, key) => acc?.[key], obj);
22587
22587
  }
22588
22588
  function promiseAllObject(promisesObj) {
22589
22589
  const keys = Object.keys(promisesObj);
@@ -22992,11 +22992,11 @@ function explicitlyAborted(x, startIndex = 0) {
22992
22992
  }
22993
22993
  return false;
22994
22994
  }
22995
- function prefixIssues(path16, issues) {
22995
+ function prefixIssues(path17, issues) {
22996
22996
  return issues.map((iss) => {
22997
22997
  var _a3;
22998
22998
  (_a3 = iss).path ?? (_a3.path = []);
22999
- iss.path.unshift(path16);
22999
+ iss.path.unshift(path17);
23000
23000
  return iss;
23001
23001
  });
23002
23002
  }
@@ -23143,16 +23143,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
23143
23143
  }
23144
23144
  function formatError(error51, mapper = (issue2) => issue2.message) {
23145
23145
  const fieldErrors = { _errors: [] };
23146
- const processError = (error52, path16 = []) => {
23146
+ const processError = (error52, path17 = []) => {
23147
23147
  for (const issue2 of error52.issues) {
23148
23148
  if (issue2.code === "invalid_union" && issue2.errors.length) {
23149
- issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
23149
+ issue2.errors.map((issues) => processError({ issues }, [...path17, ...issue2.path]));
23150
23150
  } else if (issue2.code === "invalid_key") {
23151
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
23151
+ processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
23152
23152
  } else if (issue2.code === "invalid_element") {
23153
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
23153
+ processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
23154
23154
  } else {
23155
- const fullpath = [...path16, ...issue2.path];
23155
+ const fullpath = [...path17, ...issue2.path];
23156
23156
  if (fullpath.length === 0) {
23157
23157
  fieldErrors._errors.push(mapper(issue2));
23158
23158
  } else {
@@ -23179,17 +23179,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
23179
23179
  }
23180
23180
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
23181
23181
  const result = { errors: [] };
23182
- const processError = (error52, path16 = []) => {
23182
+ const processError = (error52, path17 = []) => {
23183
23183
  var _a3, _b;
23184
23184
  for (const issue2 of error52.issues) {
23185
23185
  if (issue2.code === "invalid_union" && issue2.errors.length) {
23186
- issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
23186
+ issue2.errors.map((issues) => processError({ issues }, [...path17, ...issue2.path]));
23187
23187
  } else if (issue2.code === "invalid_key") {
23188
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
23188
+ processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
23189
23189
  } else if (issue2.code === "invalid_element") {
23190
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
23190
+ processError({ issues: issue2.issues }, [...path17, ...issue2.path]);
23191
23191
  } else {
23192
- const fullpath = [...path16, ...issue2.path];
23192
+ const fullpath = [...path17, ...issue2.path];
23193
23193
  if (fullpath.length === 0) {
23194
23194
  result.errors.push(mapper(issue2));
23195
23195
  continue;
@@ -23221,8 +23221,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
23221
23221
  }
23222
23222
  function toDotPath(_path) {
23223
23223
  const segs = [];
23224
- const path16 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
23225
- for (const seg of path16) {
23224
+ const path17 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
23225
+ for (const seg of path17) {
23226
23226
  if (typeof seg === "number")
23227
23227
  segs.push(`[${seg}]`);
23228
23228
  else if (typeof seg === "symbol")
@@ -35914,13 +35914,13 @@ function resolveRef(ref, ctx) {
35914
35914
  if (!ref.startsWith("#")) {
35915
35915
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
35916
35916
  }
35917
- const path16 = ref.slice(1).split("/").filter(Boolean);
35918
- if (path16.length === 0) {
35917
+ const path17 = ref.slice(1).split("/").filter(Boolean);
35918
+ if (path17.length === 0) {
35919
35919
  return ctx.rootSchema;
35920
35920
  }
35921
35921
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
35922
- if (path16[0] === defsKey) {
35923
- const key = path16[1];
35922
+ if (path17[0] === defsKey) {
35923
+ const key = path17[1];
35924
35924
  if (!key || !ctx.defs[key]) {
35925
35925
  throw new Error(`Reference not found: ${ref}`);
35926
35926
  }
@@ -36715,9 +36715,21 @@ var mrrlinDeliverablePayloadSchema = external_exports.object({
36715
36715
  contentHash: external_exports.string().min(1),
36716
36716
  format: external_exports.enum(["markdown"])
36717
36717
  });
36718
- var SUPPORTED_EXECUTION_DOMAINS = ["code", "seo"];
36718
+ var SUPPORTED_EXECUTION_POLICY_BY_DOMAIN = {
36719
+ code: { lane: "code", supported: true },
36720
+ seo: { lane: "low_risk_non_code", supported: true },
36721
+ marketing: { lane: "low_risk_non_code", supported: true },
36722
+ content: { lane: "low_risk_non_code", supported: true }
36723
+ };
36724
+ var SUPPORTED_EXECUTION_DOMAINS = Object.keys(SUPPORTED_EXECUTION_POLICY_BY_DOMAIN);
36725
+ function resolveExecutionDomainPolicy(domain2) {
36726
+ return SUPPORTED_EXECUTION_POLICY_BY_DOMAIN[domain2] ?? {
36727
+ lane: "unsupported",
36728
+ supported: false
36729
+ };
36730
+ }
36719
36731
  function isExecutionDomainSupported(domain2) {
36720
- return SUPPORTED_EXECUTION_DOMAINS.includes(domain2);
36732
+ return resolveExecutionDomainPolicy(domain2).supported;
36721
36733
  }
36722
36734
  var taxonomyCategorySchema = external_exports.string().min(1).regex(/^[a-z][a-z0-9-]*$/);
36723
36735
  var taxonomySubcategorySchema = external_exports.string().min(1).regex(/^[a-z][a-z0-9-]*$/);
@@ -37913,18 +37925,18 @@ function createMrrlinClient(config2) {
37913
37925
  const customFetch = config2.fetch ?? globalThis.fetch;
37914
37926
  const baseUrl = config2.baseUrl.replace(/\/$/, "");
37915
37927
  const token = config2.token;
37916
- async function request(path16, init) {
37928
+ async function request(path17, init) {
37917
37929
  const method = init?.method ?? "GET";
37918
37930
  const headers = new Headers(init?.headers ?? {});
37919
37931
  if (token && !headers.has("authorization")) {
37920
37932
  headers.set("authorization", `Bearer ${token}`);
37921
37933
  }
37922
- const response = await customFetch(`${baseUrl}${path16}`, { ...init, headers });
37934
+ const response = await customFetch(`${baseUrl}${path17}`, { ...init, headers });
37923
37935
  if (!response.ok) {
37924
37936
  const body = await response.text();
37925
37937
  let code = `HTTP_${response.status}`;
37926
37938
  let violations = null;
37927
- let message = `Mrrlin API ${method} ${path16} failed: ${response.status}`;
37939
+ let message = `Mrrlin API ${method} ${path17} failed: ${response.status}`;
37928
37940
  try {
37929
37941
  const parsed = JSON.parse(body);
37930
37942
  const violationsParsed = apiViolationsErrorSchema.safeParse(parsed);
@@ -37944,7 +37956,7 @@ function createMrrlinClient(config2) {
37944
37956
  throw new MrrlinApiError({
37945
37957
  code,
37946
37958
  method,
37947
- path: path16,
37959
+ path: path17,
37948
37960
  responseBody: body,
37949
37961
  status: response.status,
37950
37962
  violations,
@@ -38199,7 +38211,7 @@ function createMrrlinClient(config2) {
38199
38211
  return taskEventListResponseSchema.parse(body).data;
38200
38212
  },
38201
38213
  async listTasks(projectSlug, filters = {}) {
38202
- const path16 = appendQuery(`${projectPath(projectSlug)}/tasks`, {
38214
+ const path17 = appendQuery(`${projectPath(projectSlug)}/tasks`, {
38203
38215
  assignee: filters.assignee,
38204
38216
  autonomyLevel: filters.autonomyLevel,
38205
38217
  blockedBy: filters.blockedBy,
@@ -38211,7 +38223,7 @@ function createMrrlinClient(config2) {
38211
38223
  subcategory: filters.subcategory,
38212
38224
  type: filters.type
38213
38225
  });
38214
- const body = await request(path16);
38226
+ const body = await request(path17);
38215
38227
  return taskListResponseSchema.parse(body).data;
38216
38228
  },
38217
38229
  async listTaxonomy(projectSlug) {
@@ -38219,22 +38231,22 @@ function createMrrlinClient(config2) {
38219
38231
  return taxonomyListResponseSchema.parse(body).data;
38220
38232
  },
38221
38233
  async listWikiPages(projectSlug, filters = {}) {
38222
- const path16 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
38234
+ const path17 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
38223
38235
  folder: filters.folder,
38224
38236
  q: filters.q,
38225
38237
  taskId: filters.taskId
38226
38238
  });
38227
- const body = await request(path16);
38239
+ const body = await request(path17);
38228
38240
  return wikiPageListResponseSchema.parse(body).data;
38229
38241
  },
38230
38242
  async searchWikiPages(projectSlug, query) {
38231
- const path16 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
38243
+ const path17 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
38232
38244
  folder: query.folder,
38233
38245
  limit: query.limit === void 0 ? void 0 : String(query.limit),
38234
38246
  pathPrefix: query.pathPrefix,
38235
38247
  q: query.q
38236
38248
  });
38237
- const body = await request(path16);
38249
+ const body = await request(path17);
38238
38250
  return wikiPageSearchResponseSchema.parse(body).data;
38239
38251
  },
38240
38252
  async updatePlan(projectSlug, planId, patch) {
@@ -39117,7 +39129,7 @@ function startCodexProbe(deps = {}) {
39117
39129
  }
39118
39130
 
39119
39131
  // src/_generated/version.ts
39120
- var PKG_VERSION = "0.3.47";
39132
+ var PKG_VERSION = "0.3.48";
39121
39133
 
39122
39134
  // src/api-base-url.ts
39123
39135
  var DEFAULT_API_BASE_URL = "http://127.0.0.1:8787";
@@ -39181,6 +39193,159 @@ async function resolveApiBaseUrlDynamic(opts = {}) {
39181
39193
  );
39182
39194
  }
39183
39195
 
39196
+ // src/bridge-health.ts
39197
+ var import_node_fs2 = require("node:fs");
39198
+ var import_node_path4 = __toESM(require("node:path"), 1);
39199
+ var SENTINEL_FILE_NAME = "bridge-health-circuit-breaker.json";
39200
+ var CRASH_WINDOW_MS = 60 * 60 * 1e3;
39201
+ var MAX_CRASHES_PER_WINDOW = 3;
39202
+ var DEFAULT_STUCK_MS = 15 * 60 * 1e3;
39203
+ var DEFAULT_OPERATION_TIMEOUT_MS = 3e4;
39204
+ function isCrashSentinel(value) {
39205
+ if (typeof value !== "object" || value === null) return false;
39206
+ const candidate = value;
39207
+ return typeof candidate.crashCount === "number" && Number.isInteger(candidate.crashCount) && candidate.crashCount >= 0 && typeof candidate.windowStartedAt === "string";
39208
+ }
39209
+ async function readCrashSentinel(stateDir, now = Date.now) {
39210
+ const sentinelPath = import_node_path4.default.join(stateDir, SENTINEL_FILE_NAME);
39211
+ try {
39212
+ const raw = await import_node_fs2.promises.readFile(sentinelPath, "utf8");
39213
+ const parsed = JSON.parse(raw);
39214
+ if (isCrashSentinel(parsed)) return parsed;
39215
+ } catch {
39216
+ }
39217
+ return { crashCount: 0, windowStartedAt: new Date(now()).toISOString() };
39218
+ }
39219
+ async function writeCrashSentinel(stateDir, sentinel) {
39220
+ await import_node_fs2.promises.mkdir(stateDir, { recursive: true });
39221
+ const sentinelPath = import_node_path4.default.join(stateDir, SENTINEL_FILE_NAME);
39222
+ const tmpPath = `${sentinelPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
39223
+ await import_node_fs2.promises.writeFile(tmpPath, JSON.stringify(sentinel), "utf8");
39224
+ await import_node_fs2.promises.rename(tmpPath, sentinelPath);
39225
+ }
39226
+ function withTimeout(fn, ms = DEFAULT_OPERATION_TIMEOUT_MS) {
39227
+ const controller = new AbortController();
39228
+ return new Promise((resolve, reject) => {
39229
+ const timer = setTimeout(() => {
39230
+ controller.abort();
39231
+ const timeoutError = new Error(`operation timed out after ${ms}ms`);
39232
+ timeoutError.code = "BRIDGE_HEALTH_TIMEOUT";
39233
+ reject(timeoutError);
39234
+ }, ms);
39235
+ fn(controller.signal).then(
39236
+ (value) => {
39237
+ clearTimeout(timer);
39238
+ resolve(value);
39239
+ },
39240
+ (error51) => {
39241
+ clearTimeout(timer);
39242
+ reject(error51);
39243
+ }
39244
+ );
39245
+ });
39246
+ }
39247
+ var defaultLogger = {
39248
+ critical(message) {
39249
+ process.stderr.write(`[mrrlin-mcp director-bridge] ${message}
39250
+ `);
39251
+ }
39252
+ };
39253
+ var BridgeHealthTracker = class {
39254
+ stateDir;
39255
+ stuckMs;
39256
+ now;
39257
+ processExit;
39258
+ logger;
39259
+ // Initialized to construction time, NOT 0/undefined: a freshly (re)started process — including
39260
+ // one that just restarted BECAUSE this breaker tripped — must not treat its own startup instant
39261
+ // as "ages ago that nothing succeeded." Without this, the very first tracked failure after any
39262
+ // restart would evaluate as instantly stuck, exhausting the crash-loop guard's 3 attempts within
39263
+ // seconds and inverting this mechanism into the outage it exists to prevent.
39264
+ lastSuccessAt;
39265
+ disabled = false;
39266
+ knownCrashCount = null;
39267
+ lastErrorByOperation = /* @__PURE__ */ new Map();
39268
+ constructor(opts) {
39269
+ this.stateDir = opts.stateDir;
39270
+ this.stuckMs = opts.stuckMs ?? readStuckMsFromEnv() ?? DEFAULT_STUCK_MS;
39271
+ this.now = opts.now ?? Date.now;
39272
+ this.processExit = opts.processExit ?? ((code) => process.exit(code));
39273
+ this.logger = opts.logger ?? defaultLogger;
39274
+ this.lastSuccessAt = this.now();
39275
+ }
39276
+ /** Wraps a tracked operation: applies the hard timeout, records the outcome, and re-throws or
39277
+ * returns exactly what `fn` produced so the caller's own existing error handling is untouched. */
39278
+ async track(id, fn) {
39279
+ try {
39280
+ const result = await withTimeout(fn);
39281
+ await this.recordSuccess();
39282
+ return result;
39283
+ } catch (error51) {
39284
+ this.recordFailure(id, error51);
39285
+ throw error51;
39286
+ }
39287
+ }
39288
+ async recordSuccess() {
39289
+ this.lastSuccessAt = this.now();
39290
+ if (this.knownCrashCount === null) {
39291
+ await this.reconcileCrashCountOnFirstSuccess();
39292
+ }
39293
+ }
39294
+ recordFailure(id, error51) {
39295
+ this.lastErrorByOperation.set(id, error51 instanceof Error ? error51.message : String(error51));
39296
+ }
39297
+ /** True when no tracked operation has succeeded within `stuckMs`. */
39298
+ isStuck() {
39299
+ return this.now() - this.lastSuccessAt >= this.stuckMs;
39300
+ }
39301
+ /** Call after `track()` settles a failure. Exits the process (up to 3 times per rolling hour)
39302
+ * once stuck; a no-op once the breaker has disabled itself for this process's lifetime. */
39303
+ async maybeCrash() {
39304
+ if (this.disabled) return;
39305
+ if (!this.isStuck()) return;
39306
+ const decision = await this.decideExitOrDisable();
39307
+ if (decision.exit) {
39308
+ this.logger.critical(
39309
+ `bridge health: stuck ${Math.round((this.now() - this.lastSuccessAt) / 1e3)}s (threshold ${Math.round(this.stuckMs / 1e3)}s) \u2014 crashing so pm2 restarts clean. Last errors: ${this.formatLastErrors()}`
39310
+ );
39311
+ this.processExit(1);
39312
+ } else {
39313
+ this.disabled = true;
39314
+ this.logger.critical(
39315
+ "bridge health: circuit breaker disabled after 3 restarts in the last hour \u2014 this looks like a persistent outage, not a stuck process."
39316
+ );
39317
+ }
39318
+ }
39319
+ async decideExitOrDisable() {
39320
+ const nowMs = this.now();
39321
+ let sentinel = await readCrashSentinel(this.stateDir, this.now);
39322
+ const windowStartedMs = Date.parse(sentinel.windowStartedAt);
39323
+ if (!Number.isFinite(windowStartedMs) || nowMs - windowStartedMs > CRASH_WINDOW_MS) {
39324
+ sentinel = { crashCount: 0, windowStartedAt: new Date(nowMs).toISOString() };
39325
+ }
39326
+ sentinel = { ...sentinel, crashCount: sentinel.crashCount + 1 };
39327
+ await writeCrashSentinel(this.stateDir, sentinel);
39328
+ return { exit: sentinel.crashCount <= MAX_CRASHES_PER_WINDOW };
39329
+ }
39330
+ async reconcileCrashCountOnFirstSuccess() {
39331
+ const sentinel = await readCrashSentinel(this.stateDir, this.now);
39332
+ this.knownCrashCount = sentinel.crashCount;
39333
+ if (sentinel.crashCount > 0) {
39334
+ await writeCrashSentinel(this.stateDir, { ...sentinel, crashCount: 0 });
39335
+ this.knownCrashCount = 0;
39336
+ }
39337
+ }
39338
+ formatLastErrors() {
39339
+ if (this.lastErrorByOperation.size === 0) return "none recorded";
39340
+ return Array.from(this.lastErrorByOperation.entries()).map(([id, message]) => `${id}=${message}`).join(", ");
39341
+ }
39342
+ };
39343
+ function readStuckMsFromEnv(env = process.env) {
39344
+ const raw = (env.MRRLIN_BRIDGE_HEALTH_STUCK_MS ?? "").trim();
39345
+ const parsed = Number.parseInt(raw, 10);
39346
+ return Number.isInteger(parsed) && parsed > 0 ? parsed : null;
39347
+ }
39348
+
39184
39349
  // src/scheduler-tick.ts
39185
39350
  var SCHEDULER_TICK_MIN_MS = 6e4;
39186
39351
  var SCHEDULER_TICK_FALLBACK_MS = 3e5;
@@ -39219,17 +39384,30 @@ function dispatchTickWork(deps, results) {
39219
39384
  }
39220
39385
  }
39221
39386
  async function fireSchedulerTick(deps) {
39387
+ const bridgeHealth = deps.bridgeHealth;
39388
+ const { nextWakeAt, failed } = await attemptSchedulerTick(deps);
39389
+ if (failed) await bridgeHealth?.maybeCrash();
39390
+ return { nextWakeAt };
39391
+ }
39392
+ async function attemptSchedulerTick(deps) {
39222
39393
  const fetchImpl = deps.fetchImpl ?? fetch;
39394
+ const bridgeHealth = deps.bridgeHealth;
39223
39395
  try {
39224
- const response = await fetchImpl(`${deps.apiBaseUrl}/internal/scheduler/run`, { method: "POST" });
39396
+ const parseTick = async (signal) => {
39397
+ const response2 = await fetchImpl(`${deps.apiBaseUrl}/internal/scheduler/run`, { method: "POST", signal });
39398
+ const parsedBody2 = response2.ok ? await response2.json() : null;
39399
+ return { response: response2, parsedBody: parsedBody2 };
39400
+ };
39401
+ const { response, parsedBody } = bridgeHealth ? await withTimeout(parseTick) : await parseTick(new AbortController().signal);
39225
39402
  if (!response.ok) {
39226
39403
  process.stderr.write(
39227
39404
  `[mrrlin-mcp director-bridge] scheduler tick failed: HTTP ${response.status} from /internal/scheduler/run
39228
39405
  `
39229
39406
  );
39230
- return { nextWakeAt: null };
39407
+ bridgeHealth?.recordFailure("schedulerTick", new Error(`HTTP ${response.status}`));
39408
+ return { nextWakeAt: null, failed: true };
39231
39409
  }
39232
- const body = await response.json();
39410
+ const body = parsedBody;
39233
39411
  const data = body?.data ?? {};
39234
39412
  const results = Array.isArray(data.results) ? data.results : [];
39235
39413
  deps.logger.logOut({
@@ -39263,13 +39441,15 @@ async function fireSchedulerTick(deps) {
39263
39441
  }
39264
39442
  });
39265
39443
  dispatchTickWork(deps, results);
39266
- return { nextWakeAt: typeof data.nextWakeAt === "string" ? data.nextWakeAt : null };
39444
+ await bridgeHealth?.recordSuccess();
39445
+ return { nextWakeAt: typeof data.nextWakeAt === "string" ? data.nextWakeAt : null, failed: false };
39267
39446
  } catch (error51) {
39268
39447
  process.stderr.write(
39269
39448
  `[mrrlin-mcp director-bridge] scheduler tick failed: ${error51 instanceof Error ? error51.message : String(error51)}
39270
39449
  `
39271
39450
  );
39272
- return { nextWakeAt: null };
39451
+ bridgeHealth?.recordFailure("schedulerTick", error51);
39452
+ return { nextWakeAt: null, failed: true };
39273
39453
  }
39274
39454
  }
39275
39455
  function startSchedulerTickLoop(deps) {
@@ -39505,7 +39685,7 @@ function startAgentPoolLoop(deps) {
39505
39685
  // src/execution-consumer.ts
39506
39686
  var import_node_child_process9 = require("node:child_process");
39507
39687
  var import_node_crypto4 = __toESM(require("node:crypto"), 1);
39508
- var import_node_path7 = __toESM(require("node:path"), 1);
39688
+ var import_node_path8 = __toESM(require("node:path"), 1);
39509
39689
  var import_node_util = require("node:util");
39510
39690
 
39511
39691
  // src/consensus/heads.ts
@@ -39514,8 +39694,8 @@ var DOMAINS = ["code", "seo", "marketing", "content"];
39514
39694
  var HEADS_BY_DOMAIN = {
39515
39695
  code: ["plan-reviewer", "architect", "security-analyst", "scope-analyst"],
39516
39696
  seo: ["plan-reviewer", "scope-analyst", "seo-analyst"],
39517
- marketing: ["plan-reviewer", "scope-analyst", "content-editor"],
39518
- content: ["plan-reviewer", "scope-analyst", "content-editor"]
39697
+ marketing: ["plan-reviewer", "scope-analyst", "content-editor", "compliance-reviewer"],
39698
+ content: ["plan-reviewer", "scope-analyst", "content-editor", "compliance-reviewer"]
39519
39699
  };
39520
39700
  var SPEC_HEADS = HEADS_BY_DOMAIN.code;
39521
39701
  function normalizeDomain(value) {
@@ -39542,8 +39722,8 @@ function resolveProducerPersona(domain2) {
39542
39722
 
39543
39723
  // src/consensus/wiring.ts
39544
39724
  var import_node_crypto2 = __toESM(require("node:crypto"), 1);
39545
- var import_node_fs2 = __toESM(require("node:fs"), 1);
39546
- var import_node_path4 = __toESM(require("node:path"), 1);
39725
+ var import_node_fs3 = __toESM(require("node:fs"), 1);
39726
+ var import_node_path5 = __toESM(require("node:path"), 1);
39547
39727
  var import_node_url2 = require("node:url");
39548
39728
 
39549
39729
  // src/consensus/codex-exec.ts
@@ -39962,15 +40142,15 @@ ${res.stdout}${res.stderr}`);
39962
40142
  var import_meta2 = {};
39963
40143
  function getPersonasDir() {
39964
40144
  if (typeof __dirname !== "undefined") {
39965
- return import_node_path4.default.join(__dirname, "consensus", "personas");
40145
+ return import_node_path5.default.join(__dirname, "consensus", "personas");
39966
40146
  }
39967
- return import_node_path4.default.join(import_node_path4.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)), "personas");
40147
+ return import_node_path5.default.join(import_node_path5.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)), "personas");
39968
40148
  }
39969
40149
  var personaCache = /* @__PURE__ */ new Map();
39970
40150
  function loadPersona(name) {
39971
40151
  const cached2 = personaCache.get(name);
39972
40152
  if (cached2 !== void 0) return cached2;
39973
- const content = import_node_fs2.default.readFileSync(import_node_path4.default.join(getPersonasDir(), `${name}.md`), "utf8");
40153
+ const content = import_node_fs3.default.readFileSync(import_node_path5.default.join(getPersonasDir(), `${name}.md`), "utf8");
39974
40154
  personaCache.set(name, content);
39975
40155
  return content;
39976
40156
  }
@@ -41097,7 +41277,7 @@ function isDeployGateRunStatus(status) {
41097
41277
 
41098
41278
  // src/turn-deadline.ts
41099
41279
  var DEFAULT_TURN_INTERRUPT_TIMEOUT_MS = 5e3;
41100
- function withTimeout(promise2, ms, message) {
41280
+ function withTimeout2(promise2, ms, message) {
41101
41281
  let timer = null;
41102
41282
  const timeout = new Promise((_, reject) => {
41103
41283
  timer = setTimeout(() => reject(new Error(message)), ms);
@@ -41145,7 +41325,7 @@ async function awaitTurnWithDeadline(opts) {
41145
41325
  const isDeadline = message === opts.timeoutMessage || hasIdle && message === opts.idleTimeoutMessage;
41146
41326
  if (isDeadline) {
41147
41327
  try {
41148
- await withTimeout(
41328
+ await withTimeout2(
41149
41329
  opts.interrupt(),
41150
41330
  opts.interruptTimeoutMs ?? DEFAULT_TURN_INTERRUPT_TIMEOUT_MS,
41151
41331
  "turn.interrupt timed out"
@@ -41161,18 +41341,18 @@ async function awaitTurnWithDeadline(opts) {
41161
41341
 
41162
41342
  // src/worktree.ts
41163
41343
  var import_node_child_process8 = require("node:child_process");
41164
- var import_node_fs4 = require("node:fs");
41344
+ var import_node_fs5 = require("node:fs");
41165
41345
  var import_node_os3 = require("node:os");
41166
- var import_node_path6 = require("node:path");
41346
+ var import_node_path7 = require("node:path");
41167
41347
 
41168
41348
  // src/checkout-lock.ts
41169
- var import_node_fs3 = require("node:fs");
41170
- var import_node_path5 = require("node:path");
41349
+ var import_node_fs4 = require("node:fs");
41350
+ var import_node_path6 = require("node:path");
41171
41351
  var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
41172
41352
  async function withCheckoutLock(locksDir, slug, fn) {
41173
- (0, import_node_fs3.mkdirSync)(locksDir, { recursive: true });
41174
- const target = (0, import_node_path5.join)(locksDir, `${slug}.lock`);
41175
- if (!(0, import_node_fs3.existsSync)(target)) (0, import_node_fs3.writeFileSync)(target, "");
41353
+ (0, import_node_fs4.mkdirSync)(locksDir, { recursive: true });
41354
+ const target = (0, import_node_path6.join)(locksDir, `${slug}.lock`);
41355
+ if (!(0, import_node_fs4.existsSync)(target)) (0, import_node_fs4.writeFileSync)(target, "");
41176
41356
  const release = await import_proper_lockfile.default.lock(target, {
41177
41357
  retries: { retries: 600, factor: 1, minTimeout: 100, maxTimeout: 100 },
41178
41358
  stale: 5 * 6e4
@@ -41197,12 +41377,12 @@ function git(checkout, args) {
41197
41377
  });
41198
41378
  }
41199
41379
  async function createRunWorktree(opts) {
41200
- const worktreePath = (0, import_node_path6.join)(opts.worktreeRoot, opts.slug, opts.runId);
41380
+ const worktreePath = (0, import_node_path7.join)(opts.worktreeRoot, opts.slug, opts.runId);
41201
41381
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
41202
- (0, import_node_fs4.mkdirSync)(opts.worktreeRoot, { recursive: true });
41382
+ (0, import_node_fs5.mkdirSync)(opts.worktreeRoot, { recursive: true });
41203
41383
  try {
41204
41384
  git(opts.checkout, ["fetch", "origin", opts.defaultBranch]);
41205
- if (!(0, import_node_fs4.existsSync)(worktreePath)) {
41385
+ if (!(0, import_node_fs5.existsSync)(worktreePath)) {
41206
41386
  git(opts.checkout, [
41207
41387
  "worktree",
41208
41388
  "add",
@@ -41260,15 +41440,15 @@ async function doPushRunBranch(opts, execGit) {
41260
41440
  if (localConfig.trim()) {
41261
41441
  throw new Error(`push aborted: agent-controlled git config present in worktree: ${localConfig.trim().split("\n")[0]}`);
41262
41442
  }
41263
- const dir = (0, import_node_fs4.mkdtempSync)((0, import_node_path6.join)((0, import_node_os3.tmpdir)(), "mrrlin-push-"));
41264
- const askpass = (0, import_node_path6.join)(dir, "askpass");
41443
+ const dir = (0, import_node_fs5.mkdtempSync)((0, import_node_path7.join)((0, import_node_os3.tmpdir)(), "mrrlin-push-"));
41444
+ const askpass = (0, import_node_path7.join)(dir, "askpass");
41265
41445
  try {
41266
- (0, import_node_fs4.writeFileSync)(
41446
+ (0, import_node_fs5.writeFileSync)(
41267
41447
  askpass,
41268
41448
  '#!/bin/sh\ncase "$1" in *[Uu]sername*) printf %s "x-access-token" ;; *) printf %s "$MRRLIN_PUSH_TOKEN" ;; esac\n',
41269
41449
  { mode: 320 }
41270
41450
  );
41271
- (0, import_node_fs4.chmodSync)(askpass, 320);
41451
+ (0, import_node_fs5.chmodSync)(askpass, 320);
41272
41452
  execGit(
41273
41453
  [
41274
41454
  "-C",
@@ -41287,18 +41467,18 @@ async function doPushRunBranch(opts, execGit) {
41287
41467
  );
41288
41468
  return { pushedSha: localSha };
41289
41469
  } finally {
41290
- (0, import_node_fs4.rmSync)(dir, { recursive: true, force: true });
41470
+ (0, import_node_fs5.rmSync)(dir, { recursive: true, force: true });
41291
41471
  }
41292
41472
  }
41293
41473
  async function sweepOrphanWorktrees(opts) {
41294
41474
  const reaped = [];
41295
41475
  const ownedPrefix = (() => {
41296
41476
  try {
41297
- return (0, import_node_fs4.realpathSync)(opts.worktreeRoot);
41477
+ return (0, import_node_fs5.realpathSync)(opts.worktreeRoot);
41298
41478
  } catch {
41299
41479
  return opts.worktreeRoot;
41300
41480
  }
41301
- })() + import_node_path6.sep + opts.slug + import_node_path6.sep;
41481
+ })() + import_node_path7.sep + opts.slug + import_node_path7.sep;
41302
41482
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
41303
41483
  const listing = git(opts.checkout, ["worktree", "list", "--porcelain"]);
41304
41484
  for (const block of listing.split("\n\n")) {
@@ -41559,8 +41739,8 @@ function newArtifactId() {
41559
41739
  return `EA-${import_node_crypto4.default.randomUUID()}`;
41560
41740
  }
41561
41741
  var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
41562
- function isBlastRadiusFloorPath(path16) {
41563
- return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path16));
41742
+ function isBlastRadiusFloorPath(path17) {
41743
+ return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path17));
41564
41744
  }
41565
41745
  var execFileAsync = (0, import_node_util.promisify)(import_node_child_process9.execFile);
41566
41746
  async function defaultListRunDiffPaths(opts) {
@@ -42192,7 +42372,7 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2)
42192
42372
  task,
42193
42373
  runId,
42194
42374
  leaseId,
42195
- `non_code_execution_unsupported: task ${task.id} domain "${domain2}" is not in the execution whitelist.`
42375
+ `non_code_execution_unsupported: task ${task.id} domain "${domain2}" is not approved by the autonomous execution policy.`
42196
42376
  );
42197
42377
  return;
42198
42378
  }
@@ -42522,8 +42702,8 @@ async function runBackstopSweep(deps, drive = (slug, id) => driveRun(deps, slug,
42522
42702
  function isRunRecoverableByThisBridge(run3, worktreeRoot) {
42523
42703
  if (!worktreeRoot) return true;
42524
42704
  if (!run3.worktreeId) return false;
42525
- const relative = import_node_path7.default.relative(import_node_path7.default.resolve(worktreeRoot), import_node_path7.default.resolve(run3.worktreeId));
42526
- return relative === "" || relative.length > 0 && !relative.startsWith("..") && !import_node_path7.default.isAbsolute(relative);
42705
+ const relative = import_node_path8.default.relative(import_node_path8.default.resolve(worktreeRoot), import_node_path8.default.resolve(run3.worktreeId));
42706
+ return relative === "" || relative.length > 0 && !relative.startsWith("..") && !import_node_path8.default.isAbsolute(relative);
42527
42707
  }
42528
42708
  async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId) {
42529
42709
  await deps.client.updateExecutionRun(projectSlug, runId, { status: "failed", finishedAt: (/* @__PURE__ */ new Date()).toISOString(), leaseId: leaseId ?? void 0 }).catch(() => {
@@ -42987,19 +43167,19 @@ function codexIdleMs() {
42987
43167
  }
42988
43168
 
42989
43169
  // src/operator-token.ts
42990
- var import_node_fs5 = require("node:fs");
43170
+ var import_node_fs6 = require("node:fs");
42991
43171
  var import_node_os4 = __toESM(require("node:os"), 1);
42992
- var import_node_path8 = __toESM(require("node:path"), 1);
43172
+ var import_node_path9 = __toESM(require("node:path"), 1);
42993
43173
  function operatorDir() {
42994
- const base = process.env.CODEX_HOME ? import_node_path8.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path8.default.join(import_node_os4.default.homedir(), ".mrrlin");
43174
+ const base = process.env.CODEX_HOME ? import_node_path9.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path9.default.join(import_node_os4.default.homedir(), ".mrrlin");
42995
43175
  return base;
42996
43176
  }
42997
43177
  function operatorTokenPath() {
42998
- return import_node_path8.default.join(operatorDir(), "operator-token");
43178
+ return import_node_path9.default.join(operatorDir(), "operator-token");
42999
43179
  }
43000
43180
  function readOperatorToken() {
43001
43181
  try {
43002
- const token = (0, import_node_fs5.readFileSync)(operatorTokenPath(), "utf8").trim();
43182
+ const token = (0, import_node_fs6.readFileSync)(operatorTokenPath(), "utf8").trim();
43003
43183
  return token.length > 0 ? token : null;
43004
43184
  } catch {
43005
43185
  return null;
@@ -43007,24 +43187,24 @@ function readOperatorToken() {
43007
43187
  }
43008
43188
  function persistOperatorToken(token) {
43009
43189
  const dir = operatorDir();
43010
- (0, import_node_fs5.mkdirSync)(dir, { recursive: true, mode: 448 });
43011
- (0, import_node_fs5.writeFileSync)(operatorTokenPath(), `${token.trim()}
43190
+ (0, import_node_fs6.mkdirSync)(dir, { recursive: true, mode: 448 });
43191
+ (0, import_node_fs6.writeFileSync)(operatorTokenPath(), `${token.trim()}
43012
43192
  `, { encoding: "utf8", mode: 384 });
43013
43193
  }
43014
43194
  function agentCredentialPath() {
43015
- return import_node_path8.default.join(operatorDir(), "agent-credential");
43195
+ return import_node_path9.default.join(operatorDir(), "agent-credential");
43016
43196
  }
43017
43197
  function persistAgentSecret(secret) {
43018
43198
  const dir = operatorDir();
43019
- (0, import_node_fs5.mkdirSync)(dir, { recursive: true, mode: 448 });
43020
- (0, import_node_fs5.writeFileSync)(agentCredentialPath(), `${secret.trim()}
43199
+ (0, import_node_fs6.mkdirSync)(dir, { recursive: true, mode: 448 });
43200
+ (0, import_node_fs6.writeFileSync)(agentCredentialPath(), `${secret.trim()}
43021
43201
  `, { encoding: "utf8", mode: 384 });
43022
43202
  }
43023
43203
  function readAgentSecret() {
43024
43204
  const fromEnv = process.env.MRRLIN_AGENT_SECRET?.trim();
43025
43205
  if (fromEnv) return fromEnv;
43026
43206
  try {
43027
- const raw = (0, import_node_fs5.readFileSync)(agentCredentialPath(), "utf8").trim();
43207
+ const raw = (0, import_node_fs6.readFileSync)(agentCredentialPath(), "utf8").trim();
43028
43208
  return raw || void 0;
43029
43209
  } catch {
43030
43210
  return void 0;
@@ -43032,16 +43212,16 @@ function readAgentSecret() {
43032
43212
  }
43033
43213
 
43034
43214
  // src/thread-index.ts
43035
- var import_node_fs6 = require("node:fs");
43036
- var import_node_path9 = __toESM(require("node:path"), 1);
43215
+ var import_node_fs7 = require("node:fs");
43216
+ var import_node_path10 = __toESM(require("node:path"), 1);
43037
43217
  function threadIndexPath(stateDir) {
43038
- return import_node_path9.default.join(stateDir, "threads.json");
43218
+ return import_node_path10.default.join(stateDir, "threads.json");
43039
43219
  }
43040
43220
  function loadThreadIndex(stateDir, ttlMs, now) {
43041
43221
  const result = /* @__PURE__ */ new Map();
43042
43222
  let parsed;
43043
43223
  try {
43044
- parsed = JSON.parse((0, import_node_fs6.readFileSync)(threadIndexPath(stateDir), "utf8"));
43224
+ parsed = JSON.parse((0, import_node_fs7.readFileSync)(threadIndexPath(stateDir), "utf8"));
43045
43225
  } catch {
43046
43226
  return result;
43047
43227
  }
@@ -43063,8 +43243,8 @@ function loadThreadIndex(stateDir, ttlMs, now) {
43063
43243
  return result;
43064
43244
  }
43065
43245
  function saveThreadIndex(stateDir, entries) {
43066
- (0, import_node_fs6.mkdirSync)(stateDir, { recursive: true, mode: 448 });
43067
- (0, import_node_fs6.writeFileSync)(threadIndexPath(stateDir), `${JSON.stringify(Object.fromEntries(entries), null, 2)}
43246
+ (0, import_node_fs7.mkdirSync)(stateDir, { recursive: true, mode: 448 });
43247
+ (0, import_node_fs7.writeFileSync)(threadIndexPath(stateDir), `${JSON.stringify(Object.fromEntries(entries), null, 2)}
43068
43248
  `, {
43069
43249
  encoding: "utf8",
43070
43250
  mode: 384
@@ -43150,9 +43330,9 @@ function chatTurnMaxMs() {
43150
43330
 
43151
43331
  // src/worker-token.ts
43152
43332
  var import_node_crypto6 = require("node:crypto");
43153
- var import_node_fs7 = require("node:fs");
43333
+ var import_node_fs8 = require("node:fs");
43154
43334
  var import_node_os5 = __toESM(require("node:os"), 1);
43155
- var import_node_path10 = __toESM(require("node:path"), 1);
43335
+ var import_node_path11 = __toESM(require("node:path"), 1);
43156
43336
  var DEFAULT_WORKER_PORT = 8792;
43157
43337
  function workerPort() {
43158
43338
  const raw = process.env.MRRLIN_WORKER_PORT;
@@ -43161,15 +43341,15 @@ function workerPort() {
43161
43341
  return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_WORKER_PORT;
43162
43342
  }
43163
43343
  function workerDir() {
43164
- const base = process.env.CODEX_HOME ? import_node_path10.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path10.default.join(import_node_os5.default.homedir(), ".mrrlin");
43165
- return import_node_path10.default.join(base, "worker");
43344
+ const base = process.env.CODEX_HOME ? import_node_path11.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path11.default.join(import_node_os5.default.homedir(), ".mrrlin");
43345
+ return import_node_path11.default.join(base, "worker");
43166
43346
  }
43167
43347
  function workerTokenPath() {
43168
- return import_node_path10.default.join(workerDir(), "token");
43348
+ return import_node_path11.default.join(workerDir(), "token");
43169
43349
  }
43170
43350
  function readWorkerToken() {
43171
43351
  try {
43172
- const token = (0, import_node_fs7.readFileSync)(workerTokenPath(), "utf8").trim();
43352
+ const token = (0, import_node_fs8.readFileSync)(workerTokenPath(), "utf8").trim();
43173
43353
  return token.length > 0 ? token : null;
43174
43354
  } catch {
43175
43355
  return null;
@@ -43179,18 +43359,18 @@ function readOrCreateWorkerToken() {
43179
43359
  const existing = readWorkerToken();
43180
43360
  if (existing) return existing;
43181
43361
  const dir = workerDir();
43182
- (0, import_node_fs7.mkdirSync)(dir, { recursive: true, mode: 448 });
43362
+ (0, import_node_fs8.mkdirSync)(dir, { recursive: true, mode: 448 });
43183
43363
  const token = (0, import_node_crypto6.randomBytes)(32).toString("hex");
43184
- (0, import_node_fs7.writeFileSync)(workerTokenPath(), `${token}
43364
+ (0, import_node_fs8.writeFileSync)(workerTokenPath(), `${token}
43185
43365
  `, { encoding: "utf8", mode: 384 });
43186
43366
  return token;
43187
43367
  }
43188
43368
 
43189
43369
  // src/remote-phone-relay.ts
43190
43370
  var import_node_events2 = require("node:events");
43191
- var import_node_fs8 = require("node:fs");
43371
+ var import_node_fs9 = require("node:fs");
43192
43372
  var import_node_os6 = require("node:os");
43193
- var import_node_path11 = require("node:path");
43373
+ var import_node_path12 = require("node:path");
43194
43374
 
43195
43375
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/cryptoNode.js
43196
43376
  var nc = __toESM(require("node:crypto"), 1);
@@ -46761,9 +46941,9 @@ var DirectorRelay = class {
46761
46941
 
46762
46942
  // src/remote-phone-relay.ts
46763
46943
  function loadOrCreateAgentDeviceKey() {
46764
- const path16 = (0, import_node_path11.join)((0, import_node_os6.homedir)(), ".mrrlin", "agent-device-key");
46944
+ const path17 = (0, import_node_path12.join)((0, import_node_os6.homedir)(), ".mrrlin", "agent-device-key");
46765
46945
  try {
46766
- const raw = JSON.parse((0, import_node_fs8.readFileSync)(path16, "utf8"));
46946
+ const raw = JSON.parse((0, import_node_fs9.readFileSync)(path17, "utf8"));
46767
46947
  if (typeof raw.priv === "string" && typeof raw.pub === "string") {
46768
46948
  return { privateKey: fromBase64Url(raw.priv), publicKey: fromBase64Url(raw.pub) };
46769
46949
  }
@@ -46771,9 +46951,9 @@ function loadOrCreateAgentDeviceKey() {
46771
46951
  }
46772
46952
  const kp = generateIdentityKeyPair();
46773
46953
  try {
46774
- (0, import_node_fs8.mkdirSync)((0, import_node_path11.join)((0, import_node_os6.homedir)(), ".mrrlin"), { recursive: true });
46775
- (0, import_node_fs8.writeFileSync)(
46776
- path16,
46954
+ (0, import_node_fs9.mkdirSync)((0, import_node_path12.join)((0, import_node_os6.homedir)(), ".mrrlin"), { recursive: true });
46955
+ (0, import_node_fs9.writeFileSync)(
46956
+ path17,
46777
46957
  JSON.stringify({ priv: toBase64Url(kp.privateKey), pub: toBase64Url(kp.publicKey) }),
46778
46958
  { mode: 384 }
46779
46959
  );
@@ -46781,10 +46961,10 @@ function loadOrCreateAgentDeviceKey() {
46781
46961
  }
46782
46962
  return kp;
46783
46963
  }
46784
- var AGENT_PAIRING_PATH = (0, import_node_path11.join)((0, import_node_os6.homedir)(), ".mrrlin", "agent-pairing.json");
46964
+ var AGENT_PAIRING_PATH = (0, import_node_path12.join)((0, import_node_os6.homedir)(), ".mrrlin", "agent-pairing.json");
46785
46965
  function loadAgentPairing() {
46786
46966
  try {
46787
- const raw = JSON.parse((0, import_node_fs8.readFileSync)(AGENT_PAIRING_PATH, "utf8"));
46967
+ const raw = JSON.parse((0, import_node_fs9.readFileSync)(AGENT_PAIRING_PATH, "utf8"));
46788
46968
  if (typeof raw.channelId === "string" && typeof raw.agentControlSecret === "string" && typeof raw.relayAuth === "string" && typeof raw.peerIdentityKey === "string") {
46789
46969
  return {
46790
46970
  channelId: raw.channelId,
@@ -46799,8 +46979,8 @@ function loadAgentPairing() {
46799
46979
  }
46800
46980
  function saveAgentPairing(record2) {
46801
46981
  try {
46802
- (0, import_node_fs8.mkdirSync)((0, import_node_path11.join)((0, import_node_os6.homedir)(), ".mrrlin"), { recursive: true });
46803
- (0, import_node_fs8.writeFileSync)(AGENT_PAIRING_PATH, JSON.stringify(record2), { mode: 384 });
46982
+ (0, import_node_fs9.mkdirSync)((0, import_node_path12.join)((0, import_node_os6.homedir)(), ".mrrlin"), { recursive: true });
46983
+ (0, import_node_fs9.writeFileSync)(AGENT_PAIRING_PATH, JSON.stringify(record2), { mode: 384 });
46804
46984
  } catch {
46805
46985
  }
46806
46986
  }
@@ -46977,18 +47157,18 @@ async function renderPairingQrSvg(payload) {
46977
47157
  }
46978
47158
 
46979
47159
  // src/checkout-registry.ts
46980
- var import_node_fs9 = require("node:fs");
46981
- var import_node_path12 = require("node:path");
47160
+ var import_node_fs10 = require("node:fs");
47161
+ var import_node_path13 = require("node:path");
46982
47162
  var CheckoutRegistry = class {
46983
47163
  file;
46984
47164
  constructor(stateDir) {
46985
- this.file = (0, import_node_path12.join)(stateDir, "checkouts.json");
46986
- (0, import_node_fs9.mkdirSync)(stateDir, { recursive: true });
47165
+ this.file = (0, import_node_path13.join)(stateDir, "checkouts.json");
47166
+ (0, import_node_fs10.mkdirSync)(stateDir, { recursive: true });
46987
47167
  }
46988
47168
  read() {
46989
- if (!(0, import_node_fs9.existsSync)(this.file)) return {};
47169
+ if (!(0, import_node_fs10.existsSync)(this.file)) return {};
46990
47170
  try {
46991
- return JSON.parse((0, import_node_fs9.readFileSync)(this.file, "utf8"));
47171
+ return JSON.parse((0, import_node_fs10.readFileSync)(this.file, "utf8"));
46992
47172
  } catch {
46993
47173
  return {};
46994
47174
  }
@@ -46996,10 +47176,10 @@ var CheckoutRegistry = class {
46996
47176
  get(slug) {
46997
47177
  return this.read()[slug] ?? null;
46998
47178
  }
46999
- confirm(slug, path16, now) {
47179
+ confirm(slug, path17, now) {
47000
47180
  const all = this.read();
47001
- all[slug] = { path: path16, confirmedAt: now };
47002
- (0, import_node_fs9.writeFileSync)(this.file, JSON.stringify(all, null, 2));
47181
+ all[slug] = { path: path17, confirmedAt: now };
47182
+ (0, import_node_fs10.writeFileSync)(this.file, JSON.stringify(all, null, 2));
47003
47183
  }
47004
47184
  };
47005
47185
 
@@ -47210,8 +47390,8 @@ function extractVerificationSection(markdown) {
47210
47390
  }
47211
47391
 
47212
47392
  // src/bridge-log.ts
47213
- var import_node_fs10 = require("node:fs");
47214
- var import_node_path13 = require("node:path");
47393
+ var import_node_fs11 = require("node:fs");
47394
+ var import_node_path14 = require("node:path");
47215
47395
 
47216
47396
  // src/redact.ts
47217
47397
  var REDACTED = "[REDACTED]";
@@ -47296,14 +47476,14 @@ function resolvePromptsEnabled(env) {
47296
47476
  }
47297
47477
  function createBridgeLogger(stateDir, env = process.env) {
47298
47478
  if (!resolveBridgeLogEnabled(env)) return NOOP_LOGGER;
47299
- const logsDir = (0, import_node_path13.join)(stateDir, "logs");
47479
+ const logsDir = (0, import_node_path14.join)(stateDir, "logs");
47300
47480
  try {
47301
- (0, import_node_fs10.mkdirSync)(logsDir, { recursive: true });
47481
+ (0, import_node_fs11.mkdirSync)(logsDir, { recursive: true });
47302
47482
  } catch {
47303
47483
  return NOOP_LOGGER;
47304
47484
  }
47305
47485
  const includePrompts = resolvePromptsEnabled(env);
47306
- const fileFor = () => (0, import_node_path13.join)(logsDir, `bridge-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.jsonl`);
47486
+ const fileFor = () => (0, import_node_path14.join)(logsDir, `bridge-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.jsonl`);
47307
47487
  const write = (dir, rec) => {
47308
47488
  try {
47309
47489
  const line = JSON.stringify({
@@ -47315,7 +47495,7 @@ function createBridgeLogger(stateDir, env = process.env) {
47315
47495
  ...rec.ms !== void 0 ? { ms: rec.ms } : {},
47316
47496
  payload: redactMessage(rec.payload, { includePrompts })
47317
47497
  }) + "\n";
47318
- (0, import_node_fs10.appendFileSync)(fileFor(), line);
47498
+ (0, import_node_fs11.appendFileSync)(fileFor(), line);
47319
47499
  } catch {
47320
47500
  }
47321
47501
  };
@@ -47385,7 +47565,7 @@ function addBridgeModel(target, model) {
47385
47565
  }
47386
47566
  function readTextIfExists(filePath) {
47387
47567
  try {
47388
- return import_node_fs11.default.readFileSync(filePath, "utf8");
47568
+ return import_node_fs12.default.readFileSync(filePath, "utf8");
47389
47569
  } catch {
47390
47570
  return null;
47391
47571
  }
@@ -47396,9 +47576,9 @@ function readKnownGptSlugsFromTomlFile(filePath) {
47396
47576
  return Array.from(raw.matchAll(/^\s*model\s*=\s*"([^"]+)"/gm)).map((match) => match[1]?.trim() ?? "").filter(isSelectableModelSlug);
47397
47577
  }
47398
47578
  function readCodexFallbackModels() {
47399
- const codexHome = process.env.CODEX_HOME?.trim() || import_node_path14.default.join(import_node_os7.default.homedir(), ".codex");
47579
+ const codexHome = process.env.CODEX_HOME?.trim() || import_node_path15.default.join(import_node_os7.default.homedir(), ".codex");
47400
47580
  const models = /* @__PURE__ */ new Map();
47401
- const cachePath = import_node_path14.default.join(codexHome, "models_cache.json");
47581
+ const cachePath = import_node_path15.default.join(codexHome, "models_cache.json");
47402
47582
  const cacheRaw = readTextIfExists(cachePath);
47403
47583
  if (cacheRaw) {
47404
47584
  try {
@@ -47448,7 +47628,7 @@ function readCodexFallbackModels() {
47448
47628
  );
47449
47629
  }
47450
47630
  }
47451
- for (const slug of readKnownGptSlugsFromTomlFile(import_node_path14.default.join(codexHome, "config.toml"))) {
47631
+ for (const slug of readKnownGptSlugsFromTomlFile(import_node_path15.default.join(codexHome, "config.toml"))) {
47452
47632
  addBridgeModel(
47453
47633
  models,
47454
47634
  mapBridgeModel({
@@ -47462,11 +47642,11 @@ function readCodexFallbackModels() {
47462
47642
  })
47463
47643
  );
47464
47644
  }
47465
- const automationsDir = import_node_path14.default.join(codexHome, "automations");
47645
+ const automationsDir = import_node_path15.default.join(codexHome, "automations");
47466
47646
  try {
47467
- for (const entry of import_node_fs11.default.readdirSync(automationsDir, { withFileTypes: true })) {
47647
+ for (const entry of import_node_fs12.default.readdirSync(automationsDir, { withFileTypes: true })) {
47468
47648
  if (!entry.isDirectory()) continue;
47469
- for (const slug of readKnownGptSlugsFromTomlFile(import_node_path14.default.join(automationsDir, entry.name, "automation.toml"))) {
47649
+ for (const slug of readKnownGptSlugsFromTomlFile(import_node_path15.default.join(automationsDir, entry.name, "automation.toml"))) {
47470
47650
  addBridgeModel(
47471
47651
  models,
47472
47652
  mapBridgeModel({
@@ -47486,9 +47666,9 @@ function readCodexFallbackModels() {
47486
47666
  return [...models.values()];
47487
47667
  }
47488
47668
  function neutralCheckoutCwd(stateDir) {
47489
- const dir = import_node_path14.default.join(stateDir, "no-checkout");
47669
+ const dir = import_node_path15.default.join(stateDir, "no-checkout");
47490
47670
  try {
47491
- import_node_fs11.default.mkdirSync(dir, { recursive: true });
47671
+ import_node_fs12.default.mkdirSync(dir, { recursive: true });
47492
47672
  } catch {
47493
47673
  }
47494
47674
  return dir;
@@ -47538,7 +47718,7 @@ function buildThreadStartParams(msg, config2, desiredModel) {
47538
47718
  " bullets (`- AND ...` as needed). Scenarios make the spec verifiable.",
47539
47719
  "- Keep behavior contracts in the spec; implementation details belong in `## Implementation Plan`.",
47540
47720
  "- Apply this format ONLY to Specs/{id} pages; do not retro-fit it onto other wiki page types.",
47541
- "- Spec consensus runs ASYNCHRONOUSLY. Call `run_spec_consensus` for a `Specs/{id}` page; it returns IMMEDIATELY. On `already_converged`, the spec is already marked ready \u2014 proceed straight to `create_execution_run`; do NOT call `mark_spec_ready` and do NOT re-run consensus. On `queued` or `already_running`, tell the user it was launched and END your turn \u2014 do NOT poll or call it again; the result arrives in the inbox (an `info` item on CONVERGED, a `handoff` item if it was blocked/failed). When a consensus `info` item says CONVERGED, proceed to `create_execution_run`. When a `handoff` says it was blocked, address the recorded issues in the spec (any edit re-arms the gate) and call `run_spec_consensus` once more. For a NON-code task (domain seo/marketing/content, ADR 0020): supported domains like `seo` proceed to `create_execution_run` after consensus converges; unsupported domains fail-close with `non_code_execution_unsupported`. Report the spec's review outcome to the operator.",
47721
+ "- Spec consensus runs ASYNCHRONOUSLY. Call `run_spec_consensus` for a `Specs/{id}` page; it returns IMMEDIATELY. On `already_converged`, the spec is already marked ready \u2014 proceed straight to `create_execution_run`; do NOT call `mark_spec_ready` and do NOT re-run consensus. On `queued` or `already_running`, tell the user it was launched and END your turn \u2014 do NOT poll or call it again; the result arrives in the inbox (an `info` item on CONVERGED, a `handoff` item if it was blocked/failed). When a consensus `info` item says CONVERGED, proceed to `create_execution_run`. When a `handoff` says it was blocked, address the recorded issues in the spec (any edit re-arms the gate) and call `run_spec_consensus` once more. For a NON-code task (domain seo/marketing/content, ADR 0020): currently supported low-risk domains `seo`, `marketing`, and `content` proceed to `create_execution_run` after consensus converges; unsupported domains still fail-close with `non_code_execution_unsupported`. Report the spec's review outcome to the operator.",
47542
47722
  '- When a task needs a browser (login flows, UI verification/clicks, scraping), pass `prerequisites:[{mcp:"mrrlin-browser",reason:"..."}]` to `create_execution_run`. If that run later fails into a handoff, the operator gets a one-click "Launch browser & resume" that brings up the dedicated browser as the turn starts.',
47543
47723
  "- When you actually drive a browser (calling `browser_navigate`, `browser_click`, `browser_snapshot`, `browser_type`, etc.), invoke those tools from the **`mrrlin-browser`** MCP server ONLY. Do NOT use tools from any other browser MCP (`playwright`, `chrome-devtools`, `puppeteer`, etc.) even if they are also connected on this operator's box \u2014 those use a shared/default Playwright profile that is fragile across runs. Only `mrrlin-browser` uses this project's dedicated Chromium + persistent operator profile (`~/.mrrlin/browser/profile`). If your host exposes multiple browser MCPs with overlapping tool names, prefer the `mrrlin-browser` server unconditionally.",
47544
47724
  "",
@@ -47804,7 +47984,7 @@ async function runOrphanWorktreeSweep(client, opts) {
47804
47984
  const cutoff = Date.now() - worktreeRetentionMs();
47805
47985
  const isReapable = (worktreePath) => {
47806
47986
  try {
47807
- return import_node_fs11.default.statSync(worktreePath).mtimeMs < cutoff;
47987
+ return import_node_fs12.default.statSync(worktreePath).mtimeMs < cutoff;
47808
47988
  } catch {
47809
47989
  return false;
47810
47990
  }
@@ -47842,8 +48022,8 @@ async function runOrphanWorktreeSweep(client, opts) {
47842
48022
  }
47843
48023
  }
47844
48024
  function readStateDir() {
47845
- if (process.env.CODEX_HOME) return import_node_path14.default.join(process.env.CODEX_HOME, "mrrlin", "director-bridge");
47846
- return import_node_path14.default.join(import_node_os7.default.homedir(), ".mrrlin", "director-bridge");
48025
+ if (process.env.CODEX_HOME) return import_node_path15.default.join(process.env.CODEX_HOME, "mrrlin", "director-bridge");
48026
+ return import_node_path15.default.join(import_node_os7.default.homedir(), ".mrrlin", "director-bridge");
47847
48027
  }
47848
48028
  function readAllowedOrigins() {
47849
48029
  const raw = (process.env.MRRLIN_DIRECTOR_BRIDGE_ALLOWED_ORIGINS ?? "").trim();
@@ -48378,7 +48558,7 @@ function createBridgeMessageHandler(deps) {
48378
48558
  }
48379
48559
  }
48380
48560
  takenOver.cancel?.();
48381
- void withTimeout(
48561
+ void withTimeout2(
48382
48562
  codexClient.turn.interrupt({ threadId: takenOver.threadId }),
48383
48563
  DEFAULT_TURN_INTERRUPT_TIMEOUT_MS,
48384
48564
  "interrupt timed out"
@@ -48580,7 +48760,7 @@ function createBridgeMessageHandler(deps) {
48580
48760
  reason === "idle" ? `Director turn stalled \u2014 no activity for ${Math.round(idleMs / 1e3)}s. Stopping; try again.` : `Director turn exceeded the ${Math.round(maxMs / 1e3)}s ceiling. Stopping; try again.`
48581
48761
  )
48582
48762
  );
48583
- void withTimeout(codexClient.turn.interrupt({ threadId }), DEFAULT_TURN_INTERRUPT_TIMEOUT_MS, "interrupt timed out").catch(
48763
+ void withTimeout2(codexClient.turn.interrupt({ threadId }), DEFAULT_TURN_INTERRUPT_TIMEOUT_MS, "interrupt timed out").catch(
48584
48764
  () => {
48585
48765
  if (deps.threads.get(directorSessionId) === thread) {
48586
48766
  deps.threads.delete(directorSessionId);
@@ -48870,8 +49050,8 @@ async function startDirectorBridge() {
48870
49050
  codexCwd: config2.codexCwd,
48871
49051
  codexExecutable: config2.codexExecutable,
48872
49052
  checkoutRegistry,
48873
- worktreeRoot: import_node_path14.default.join(config2.stateDir, "worktrees"),
48874
- locksDir: import_node_path14.default.join(config2.stateDir, "locks"),
49053
+ worktreeRoot: import_node_path15.default.join(config2.stateDir, "worktrees"),
49054
+ locksDir: import_node_path15.default.join(config2.stateDir, "locks"),
48875
49055
  // Wire the executor server for code-execution runs. Each run gets its own app-server
48876
49056
  // process at the run worktree, running UNRESTRICTED from the real ~/.codex (owner
48877
49057
  // no-sandbox decision — auth + mrrlin MCP come from the operator config).
@@ -48907,13 +49087,13 @@ async function startDirectorBridge() {
48907
49087
  // egressDomains is retained in the seam signature (verification-turn.ts still computes the
48908
49088
  // env host) but no longer constrains anything — the executor is unrestricted.
48909
49089
  startSandbox: async (_egressDomains) => {
48910
- const cwd = import_node_fs11.default.mkdtempSync(import_node_path14.default.join(import_node_os7.default.tmpdir(), "mrrlin-verify-"));
49090
+ const cwd = import_node_fs12.default.mkdtempSync(import_node_path15.default.join(import_node_os7.default.tmpdir(), "mrrlin-verify-"));
48911
49091
  let handle;
48912
49092
  try {
48913
49093
  handle = await startExecutorServer({ worktree: cwd });
48914
49094
  } catch (error51) {
48915
49095
  try {
48916
- import_node_fs11.default.rmSync(cwd, { recursive: true, force: true });
49096
+ import_node_fs12.default.rmSync(cwd, { recursive: true, force: true });
48917
49097
  } catch {
48918
49098
  }
48919
49099
  throw error51;
@@ -48924,7 +49104,7 @@ async function startDirectorBridge() {
48924
49104
  dispose: () => {
48925
49105
  handle.dispose();
48926
49106
  try {
48927
- import_node_fs11.default.rmSync(cwd, { recursive: true, force: true });
49107
+ import_node_fs12.default.rmSync(cwd, { recursive: true, force: true });
48928
49108
  } catch {
48929
49109
  }
48930
49110
  }
@@ -49132,7 +49312,7 @@ async function startDirectorBridge() {
49132
49312
  const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
49133
49313
  let bridgeBinShaShort = "unknown00000";
49134
49314
  try {
49135
- bridgeBinShaShort = import_node_crypto7.default.createHash("sha256").update(import_node_fs11.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
49315
+ bridgeBinShaShort = import_node_crypto7.default.createHash("sha256").update(import_node_fs12.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
49136
49316
  } catch {
49137
49317
  }
49138
49318
  attachBridgeWss(server, {
@@ -49219,34 +49399,50 @@ async function startDirectorBridge() {
49219
49399
  dispatchServer.on("error", reject);
49220
49400
  dispatchServer.listen(workerPort(), "127.0.0.1", () => resolve());
49221
49401
  });
49402
+ const bridgeHealth = new BridgeHealthTracker({ stateDir: config2.stateDir });
49403
+ const runTrackedSweep = async (id, label, fn) => {
49404
+ try {
49405
+ await fn();
49406
+ await bridgeHealth.recordSuccess();
49407
+ } catch (error51) {
49408
+ process.stderr.write(
49409
+ `[mrrlin-mcp director-bridge] ${label} failed: ${error51 instanceof Error ? error51.message : String(error51)}
49410
+ `
49411
+ );
49412
+ bridgeHealth.recordFailure(id, error51);
49413
+ await bridgeHealth.maybeCrash();
49414
+ }
49415
+ };
49222
49416
  let claimLoopStopped = false;
49223
49417
  let claimTimer = null;
49224
49418
  const scheduleClaimLoop = () => {
49225
49419
  if (claimLoopStopped) return;
49226
49420
  claimTimer = setTimeout(() => {
49227
49421
  enqueueRun(
49228
- () => runBackstopSweep(consumerDeps, (slug, runId) => {
49229
- driveTracked(slug, runId);
49230
- return Promise.resolve();
49231
- }).catch((error51) => {
49232
- process.stderr.write(`[mrrlin-mcp director-bridge] claim sweep failed: ${error51 instanceof Error ? error51.message : String(error51)}
49233
- `);
49234
- })
49422
+ () => runTrackedSweep(
49423
+ "claimSweep",
49424
+ "claim sweep",
49425
+ () => runBackstopSweep(consumerDeps, (slug, runId) => {
49426
+ driveTracked(slug, runId);
49427
+ return Promise.resolve();
49428
+ })
49429
+ )
49235
49430
  );
49236
49431
  enqueueRun(
49237
- () => runAsyncBackstopSweep(asyncConsumerDeps, (slug, jobId) => {
49238
- driveAsyncTracked(slug, jobId);
49239
- return Promise.resolve();
49240
- }).catch((error51) => {
49241
- process.stderr.write(`[mrrlin-mcp director-bridge] async sweep failed: ${error51 instanceof Error ? error51.message : String(error51)}
49242
- `);
49243
- })
49432
+ () => runTrackedSweep(
49433
+ "asyncSweep",
49434
+ "async sweep",
49435
+ () => runAsyncBackstopSweep(asyncConsumerDeps, (slug, jobId) => {
49436
+ driveAsyncTracked(slug, jobId);
49437
+ return Promise.resolve();
49438
+ })
49439
+ )
49244
49440
  );
49245
49441
  enqueueRun(
49246
49442
  () => runOrphanWorktreeSweep(client, {
49247
49443
  checkoutRegistry,
49248
- worktreeRoot: import_node_path14.default.join(config2.stateDir, "worktrees"),
49249
- locksDir: import_node_path14.default.join(config2.stateDir, "locks")
49444
+ worktreeRoot: import_node_path15.default.join(config2.stateDir, "worktrees"),
49445
+ locksDir: import_node_path15.default.join(config2.stateDir, "locks")
49250
49446
  })
49251
49447
  );
49252
49448
  enqueueRun(async () => {
@@ -49307,6 +49503,7 @@ async function startDirectorBridge() {
49307
49503
  apiBaseUrl,
49308
49504
  fetchImpl: authedFetch,
49309
49505
  logger: bridgeLogger,
49506
+ bridgeHealth,
49310
49507
  dispatchEnqueued: (projectSlug, work) => {
49311
49508
  if (work.kind === "execution_run") driveRunNow(projectSlug, work.runId);
49312
49509
  else driveAsyncNow(projectSlug, work.jobId);
@@ -49507,15 +49704,15 @@ function readDispatchBody(req) {
49507
49704
  function readOrCreateBridgeToken(stateDir) {
49508
49705
  const explicit = (process.env.MRRLIN_DIRECTOR_BRIDGE_TOKEN ?? "").trim();
49509
49706
  if (explicit) return explicit;
49510
- const tokenPath = import_node_path14.default.join(stateDir, "token.txt");
49707
+ const tokenPath = import_node_path15.default.join(stateDir, "token.txt");
49511
49708
  try {
49512
- const existing = import_node_fs11.default.readFileSync(tokenPath, "utf8").trim();
49709
+ const existing = import_node_fs12.default.readFileSync(tokenPath, "utf8").trim();
49513
49710
  if (existing) return existing;
49514
49711
  } catch {
49515
49712
  }
49516
- import_node_fs11.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
49713
+ import_node_fs12.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
49517
49714
  const token = import_node_crypto7.default.randomBytes(32).toString("base64url");
49518
- import_node_fs11.default.writeFileSync(tokenPath, `${token}
49715
+ import_node_fs12.default.writeFileSync(tokenPath, `${token}
49519
49716
  `, { mode: 384 });
49520
49717
  return token;
49521
49718
  }
@@ -52899,17 +53096,17 @@ var StdioServerTransport = class {
52899
53096
  // src/tools.ts
52900
53097
  var import_node_crypto10 = require("node:crypto");
52901
53098
  var import_promises3 = require("node:fs/promises");
52902
- var import_node_fs12 = require("node:fs");
52903
- var import_node_path16 = __toESM(require("node:path"), 1);
53099
+ var import_node_fs13 = require("node:fs");
53100
+ var import_node_path17 = __toESM(require("node:path"), 1);
52904
53101
  var import_node_os8 = __toESM(require("node:os"), 1);
52905
53102
  var import_node_child_process12 = require("node:child_process");
52906
53103
 
52907
53104
  // ../../packages/wiki/dist/index.js
52908
53105
  var import_promises2 = __toESM(require("node:fs/promises"), 1);
52909
- var import_node_path15 = __toESM(require("node:path"), 1);
53106
+ var import_node_path16 = __toESM(require("node:path"), 1);
52910
53107
  var INCLUDED_DOC_FOLDERS = /* @__PURE__ */ new Set(["_meta", "explanation", "how-to", "reference", "sdd", "tutorials"]);
52911
53108
  function toPosixPath(input) {
52912
- return input.split(import_node_path15.default.sep).join("/");
53109
+ return input.split(import_node_path16.default.sep).join("/");
52913
53110
  }
52914
53111
  function slugifyWikiSegment(input) {
52915
53112
  return input.trim().toLowerCase().replace(/`/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
@@ -52923,12 +53120,12 @@ async function pathExists2(input) {
52923
53120
  }
52924
53121
  }
52925
53122
  async function findWorkspaceRoot(start = process.cwd()) {
52926
- let current = import_node_path15.default.resolve(start);
53123
+ let current = import_node_path16.default.resolve(start);
52927
53124
  while (true) {
52928
- if (await pathExists2(import_node_path15.default.join(current, "pnpm-workspace.yaml")) && await pathExists2(import_node_path15.default.join(current, "docs"))) {
53125
+ if (await pathExists2(import_node_path16.default.join(current, "pnpm-workspace.yaml")) && await pathExists2(import_node_path16.default.join(current, "docs"))) {
52929
53126
  return current;
52930
53127
  }
52931
- const parent = import_node_path15.default.dirname(current);
53128
+ const parent = import_node_path16.default.dirname(current);
52932
53129
  if (parent === current) {
52933
53130
  throw new Error(`Unable to find Mrrlin workspace root from ${start}`);
52934
53131
  }
@@ -52937,28 +53134,28 @@ async function findWorkspaceRoot(start = process.cwd()) {
52937
53134
  }
52938
53135
  async function resolveDocsRoot(input) {
52939
53136
  if (input) {
52940
- return import_node_path15.default.resolve(input);
53137
+ return import_node_path16.default.resolve(input);
52941
53138
  }
52942
53139
  if (process.env.MRRLIN_DOCS_ROOT) {
52943
- return import_node_path15.default.resolve(process.env.MRRLIN_DOCS_ROOT);
53140
+ return import_node_path16.default.resolve(process.env.MRRLIN_DOCS_ROOT);
52944
53141
  }
52945
- return import_node_path15.default.join(await findWorkspaceRoot(), "docs");
53142
+ return import_node_path16.default.join(await findWorkspaceRoot(), "docs");
52946
53143
  }
52947
53144
  async function resolveIndexPath(input) {
52948
53145
  if (input) {
52949
- return import_node_path15.default.resolve(input);
53146
+ return import_node_path16.default.resolve(input);
52950
53147
  }
52951
53148
  if (process.env.MRRLIN_WIKI_INDEX_PATH) {
52952
- return import_node_path15.default.resolve(process.env.MRRLIN_WIKI_INDEX_PATH);
53149
+ return import_node_path16.default.resolve(process.env.MRRLIN_WIKI_INDEX_PATH);
52953
53150
  }
52954
53151
  const workspaceRoot = await findWorkspaceRoot();
52955
- return import_node_path15.default.join(workspaceRoot, "apps", "web", "public", "wiki-index.json");
53152
+ return import_node_path16.default.join(workspaceRoot, "apps", "web", "public", "wiki-index.json");
52956
53153
  }
52957
53154
  async function walkMarkdownFiles(root, dir = root) {
52958
53155
  const entries = await import_promises2.default.readdir(dir, { withFileTypes: true });
52959
53156
  const files = [];
52960
53157
  for (const entry of entries) {
52961
- const absolute = import_node_path15.default.join(dir, entry.name);
53158
+ const absolute = import_node_path16.default.join(dir, entry.name);
52962
53159
  if (entry.isDirectory()) {
52963
53160
  files.push(...await walkMarkdownFiles(root, absolute));
52964
53161
  continue;
@@ -52977,7 +53174,7 @@ function parseTitle(markdown, sourcePath) {
52977
53174
  return title;
52978
53175
  }
52979
53176
  function documentFromFile(docsRoot, absolutePath, markdown) {
52980
- const relativePath = toPosixPath(import_node_path15.default.relative(docsRoot, absolutePath));
53177
+ const relativePath = toPosixPath(import_node_path16.default.relative(docsRoot, absolutePath));
52981
53178
  const [section, fileName] = relativePath.split("/");
52982
53179
  if (!section || !fileName || !INCLUDED_DOC_FOLDERS.has(section)) {
52983
53180
  return null;
@@ -54875,7 +55072,7 @@ var mcpToolDescriptions = {
54875
55072
  [mcpToolNames.resetDirectorThread]: "Clear a task's persisted Director execution thread handle so the next execution run starts a fresh provider thread. Records a director_thread_reset task event.",
54876
55073
  [mcpToolNames.updateWikiPage]: "Update a markdown Wiki page.",
54877
55074
  [mcpToolNames.markSpecReady]: "Mark a wiki page (folder=Specs) as ready (or not) for execution-run gating. The Director sets this true after validating the spec; any edit to the page's markdown auto-resets it to false.",
54878
- [mcpToolNames.runSpecConsensus]: 'Enqueue the consensus review gate over a Specs/{id} page. Returns IMMEDIATELY with one of: already_converged (a CONVERGED review already exists for the current content \u2014 proceed straight to create_execution_run, do NOT call mark_spec_ready, it is already set), already_reviewed (a terminal CONSENSUS_BLOCKED for this content), already_running (a consensus job is in flight), or queued (a new job was launched). The review runs in the background; its result/blocker arrives in the inbox (info on CONVERGED, handoff on failure) and is surfaced into the open chat. Do NOT call again for the same spec and do NOT poll. On queued/already_running, tell the user it was launched and end the turn. Pass extraHeads: ["researcher"] for specs referencing external libraries/APIs, or ["debugger"] for root-cause/investigation specs to add opt-in specialist reviewers on top of the fixed four. For a NON-code task (domain seo/marketing/content, ADR 0020): supported domains like `seo` proceed to `create_execution_run` after consensus; unsupported domains fail-close with `non_code_execution_unsupported`. Report the spec\'s review outcome to the operator.',
55075
+ [mcpToolNames.runSpecConsensus]: 'Enqueue the consensus review gate over a Specs/{id} page. Returns IMMEDIATELY with one of: already_converged (a CONVERGED review already exists for the current content \u2014 proceed straight to create_execution_run, do NOT call mark_spec_ready, it is already set), already_reviewed (a terminal CONSENSUS_BLOCKED for this content), already_running (a consensus job is in flight), or queued (a new job was launched). The review runs in the background; its result/blocker arrives in the inbox (info on CONVERGED, handoff on failure) and is surfaced into the open chat. Do NOT call again for the same spec and do NOT poll. On queued/already_running, tell the user it was launched and end the turn. Pass extraHeads: ["researcher"] for specs referencing external libraries/APIs, or ["debugger"] for root-cause/investigation specs to add opt-in specialist reviewers on top of the fixed four. For a NON-code task (domain seo/marketing/content, ADR 0020): currently supported low-risk domains `seo`, `marketing`, and `content` proceed to `create_execution_run` after consensus; unsupported domains still fail-close with `non_code_execution_unsupported`. Report the spec\'s review outcome to the operator.',
54879
55076
  [mcpToolNames.runCodeReviewerGate]: `Review the current branch's code diff (vs baseRef) with a Code Reviewer gate \u2014 independent reviewers iterate review\u2192fix\u2192re-check (checkpoint, scope-limited reviser edits, typecheck/build fast-gate, rollback) until the diff converges or is blocked. Run before opening a PR. Pass extraHeads: ["security-analyst"] for sensitive diffs (auth, secrets, input handling, new endpoints).`,
54880
55077
  [mcpToolNames.appendExecutionArtifact]: "Append a durable artifact (plan, checkpoint, command output, test result, diff summary, self-review, error, deploy attempt, or handoff judgement) to an execution run.",
54881
55078
  [mcpToolNames.recordProducedUrl]: 'Call this after publishing each web page produced by the task, so the UI link opens the page itself instead of the deployed site root. Pass the page\'s full https URL (for external pages, e.g. "https://dev.to/<slug>") OR a path starting with "/" for the deploy environment (e.g. "/blog/<slug>") \u2014 paths are resolved against the run\'s deployed env URL at render time. Optional `label` (\u226440 chars) is shown next to the link; omit and the UI defaults to the page title. Call once per page; multiple calls dedupe by resolved URL in the UI.',
@@ -55532,7 +55729,7 @@ function createMrrlinTools(options) {
55532
55729
  "ARTIFACT_FILE_UPLOAD_FAILED",
55533
55730
  "Unable to upload artifact file.",
55534
55731
  async (c, { projectSlug, path: filePath, class: artifactClass, taskId, runId, description }) => {
55535
- const extension2 = import_node_path16.default.extname(filePath).toLowerCase();
55732
+ const extension2 = import_node_path17.default.extname(filePath).toLowerCase();
55536
55733
  const contentType = ARTIFACT_EXTENSION_TYPES[extension2];
55537
55734
  if (!contentType) {
55538
55735
  throw new McpToolCodedError(
@@ -55560,7 +55757,7 @@ function createMrrlinTools(options) {
55560
55757
  "Artifact exceeds 5MB; split or summarize instead."
55561
55758
  );
55562
55759
  }
55563
- const filename = import_node_path16.default.basename(filePath);
55760
+ const filename = import_node_path17.default.basename(filePath);
55564
55761
  const created = await c.createArtifactFile(projectSlug, {
55565
55762
  class: artifactClass,
55566
55763
  contentType,
@@ -55643,7 +55840,7 @@ function createMrrlinTools(options) {
55643
55840
  "Unable to register local checkout.",
55644
55841
  async (_c, { projectSlug, path: checkoutPath, repo }) => {
55645
55842
  const trimmedPath = checkoutPath.trim();
55646
- if (!import_node_path16.default.isAbsolute(trimmedPath)) {
55843
+ if (!import_node_path17.default.isAbsolute(trimmedPath)) {
55647
55844
  throw new McpToolCodedError(
55648
55845
  "LOCAL_CHECKOUT_PATH_NOT_ABSOLUTE",
55649
55846
  `Path must be absolute, got: ${trimmedPath}`
@@ -55651,7 +55848,7 @@ function createMrrlinTools(options) {
55651
55848
  }
55652
55849
  let resolvedPath;
55653
55850
  try {
55654
- resolvedPath = (0, import_node_fs12.realpathSync)(trimmedPath);
55851
+ resolvedPath = (0, import_node_fs13.realpathSync)(trimmedPath);
55655
55852
  } catch {
55656
55853
  throw new McpToolCodedError(
55657
55854
  "LOCAL_CHECKOUT_PATH_NOT_FOUND",
@@ -55678,7 +55875,7 @@ function createMrrlinTools(options) {
55678
55875
  `Origin remote ${remoteUrl} does not match repo ${repo}.`
55679
55876
  );
55680
55877
  }
55681
- const stateDir = process.env.CODEX_HOME ? import_node_path16.default.join(process.env.CODEX_HOME, "mrrlin", "director-bridge") : import_node_path16.default.join(import_node_os8.default.homedir(), ".mrrlin", "director-bridge");
55878
+ const stateDir = process.env.CODEX_HOME ? import_node_path17.default.join(process.env.CODEX_HOME, "mrrlin", "director-bridge") : import_node_path17.default.join(import_node_os8.default.homedir(), ".mrrlin", "director-bridge");
55682
55879
  const registry3 = new CheckoutRegistry(stateDir);
55683
55880
  const confirmedAt = (/* @__PURE__ */ new Date()).toISOString();
55684
55881
  registry3.confirm(projectSlug, resolvedPath, confirmedAt);
@@ -55886,12 +56083,12 @@ function runSetCredential(args) {
55886
56083
 
55887
56084
  // src/install-service.ts
55888
56085
  var import_node_os9 = __toESM(require("node:os"), 1);
55889
- var import_node_path18 = __toESM(require("node:path"), 1);
56086
+ var import_node_path19 = __toESM(require("node:path"), 1);
55890
56087
 
55891
56088
  // src/service-paths.ts
55892
- var import_node_path17 = __toESM(require("node:path"), 1);
56089
+ var import_node_path18 = __toESM(require("node:path"), 1);
55893
56090
  function isWorktreePath(p) {
55894
- const norm = import_node_path17.default.normalize(p).split(import_node_path17.default.sep).join("/");
56091
+ const norm = import_node_path18.default.normalize(p).split(import_node_path18.default.sep).join("/");
55895
56092
  return norm.includes("/.claude/worktrees/");
55896
56093
  }
55897
56094
  function resolveServiceCwd(opts) {
@@ -55956,7 +56153,7 @@ function installService(deps) {
55956
56153
  return { ok: false };
55957
56154
  }
55958
56155
  const resolvedBins = bins.filter((b) => b !== null);
55959
- const pathEnv = Array.from(new Set(resolvedBins.map((b) => import_node_path18.default.dirname(b)))).join(":");
56156
+ const pathEnv = Array.from(new Set(resolvedBins.map((b) => import_node_path19.default.dirname(b)))).join(":");
55960
56157
  const text = renderEcosystemConfig({
55961
56158
  cwd: resolved.cwd,
55962
56159
  home,
@@ -55965,7 +56162,7 @@ function installService(deps) {
55965
56162
  staging: deps.env.MRRLIN_STAGING === "1",
55966
56163
  apiBaseUrl: deps.env.MRRLIN_API_BASE_URL?.trim() || void 0
55967
56164
  });
55968
- const ecoPath = import_node_path18.default.join(home, ".mrrlin", "ecosystem.config.cjs");
56165
+ const ecoPath = import_node_path19.default.join(home, ".mrrlin", "ecosystem.config.cjs");
55969
56166
  deps.writeFile(ecoPath, text);
55970
56167
  const start = deps.runPm2(["startOrReload", ecoPath]);
55971
56168
  if (start.code !== 0) {
@@ -55997,12 +56194,12 @@ function uninstallService(deps) {
55997
56194
  // src/uninstall-codex.ts
55998
56195
  var import_promises4 = __toESM(require("node:fs/promises"), 1);
55999
56196
  var import_node_os10 = __toESM(require("node:os"), 1);
56000
- var import_node_path19 = __toESM(require("node:path"), 1);
56197
+ var import_node_path20 = __toESM(require("node:path"), 1);
56001
56198
  var toml2 = __toESM(require_toml(), 1);
56002
56199
  function resolveCodexHome2(options) {
56003
56200
  if (options.codexHome) return options.codexHome;
56004
56201
  if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
56005
- return import_node_path19.default.join(options.homeDir ?? import_node_os10.default.homedir(), ".codex");
56202
+ return import_node_path20.default.join(options.homeDir ?? import_node_os10.default.homedir(), ".codex");
56006
56203
  }
56007
56204
  async function pathExists3(target) {
56008
56205
  try {
@@ -56015,7 +56212,7 @@ async function pathExists3(target) {
56015
56212
  var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.(?:mrrlin(?:-browser)?|external-agents)(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
56016
56213
  async function uninstallCodex(options = {}) {
56017
56214
  const codexHome = resolveCodexHome2(options);
56018
- const configPath = import_node_path19.default.join(codexHome, "config.toml");
56215
+ const configPath = import_node_path20.default.join(codexHome, "config.toml");
56019
56216
  const removePrompts = async () => uninstallPrompts(codexHome, options.promptNames ?? []);
56020
56217
  if (!await pathExists3(configPath)) {
56021
56218
  return { action: "missing", configPath, prompts: await removePrompts() };
@@ -56043,10 +56240,10 @@ async function uninstallCodex(options = {}) {
56043
56240
  }
56044
56241
  async function uninstallPrompts(codexHome, names) {
56045
56242
  if (names.length === 0) return [];
56046
- const promptsDir = import_node_path19.default.join(codexHome, "prompts");
56243
+ const promptsDir = import_node_path20.default.join(codexHome, "prompts");
56047
56244
  const out = [];
56048
56245
  for (const name of names) {
56049
- const promptPath = import_node_path19.default.join(promptsDir, `${name}.md`);
56246
+ const promptPath = import_node_path20.default.join(promptsDir, `${name}.md`);
56050
56247
  try {
56051
56248
  await import_promises4.default.unlink(promptPath);
56052
56249
  out.push({ name, action: "removed", promptPath });
@@ -56299,8 +56496,8 @@ async function main() {
56299
56496
  }
56300
56497
  }
56301
56498
  try {
56302
- const codexHome = process.env.CODEX_HOME ?? import_node_path21.default.join(process.env.HOME ?? (0, import_node_os11.homedir)(), ".codex");
56303
- (0, import_node_fs13.rmSync)(import_node_path21.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
56499
+ const codexHome = process.env.CODEX_HOME ?? import_node_path22.default.join(process.env.HOME ?? (0, import_node_os11.homedir)(), ".codex");
56500
+ (0, import_node_fs14.rmSync)(import_node_path22.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
56304
56501
  } catch {
56305
56502
  }
56306
56503
  return;
@@ -56330,8 +56527,8 @@ async function main() {
56330
56527
  env: process.env,
56331
56528
  cwd: process.cwd(),
56332
56529
  writeFile: (p, c) => {
56333
- (0, import_node_fs13.mkdirSync)(import_node_path21.default.dirname(p), { recursive: true, mode: 448 });
56334
- (0, import_node_fs13.writeFileSync)(p, c, { mode: 384 });
56530
+ (0, import_node_fs14.mkdirSync)(import_node_path22.default.dirname(p), { recursive: true, mode: 448 });
56531
+ (0, import_node_fs14.writeFileSync)(p, c, { mode: 384 });
56335
56532
  },
56336
56533
  runPm2: pm2Runner,
56337
56534
  which: whichBin,
@@ -56348,14 +56545,14 @@ async function main() {
56348
56545
  runPm2: (a) => ({ code: pm2Runner(a).code }),
56349
56546
  removeFile: (p) => {
56350
56547
  try {
56351
- (0, import_node_fs13.rmSync)(p, { force: true });
56548
+ (0, import_node_fs14.rmSync)(p, { force: true });
56352
56549
  } catch {
56353
56550
  }
56354
56551
  },
56355
56552
  purgeSecret: purge,
56356
56553
  secretPath: agentCredentialPath(),
56357
56554
  tokenPath: operatorTokenPath(),
56358
- ecoPath: import_node_path21.default.join(process.env.HOME ?? (0, import_node_os11.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
56555
+ ecoPath: import_node_path22.default.join(process.env.HOME ?? (0, import_node_os11.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
56359
56556
  log: (m) => process.stderr.write(`[mrrlin-mcp uninstall-service] ${m}
56360
56557
  `)
56361
56558
  });
@@ -56369,14 +56566,14 @@ async function main() {
56369
56566
  runPm2: (a) => ({ code: pm2Runner(a).code }),
56370
56567
  removeFile: (p) => {
56371
56568
  try {
56372
- (0, import_node_fs13.rmSync)(p, { force: true });
56569
+ (0, import_node_fs14.rmSync)(p, { force: true });
56373
56570
  } catch {
56374
56571
  }
56375
56572
  },
56376
56573
  purgeSecret: true,
56377
56574
  secretPath: agentCredentialPath(),
56378
56575
  tokenPath: operatorTokenPath(),
56379
- ecoPath: import_node_path21.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
56576
+ ecoPath: import_node_path22.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
56380
56577
  log
56381
56578
  });
56382
56579
  let codexOk = true;
@@ -56396,7 +56593,7 @@ async function main() {
56396
56593
  log(`codex config NOT modified: ${error51 instanceof Error ? error51.message : String(error51)}`);
56397
56594
  }
56398
56595
  try {
56399
- (0, import_node_fs13.rmSync)(import_node_path21.default.join(home, ".mrrlin"), { recursive: true, force: true });
56596
+ (0, import_node_fs14.rmSync)(import_node_path22.default.join(home, ".mrrlin"), { recursive: true, force: true });
56400
56597
  } catch {
56401
56598
  }
56402
56599
  log("removed ~/.mrrlin");
@@ -56437,7 +56634,7 @@ ${HELP_TEXT}`);
56437
56634
  }
56438
56635
  }
56439
56636
  function resolveSelfBinPath() {
56440
- return import_node_path20.default.resolve(process.argv[1] ?? process.execPath);
56637
+ return import_node_path21.default.resolve(process.argv[1] ?? process.execPath);
56441
56638
  }
56442
56639
  main().catch((error51) => {
56443
56640
  process.stderr.write(`mrrlin-mcp fatal error: ${error51 instanceof Error ? error51.message : String(error51)}