@mrrlin-dev/mcp 0.3.46 → 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
  }
@@ -36550,6 +36550,7 @@ var mrrlinAsyncJobSchema = external_exports.object({
36550
36550
  failureReason: mrrlinAsyncJobFailureReasonSchema.nullable().default(null),
36551
36551
  requestedHash: external_exports.string().nullable().default(null),
36552
36552
  finalReviewedHash: external_exports.string().nullable().default(null),
36553
+ supersededAt: external_exports.string().nullable().default(null),
36553
36554
  attemptCount: external_exports.number().int().nonnegative(),
36554
36555
  leaseId: external_exports.string().nullable().default(null),
36555
36556
  claimedAt: external_exports.string().nullable().default(null),
@@ -36714,9 +36715,21 @@ var mrrlinDeliverablePayloadSchema = external_exports.object({
36714
36715
  contentHash: external_exports.string().min(1),
36715
36716
  format: external_exports.enum(["markdown"])
36716
36717
  });
36717
- var SUPPORTED_EXECUTION_DOMAINS = ["code"];
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
+ }
36718
36731
  function isExecutionDomainSupported(domain2) {
36719
- return SUPPORTED_EXECUTION_DOMAINS.includes(domain2);
36732
+ return resolveExecutionDomainPolicy(domain2).supported;
36720
36733
  }
36721
36734
  var taxonomyCategorySchema = external_exports.string().min(1).regex(/^[a-z][a-z0-9-]*$/);
36722
36735
  var taxonomySubcategorySchema = external_exports.string().min(1).regex(/^[a-z][a-z0-9-]*$/);
@@ -37510,7 +37523,8 @@ var mrrlinProjectSchedulerPolicySchema = external_exports.object({
37510
37523
  prodGraceSeconds: external_exports.number().int().nonnegative(),
37511
37524
  projectSlug: mrrlinProjectSlugSchema,
37512
37525
  updatedAt: external_exports.string().datetime(),
37513
- wakeFloor: external_exports.string().datetime().nullable()
37526
+ wakeFloor: external_exports.string().datetime().nullable(),
37527
+ maxConsecutiveJobFailures: external_exports.number().int().positive()
37514
37528
  });
37515
37529
  var mrrlinProjectSchedulerPolicyUpsertSchema = external_exports.object({
37516
37530
  autoSpecApproval: mrrlinAutoSpecApprovalSchema.optional(),
@@ -37519,7 +37533,8 @@ var mrrlinProjectSchedulerPolicyUpsertSchema = external_exports.object({
37519
37533
  eligibleAutonomyLevels: external_exports.array(mrrlinAutonomyLevelSchema).min(1).optional(),
37520
37534
  maxConcurrentAutonomousRuns: external_exports.number().int().nonnegative().optional(),
37521
37535
  prodGraceSeconds: external_exports.number().int().nonnegative().optional(),
37522
- wakeFloor: external_exports.string().datetime().nullable().optional()
37536
+ wakeFloor: external_exports.string().datetime().nullable().optional(),
37537
+ maxConsecutiveJobFailures: external_exports.number().int().positive().optional()
37523
37538
  }).refine((value) => Object.keys(value).length > 0, {
37524
37539
  message: "ProjectSchedulerPolicyUpsert requires at least one field"
37525
37540
  });
@@ -37680,7 +37695,10 @@ var mrrlinInboxItemActionPayloadSchema = external_exports.object({
37680
37695
  runId: mrrlinExecutionRunIdSchema,
37681
37696
  // Optional (additive): when true, approving the proposal creates a full code-execution run
37682
37697
  // (worktree + push/PR path). Scheduler proposals set it; legacy payloads omit it.
37683
- codeExecution: external_exports.boolean().optional()
37698
+ codeExecution: external_exports.boolean().optional(),
37699
+ // Optional scheduler recovery action carried by an info item.
37700
+ retryToolName: external_exports.string().min(1).optional(),
37701
+ retryDedupKey: external_exports.string().min(1).optional()
37684
37702
  });
37685
37703
  var mrrlinInboxQuestionOptionSchema = external_exports.object({
37686
37704
  answer: external_exports.string().trim().min(1),
@@ -37907,18 +37925,18 @@ function createMrrlinClient(config2) {
37907
37925
  const customFetch = config2.fetch ?? globalThis.fetch;
37908
37926
  const baseUrl = config2.baseUrl.replace(/\/$/, "");
37909
37927
  const token = config2.token;
37910
- async function request(path16, init) {
37928
+ async function request(path17, init) {
37911
37929
  const method = init?.method ?? "GET";
37912
37930
  const headers = new Headers(init?.headers ?? {});
37913
37931
  if (token && !headers.has("authorization")) {
37914
37932
  headers.set("authorization", `Bearer ${token}`);
37915
37933
  }
37916
- const response = await customFetch(`${baseUrl}${path16}`, { ...init, headers });
37934
+ const response = await customFetch(`${baseUrl}${path17}`, { ...init, headers });
37917
37935
  if (!response.ok) {
37918
37936
  const body = await response.text();
37919
37937
  let code = `HTTP_${response.status}`;
37920
37938
  let violations = null;
37921
- let message = `Mrrlin API ${method} ${path16} failed: ${response.status}`;
37939
+ let message = `Mrrlin API ${method} ${path17} failed: ${response.status}`;
37922
37940
  try {
37923
37941
  const parsed = JSON.parse(body);
37924
37942
  const violationsParsed = apiViolationsErrorSchema.safeParse(parsed);
@@ -37938,7 +37956,7 @@ function createMrrlinClient(config2) {
37938
37956
  throw new MrrlinApiError({
37939
37957
  code,
37940
37958
  method,
37941
- path: path16,
37959
+ path: path17,
37942
37960
  responseBody: body,
37943
37961
  status: response.status,
37944
37962
  violations,
@@ -38193,7 +38211,7 @@ function createMrrlinClient(config2) {
38193
38211
  return taskEventListResponseSchema.parse(body).data;
38194
38212
  },
38195
38213
  async listTasks(projectSlug, filters = {}) {
38196
- const path16 = appendQuery(`${projectPath(projectSlug)}/tasks`, {
38214
+ const path17 = appendQuery(`${projectPath(projectSlug)}/tasks`, {
38197
38215
  assignee: filters.assignee,
38198
38216
  autonomyLevel: filters.autonomyLevel,
38199
38217
  blockedBy: filters.blockedBy,
@@ -38205,7 +38223,7 @@ function createMrrlinClient(config2) {
38205
38223
  subcategory: filters.subcategory,
38206
38224
  type: filters.type
38207
38225
  });
38208
- const body = await request(path16);
38226
+ const body = await request(path17);
38209
38227
  return taskListResponseSchema.parse(body).data;
38210
38228
  },
38211
38229
  async listTaxonomy(projectSlug) {
@@ -38213,22 +38231,22 @@ function createMrrlinClient(config2) {
38213
38231
  return taxonomyListResponseSchema.parse(body).data;
38214
38232
  },
38215
38233
  async listWikiPages(projectSlug, filters = {}) {
38216
- const path16 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
38234
+ const path17 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
38217
38235
  folder: filters.folder,
38218
38236
  q: filters.q,
38219
38237
  taskId: filters.taskId
38220
38238
  });
38221
- const body = await request(path16);
38239
+ const body = await request(path17);
38222
38240
  return wikiPageListResponseSchema.parse(body).data;
38223
38241
  },
38224
38242
  async searchWikiPages(projectSlug, query) {
38225
- const path16 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
38243
+ const path17 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
38226
38244
  folder: query.folder,
38227
38245
  limit: query.limit === void 0 ? void 0 : String(query.limit),
38228
38246
  pathPrefix: query.pathPrefix,
38229
38247
  q: query.q
38230
38248
  });
38231
- const body = await request(path16);
38249
+ const body = await request(path17);
38232
38250
  return wikiPageSearchResponseSchema.parse(body).data;
38233
38251
  },
38234
38252
  async updatePlan(projectSlug, planId, patch) {
@@ -38401,6 +38419,7 @@ function createMrrlinClient(config2) {
38401
38419
  },
38402
38420
  async listInboxItems(projectSlug, filters = {}) {
38403
38421
  const url2 = appendQuery(`${projectPath(projectSlug)}/inbox`, {
38422
+ groupId: filters.groupId,
38404
38423
  kind: filters.kind,
38405
38424
  readState: filters.readState,
38406
38425
  status: filters.status,
@@ -39110,7 +39129,7 @@ function startCodexProbe(deps = {}) {
39110
39129
  }
39111
39130
 
39112
39131
  // src/_generated/version.ts
39113
- var PKG_VERSION = "0.3.46";
39132
+ var PKG_VERSION = "0.3.48";
39114
39133
 
39115
39134
  // src/api-base-url.ts
39116
39135
  var DEFAULT_API_BASE_URL = "http://127.0.0.1:8787";
@@ -39174,6 +39193,159 @@ async function resolveApiBaseUrlDynamic(opts = {}) {
39174
39193
  );
39175
39194
  }
39176
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
+
39177
39349
  // src/scheduler-tick.ts
39178
39350
  var SCHEDULER_TICK_MIN_MS = 6e4;
39179
39351
  var SCHEDULER_TICK_FALLBACK_MS = 3e5;
@@ -39212,17 +39384,30 @@ function dispatchTickWork(deps, results) {
39212
39384
  }
39213
39385
  }
39214
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) {
39215
39393
  const fetchImpl = deps.fetchImpl ?? fetch;
39394
+ const bridgeHealth = deps.bridgeHealth;
39216
39395
  try {
39217
- 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);
39218
39402
  if (!response.ok) {
39219
39403
  process.stderr.write(
39220
39404
  `[mrrlin-mcp director-bridge] scheduler tick failed: HTTP ${response.status} from /internal/scheduler/run
39221
39405
  `
39222
39406
  );
39223
- return { nextWakeAt: null };
39407
+ bridgeHealth?.recordFailure("schedulerTick", new Error(`HTTP ${response.status}`));
39408
+ return { nextWakeAt: null, failed: true };
39224
39409
  }
39225
- const body = await response.json();
39410
+ const body = parsedBody;
39226
39411
  const data = body?.data ?? {};
39227
39412
  const results = Array.isArray(data.results) ? data.results : [];
39228
39413
  deps.logger.logOut({
@@ -39256,27 +39441,29 @@ async function fireSchedulerTick(deps) {
39256
39441
  }
39257
39442
  });
39258
39443
  dispatchTickWork(deps, results);
39259
- 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 };
39260
39446
  } catch (error51) {
39261
39447
  process.stderr.write(
39262
39448
  `[mrrlin-mcp director-bridge] scheduler tick failed: ${error51 instanceof Error ? error51.message : String(error51)}
39263
39449
  `
39264
39450
  );
39265
- return { nextWakeAt: null };
39451
+ bridgeHealth?.recordFailure("schedulerTick", error51);
39452
+ return { nextWakeAt: null, failed: true };
39266
39453
  }
39267
39454
  }
39268
39455
  function startSchedulerTickLoop(deps) {
39269
39456
  let stopped = false;
39270
39457
  let timer = null;
39271
39458
  const env = deps.env ?? process.env;
39272
- const schedule = (delayMs) => {
39459
+ const schedule = (delayMs2) => {
39273
39460
  if (stopped) return;
39274
39461
  timer = setTimeout(() => {
39275
39462
  void fireSchedulerTick(deps).then(({ nextWakeAt }) => {
39276
39463
  if (stopped) return;
39277
39464
  schedule(computeNextTickDelayMs(nextWakeAt, Date.now(), { env }));
39278
39465
  });
39279
- }, delayMs);
39466
+ }, delayMs2);
39280
39467
  timer.unref?.();
39281
39468
  };
39282
39469
  schedule(computeNextTickDelayMs((/* @__PURE__ */ new Date()).toISOString(), Date.now(), { env }));
@@ -39498,7 +39685,7 @@ function startAgentPoolLoop(deps) {
39498
39685
  // src/execution-consumer.ts
39499
39686
  var import_node_child_process9 = require("node:child_process");
39500
39687
  var import_node_crypto4 = __toESM(require("node:crypto"), 1);
39501
- var import_node_path7 = __toESM(require("node:path"), 1);
39688
+ var import_node_path8 = __toESM(require("node:path"), 1);
39502
39689
  var import_node_util = require("node:util");
39503
39690
 
39504
39691
  // src/consensus/heads.ts
@@ -39507,8 +39694,8 @@ var DOMAINS = ["code", "seo", "marketing", "content"];
39507
39694
  var HEADS_BY_DOMAIN = {
39508
39695
  code: ["plan-reviewer", "architect", "security-analyst", "scope-analyst"],
39509
39696
  seo: ["plan-reviewer", "scope-analyst", "seo-analyst"],
39510
- marketing: ["plan-reviewer", "scope-analyst", "content-editor"],
39511
- 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"]
39512
39699
  };
39513
39700
  var SPEC_HEADS = HEADS_BY_DOMAIN.code;
39514
39701
  function normalizeDomain(value) {
@@ -39535,8 +39722,8 @@ function resolveProducerPersona(domain2) {
39535
39722
 
39536
39723
  // src/consensus/wiring.ts
39537
39724
  var import_node_crypto2 = __toESM(require("node:crypto"), 1);
39538
- var import_node_fs2 = __toESM(require("node:fs"), 1);
39539
- 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);
39540
39727
  var import_node_url2 = require("node:url");
39541
39728
 
39542
39729
  // src/consensus/codex-exec.ts
@@ -39955,15 +40142,15 @@ ${res.stdout}${res.stderr}`);
39955
40142
  var import_meta2 = {};
39956
40143
  function getPersonasDir() {
39957
40144
  if (typeof __dirname !== "undefined") {
39958
- return import_node_path4.default.join(__dirname, "consensus", "personas");
40145
+ return import_node_path5.default.join(__dirname, "consensus", "personas");
39959
40146
  }
39960
- 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");
39961
40148
  }
39962
40149
  var personaCache = /* @__PURE__ */ new Map();
39963
40150
  function loadPersona(name) {
39964
40151
  const cached2 = personaCache.get(name);
39965
40152
  if (cached2 !== void 0) return cached2;
39966
- 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");
39967
40154
  personaCache.set(name, content);
39968
40155
  return content;
39969
40156
  }
@@ -41090,7 +41277,7 @@ function isDeployGateRunStatus(status) {
41090
41277
 
41091
41278
  // src/turn-deadline.ts
41092
41279
  var DEFAULT_TURN_INTERRUPT_TIMEOUT_MS = 5e3;
41093
- function withTimeout(promise2, ms, message) {
41280
+ function withTimeout2(promise2, ms, message) {
41094
41281
  let timer = null;
41095
41282
  const timeout = new Promise((_, reject) => {
41096
41283
  timer = setTimeout(() => reject(new Error(message)), ms);
@@ -41138,7 +41325,7 @@ async function awaitTurnWithDeadline(opts) {
41138
41325
  const isDeadline = message === opts.timeoutMessage || hasIdle && message === opts.idleTimeoutMessage;
41139
41326
  if (isDeadline) {
41140
41327
  try {
41141
- await withTimeout(
41328
+ await withTimeout2(
41142
41329
  opts.interrupt(),
41143
41330
  opts.interruptTimeoutMs ?? DEFAULT_TURN_INTERRUPT_TIMEOUT_MS,
41144
41331
  "turn.interrupt timed out"
@@ -41154,18 +41341,18 @@ async function awaitTurnWithDeadline(opts) {
41154
41341
 
41155
41342
  // src/worktree.ts
41156
41343
  var import_node_child_process8 = require("node:child_process");
41157
- var import_node_fs4 = require("node:fs");
41344
+ var import_node_fs5 = require("node:fs");
41158
41345
  var import_node_os3 = require("node:os");
41159
- var import_node_path6 = require("node:path");
41346
+ var import_node_path7 = require("node:path");
41160
41347
 
41161
41348
  // src/checkout-lock.ts
41162
- var import_node_fs3 = require("node:fs");
41163
- var import_node_path5 = require("node:path");
41349
+ var import_node_fs4 = require("node:fs");
41350
+ var import_node_path6 = require("node:path");
41164
41351
  var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
41165
41352
  async function withCheckoutLock(locksDir, slug, fn) {
41166
- (0, import_node_fs3.mkdirSync)(locksDir, { recursive: true });
41167
- const target = (0, import_node_path5.join)(locksDir, `${slug}.lock`);
41168
- 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, "");
41169
41356
  const release = await import_proper_lockfile.default.lock(target, {
41170
41357
  retries: { retries: 600, factor: 1, minTimeout: 100, maxTimeout: 100 },
41171
41358
  stale: 5 * 6e4
@@ -41190,12 +41377,12 @@ function git(checkout, args) {
41190
41377
  });
41191
41378
  }
41192
41379
  async function createRunWorktree(opts) {
41193
- 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);
41194
41381
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
41195
- (0, import_node_fs4.mkdirSync)(opts.worktreeRoot, { recursive: true });
41382
+ (0, import_node_fs5.mkdirSync)(opts.worktreeRoot, { recursive: true });
41196
41383
  try {
41197
41384
  git(opts.checkout, ["fetch", "origin", opts.defaultBranch]);
41198
- if (!(0, import_node_fs4.existsSync)(worktreePath)) {
41385
+ if (!(0, import_node_fs5.existsSync)(worktreePath)) {
41199
41386
  git(opts.checkout, [
41200
41387
  "worktree",
41201
41388
  "add",
@@ -41253,15 +41440,15 @@ async function doPushRunBranch(opts, execGit) {
41253
41440
  if (localConfig.trim()) {
41254
41441
  throw new Error(`push aborted: agent-controlled git config present in worktree: ${localConfig.trim().split("\n")[0]}`);
41255
41442
  }
41256
- const dir = (0, import_node_fs4.mkdtempSync)((0, import_node_path6.join)((0, import_node_os3.tmpdir)(), "mrrlin-push-"));
41257
- 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");
41258
41445
  try {
41259
- (0, import_node_fs4.writeFileSync)(
41446
+ (0, import_node_fs5.writeFileSync)(
41260
41447
  askpass,
41261
41448
  '#!/bin/sh\ncase "$1" in *[Uu]sername*) printf %s "x-access-token" ;; *) printf %s "$MRRLIN_PUSH_TOKEN" ;; esac\n',
41262
41449
  { mode: 320 }
41263
41450
  );
41264
- (0, import_node_fs4.chmodSync)(askpass, 320);
41451
+ (0, import_node_fs5.chmodSync)(askpass, 320);
41265
41452
  execGit(
41266
41453
  [
41267
41454
  "-C",
@@ -41280,18 +41467,18 @@ async function doPushRunBranch(opts, execGit) {
41280
41467
  );
41281
41468
  return { pushedSha: localSha };
41282
41469
  } finally {
41283
- (0, import_node_fs4.rmSync)(dir, { recursive: true, force: true });
41470
+ (0, import_node_fs5.rmSync)(dir, { recursive: true, force: true });
41284
41471
  }
41285
41472
  }
41286
41473
  async function sweepOrphanWorktrees(opts) {
41287
41474
  const reaped = [];
41288
41475
  const ownedPrefix = (() => {
41289
41476
  try {
41290
- return (0, import_node_fs4.realpathSync)(opts.worktreeRoot);
41477
+ return (0, import_node_fs5.realpathSync)(opts.worktreeRoot);
41291
41478
  } catch {
41292
41479
  return opts.worktreeRoot;
41293
41480
  }
41294
- })() + import_node_path6.sep + opts.slug + import_node_path6.sep;
41481
+ })() + import_node_path7.sep + opts.slug + import_node_path7.sep;
41295
41482
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
41296
41483
  const listing = git(opts.checkout, ["worktree", "list", "--porcelain"]);
41297
41484
  for (const block of listing.split("\n\n")) {
@@ -41358,12 +41545,16 @@ var EXECUTION_TURN_BUDGET_PREFIX = "Execution turn exceeded the run wall-clock b
41358
41545
  var EXECUTION_TURN_TIMEOUT_RETRY_CODE = "execution_turn_timeout_retry";
41359
41546
  var EXECUTION_TURN_TIMEOUT_RETRY_SUMMARY = "Execution turn timed out; requeued for one automatic retry.";
41360
41547
  var EXECUTION_TURN_TIMEOUT_RETRY_CURSOR = "execution_turn_timeout_retry:1";
41548
+ var AWAITING_MERGE_STATUS_RETRY_DELAYS_MS = [50, 100];
41361
41549
  function readPositiveIntEnv(name, fallback) {
41362
41550
  const raw = (process.env[name] ?? "").trim();
41363
41551
  if (!raw) return fallback;
41364
41552
  const parsed = Number.parseInt(raw, 10);
41365
41553
  return Number.isInteger(parsed) && parsed > 0 ? parsed : fallback;
41366
41554
  }
41555
+ function delayMs(ms) {
41556
+ return new Promise((resolve) => setTimeout(resolve, ms));
41557
+ }
41367
41558
  function execTurnIdleTimeoutMs() {
41368
41559
  return readPositiveIntEnv("MRRLIN_DIRECTOR_BRIDGE_EXEC_TURN_IDLE_TIMEOUT_SECONDS", DEFAULT_EXEC_TURN_IDLE_TIMEOUT_SECONDS) * 1e3;
41369
41560
  }
@@ -41548,8 +41739,8 @@ function newArtifactId() {
41548
41739
  return `EA-${import_node_crypto4.default.randomUUID()}`;
41549
41740
  }
41550
41741
  var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
41551
- function isBlastRadiusFloorPath(path16) {
41552
- 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));
41553
41744
  }
41554
41745
  var execFileAsync = (0, import_node_util.promisify)(import_node_child_process9.execFile);
41555
41746
  async function defaultListRunDiffPaths(opts) {
@@ -42181,7 +42372,7 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2)
42181
42372
  task,
42182
42373
  runId,
42183
42374
  leaseId,
42184
- `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.`
42185
42376
  );
42186
42377
  return;
42187
42378
  }
@@ -42387,19 +42578,42 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
42387
42578
  }
42388
42579
  }).catch(() => {
42389
42580
  });
42581
+ let lastError = null;
42582
+ for (let attempt = 1; attempt <= AWAITING_MERGE_STATUS_RETRY_DELAYS_MS.length + 1; attempt += 1) {
42583
+ try {
42584
+ await deps.client.updateTask(projectSlug, task.id, { status: "handoff_needed" });
42585
+ return;
42586
+ } catch (error51) {
42587
+ lastError = error51;
42588
+ const retryDelay = AWAITING_MERGE_STATUS_RETRY_DELAYS_MS[attempt - 1];
42589
+ if (retryDelay !== void 0) {
42590
+ await delayMs(retryDelay);
42591
+ }
42592
+ }
42593
+ }
42390
42594
  try {
42391
- await deps.client.updateTask(projectSlug, task.id, { status: "handoff_needed" });
42392
- } catch (error51) {
42393
- console.warn(
42394
- JSON.stringify({
42395
- event: "reconcile_awaiting_merge_failed",
42396
- projectSlug,
42397
- taskId: task.id,
42398
- runId,
42399
- error: error51 instanceof Error ? error51.message : String(error51)
42400
- })
42401
- );
42595
+ await deps.client.updateExecutionRun(projectSlug, runId, { status: "handoff_queued" });
42596
+ } catch {
42597
+ }
42598
+ try {
42599
+ await deps.client.createInboxItem(projectSlug, {
42600
+ id: `II-${import_node_crypto4.default.randomUUID()}`,
42601
+ kind: "handoff",
42602
+ taskId: task.id,
42603
+ body: `Task ${task.id} (${task.title}) still needs operator follow-up: ${reason}. Mrrlin could not move the task back to Handoff needed automatically.`
42604
+ });
42605
+ } catch {
42402
42606
  }
42607
+ console.warn(
42608
+ JSON.stringify({
42609
+ event: "reconcile_awaiting_merge_failed",
42610
+ projectSlug,
42611
+ taskId: task.id,
42612
+ runId,
42613
+ error: lastError instanceof Error ? lastError.message : String(lastError),
42614
+ attempts: AWAITING_MERGE_STATUS_RETRY_DELAYS_MS.length + 1
42615
+ })
42616
+ );
42403
42617
  }
42404
42618
  async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
42405
42619
  try {
@@ -42488,8 +42702,8 @@ async function runBackstopSweep(deps, drive = (slug, id) => driveRun(deps, slug,
42488
42702
  function isRunRecoverableByThisBridge(run3, worktreeRoot) {
42489
42703
  if (!worktreeRoot) return true;
42490
42704
  if (!run3.worktreeId) return false;
42491
- const relative = import_node_path7.default.relative(import_node_path7.default.resolve(worktreeRoot), import_node_path7.default.resolve(run3.worktreeId));
42492
- 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);
42493
42707
  }
42494
42708
  async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId) {
42495
42709
  await deps.client.updateExecutionRun(projectSlug, runId, { status: "failed", finishedAt: (/* @__PURE__ */ new Date()).toISOString(), leaseId: leaseId ?? void 0 }).catch(() => {
@@ -42560,7 +42774,12 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
42560
42774
  let outcome = { kind: "failed", failureReason: "provider_unavailable", error: "did not run" };
42561
42775
  try {
42562
42776
  for (; ; ) {
42563
- const begun = await deps.client.beginAsyncJobAttempt(projectSlug, jobId, leaseId, deriveHash());
42777
+ const begun = await deps.client.beginAsyncJobAttempt(
42778
+ projectSlug,
42779
+ jobId,
42780
+ leaseId,
42781
+ await deriveRequestedHash(deps.client, claimed.toolName, input)
42782
+ );
42564
42783
  if (!begun) return;
42565
42784
  if (begun.attemptCount > ASYNC_JOB_MAX_ATTEMPTS) {
42566
42785
  outcome = { kind: "failed", failureReason: "provider_unavailable", error: "exceeded retry budget" };
@@ -42611,8 +42830,17 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
42611
42830
  }
42612
42831
  if (descriptor2.wakeDirector) deps.wake(projectSlug, claimed.directorSessionId, delivery.body, delivery.kind);
42613
42832
  }
42614
- function deriveHash() {
42615
- return `attempt-${Date.now()}`;
42833
+ async function deriveRequestedHash(client, toolName, input) {
42834
+ if (input.requestedHash) return input.requestedHash;
42835
+ if (toolName === "run_spec_consensus" && input.pageId) {
42836
+ const page = await client.getWikiPage(input.projectSlug, input.pageId);
42837
+ return page.contentHash ?? import_node_crypto5.default.createHash("sha256").update(page.markdownBody).digest("hex");
42838
+ }
42839
+ if (toolName === "draft_task_spec" && input.taskId) {
42840
+ const task = await client.getTask(input.projectSlug, input.taskId);
42841
+ return task.updatedAt ?? import_node_crypto5.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
42842
+ }
42843
+ return import_node_crypto5.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
42616
42844
  }
42617
42845
  async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId)) {
42618
42846
  const projects = await deps.client.listProjects();
@@ -42939,19 +43167,19 @@ function codexIdleMs() {
42939
43167
  }
42940
43168
 
42941
43169
  // src/operator-token.ts
42942
- var import_node_fs5 = require("node:fs");
43170
+ var import_node_fs6 = require("node:fs");
42943
43171
  var import_node_os4 = __toESM(require("node:os"), 1);
42944
- var import_node_path8 = __toESM(require("node:path"), 1);
43172
+ var import_node_path9 = __toESM(require("node:path"), 1);
42945
43173
  function operatorDir() {
42946
- 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");
42947
43175
  return base;
42948
43176
  }
42949
43177
  function operatorTokenPath() {
42950
- return import_node_path8.default.join(operatorDir(), "operator-token");
43178
+ return import_node_path9.default.join(operatorDir(), "operator-token");
42951
43179
  }
42952
43180
  function readOperatorToken() {
42953
43181
  try {
42954
- const token = (0, import_node_fs5.readFileSync)(operatorTokenPath(), "utf8").trim();
43182
+ const token = (0, import_node_fs6.readFileSync)(operatorTokenPath(), "utf8").trim();
42955
43183
  return token.length > 0 ? token : null;
42956
43184
  } catch {
42957
43185
  return null;
@@ -42959,24 +43187,24 @@ function readOperatorToken() {
42959
43187
  }
42960
43188
  function persistOperatorToken(token) {
42961
43189
  const dir = operatorDir();
42962
- (0, import_node_fs5.mkdirSync)(dir, { recursive: true, mode: 448 });
42963
- (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()}
42964
43192
  `, { encoding: "utf8", mode: 384 });
42965
43193
  }
42966
43194
  function agentCredentialPath() {
42967
- return import_node_path8.default.join(operatorDir(), "agent-credential");
43195
+ return import_node_path9.default.join(operatorDir(), "agent-credential");
42968
43196
  }
42969
43197
  function persistAgentSecret(secret) {
42970
43198
  const dir = operatorDir();
42971
- (0, import_node_fs5.mkdirSync)(dir, { recursive: true, mode: 448 });
42972
- (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()}
42973
43201
  `, { encoding: "utf8", mode: 384 });
42974
43202
  }
42975
43203
  function readAgentSecret() {
42976
43204
  const fromEnv = process.env.MRRLIN_AGENT_SECRET?.trim();
42977
43205
  if (fromEnv) return fromEnv;
42978
43206
  try {
42979
- const raw = (0, import_node_fs5.readFileSync)(agentCredentialPath(), "utf8").trim();
43207
+ const raw = (0, import_node_fs6.readFileSync)(agentCredentialPath(), "utf8").trim();
42980
43208
  return raw || void 0;
42981
43209
  } catch {
42982
43210
  return void 0;
@@ -42984,16 +43212,16 @@ function readAgentSecret() {
42984
43212
  }
42985
43213
 
42986
43214
  // src/thread-index.ts
42987
- var import_node_fs6 = require("node:fs");
42988
- 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);
42989
43217
  function threadIndexPath(stateDir) {
42990
- return import_node_path9.default.join(stateDir, "threads.json");
43218
+ return import_node_path10.default.join(stateDir, "threads.json");
42991
43219
  }
42992
43220
  function loadThreadIndex(stateDir, ttlMs, now) {
42993
43221
  const result = /* @__PURE__ */ new Map();
42994
43222
  let parsed;
42995
43223
  try {
42996
- parsed = JSON.parse((0, import_node_fs6.readFileSync)(threadIndexPath(stateDir), "utf8"));
43224
+ parsed = JSON.parse((0, import_node_fs7.readFileSync)(threadIndexPath(stateDir), "utf8"));
42997
43225
  } catch {
42998
43226
  return result;
42999
43227
  }
@@ -43015,8 +43243,8 @@ function loadThreadIndex(stateDir, ttlMs, now) {
43015
43243
  return result;
43016
43244
  }
43017
43245
  function saveThreadIndex(stateDir, entries) {
43018
- (0, import_node_fs6.mkdirSync)(stateDir, { recursive: true, mode: 448 });
43019
- (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)}
43020
43248
  `, {
43021
43249
  encoding: "utf8",
43022
43250
  mode: 384
@@ -43102,9 +43330,9 @@ function chatTurnMaxMs() {
43102
43330
 
43103
43331
  // src/worker-token.ts
43104
43332
  var import_node_crypto6 = require("node:crypto");
43105
- var import_node_fs7 = require("node:fs");
43333
+ var import_node_fs8 = require("node:fs");
43106
43334
  var import_node_os5 = __toESM(require("node:os"), 1);
43107
- var import_node_path10 = __toESM(require("node:path"), 1);
43335
+ var import_node_path11 = __toESM(require("node:path"), 1);
43108
43336
  var DEFAULT_WORKER_PORT = 8792;
43109
43337
  function workerPort() {
43110
43338
  const raw = process.env.MRRLIN_WORKER_PORT;
@@ -43113,15 +43341,15 @@ function workerPort() {
43113
43341
  return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_WORKER_PORT;
43114
43342
  }
43115
43343
  function workerDir() {
43116
- 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");
43117
- 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");
43118
43346
  }
43119
43347
  function workerTokenPath() {
43120
- return import_node_path10.default.join(workerDir(), "token");
43348
+ return import_node_path11.default.join(workerDir(), "token");
43121
43349
  }
43122
43350
  function readWorkerToken() {
43123
43351
  try {
43124
- const token = (0, import_node_fs7.readFileSync)(workerTokenPath(), "utf8").trim();
43352
+ const token = (0, import_node_fs8.readFileSync)(workerTokenPath(), "utf8").trim();
43125
43353
  return token.length > 0 ? token : null;
43126
43354
  } catch {
43127
43355
  return null;
@@ -43131,18 +43359,18 @@ function readOrCreateWorkerToken() {
43131
43359
  const existing = readWorkerToken();
43132
43360
  if (existing) return existing;
43133
43361
  const dir = workerDir();
43134
- (0, import_node_fs7.mkdirSync)(dir, { recursive: true, mode: 448 });
43362
+ (0, import_node_fs8.mkdirSync)(dir, { recursive: true, mode: 448 });
43135
43363
  const token = (0, import_node_crypto6.randomBytes)(32).toString("hex");
43136
- (0, import_node_fs7.writeFileSync)(workerTokenPath(), `${token}
43364
+ (0, import_node_fs8.writeFileSync)(workerTokenPath(), `${token}
43137
43365
  `, { encoding: "utf8", mode: 384 });
43138
43366
  return token;
43139
43367
  }
43140
43368
 
43141
43369
  // src/remote-phone-relay.ts
43142
43370
  var import_node_events2 = require("node:events");
43143
- var import_node_fs8 = require("node:fs");
43371
+ var import_node_fs9 = require("node:fs");
43144
43372
  var import_node_os6 = require("node:os");
43145
- var import_node_path11 = require("node:path");
43373
+ var import_node_path12 = require("node:path");
43146
43374
 
43147
43375
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/cryptoNode.js
43148
43376
  var nc = __toESM(require("node:crypto"), 1);
@@ -46713,9 +46941,9 @@ var DirectorRelay = class {
46713
46941
 
46714
46942
  // src/remote-phone-relay.ts
46715
46943
  function loadOrCreateAgentDeviceKey() {
46716
- 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");
46717
46945
  try {
46718
- const raw = JSON.parse((0, import_node_fs8.readFileSync)(path16, "utf8"));
46946
+ const raw = JSON.parse((0, import_node_fs9.readFileSync)(path17, "utf8"));
46719
46947
  if (typeof raw.priv === "string" && typeof raw.pub === "string") {
46720
46948
  return { privateKey: fromBase64Url(raw.priv), publicKey: fromBase64Url(raw.pub) };
46721
46949
  }
@@ -46723,9 +46951,9 @@ function loadOrCreateAgentDeviceKey() {
46723
46951
  }
46724
46952
  const kp = generateIdentityKeyPair();
46725
46953
  try {
46726
- (0, import_node_fs8.mkdirSync)((0, import_node_path11.join)((0, import_node_os6.homedir)(), ".mrrlin"), { recursive: true });
46727
- (0, import_node_fs8.writeFileSync)(
46728
- 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,
46729
46957
  JSON.stringify({ priv: toBase64Url(kp.privateKey), pub: toBase64Url(kp.publicKey) }),
46730
46958
  { mode: 384 }
46731
46959
  );
@@ -46733,10 +46961,10 @@ function loadOrCreateAgentDeviceKey() {
46733
46961
  }
46734
46962
  return kp;
46735
46963
  }
46736
- 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");
46737
46965
  function loadAgentPairing() {
46738
46966
  try {
46739
- 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"));
46740
46968
  if (typeof raw.channelId === "string" && typeof raw.agentControlSecret === "string" && typeof raw.relayAuth === "string" && typeof raw.peerIdentityKey === "string") {
46741
46969
  return {
46742
46970
  channelId: raw.channelId,
@@ -46751,8 +46979,8 @@ function loadAgentPairing() {
46751
46979
  }
46752
46980
  function saveAgentPairing(record2) {
46753
46981
  try {
46754
- (0, import_node_fs8.mkdirSync)((0, import_node_path11.join)((0, import_node_os6.homedir)(), ".mrrlin"), { recursive: true });
46755
- (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 });
46756
46984
  } catch {
46757
46985
  }
46758
46986
  }
@@ -46929,18 +47157,18 @@ async function renderPairingQrSvg(payload) {
46929
47157
  }
46930
47158
 
46931
47159
  // src/checkout-registry.ts
46932
- var import_node_fs9 = require("node:fs");
46933
- var import_node_path12 = require("node:path");
47160
+ var import_node_fs10 = require("node:fs");
47161
+ var import_node_path13 = require("node:path");
46934
47162
  var CheckoutRegistry = class {
46935
47163
  file;
46936
47164
  constructor(stateDir) {
46937
- this.file = (0, import_node_path12.join)(stateDir, "checkouts.json");
46938
- (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 });
46939
47167
  }
46940
47168
  read() {
46941
- if (!(0, import_node_fs9.existsSync)(this.file)) return {};
47169
+ if (!(0, import_node_fs10.existsSync)(this.file)) return {};
46942
47170
  try {
46943
- return JSON.parse((0, import_node_fs9.readFileSync)(this.file, "utf8"));
47171
+ return JSON.parse((0, import_node_fs10.readFileSync)(this.file, "utf8"));
46944
47172
  } catch {
46945
47173
  return {};
46946
47174
  }
@@ -46948,10 +47176,10 @@ var CheckoutRegistry = class {
46948
47176
  get(slug) {
46949
47177
  return this.read()[slug] ?? null;
46950
47178
  }
46951
- confirm(slug, path16, now) {
47179
+ confirm(slug, path17, now) {
46952
47180
  const all = this.read();
46953
- all[slug] = { path: path16, confirmedAt: now };
46954
- (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));
46955
47183
  }
46956
47184
  };
46957
47185
 
@@ -47162,8 +47390,8 @@ function extractVerificationSection(markdown) {
47162
47390
  }
47163
47391
 
47164
47392
  // src/bridge-log.ts
47165
- var import_node_fs10 = require("node:fs");
47166
- var import_node_path13 = require("node:path");
47393
+ var import_node_fs11 = require("node:fs");
47394
+ var import_node_path14 = require("node:path");
47167
47395
 
47168
47396
  // src/redact.ts
47169
47397
  var REDACTED = "[REDACTED]";
@@ -47248,14 +47476,14 @@ function resolvePromptsEnabled(env) {
47248
47476
  }
47249
47477
  function createBridgeLogger(stateDir, env = process.env) {
47250
47478
  if (!resolveBridgeLogEnabled(env)) return NOOP_LOGGER;
47251
- const logsDir = (0, import_node_path13.join)(stateDir, "logs");
47479
+ const logsDir = (0, import_node_path14.join)(stateDir, "logs");
47252
47480
  try {
47253
- (0, import_node_fs10.mkdirSync)(logsDir, { recursive: true });
47481
+ (0, import_node_fs11.mkdirSync)(logsDir, { recursive: true });
47254
47482
  } catch {
47255
47483
  return NOOP_LOGGER;
47256
47484
  }
47257
47485
  const includePrompts = resolvePromptsEnabled(env);
47258
- 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`);
47259
47487
  const write = (dir, rec) => {
47260
47488
  try {
47261
47489
  const line = JSON.stringify({
@@ -47267,7 +47495,7 @@ function createBridgeLogger(stateDir, env = process.env) {
47267
47495
  ...rec.ms !== void 0 ? { ms: rec.ms } : {},
47268
47496
  payload: redactMessage(rec.payload, { includePrompts })
47269
47497
  }) + "\n";
47270
- (0, import_node_fs10.appendFileSync)(fileFor(), line);
47498
+ (0, import_node_fs11.appendFileSync)(fileFor(), line);
47271
47499
  } catch {
47272
47500
  }
47273
47501
  };
@@ -47337,7 +47565,7 @@ function addBridgeModel(target, model) {
47337
47565
  }
47338
47566
  function readTextIfExists(filePath) {
47339
47567
  try {
47340
- return import_node_fs11.default.readFileSync(filePath, "utf8");
47568
+ return import_node_fs12.default.readFileSync(filePath, "utf8");
47341
47569
  } catch {
47342
47570
  return null;
47343
47571
  }
@@ -47348,9 +47576,9 @@ function readKnownGptSlugsFromTomlFile(filePath) {
47348
47576
  return Array.from(raw.matchAll(/^\s*model\s*=\s*"([^"]+)"/gm)).map((match) => match[1]?.trim() ?? "").filter(isSelectableModelSlug);
47349
47577
  }
47350
47578
  function readCodexFallbackModels() {
47351
- 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");
47352
47580
  const models = /* @__PURE__ */ new Map();
47353
- const cachePath = import_node_path14.default.join(codexHome, "models_cache.json");
47581
+ const cachePath = import_node_path15.default.join(codexHome, "models_cache.json");
47354
47582
  const cacheRaw = readTextIfExists(cachePath);
47355
47583
  if (cacheRaw) {
47356
47584
  try {
@@ -47400,7 +47628,7 @@ function readCodexFallbackModels() {
47400
47628
  );
47401
47629
  }
47402
47630
  }
47403
- 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"))) {
47404
47632
  addBridgeModel(
47405
47633
  models,
47406
47634
  mapBridgeModel({
@@ -47414,11 +47642,11 @@ function readCodexFallbackModels() {
47414
47642
  })
47415
47643
  );
47416
47644
  }
47417
- const automationsDir = import_node_path14.default.join(codexHome, "automations");
47645
+ const automationsDir = import_node_path15.default.join(codexHome, "automations");
47418
47646
  try {
47419
- 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 })) {
47420
47648
  if (!entry.isDirectory()) continue;
47421
- 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"))) {
47422
47650
  addBridgeModel(
47423
47651
  models,
47424
47652
  mapBridgeModel({
@@ -47438,9 +47666,9 @@ function readCodexFallbackModels() {
47438
47666
  return [...models.values()];
47439
47667
  }
47440
47668
  function neutralCheckoutCwd(stateDir) {
47441
- const dir = import_node_path14.default.join(stateDir, "no-checkout");
47669
+ const dir = import_node_path15.default.join(stateDir, "no-checkout");
47442
47670
  try {
47443
- import_node_fs11.default.mkdirSync(dir, { recursive: true });
47671
+ import_node_fs12.default.mkdirSync(dir, { recursive: true });
47444
47672
  } catch {
47445
47673
  }
47446
47674
  return dir;
@@ -47490,7 +47718,7 @@ function buildThreadStartParams(msg, config2, desiredModel) {
47490
47718
  " bullets (`- AND ...` as needed). Scenarios make the spec verifiable.",
47491
47719
  "- Keep behavior contracts in the spec; implementation details belong in `## Implementation Plan`.",
47492
47720
  "- Apply this format ONLY to Specs/{id} pages; do not retro-fit it onto other wiki page types.",
47493
- "- 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) the spec is review-only \u2014 do NOT call `create_execution_run` (non-code execution is not yet supported and fail-closes); tell the operator the spec was reviewed.",
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.",
47494
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.',
47495
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.",
47496
47724
  "",
@@ -47756,7 +47984,7 @@ async function runOrphanWorktreeSweep(client, opts) {
47756
47984
  const cutoff = Date.now() - worktreeRetentionMs();
47757
47985
  const isReapable = (worktreePath) => {
47758
47986
  try {
47759
- return import_node_fs11.default.statSync(worktreePath).mtimeMs < cutoff;
47987
+ return import_node_fs12.default.statSync(worktreePath).mtimeMs < cutoff;
47760
47988
  } catch {
47761
47989
  return false;
47762
47990
  }
@@ -47794,8 +48022,8 @@ async function runOrphanWorktreeSweep(client, opts) {
47794
48022
  }
47795
48023
  }
47796
48024
  function readStateDir() {
47797
- if (process.env.CODEX_HOME) return import_node_path14.default.join(process.env.CODEX_HOME, "mrrlin", "director-bridge");
47798
- 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");
47799
48027
  }
47800
48028
  function readAllowedOrigins() {
47801
48029
  const raw = (process.env.MRRLIN_DIRECTOR_BRIDGE_ALLOWED_ORIGINS ?? "").trim();
@@ -48330,7 +48558,7 @@ function createBridgeMessageHandler(deps) {
48330
48558
  }
48331
48559
  }
48332
48560
  takenOver.cancel?.();
48333
- void withTimeout(
48561
+ void withTimeout2(
48334
48562
  codexClient.turn.interrupt({ threadId: takenOver.threadId }),
48335
48563
  DEFAULT_TURN_INTERRUPT_TIMEOUT_MS,
48336
48564
  "interrupt timed out"
@@ -48532,7 +48760,7 @@ function createBridgeMessageHandler(deps) {
48532
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.`
48533
48761
  )
48534
48762
  );
48535
- 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(
48536
48764
  () => {
48537
48765
  if (deps.threads.get(directorSessionId) === thread) {
48538
48766
  deps.threads.delete(directorSessionId);
@@ -48822,8 +49050,8 @@ async function startDirectorBridge() {
48822
49050
  codexCwd: config2.codexCwd,
48823
49051
  codexExecutable: config2.codexExecutable,
48824
49052
  checkoutRegistry,
48825
- worktreeRoot: import_node_path14.default.join(config2.stateDir, "worktrees"),
48826
- 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"),
48827
49055
  // Wire the executor server for code-execution runs. Each run gets its own app-server
48828
49056
  // process at the run worktree, running UNRESTRICTED from the real ~/.codex (owner
48829
49057
  // no-sandbox decision — auth + mrrlin MCP come from the operator config).
@@ -48859,13 +49087,13 @@ async function startDirectorBridge() {
48859
49087
  // egressDomains is retained in the seam signature (verification-turn.ts still computes the
48860
49088
  // env host) but no longer constrains anything — the executor is unrestricted.
48861
49089
  startSandbox: async (_egressDomains) => {
48862
- 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-"));
48863
49091
  let handle;
48864
49092
  try {
48865
49093
  handle = await startExecutorServer({ worktree: cwd });
48866
49094
  } catch (error51) {
48867
49095
  try {
48868
- import_node_fs11.default.rmSync(cwd, { recursive: true, force: true });
49096
+ import_node_fs12.default.rmSync(cwd, { recursive: true, force: true });
48869
49097
  } catch {
48870
49098
  }
48871
49099
  throw error51;
@@ -48876,7 +49104,7 @@ async function startDirectorBridge() {
48876
49104
  dispose: () => {
48877
49105
  handle.dispose();
48878
49106
  try {
48879
- import_node_fs11.default.rmSync(cwd, { recursive: true, force: true });
49107
+ import_node_fs12.default.rmSync(cwd, { recursive: true, force: true });
48880
49108
  } catch {
48881
49109
  }
48882
49110
  }
@@ -49084,7 +49312,7 @@ async function startDirectorBridge() {
49084
49312
  const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
49085
49313
  let bridgeBinShaShort = "unknown00000";
49086
49314
  try {
49087
- 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);
49088
49316
  } catch {
49089
49317
  }
49090
49318
  attachBridgeWss(server, {
@@ -49171,34 +49399,50 @@ async function startDirectorBridge() {
49171
49399
  dispatchServer.on("error", reject);
49172
49400
  dispatchServer.listen(workerPort(), "127.0.0.1", () => resolve());
49173
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
+ };
49174
49416
  let claimLoopStopped = false;
49175
49417
  let claimTimer = null;
49176
49418
  const scheduleClaimLoop = () => {
49177
49419
  if (claimLoopStopped) return;
49178
49420
  claimTimer = setTimeout(() => {
49179
49421
  enqueueRun(
49180
- () => runBackstopSweep(consumerDeps, (slug, runId) => {
49181
- driveTracked(slug, runId);
49182
- return Promise.resolve();
49183
- }).catch((error51) => {
49184
- process.stderr.write(`[mrrlin-mcp director-bridge] claim sweep failed: ${error51 instanceof Error ? error51.message : String(error51)}
49185
- `);
49186
- })
49422
+ () => runTrackedSweep(
49423
+ "claimSweep",
49424
+ "claim sweep",
49425
+ () => runBackstopSweep(consumerDeps, (slug, runId) => {
49426
+ driveTracked(slug, runId);
49427
+ return Promise.resolve();
49428
+ })
49429
+ )
49187
49430
  );
49188
49431
  enqueueRun(
49189
- () => runAsyncBackstopSweep(asyncConsumerDeps, (slug, jobId) => {
49190
- driveAsyncTracked(slug, jobId);
49191
- return Promise.resolve();
49192
- }).catch((error51) => {
49193
- process.stderr.write(`[mrrlin-mcp director-bridge] async sweep failed: ${error51 instanceof Error ? error51.message : String(error51)}
49194
- `);
49195
- })
49432
+ () => runTrackedSweep(
49433
+ "asyncSweep",
49434
+ "async sweep",
49435
+ () => runAsyncBackstopSweep(asyncConsumerDeps, (slug, jobId) => {
49436
+ driveAsyncTracked(slug, jobId);
49437
+ return Promise.resolve();
49438
+ })
49439
+ )
49196
49440
  );
49197
49441
  enqueueRun(
49198
49442
  () => runOrphanWorktreeSweep(client, {
49199
49443
  checkoutRegistry,
49200
- worktreeRoot: import_node_path14.default.join(config2.stateDir, "worktrees"),
49201
- 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")
49202
49446
  })
49203
49447
  );
49204
49448
  enqueueRun(async () => {
@@ -49259,6 +49503,7 @@ async function startDirectorBridge() {
49259
49503
  apiBaseUrl,
49260
49504
  fetchImpl: authedFetch,
49261
49505
  logger: bridgeLogger,
49506
+ bridgeHealth,
49262
49507
  dispatchEnqueued: (projectSlug, work) => {
49263
49508
  if (work.kind === "execution_run") driveRunNow(projectSlug, work.runId);
49264
49509
  else driveAsyncNow(projectSlug, work.jobId);
@@ -49459,15 +49704,15 @@ function readDispatchBody(req) {
49459
49704
  function readOrCreateBridgeToken(stateDir) {
49460
49705
  const explicit = (process.env.MRRLIN_DIRECTOR_BRIDGE_TOKEN ?? "").trim();
49461
49706
  if (explicit) return explicit;
49462
- const tokenPath = import_node_path14.default.join(stateDir, "token.txt");
49707
+ const tokenPath = import_node_path15.default.join(stateDir, "token.txt");
49463
49708
  try {
49464
- const existing = import_node_fs11.default.readFileSync(tokenPath, "utf8").trim();
49709
+ const existing = import_node_fs12.default.readFileSync(tokenPath, "utf8").trim();
49465
49710
  if (existing) return existing;
49466
49711
  } catch {
49467
49712
  }
49468
- import_node_fs11.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
49713
+ import_node_fs12.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
49469
49714
  const token = import_node_crypto7.default.randomBytes(32).toString("base64url");
49470
- import_node_fs11.default.writeFileSync(tokenPath, `${token}
49715
+ import_node_fs12.default.writeFileSync(tokenPath, `${token}
49471
49716
  `, { mode: 384 });
49472
49717
  return token;
49473
49718
  }
@@ -52851,17 +53096,17 @@ var StdioServerTransport = class {
52851
53096
  // src/tools.ts
52852
53097
  var import_node_crypto10 = require("node:crypto");
52853
53098
  var import_promises3 = require("node:fs/promises");
52854
- var import_node_fs12 = require("node:fs");
52855
- 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);
52856
53101
  var import_node_os8 = __toESM(require("node:os"), 1);
52857
53102
  var import_node_child_process12 = require("node:child_process");
52858
53103
 
52859
53104
  // ../../packages/wiki/dist/index.js
52860
53105
  var import_promises2 = __toESM(require("node:fs/promises"), 1);
52861
- var import_node_path15 = __toESM(require("node:path"), 1);
53106
+ var import_node_path16 = __toESM(require("node:path"), 1);
52862
53107
  var INCLUDED_DOC_FOLDERS = /* @__PURE__ */ new Set(["_meta", "explanation", "how-to", "reference", "sdd", "tutorials"]);
52863
53108
  function toPosixPath(input) {
52864
- return input.split(import_node_path15.default.sep).join("/");
53109
+ return input.split(import_node_path16.default.sep).join("/");
52865
53110
  }
52866
53111
  function slugifyWikiSegment(input) {
52867
53112
  return input.trim().toLowerCase().replace(/`/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
@@ -52875,12 +53120,12 @@ async function pathExists2(input) {
52875
53120
  }
52876
53121
  }
52877
53122
  async function findWorkspaceRoot(start = process.cwd()) {
52878
- let current = import_node_path15.default.resolve(start);
53123
+ let current = import_node_path16.default.resolve(start);
52879
53124
  while (true) {
52880
- 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"))) {
52881
53126
  return current;
52882
53127
  }
52883
- const parent = import_node_path15.default.dirname(current);
53128
+ const parent = import_node_path16.default.dirname(current);
52884
53129
  if (parent === current) {
52885
53130
  throw new Error(`Unable to find Mrrlin workspace root from ${start}`);
52886
53131
  }
@@ -52889,28 +53134,28 @@ async function findWorkspaceRoot(start = process.cwd()) {
52889
53134
  }
52890
53135
  async function resolveDocsRoot(input) {
52891
53136
  if (input) {
52892
- return import_node_path15.default.resolve(input);
53137
+ return import_node_path16.default.resolve(input);
52893
53138
  }
52894
53139
  if (process.env.MRRLIN_DOCS_ROOT) {
52895
- return import_node_path15.default.resolve(process.env.MRRLIN_DOCS_ROOT);
53140
+ return import_node_path16.default.resolve(process.env.MRRLIN_DOCS_ROOT);
52896
53141
  }
52897
- return import_node_path15.default.join(await findWorkspaceRoot(), "docs");
53142
+ return import_node_path16.default.join(await findWorkspaceRoot(), "docs");
52898
53143
  }
52899
53144
  async function resolveIndexPath(input) {
52900
53145
  if (input) {
52901
- return import_node_path15.default.resolve(input);
53146
+ return import_node_path16.default.resolve(input);
52902
53147
  }
52903
53148
  if (process.env.MRRLIN_WIKI_INDEX_PATH) {
52904
- 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);
52905
53150
  }
52906
53151
  const workspaceRoot = await findWorkspaceRoot();
52907
- 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");
52908
53153
  }
52909
53154
  async function walkMarkdownFiles(root, dir = root) {
52910
53155
  const entries = await import_promises2.default.readdir(dir, { withFileTypes: true });
52911
53156
  const files = [];
52912
53157
  for (const entry of entries) {
52913
- const absolute = import_node_path15.default.join(dir, entry.name);
53158
+ const absolute = import_node_path16.default.join(dir, entry.name);
52914
53159
  if (entry.isDirectory()) {
52915
53160
  files.push(...await walkMarkdownFiles(root, absolute));
52916
53161
  continue;
@@ -52929,7 +53174,7 @@ function parseTitle(markdown, sourcePath) {
52929
53174
  return title;
52930
53175
  }
52931
53176
  function documentFromFile(docsRoot, absolutePath, markdown) {
52932
- const relativePath = toPosixPath(import_node_path15.default.relative(docsRoot, absolutePath));
53177
+ const relativePath = toPosixPath(import_node_path16.default.relative(docsRoot, absolutePath));
52933
53178
  const [section, fileName] = relativePath.split("/");
52934
53179
  if (!section || !fileName || !INCLUDED_DOC_FOLDERS.has(section)) {
52935
53180
  return null;
@@ -53658,8 +53903,8 @@ async function cachedResult(client, input) {
53658
53903
  }
53659
53904
  return { status: "already_converged", payload: { outcome: "CONVERGED", contentHash: page.contentHash } };
53660
53905
  }
53661
- if (review?.outcome === "CONSENSUS_BLOCKED") {
53662
- return { status: "already_reviewed", payload: { outcome: "CONSENSUS_BLOCKED", contentHash: page.contentHash } };
53906
+ if (review?.outcome === "CONSENSUS_BLOCKED" || review?.outcome === "CONSENSUS_BLOCKED_CLARIFICATION") {
53907
+ return { status: "already_reviewed", payload: { outcome: review.outcome, contentHash: page.contentHash } };
53663
53908
  }
53664
53909
  return null;
53665
53910
  }
@@ -53708,6 +53953,27 @@ async function run(ctx, input) {
53708
53953
  }
53709
53954
  if (result.outcome === "CONSENSUS_BLOCKED") {
53710
53955
  const clarifications = result.clarifications ?? [];
53956
+ if (clarifications.length > 0) {
53957
+ try {
53958
+ const page = await ctx.client.getWikiPage(input.projectSlug, input.pageId);
53959
+ if (page) {
53960
+ const domain2 = await resolveSpecDomain(ctx.client, input.projectSlug, {
53961
+ id: page.id,
53962
+ taskId: page.taskId ?? null
53963
+ });
53964
+ await ctx.client.recordSpecConsensusReview(input.projectSlug, input.pageId, {
53965
+ contentHash: domainScopedReviewHash(page.contentHash, domain2),
53966
+ outcome: "CONSENSUS_BLOCKED_CLARIFICATION",
53967
+ rounds: 0
53968
+ });
53969
+ }
53970
+ } catch (error52) {
53971
+ process.stderr.write(
53972
+ `[mrrlin-mcp consensus] clarification verdict write failed for ${input.projectSlug}/${input.pageId}: ${error52 instanceof Error ? error52.message : String(error52)}
53973
+ `
53974
+ );
53975
+ }
53976
+ }
53711
53977
  let filedQuestionCount = 0;
53712
53978
  if (clarifications.length > 0) {
53713
53979
  const page = await ctx.client.getWikiPage(input.projectSlug, input.pageId);
@@ -53731,7 +53997,7 @@ async function run(ctx, input) {
53731
53997
  taskId: scopeId,
53732
53998
  body: clarification.question,
53733
53999
  origin: "gate",
53734
- ...questionOptions ? { questionOptions } : {},
54000
+ questionOptions,
53735
54001
  ...groupId ? { groupId } : {}
53736
54002
  });
53737
54003
  } catch {
@@ -53751,7 +54017,7 @@ async function run(ctx, input) {
53751
54017
  planId: scopeId,
53752
54018
  body: clarification.question,
53753
54019
  origin: "gate",
53754
- ...questionOptions ? { questionOptions } : {},
54020
+ questionOptions,
53755
54021
  ...groupId ? { groupId } : {}
53756
54022
  });
53757
54023
  } catch {
@@ -54806,7 +55072,7 @@ var mcpToolDescriptions = {
54806
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.",
54807
55073
  [mcpToolNames.updateWikiPage]: "Update a markdown Wiki page.",
54808
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.",
54809
- [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) the spec is REVIEW-ONLY: do NOT call create_execution_run (it fail-closes with non_code_execution_unsupported until Phase 2) \u2014 report that the spec was reviewed and end the turn.',
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.',
54810
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).`,
54811
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.",
54812
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.',
@@ -55463,7 +55729,7 @@ function createMrrlinTools(options) {
55463
55729
  "ARTIFACT_FILE_UPLOAD_FAILED",
55464
55730
  "Unable to upload artifact file.",
55465
55731
  async (c, { projectSlug, path: filePath, class: artifactClass, taskId, runId, description }) => {
55466
- const extension2 = import_node_path16.default.extname(filePath).toLowerCase();
55732
+ const extension2 = import_node_path17.default.extname(filePath).toLowerCase();
55467
55733
  const contentType = ARTIFACT_EXTENSION_TYPES[extension2];
55468
55734
  if (!contentType) {
55469
55735
  throw new McpToolCodedError(
@@ -55491,7 +55757,7 @@ function createMrrlinTools(options) {
55491
55757
  "Artifact exceeds 5MB; split or summarize instead."
55492
55758
  );
55493
55759
  }
55494
- const filename = import_node_path16.default.basename(filePath);
55760
+ const filename = import_node_path17.default.basename(filePath);
55495
55761
  const created = await c.createArtifactFile(projectSlug, {
55496
55762
  class: artifactClass,
55497
55763
  contentType,
@@ -55574,7 +55840,7 @@ function createMrrlinTools(options) {
55574
55840
  "Unable to register local checkout.",
55575
55841
  async (_c, { projectSlug, path: checkoutPath, repo }) => {
55576
55842
  const trimmedPath = checkoutPath.trim();
55577
- if (!import_node_path16.default.isAbsolute(trimmedPath)) {
55843
+ if (!import_node_path17.default.isAbsolute(trimmedPath)) {
55578
55844
  throw new McpToolCodedError(
55579
55845
  "LOCAL_CHECKOUT_PATH_NOT_ABSOLUTE",
55580
55846
  `Path must be absolute, got: ${trimmedPath}`
@@ -55582,7 +55848,7 @@ function createMrrlinTools(options) {
55582
55848
  }
55583
55849
  let resolvedPath;
55584
55850
  try {
55585
- resolvedPath = (0, import_node_fs12.realpathSync)(trimmedPath);
55851
+ resolvedPath = (0, import_node_fs13.realpathSync)(trimmedPath);
55586
55852
  } catch {
55587
55853
  throw new McpToolCodedError(
55588
55854
  "LOCAL_CHECKOUT_PATH_NOT_FOUND",
@@ -55609,7 +55875,7 @@ function createMrrlinTools(options) {
55609
55875
  `Origin remote ${remoteUrl} does not match repo ${repo}.`
55610
55876
  );
55611
55877
  }
55612
- 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");
55613
55879
  const registry3 = new CheckoutRegistry(stateDir);
55614
55880
  const confirmedAt = (/* @__PURE__ */ new Date()).toISOString();
55615
55881
  registry3.confirm(projectSlug, resolvedPath, confirmedAt);
@@ -55817,12 +56083,12 @@ function runSetCredential(args) {
55817
56083
 
55818
56084
  // src/install-service.ts
55819
56085
  var import_node_os9 = __toESM(require("node:os"), 1);
55820
- var import_node_path18 = __toESM(require("node:path"), 1);
56086
+ var import_node_path19 = __toESM(require("node:path"), 1);
55821
56087
 
55822
56088
  // src/service-paths.ts
55823
- var import_node_path17 = __toESM(require("node:path"), 1);
56089
+ var import_node_path18 = __toESM(require("node:path"), 1);
55824
56090
  function isWorktreePath(p) {
55825
- 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("/");
55826
56092
  return norm.includes("/.claude/worktrees/");
55827
56093
  }
55828
56094
  function resolveServiceCwd(opts) {
@@ -55887,7 +56153,7 @@ function installService(deps) {
55887
56153
  return { ok: false };
55888
56154
  }
55889
56155
  const resolvedBins = bins.filter((b) => b !== null);
55890
- 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(":");
55891
56157
  const text = renderEcosystemConfig({
55892
56158
  cwd: resolved.cwd,
55893
56159
  home,
@@ -55896,7 +56162,7 @@ function installService(deps) {
55896
56162
  staging: deps.env.MRRLIN_STAGING === "1",
55897
56163
  apiBaseUrl: deps.env.MRRLIN_API_BASE_URL?.trim() || void 0
55898
56164
  });
55899
- 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");
55900
56166
  deps.writeFile(ecoPath, text);
55901
56167
  const start = deps.runPm2(["startOrReload", ecoPath]);
55902
56168
  if (start.code !== 0) {
@@ -55928,12 +56194,12 @@ function uninstallService(deps) {
55928
56194
  // src/uninstall-codex.ts
55929
56195
  var import_promises4 = __toESM(require("node:fs/promises"), 1);
55930
56196
  var import_node_os10 = __toESM(require("node:os"), 1);
55931
- var import_node_path19 = __toESM(require("node:path"), 1);
56197
+ var import_node_path20 = __toESM(require("node:path"), 1);
55932
56198
  var toml2 = __toESM(require_toml(), 1);
55933
56199
  function resolveCodexHome2(options) {
55934
56200
  if (options.codexHome) return options.codexHome;
55935
56201
  if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
55936
- 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");
55937
56203
  }
55938
56204
  async function pathExists3(target) {
55939
56205
  try {
@@ -55946,7 +56212,7 @@ async function pathExists3(target) {
55946
56212
  var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.(?:mrrlin(?:-browser)?|external-agents)(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
55947
56213
  async function uninstallCodex(options = {}) {
55948
56214
  const codexHome = resolveCodexHome2(options);
55949
- const configPath = import_node_path19.default.join(codexHome, "config.toml");
56215
+ const configPath = import_node_path20.default.join(codexHome, "config.toml");
55950
56216
  const removePrompts = async () => uninstallPrompts(codexHome, options.promptNames ?? []);
55951
56217
  if (!await pathExists3(configPath)) {
55952
56218
  return { action: "missing", configPath, prompts: await removePrompts() };
@@ -55974,10 +56240,10 @@ async function uninstallCodex(options = {}) {
55974
56240
  }
55975
56241
  async function uninstallPrompts(codexHome, names) {
55976
56242
  if (names.length === 0) return [];
55977
- const promptsDir = import_node_path19.default.join(codexHome, "prompts");
56243
+ const promptsDir = import_node_path20.default.join(codexHome, "prompts");
55978
56244
  const out = [];
55979
56245
  for (const name of names) {
55980
- const promptPath = import_node_path19.default.join(promptsDir, `${name}.md`);
56246
+ const promptPath = import_node_path20.default.join(promptsDir, `${name}.md`);
55981
56247
  try {
55982
56248
  await import_promises4.default.unlink(promptPath);
55983
56249
  out.push({ name, action: "removed", promptPath });
@@ -56230,8 +56496,8 @@ async function main() {
56230
56496
  }
56231
56497
  }
56232
56498
  try {
56233
- const codexHome = process.env.CODEX_HOME ?? import_node_path21.default.join(process.env.HOME ?? (0, import_node_os11.homedir)(), ".codex");
56234
- (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 });
56235
56501
  } catch {
56236
56502
  }
56237
56503
  return;
@@ -56261,8 +56527,8 @@ async function main() {
56261
56527
  env: process.env,
56262
56528
  cwd: process.cwd(),
56263
56529
  writeFile: (p, c) => {
56264
- (0, import_node_fs13.mkdirSync)(import_node_path21.default.dirname(p), { recursive: true, mode: 448 });
56265
- (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 });
56266
56532
  },
56267
56533
  runPm2: pm2Runner,
56268
56534
  which: whichBin,
@@ -56279,14 +56545,14 @@ async function main() {
56279
56545
  runPm2: (a) => ({ code: pm2Runner(a).code }),
56280
56546
  removeFile: (p) => {
56281
56547
  try {
56282
- (0, import_node_fs13.rmSync)(p, { force: true });
56548
+ (0, import_node_fs14.rmSync)(p, { force: true });
56283
56549
  } catch {
56284
56550
  }
56285
56551
  },
56286
56552
  purgeSecret: purge,
56287
56553
  secretPath: agentCredentialPath(),
56288
56554
  tokenPath: operatorTokenPath(),
56289
- 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"),
56290
56556
  log: (m) => process.stderr.write(`[mrrlin-mcp uninstall-service] ${m}
56291
56557
  `)
56292
56558
  });
@@ -56300,14 +56566,14 @@ async function main() {
56300
56566
  runPm2: (a) => ({ code: pm2Runner(a).code }),
56301
56567
  removeFile: (p) => {
56302
56568
  try {
56303
- (0, import_node_fs13.rmSync)(p, { force: true });
56569
+ (0, import_node_fs14.rmSync)(p, { force: true });
56304
56570
  } catch {
56305
56571
  }
56306
56572
  },
56307
56573
  purgeSecret: true,
56308
56574
  secretPath: agentCredentialPath(),
56309
56575
  tokenPath: operatorTokenPath(),
56310
- ecoPath: import_node_path21.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
56576
+ ecoPath: import_node_path22.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
56311
56577
  log
56312
56578
  });
56313
56579
  let codexOk = true;
@@ -56327,7 +56593,7 @@ async function main() {
56327
56593
  log(`codex config NOT modified: ${error51 instanceof Error ? error51.message : String(error51)}`);
56328
56594
  }
56329
56595
  try {
56330
- (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 });
56331
56597
  } catch {
56332
56598
  }
56333
56599
  log("removed ~/.mrrlin");
@@ -56368,7 +56634,7 @@ ${HELP_TEXT}`);
56368
56634
  }
56369
56635
  }
56370
56636
  function resolveSelfBinPath() {
56371
- return import_node_path20.default.resolve(process.argv[1] ?? process.execPath);
56637
+ return import_node_path21.default.resolve(process.argv[1] ?? process.execPath);
56372
56638
  }
56373
56639
  main().catch((error51) => {
56374
56640
  process.stderr.write(`mrrlin-mcp fatal error: ${error51 instanceof Error ? error51.message : String(error51)}