@mrrlin-dev/mcp 0.3.26 → 0.3.34

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(fs7) {
7706
+ function patch(fs6) {
7707
7707
  if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
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(path16, mode, cb) {
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(path15, mode, cb) {
7733
7733
  if (cb) process.nextTick(cb);
7734
7734
  };
7735
- fs7.lchmodSync = function() {
7735
+ fs6.lchmodSync = function() {
7736
7736
  };
7737
7737
  }
7738
- if (fs7.chown && !fs7.lchown) {
7739
- fs7.lchown = function(path16, uid, gid, cb) {
7738
+ if (fs6.chown && !fs6.lchown) {
7739
+ fs6.lchown = function(path15, uid, gid, cb) {
7740
7740
  if (cb) process.nextTick(cb);
7741
7741
  };
7742
- fs7.lchownSync = function() {
7742
+ fs6.lchownSync = function() {
7743
7743
  };
7744
7744
  }
7745
7745
  if (platform === "win32") {
7746
- fs7.rename = typeof fs7.rename !== "function" ? fs7.rename : function(fs$rename) {
7746
+ fs6.rename = typeof fs6.rename !== "function" ? fs6.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
- fs7.stat(to, function(stater, st) {
7753
+ fs6.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
- }(fs7.rename);
7769
+ }(fs6.rename);
7770
7770
  }
7771
- fs7.read = typeof fs7.read !== "function" ? fs7.read : function(fs$read) {
7771
+ fs6.read = typeof fs6.read !== "function" ? fs6.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(fs7, fd, buffer, offset, length, position, callback);
7779
+ return fs$read.call(fs6, fd, buffer, offset, length, position, callback);
7780
7780
  }
7781
7781
  callback_.apply(this, arguments);
7782
7782
  };
7783
7783
  }
7784
- return fs$read.call(fs7, fd, buffer, offset, length, position, callback);
7784
+ return fs$read.call(fs6, fd, buffer, offset, length, position, callback);
7785
7785
  }
7786
7786
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
7787
7787
  return read;
7788
- }(fs7.read);
7789
- fs7.readSync = typeof fs7.readSync !== "function" ? fs7.readSync : /* @__PURE__ */ function(fs$readSync) {
7788
+ }(fs6.read);
7789
+ fs6.readSync = typeof fs6.readSync !== "function" ? fs6.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(fs7, fd, buffer, offset, length, position);
7794
+ return fs$readSync.call(fs6, 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
- }(fs7.readSync);
7805
- function patchLchmod(fs8) {
7806
- fs8.lchmod = function(path16, mode, callback) {
7807
- fs8.open(
7808
- path16,
7804
+ }(fs6.readSync);
7805
+ function patchLchmod(fs7) {
7806
+ fs7.lchmod = function(path15, mode, callback) {
7807
+ fs7.open(
7808
+ path15,
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
- fs8.fchmod(fd, mode, function(err2) {
7817
- fs8.close(fd, function(err22) {
7816
+ fs7.fchmod(fd, mode, function(err2) {
7817
+ fs7.close(fd, function(err22) {
7818
7818
  if (callback) callback(err2 || err22);
7819
7819
  });
7820
7820
  });
7821
7821
  }
7822
7822
  );
7823
7823
  };
7824
- fs8.lchmodSync = function(path16, mode) {
7825
- var fd = fs8.openSync(path16, constants.O_WRONLY | constants.O_SYMLINK, mode);
7824
+ fs7.lchmodSync = function(path15, mode) {
7825
+ var fd = fs7.openSync(path15, constants.O_WRONLY | constants.O_SYMLINK, mode);
7826
7826
  var threw = true;
7827
7827
  var ret;
7828
7828
  try {
7829
- ret = fs8.fchmodSync(fd, mode);
7829
+ ret = fs7.fchmodSync(fd, mode);
7830
7830
  threw = false;
7831
7831
  } finally {
7832
7832
  if (threw) {
7833
7833
  try {
7834
- fs8.closeSync(fd);
7834
+ fs7.closeSync(fd);
7835
7835
  } catch (er) {
7836
7836
  }
7837
7837
  } else {
7838
- fs8.closeSync(fd);
7838
+ fs7.closeSync(fd);
7839
7839
  }
7840
7840
  }
7841
7841
  return ret;
7842
7842
  };
7843
7843
  }
7844
- function patchLutimes(fs8) {
7845
- if (constants.hasOwnProperty("O_SYMLINK") && fs8.futimes) {
7846
- fs8.lutimes = function(path16, at, mt, cb) {
7847
- fs8.open(path16, constants.O_SYMLINK, function(er, fd) {
7844
+ function patchLutimes(fs7) {
7845
+ if (constants.hasOwnProperty("O_SYMLINK") && fs7.futimes) {
7846
+ fs7.lutimes = function(path15, at, mt, cb) {
7847
+ fs7.open(path15, constants.O_SYMLINK, function(er, fd) {
7848
7848
  if (er) {
7849
7849
  if (cb) cb(er);
7850
7850
  return;
7851
7851
  }
7852
- fs8.futimes(fd, at, mt, function(er2) {
7853
- fs8.close(fd, function(er22) {
7852
+ fs7.futimes(fd, at, mt, function(er2) {
7853
+ fs7.close(fd, function(er22) {
7854
7854
  if (cb) cb(er2 || er22);
7855
7855
  });
7856
7856
  });
7857
7857
  });
7858
7858
  };
7859
- fs8.lutimesSync = function(path16, at, mt) {
7860
- var fd = fs8.openSync(path16, constants.O_SYMLINK);
7859
+ fs7.lutimesSync = function(path15, at, mt) {
7860
+ var fd = fs7.openSync(path15, constants.O_SYMLINK);
7861
7861
  var ret;
7862
7862
  var threw = true;
7863
7863
  try {
7864
- ret = fs8.futimesSync(fd, at, mt);
7864
+ ret = fs7.futimesSync(fd, at, mt);
7865
7865
  threw = false;
7866
7866
  } finally {
7867
7867
  if (threw) {
7868
7868
  try {
7869
- fs8.closeSync(fd);
7869
+ fs7.closeSync(fd);
7870
7870
  } catch (er) {
7871
7871
  }
7872
7872
  } else {
7873
- fs8.closeSync(fd);
7873
+ fs7.closeSync(fd);
7874
7874
  }
7875
7875
  }
7876
7876
  return ret;
7877
7877
  };
7878
- } else if (fs8.futimes) {
7879
- fs8.lutimes = function(_a3, _b, _c, cb) {
7878
+ } else if (fs7.futimes) {
7879
+ fs7.lutimes = function(_a3, _b, _c, cb) {
7880
7880
  if (cb) process.nextTick(cb);
7881
7881
  };
7882
- fs8.lutimesSync = function() {
7882
+ fs7.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(fs7, target, mode, function(er) {
7889
+ return orig.call(fs6, 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(fs7, target, mode);
7899
+ return orig.call(fs6, 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(fs7, target, uid, gid, function(er) {
7908
+ return orig.call(fs6, 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(fs7, target, uid, gid);
7918
+ return orig.call(fs6, 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(fs7, target, options, callback) : orig.call(fs7, target, callback);
7938
+ return options ? orig.call(fs6, target, options, callback) : orig.call(fs6, 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(fs7, target, options) : orig.call(fs7, target);
7944
+ var stats = options ? orig.call(fs6, target, options) : orig.call(fs6, 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(fs7) {
7973
+ function legacy(fs6) {
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(path15, options) {
7979
+ if (!(this instanceof ReadStream)) return new ReadStream(path15, options);
7980
7980
  Stream.call(this);
7981
7981
  var self = this;
7982
- this.path = path16;
7982
+ this.path = path15;
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
- fs7.open(this.path, this.flags, this.mode, function(err, fd) {
8016
+ fs6.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(path15, options) {
8028
+ if (!(this instanceof WriteStream)) return new WriteStream(path15, options);
8029
8029
  Stream.call(this);
8030
- this.path = path16;
8030
+ this.path = path15;
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 = fs7.open;
8055
+ this._open = fs6.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 fs7 = require("fs");
8090
+ var fs6 = 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 (!fs7[gracefulQueue]) {
8122
+ if (!fs6[gracefulQueue]) {
8123
8123
  queue = global[gracefulQueue] || [];
8124
- publishQueue(fs7, queue);
8125
- fs7.close = function(fs$close) {
8124
+ publishQueue(fs6, queue);
8125
+ fs6.close = function(fs$close) {
8126
8126
  function close(fd, cb) {
8127
- return fs$close.call(fs7, fd, function(err) {
8127
+ return fs$close.call(fs6, 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
- }(fs7.close);
8140
- fs7.closeSync = function(fs$closeSync) {
8139
+ }(fs6.close);
8140
+ fs6.closeSync = function(fs$closeSync) {
8141
8141
  function closeSync(fd) {
8142
- fs$closeSync.apply(fs7, arguments);
8142
+ fs$closeSync.apply(fs6, arguments);
8143
8143
  resetQueue();
8144
8144
  }
8145
8145
  Object.defineProperty(closeSync, previousSymbol, {
8146
8146
  value: fs$closeSync
8147
8147
  });
8148
8148
  return closeSync;
8149
- }(fs7.closeSync);
8149
+ }(fs6.closeSync);
8150
8150
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
8151
8151
  process.on("exit", function() {
8152
- debug(fs7[gracefulQueue]);
8153
- require("assert").equal(fs7[gracefulQueue].length, 0);
8152
+ debug(fs6[gracefulQueue]);
8153
+ require("assert").equal(fs6[gracefulQueue].length, 0);
8154
8154
  });
8155
8155
  }
8156
8156
  }
8157
8157
  var queue;
8158
8158
  if (!global[gracefulQueue]) {
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(path16, options, cb) {
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(path15, 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(path15, options, cb);
8177
+ function go$readFile(path16, options2, cb2, startTime) {
8178
+ return fs$readFile(path16, 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, [path16, 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 = fs8.writeFile;
8189
- fs8.writeFile = writeFile;
8190
- function writeFile(path16, data, options, cb) {
8188
+ var fs$writeFile = fs7.writeFile;
8189
+ fs7.writeFile = writeFile;
8190
+ function writeFile(path15, 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(path15, data, options, cb);
8194
+ function go$writeFile(path16, data2, options2, cb2, startTime) {
8195
+ return fs$writeFile(path16, 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, [path16, 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 = fs8.appendFile;
8205
+ var fs$appendFile = fs7.appendFile;
8206
8206
  if (fs$appendFile)
8207
- fs8.appendFile = appendFile;
8208
- function appendFile(path16, data, options, cb) {
8207
+ fs7.appendFile = appendFile;
8208
+ function appendFile(path15, 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(path15, data, options, cb);
8212
+ function go$appendFile(path16, data2, options2, cb2, startTime) {
8213
+ return fs$appendFile(path16, 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, [path16, 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 = fs8.copyFile;
8223
+ var fs$copyFile = fs7.copyFile;
8224
8224
  if (fs$copyFile)
8225
- fs8.copyFile = copyFile;
8225
+ fs7.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 = fs8.readdir;
8244
- fs8.readdir = readdir2;
8243
+ var fs$readdir = fs7.readdir;
8244
+ fs7.readdir = readdir2;
8245
8245
  var noReaddirOptionVersions = /^v[0-5]\./;
8246
- function readdir2(path16, options, cb) {
8246
+ function readdir2(path15, 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(path16, options2, cb2, startTime) {
8250
+ return fs$readdir(path16, fs$readdirCallback(
8251
+ path16,
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(path16, options2, cb2, startTime) {
8257
+ return fs$readdir(path16, options2, fs$readdirCallback(
8258
+ path16,
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(path15, options, cb);
8265
+ function fs$readdirCallback(path16, 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
+ [path16, 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(fs8);
8285
+ var legStreams = legacy(fs7);
8286
8286
  ReadStream = legStreams.ReadStream;
8287
8287
  WriteStream = legStreams.WriteStream;
8288
8288
  }
8289
- var fs$ReadStream = fs8.ReadStream;
8289
+ var fs$ReadStream = fs7.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 = fs8.WriteStream;
8294
+ var fs$WriteStream = fs7.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(fs8, "ReadStream", {
8299
+ Object.defineProperty(fs7, "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(fs8, "WriteStream", {
8309
+ Object.defineProperty(fs7, "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(fs8, "FileReadStream", {
8320
+ Object.defineProperty(fs7, "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(fs8, "FileWriteStream", {
8331
+ Object.defineProperty(fs7, "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(path15, 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(path15, 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 fs8.ReadStream(path16, options);
8379
+ function createReadStream(path15, options) {
8380
+ return new fs7.ReadStream(path15, options);
8381
8381
  }
8382
- function createWriteStream(path16, options) {
8383
- return new fs8.WriteStream(path16, options);
8382
+ function createWriteStream(path15, options) {
8383
+ return new fs7.WriteStream(path15, options);
8384
8384
  }
8385
- var fs$open = fs8.open;
8386
- fs8.open = open;
8387
- function open(path16, flags, mode, cb) {
8385
+ var fs$open = fs7.open;
8386
+ fs7.open = open;
8387
+ function open(path15, 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(path15, flags, mode, cb);
8391
+ function go$open(path16, flags2, mode2, cb2, startTime) {
8392
+ return fs$open(path16, 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, [path16, 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 fs8;
8402
+ return fs7;
8403
8403
  }
8404
8404
  function enqueue(elem) {
8405
8405
  debug("ENQUEUE", elem[0].name, elem[1]);
8406
- fs7[gracefulQueue].push(elem);
8406
+ fs6[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 < fs7[gracefulQueue].length; ++i) {
8413
- if (fs7[gracefulQueue][i].length > 2) {
8414
- fs7[gracefulQueue][i][3] = now;
8415
- fs7[gracefulQueue][i][4] = 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;
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 (fs7[gracefulQueue].length === 0)
8423
+ if (fs6[gracefulQueue].length === 0)
8424
8424
  return;
8425
- var elem = fs7[gracefulQueue].shift();
8425
+ var elem = fs6[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
- fs7[gracefulQueue].push(elem);
8447
+ fs6[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, fs7, callback) {
8883
- const cachedPrecision = fs7[cacheSymbol];
8882
+ function probe(file2, fs6, callback) {
8883
+ const cachedPrecision = fs6[cacheSymbol];
8884
8884
  if (cachedPrecision) {
8885
- return fs7.stat(file2, (err, stat2) => {
8885
+ return fs6.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
- fs7.utimes(file2, mtime, mtime, (err) => {
8893
+ fs6.utimes(file2, mtime, mtime, (err) => {
8894
8894
  if (err) {
8895
8895
  return callback(err);
8896
8896
  }
8897
- fs7.stat(file2, (err2, stat2) => {
8897
+ fs6.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(fs7, cacheSymbol, { value: precision });
8902
+ Object.defineProperty(fs6, 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 fs7 = require_graceful_fs();
8923
+ var path15 = require("path");
8924
+ var fs6 = 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, path15.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: fs7,
9055
+ fs: fs6,
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: fs7,
9099
+ fs: fs6,
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: fs7,
9121
+ fs: fs6,
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 fs7 = require_graceful_fs();
9161
- function createSyncFs(fs8) {
9160
+ var fs6 = require_graceful_fs();
9161
+ function createSyncFs(fs7) {
9162
9162
  const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
9163
- const newFs = { ...fs8 };
9163
+ const newFs = { ...fs7 };
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 = fs8[`${method}Sync`](...args);
9169
+ ret = fs7[`${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 || fs7);
9207
+ options.fs = createSyncFs(options.fs || fs6);
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 path15 = 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 < path15.length - 1; i++) {
10801
+ optimizedSegs.push(graph.table[path15[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 fs7 = require("fs");
13237
+ var fs6 = 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(path15, 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 = fs7.createWriteStream(path16);
13289
+ const stream = fs6.createWriteStream(path15);
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(path15, qrData, options, cb) {
13352
13352
  if (typeof cb === "undefined") {
13353
13353
  cb = options;
13354
13354
  options = void 0;
13355
13355
  }
13356
- const fs7 = require("fs");
13356
+ const fs6 = require("fs");
13357
13357
  const utf8 = exports2.render(qrData, options);
13358
- fs7.writeFile(path16, utf8, cb);
13358
+ fs6.writeFile(path15, 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 path15 = "";
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
+ path15 += 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
+ path15 += svgCmd("h", lineLength);
13496
13496
  lineLength = 0;
13497
13497
  }
13498
13498
  } else {
13499
13499
  moveBy++;
13500
13500
  }
13501
13501
  }
13502
- return path16;
13502
+ return path15;
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 path15 = "<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 + path15 + "</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(path15, qrData, options, cb) {
13528
13528
  if (typeof cb === "undefined") {
13529
13529
  cb = options;
13530
13530
  options = void 0;
13531
13531
  }
13532
- const fs7 = require("fs");
13532
+ const fs6 = 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
- fs7.writeFile(path16, xmlStr, cb);
13535
+ fs6.writeFile(path15, 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(path15) {
13694
+ return path15.slice((path15.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(path15, text, opts, cb) {
13759
+ if (typeof path15 !== "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(path15);
13767
13767
  const renderer = getRendererFromType(type);
13768
- const renderToFile = renderer.renderToFile.bind(null, path16);
13768
+ const renderToFile = renderer.renderToFile.bind(null, path15);
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(path15) {
16987
+ let input = path15;
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 [path15, query] = wsComponent.resourceName.split("?");
17240
+ wsComponent.path = path15 && path15 !== "/" ? path15 : 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, fs7, exportName) {
20633
+ function addFormats(ajv, list, fs6, 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, fs7[f]);
20638
+ ajv.addFormat(f, fs6[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);
20648
- var import_node_child_process9 = require("node:child_process");
20649
- var import_node_fs14 = require("node:fs");
20647
+ var import_node_path19 = __toESM(require("node:path"), 1);
20648
+ var import_node_child_process12 = require("node:child_process");
20649
+ var import_node_fs13 = 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_path20 = __toESM(require("node:path"), 1);
20652
20652
 
20653
20653
  // src/install-codex.ts
20654
20654
  var import_promises = __toESM(require("node:fs/promises"), 1);
@@ -20747,6 +20747,9 @@ function mrrlinTable(binPath, distribution, serveEnv) {
20747
20747
  }
20748
20748
  return { ...base, startup_timeout_sec: 30 };
20749
20749
  }
20750
+ function externalAgentsTable() {
20751
+ return { command: "external-agents-mcp", args: [], startup_timeout_sec: 30 };
20752
+ }
20750
20753
  function browserTable(binPath, distribution, homeDir) {
20751
20754
  const base = distribution === "npm" ? { command: "mrrlin-mcp", args: ["browser-serve"] } : { command: "node", args: [binPath, "browser-serve"] };
20752
20755
  return { ...base, startup_timeout_sec: 30, env: { PLAYWRIGHT_BROWSERS_PATH: browserPaths(homeDir).browsersPath } };
@@ -20767,6 +20770,11 @@ function managedBlocks(options, distribution) {
20767
20770
  id: "mrrlin-browser",
20768
20771
  expected: browserTable(options.binPath, distribution, homeDir),
20769
20772
  blockRe: blockRegex("mrrlin-browser")
20773
+ },
20774
+ {
20775
+ id: "external-agents",
20776
+ expected: externalAgentsTable(),
20777
+ blockRe: blockRegex("external-agents")
20770
20778
  }
20771
20779
  ];
20772
20780
  }
@@ -20932,11 +20940,11 @@ async function installCodex(options) {
20932
20940
  }
20933
20941
  async function installPrompts(codexHome, prompts, forcePrompts) {
20934
20942
  if (prompts.length === 0) return [];
20935
- const promptsDir2 = import_node_path2.default.join(codexHome, "prompts");
20936
- await import_promises.default.mkdir(promptsDir2, { recursive: true, mode: 448 });
20943
+ const promptsDir = import_node_path2.default.join(codexHome, "prompts");
20944
+ await import_promises.default.mkdir(promptsDir, { recursive: true, mode: 448 });
20937
20945
  const out = [];
20938
20946
  for (const prompt of prompts) {
20939
- const promptPath = import_node_path2.default.join(promptsDir2, `${prompt.name}.md`);
20947
+ const promptPath = import_node_path2.default.join(promptsDir, `${prompt.name}.md`);
20940
20948
  let existing = null;
20941
20949
  try {
20942
20950
  existing = await import_promises.default.readFile(promptPath, "utf8");
@@ -20981,7 +20989,7 @@ var import_node_fs11 = __toESM(require("node:fs"), 1);
20981
20989
  var import_node_http = __toESM(require("node:http"), 1);
20982
20990
  var import_node_os7 = __toESM(require("node:os"), 1);
20983
20991
  var import_node_path13 = __toESM(require("node:path"), 1);
20984
- var import_node_child_process7 = require("node:child_process");
20992
+ var import_node_child_process9 = require("node:child_process");
20985
20993
  var import_node_crypto7 = __toESM(require("node:crypto"), 1);
20986
20994
 
20987
20995
  // src/turn-replay-buffer.ts
@@ -22537,10 +22545,10 @@ function mergeDefs(...defs) {
22537
22545
  function cloneDef(schema) {
22538
22546
  return mergeDefs(schema._zod.def);
22539
22547
  }
22540
- function getElementAtPath(obj, path16) {
22541
- if (!path16)
22548
+ function getElementAtPath(obj, path15) {
22549
+ if (!path15)
22542
22550
  return obj;
22543
- return path16.reduce((acc, key) => acc?.[key], obj);
22551
+ return path15.reduce((acc, key) => acc?.[key], obj);
22544
22552
  }
22545
22553
  function promiseAllObject(promisesObj) {
22546
22554
  const keys = Object.keys(promisesObj);
@@ -22949,11 +22957,11 @@ function explicitlyAborted(x, startIndex = 0) {
22949
22957
  }
22950
22958
  return false;
22951
22959
  }
22952
- function prefixIssues(path16, issues) {
22960
+ function prefixIssues(path15, issues) {
22953
22961
  return issues.map((iss) => {
22954
22962
  var _a3;
22955
22963
  (_a3 = iss).path ?? (_a3.path = []);
22956
- iss.path.unshift(path16);
22964
+ iss.path.unshift(path15);
22957
22965
  return iss;
22958
22966
  });
22959
22967
  }
@@ -23100,16 +23108,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
23100
23108
  }
23101
23109
  function formatError(error51, mapper = (issue2) => issue2.message) {
23102
23110
  const fieldErrors = { _errors: [] };
23103
- const processError = (error52, path16 = []) => {
23111
+ const processError = (error52, path15 = []) => {
23104
23112
  for (const issue2 of error52.issues) {
23105
23113
  if (issue2.code === "invalid_union" && issue2.errors.length) {
23106
- issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
23114
+ issue2.errors.map((issues) => processError({ issues }, [...path15, ...issue2.path]));
23107
23115
  } else if (issue2.code === "invalid_key") {
23108
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
23116
+ processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
23109
23117
  } else if (issue2.code === "invalid_element") {
23110
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
23118
+ processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
23111
23119
  } else {
23112
- const fullpath = [...path16, ...issue2.path];
23120
+ const fullpath = [...path15, ...issue2.path];
23113
23121
  if (fullpath.length === 0) {
23114
23122
  fieldErrors._errors.push(mapper(issue2));
23115
23123
  } else {
@@ -23136,17 +23144,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
23136
23144
  }
23137
23145
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
23138
23146
  const result = { errors: [] };
23139
- const processError = (error52, path16 = []) => {
23147
+ const processError = (error52, path15 = []) => {
23140
23148
  var _a3, _b;
23141
23149
  for (const issue2 of error52.issues) {
23142
23150
  if (issue2.code === "invalid_union" && issue2.errors.length) {
23143
- issue2.errors.map((issues) => processError({ issues }, [...path16, ...issue2.path]));
23151
+ issue2.errors.map((issues) => processError({ issues }, [...path15, ...issue2.path]));
23144
23152
  } else if (issue2.code === "invalid_key") {
23145
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
23153
+ processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
23146
23154
  } else if (issue2.code === "invalid_element") {
23147
- processError({ issues: issue2.issues }, [...path16, ...issue2.path]);
23155
+ processError({ issues: issue2.issues }, [...path15, ...issue2.path]);
23148
23156
  } else {
23149
- const fullpath = [...path16, ...issue2.path];
23157
+ const fullpath = [...path15, ...issue2.path];
23150
23158
  if (fullpath.length === 0) {
23151
23159
  result.errors.push(mapper(issue2));
23152
23160
  continue;
@@ -23178,8 +23186,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
23178
23186
  }
23179
23187
  function toDotPath(_path) {
23180
23188
  const segs = [];
23181
- const path16 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
23182
- for (const seg of path16) {
23189
+ const path15 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
23190
+ for (const seg of path15) {
23183
23191
  if (typeof seg === "number")
23184
23192
  segs.push(`[${seg}]`);
23185
23193
  else if (typeof seg === "symbol")
@@ -35871,13 +35879,13 @@ function resolveRef(ref, ctx) {
35871
35879
  if (!ref.startsWith("#")) {
35872
35880
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
35873
35881
  }
35874
- const path16 = ref.slice(1).split("/").filter(Boolean);
35875
- if (path16.length === 0) {
35882
+ const path15 = ref.slice(1).split("/").filter(Boolean);
35883
+ if (path15.length === 0) {
35876
35884
  return ctx.rootSchema;
35877
35885
  }
35878
35886
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
35879
- if (path16[0] === defsKey) {
35880
- const key = path16[1];
35887
+ if (path15[0] === defsKey) {
35888
+ const key = path15[1];
35881
35889
  if (!key || !ctx.defs[key]) {
35882
35890
  throw new Error(`Reference not found: ${ref}`);
35883
35891
  }
@@ -36377,6 +36385,8 @@ var openApiOperationIds = {
36377
36385
  listArtifactFiles: "listArtifactFiles",
36378
36386
  getOperatorSettings: "getOperatorSettings",
36379
36387
  updateOperatorSettings: "updateOperatorSettings",
36388
+ getAgentPool: "getAgentPool",
36389
+ putAgentPool: "putAgentPool",
36380
36390
  getConsensusConfig: "getConsensusConfig",
36381
36391
  updateWikiPageCas: "updateWikiPageCas",
36382
36392
  promoteSpecReadyCas: "promoteSpecReadyCas",
@@ -36415,15 +36425,44 @@ var mrrlinOperatorSettingsSchema = external_exports.object({
36415
36425
  // tick, async-job consumer, deploy-gate promotion, new-deploy dispatch) stops starting NEW
36416
36426
  // work; in-flight turns are never interrupted.
36417
36427
  autonomyPaused: external_exports.boolean(),
36428
+ // Operator's currently-selected project, persisted so the server-side scheduler tick can scope
36429
+ // to it (the web active-project selection is otherwise only a browser cookie). Null = not
36430
+ // selected yet.
36431
+ activeProjectSlug: external_exports.string().min(1).nullable(),
36418
36432
  createdAt: external_exports.string().datetime(),
36419
36433
  updatedAt: external_exports.string().datetime()
36420
36434
  });
36421
- var mrrlinOperatorSettingsUpdateSchema = external_exports.object({ consensusEnabled: external_exports.boolean().optional(), autonomyPaused: external_exports.boolean().optional() }).strict().refine((value) => Object.keys(value).length > 0, {
36435
+ var mrrlinOperatorSettingsUpdateSchema = external_exports.object({
36436
+ consensusEnabled: external_exports.boolean().optional(),
36437
+ autonomyPaused: external_exports.boolean().optional(),
36438
+ activeProjectSlug: external_exports.string().min(1).nullable().optional()
36439
+ }).strict().refine((value) => Object.keys(value).length > 0, {
36422
36440
  message: "OperatorSettingsUpdate requires at least one field"
36423
36441
  });
36424
36442
  var operatorSettingsResponseSchema = external_exports.object({ data: mrrlinOperatorSettingsSchema });
36425
36443
  var mrrlinConsensusConfigSchema = external_exports.object({ consensusEnabled: external_exports.boolean() });
36426
36444
  var consensusConfigResponseSchema = external_exports.object({ data: mrrlinConsensusConfigSchema });
36445
+ var agentPoolSnapshotSchema = external_exports.object({
36446
+ collected_at: external_exports.string(),
36447
+ status: external_exports.enum(["ok", "unavailable"]),
36448
+ agents: external_exports.array(external_exports.object({
36449
+ id: external_exports.string(),
36450
+ provider: external_exports.string(),
36451
+ tier: external_exports.string(),
36452
+ tags: external_exports.array(external_exports.string()),
36453
+ state: external_exports.string(),
36454
+ calls: external_exports.number(),
36455
+ tokens_in: external_exports.number(),
36456
+ tokens_out: external_exports.number(),
36457
+ success_rate: external_exports.number(),
36458
+ last_used_at: external_exports.string().nullable()
36459
+ })),
36460
+ totals: external_exports.object({ calls: external_exports.number(), tokens_in: external_exports.number(), tokens_out: external_exports.number() }),
36461
+ estimated_savings_usd: external_exports.number()
36462
+ });
36463
+ var agentPoolResponseSchema = external_exports.object({
36464
+ data: external_exports.object({ snapshot: agentPoolSnapshotSchema.nullable() })
36465
+ });
36427
36466
 
36428
36467
  // ../../packages/schemas/dist/specConsensusReview.js
36429
36468
  var mrrlinSpecConsensusReviewSchema = external_exports.object({
@@ -37607,7 +37646,8 @@ var mrrlinInboxItemDecideSchema = external_exports.object({
37607
37646
  var mrrlinInboxItemListFiltersSchema = external_exports.object({
37608
37647
  kind: mrrlinInboxItemKindSchema.optional(),
37609
37648
  readState: external_exports.enum(["read", "unread"]).optional(),
37610
- status: mrrlinInboxItemStatusSchema.optional()
37649
+ status: mrrlinInboxItemStatusSchema.optional(),
37650
+ taskId: mrrlinTaskIdSchema.optional()
37611
37651
  });
37612
37652
  var inboxItemReadResponseSchema = external_exports.object({
37613
37653
  data: external_exports.object({
@@ -37718,18 +37758,18 @@ function createMrrlinClient(config2) {
37718
37758
  const customFetch = config2.fetch ?? globalThis.fetch;
37719
37759
  const baseUrl = config2.baseUrl.replace(/\/$/, "");
37720
37760
  const token = config2.token;
37721
- async function request(path16, init) {
37761
+ async function request(path15, init) {
37722
37762
  const method = init?.method ?? "GET";
37723
37763
  const headers = new Headers(init?.headers ?? {});
37724
37764
  if (token && !headers.has("authorization")) {
37725
37765
  headers.set("authorization", `Bearer ${token}`);
37726
37766
  }
37727
- const response = await customFetch(`${baseUrl}${path16}`, { ...init, headers });
37767
+ const response = await customFetch(`${baseUrl}${path15}`, { ...init, headers });
37728
37768
  if (!response.ok) {
37729
37769
  const body = await response.text();
37730
37770
  let code = `HTTP_${response.status}`;
37731
37771
  let violations = null;
37732
- let message = `Mrrlin API ${method} ${path16} failed: ${response.status}`;
37772
+ let message = `Mrrlin API ${method} ${path15} failed: ${response.status}`;
37733
37773
  try {
37734
37774
  const parsed = JSON.parse(body);
37735
37775
  const violationsParsed = apiViolationsErrorSchema.safeParse(parsed);
@@ -37749,7 +37789,7 @@ function createMrrlinClient(config2) {
37749
37789
  throw new MrrlinApiError({
37750
37790
  code,
37751
37791
  method,
37752
- path: path16,
37792
+ path: path15,
37753
37793
  responseBody: body,
37754
37794
  status: response.status,
37755
37795
  violations,
@@ -38004,7 +38044,7 @@ function createMrrlinClient(config2) {
38004
38044
  return taskEventListResponseSchema.parse(body).data;
38005
38045
  },
38006
38046
  async listTasks(projectSlug, filters = {}) {
38007
- const path16 = appendQuery(`${projectPath(projectSlug)}/tasks`, {
38047
+ const path15 = appendQuery(`${projectPath(projectSlug)}/tasks`, {
38008
38048
  assignee: filters.assignee,
38009
38049
  autonomyLevel: filters.autonomyLevel,
38010
38050
  blockedBy: filters.blockedBy,
@@ -38016,7 +38056,7 @@ function createMrrlinClient(config2) {
38016
38056
  subcategory: filters.subcategory,
38017
38057
  type: filters.type
38018
38058
  });
38019
- const body = await request(path16);
38059
+ const body = await request(path15);
38020
38060
  return taskListResponseSchema.parse(body).data;
38021
38061
  },
38022
38062
  async listTaxonomy(projectSlug) {
@@ -38024,22 +38064,22 @@ function createMrrlinClient(config2) {
38024
38064
  return taxonomyListResponseSchema.parse(body).data;
38025
38065
  },
38026
38066
  async listWikiPages(projectSlug, filters = {}) {
38027
- const path16 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
38067
+ const path15 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
38028
38068
  folder: filters.folder,
38029
38069
  q: filters.q,
38030
38070
  taskId: filters.taskId
38031
38071
  });
38032
- const body = await request(path16);
38072
+ const body = await request(path15);
38033
38073
  return wikiPageListResponseSchema.parse(body).data;
38034
38074
  },
38035
38075
  async searchWikiPages(projectSlug, query) {
38036
- const path16 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
38076
+ const path15 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
38037
38077
  folder: query.folder,
38038
38078
  limit: query.limit === void 0 ? void 0 : String(query.limit),
38039
38079
  pathPrefix: query.pathPrefix,
38040
38080
  q: query.q
38041
38081
  });
38042
- const body = await request(path16);
38082
+ const body = await request(path15);
38043
38083
  return wikiPageSearchResponseSchema.parse(body).data;
38044
38084
  },
38045
38085
  async updatePlan(projectSlug, planId, patch) {
@@ -38214,7 +38254,8 @@ function createMrrlinClient(config2) {
38214
38254
  const url2 = appendQuery(`${projectPath(projectSlug)}/inbox`, {
38215
38255
  kind: filters.kind,
38216
38256
  readState: filters.readState,
38217
- status: filters.status
38257
+ status: filters.status,
38258
+ taskId: filters.taskId
38218
38259
  });
38219
38260
  const body = await request(url2);
38220
38261
  return inboxItemListResponseSchema.parse(body).data;
@@ -38398,6 +38439,18 @@ function createMrrlinClient(config2) {
38398
38439
  });
38399
38440
  return operatorSettingsResponseSchema.parse(body).data;
38400
38441
  },
38442
+ async getOperatorAgentPool() {
38443
+ const body = await request(`/operator/agent-pool`);
38444
+ return agentPoolResponseSchema.parse(body).data;
38445
+ },
38446
+ async putOperatorAgentPool(snapshot) {
38447
+ const body = await request(`/operator/agent-pool`, {
38448
+ body: JSON.stringify(snapshot),
38449
+ headers: { "content-type": "application/json" },
38450
+ method: "POST"
38451
+ });
38452
+ return agentPoolResponseSchema.parse(body).data;
38453
+ },
38401
38454
  async getConsensusConfig(projectSlug) {
38402
38455
  const body = await request(`${projectPath(projectSlug)}/consensus-config`);
38403
38456
  return consensusConfigResponseSchema.parse(body).data;
@@ -38780,8 +38833,92 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
38780
38833
  };
38781
38834
  }
38782
38835
 
38836
+ // src/codex-version.ts
38837
+ var import_node_child_process3 = require("node:child_process");
38838
+ var import_semver2 = __toESM(require_semver2(), 1);
38839
+ var SEMVER_RE = /\b\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?\b/;
38840
+ var CODEX_PACKAGE = process.env.MRRLIN_CODEX_PACKAGE?.trim() || "@openai/codex";
38841
+ var distTagsUrl = (pkg) => `https://registry.npmjs.org/-/package/${encodeURIComponent(pkg)}/dist-tags`;
38842
+ function parseCodexVersion(raw) {
38843
+ const m = raw.match(SEMVER_RE);
38844
+ return m ? m[0] : null;
38845
+ }
38846
+ var defaultRun = (args) => {
38847
+ const r = (0, import_node_child_process3.spawnSync)("codex", args, { encoding: "utf8", timeout: 8e3, shell: true });
38848
+ return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
38849
+ };
38850
+ function getInstalledCodexVersion(run3) {
38851
+ const r = run3(["--version"]);
38852
+ if (r.status !== 0) return null;
38853
+ return parseCodexVersion(r.stdout || r.stderr);
38854
+ }
38855
+ async function fetchLatestCodexVersion(fetchImpl = globalThis.fetch, pkg = CODEX_PACKAGE) {
38856
+ try {
38857
+ const controller = new AbortController();
38858
+ const t = setTimeout(() => controller.abort(), 5e3);
38859
+ let res;
38860
+ try {
38861
+ res = await fetchImpl(distTagsUrl(pkg), {
38862
+ headers: { Accept: "application/json" },
38863
+ signal: controller.signal
38864
+ });
38865
+ } finally {
38866
+ clearTimeout(t);
38867
+ }
38868
+ if (!res.ok) return null;
38869
+ const body = await res.json();
38870
+ const latest = body?.latest;
38871
+ return typeof latest === "string" && import_semver2.default.valid(latest) ? latest : null;
38872
+ } catch {
38873
+ return null;
38874
+ }
38875
+ }
38876
+ async function computeCodexUpdateState(run3, fetchImpl = globalThis.fetch, pkg = CODEX_PACKAGE) {
38877
+ const version2 = getInstalledCodexVersion(run3);
38878
+ if (!version2 || !import_semver2.default.valid(version2)) return { version: version2, latestVersion: null, updateAvailable: false };
38879
+ const latestVersion = await fetchLatestCodexVersion(fetchImpl, pkg);
38880
+ if (!latestVersion) return { version: version2, latestVersion: null, updateAvailable: false };
38881
+ return { version: version2, latestVersion, updateAvailable: import_semver2.default.gt(latestVersion, version2) };
38882
+ }
38883
+ function codexUpdateCommandFor(state) {
38884
+ return state.updateAvailable ? "codex update" : null;
38885
+ }
38886
+ var DEFAULT_PROBE_INTERVAL_MS = 6 * 60 * 60 * 1e3;
38887
+ var DEFAULT_STARTUP_DELAY_MS = 1e4;
38888
+ function startCodexProbe(deps = {}) {
38889
+ const run3 = deps.run ?? defaultRun;
38890
+ const fetchImpl = deps.fetchImpl ?? globalThis.fetch;
38891
+ const pkg = deps.pkg ?? CODEX_PACKAGE;
38892
+ const intervalMs = deps.intervalMs ?? DEFAULT_PROBE_INTERVAL_MS;
38893
+ const startupDelayMs = deps.startupDelayMs ?? DEFAULT_STARTUP_DELAY_MS;
38894
+ const setIntervalFn = deps.setIntervalImpl ?? setInterval;
38895
+ const clearIntervalFn = deps.clearIntervalImpl ?? clearInterval;
38896
+ const setTimeoutFn = deps.setTimeoutImpl ?? setTimeout;
38897
+ const clearTimeoutFn = deps.clearTimeoutImpl ?? clearTimeout;
38898
+ let state = { version: null, latestVersion: null, updateAvailable: false };
38899
+ const refreshNow = async () => {
38900
+ try {
38901
+ state = await computeCodexUpdateState(run3, fetchImpl, pkg);
38902
+ } catch {
38903
+ }
38904
+ };
38905
+ const startupTimer = setTimeoutFn(() => void refreshNow(), startupDelayMs);
38906
+ startupTimer.unref?.();
38907
+ const timer = setIntervalFn(() => void refreshNow(), intervalMs);
38908
+ timer.unref?.();
38909
+ return {
38910
+ getState: () => state,
38911
+ getUpdateCommand: () => codexUpdateCommandFor(state),
38912
+ refreshNow,
38913
+ stop: () => {
38914
+ clearTimeoutFn(startupTimer);
38915
+ clearIntervalFn(timer);
38916
+ }
38917
+ };
38918
+ }
38919
+
38783
38920
  // src/_generated/version.ts
38784
- var PKG_VERSION = "0.3.26";
38921
+ var PKG_VERSION = "0.3.34";
38785
38922
 
38786
38923
  // src/api-base-url.ts
38787
38924
  var DEFAULT_API_BASE_URL = "http://127.0.0.1:8787";
@@ -38959,8 +39096,192 @@ function startSchedulerTickLoop(deps) {
38959
39096
  };
38960
39097
  }
38961
39098
 
39099
+ // src/agent-pool-loop.ts
39100
+ var import_node_child_process4 = require("node:child_process");
39101
+
39102
+ // src/agent-pool-snapshot.ts
39103
+ function buildAgentPoolSnapshot(statusRows, stats, opts) {
39104
+ if (!opts.available) {
39105
+ return {
39106
+ collected_at: opts.collectedAt,
39107
+ status: "unavailable",
39108
+ agents: [],
39109
+ totals: { calls: 0, tokens_in: 0, tokens_out: 0 },
39110
+ estimated_savings_usd: 0
39111
+ };
39112
+ }
39113
+ const costPer1M = opts.paidCostPer1MTokens ?? 3;
39114
+ const agents = statusRows.map((row) => {
39115
+ const agentStats = stats.by_agent[row.id];
39116
+ const count2 = agentStats?.count ?? 0;
39117
+ const tokensIn = agentStats?.tokens_in ?? 0;
39118
+ const tokensOut = agentStats?.tokens_out ?? 0;
39119
+ let successRate = 0;
39120
+ if (count2 > 0) {
39121
+ const successOutcomes = agentStats?.outcomes.success ?? 0;
39122
+ successRate = Number((successOutcomes / count2 * 100).toFixed(2)) / 100;
39123
+ }
39124
+ return {
39125
+ id: row.id,
39126
+ provider: row.provider,
39127
+ tier: row.tier,
39128
+ tags: row.tags,
39129
+ state: row.state ?? "unknown",
39130
+ calls: count2,
39131
+ tokens_in: tokensIn,
39132
+ tokens_out: tokensOut,
39133
+ success_rate: successRate,
39134
+ last_used_at: row.last_used_at ?? null
39135
+ };
39136
+ });
39137
+ let totalCalls = 0;
39138
+ let totalTokensIn = 0;
39139
+ let totalTokensOut = 0;
39140
+ for (const entry of Object.values(stats.by_agent)) {
39141
+ totalCalls += entry.count;
39142
+ totalTokensIn += entry.tokens_in;
39143
+ totalTokensOut += entry.tokens_out;
39144
+ }
39145
+ let savedTokens = 0;
39146
+ for (const row of statusRows) {
39147
+ if (row.tags.includes("free")) {
39148
+ const agentStats = stats.by_agent[row.id];
39149
+ if (agentStats) {
39150
+ savedTokens += agentStats.tokens_in + agentStats.tokens_out;
39151
+ }
39152
+ }
39153
+ }
39154
+ const estimatedSavings = Number((savedTokens / 1e6 * costPer1M).toFixed(2));
39155
+ return {
39156
+ collected_at: opts.collectedAt,
39157
+ status: "ok",
39158
+ agents,
39159
+ totals: {
39160
+ calls: totalCalls,
39161
+ tokens_in: totalTokensIn,
39162
+ tokens_out: totalTokensOut
39163
+ },
39164
+ estimated_savings_usd: estimatedSavings
39165
+ };
39166
+ }
39167
+
39168
+ // src/agent-pool-collector.ts
39169
+ async function collectAgentPoolSnapshot(deps) {
39170
+ let statusRows;
39171
+ let stats;
39172
+ try {
39173
+ const statusResult = await deps.runCli(["status", "--json"]);
39174
+ if (statusResult.code !== 0) throw new Error("non-zero exit on status");
39175
+ let statusParsed;
39176
+ try {
39177
+ statusParsed = JSON.parse(statusResult.stdout);
39178
+ } catch {
39179
+ throw new Error("invalid status json");
39180
+ }
39181
+ if (!Array.isArray(statusParsed)) throw new Error("status not array");
39182
+ statusRows = statusParsed;
39183
+ const statsResult = await deps.runCli(["stats", "--json"]);
39184
+ if (statsResult.code !== 0) throw new Error("non-zero exit on stats");
39185
+ try {
39186
+ stats = JSON.parse(statsResult.stdout);
39187
+ } catch {
39188
+ throw new Error("invalid stats json");
39189
+ }
39190
+ } catch {
39191
+ return buildAgentPoolSnapshot(
39192
+ [],
39193
+ {},
39194
+ { collectedAt: deps.now(), available: false }
39195
+ );
39196
+ }
39197
+ return buildAgentPoolSnapshot(
39198
+ statusRows,
39199
+ stats,
39200
+ { collectedAt: deps.now(), paidCostPer1MTokens: deps.paidCostPer1MTokens, available: true }
39201
+ );
39202
+ }
39203
+
39204
+ // src/agent-pool-loop.ts
39205
+ var DEFAULT_INTERVAL_MS2 = 6e4;
39206
+ function agentPoolLoopDisabled(env = process.env) {
39207
+ return env["MRRLIN_BRIDGE_AGENT_POOL_DISABLE"] === "1";
39208
+ }
39209
+ function defaultRunCli(args) {
39210
+ const cli = process.env["EXTERNAL_AGENTS_CLI"];
39211
+ const [cmd, baseArgs] = cli ? ["node", [cli, ...args]] : ["external-agents", args];
39212
+ return new Promise((resolve) => {
39213
+ let stdout = "";
39214
+ let settled = false;
39215
+ const done = (code) => {
39216
+ if (!settled) {
39217
+ settled = true;
39218
+ resolve({ stdout, code });
39219
+ }
39220
+ };
39221
+ try {
39222
+ const child = (0, import_node_child_process4.spawn)(cmd, baseArgs, { stdio: ["ignore", "pipe", "ignore"] });
39223
+ const timer = setTimeout(() => {
39224
+ try {
39225
+ child.kill("SIGKILL");
39226
+ } catch {
39227
+ }
39228
+ done(1);
39229
+ }, 5e3);
39230
+ timer.unref?.();
39231
+ child.stdout.on("data", (d) => {
39232
+ stdout += d.toString();
39233
+ if (stdout.length > 2e5) stdout = stdout.slice(-2e5);
39234
+ });
39235
+ child.on("error", () => {
39236
+ clearTimeout(timer);
39237
+ done(1);
39238
+ });
39239
+ child.on("close", (code) => {
39240
+ clearTimeout(timer);
39241
+ done(code ?? 1);
39242
+ });
39243
+ } catch {
39244
+ done(1);
39245
+ }
39246
+ });
39247
+ }
39248
+ async function runAgentPoolCycle(deps) {
39249
+ try {
39250
+ const snapshot = await collectAgentPoolSnapshot({
39251
+ runCli: deps.runCli ?? defaultRunCli,
39252
+ now: deps.now ?? (() => (/* @__PURE__ */ new Date()).toISOString())
39253
+ });
39254
+ await deps.push(snapshot);
39255
+ } catch (err) {
39256
+ deps.onError?.(err);
39257
+ }
39258
+ }
39259
+ function startAgentPoolLoop(deps) {
39260
+ const env = deps.env ?? process.env;
39261
+ const intervalMs = deps.intervalMs ?? Number(env["MRRLIN_BRIDGE_AGENT_POOL_INTERVAL_MS"] ?? DEFAULT_INTERVAL_MS2);
39262
+ let stopped = false;
39263
+ let timer = null;
39264
+ const schedule = () => {
39265
+ if (stopped) return;
39266
+ timer = setTimeout(() => {
39267
+ void runAgentPoolCycle(deps).then(() => schedule());
39268
+ }, intervalMs);
39269
+ timer.unref?.();
39270
+ };
39271
+ timer = setTimeout(() => {
39272
+ void runAgentPoolCycle(deps).then(() => schedule());
39273
+ }, 1e3);
39274
+ timer.unref?.();
39275
+ return {
39276
+ stop() {
39277
+ stopped = true;
39278
+ if (timer) clearTimeout(timer);
39279
+ }
39280
+ };
39281
+ }
39282
+
38962
39283
  // src/execution-consumer.ts
38963
- var import_node_child_process6 = require("node:child_process");
39284
+ var import_node_child_process8 = require("node:child_process");
38964
39285
  var import_node_crypto4 = __toESM(require("node:crypto"), 1);
38965
39286
  var import_node_path6 = __toESM(require("node:path"), 1);
38966
39287
  var import_node_util = require("node:util");
@@ -38983,6 +39304,9 @@ function normalizeDomain(value) {
38983
39304
  function resolveHeads(domain2) {
38984
39305
  return [...HEADS_BY_DOMAIN[normalizeDomain(domain2)]];
38985
39306
  }
39307
+ function allReviewHeads() {
39308
+ return [...new Set(Object.values(HEADS_BY_DOMAIN).flat())];
39309
+ }
38986
39310
  var PERSONAS_BY_DOMAIN = {
38987
39311
  seo: "seo-writer",
38988
39312
  content: "content-author",
@@ -39001,7 +39325,7 @@ var import_node_path3 = __toESM(require("node:path"), 1);
39001
39325
  var import_node_url2 = require("node:url");
39002
39326
 
39003
39327
  // src/consensus/codex-exec.ts
39004
- var import_node_child_process3 = require("node:child_process");
39328
+ var import_node_child_process5 = require("node:child_process");
39005
39329
  function extractFinalMessage(stdout) {
39006
39330
  let last = null;
39007
39331
  for (const rawLine of stdout.split(/\r?\n/)) {
@@ -39046,7 +39370,7 @@ function firstString(...values) {
39046
39370
  return null;
39047
39371
  }
39048
39372
  function runCodexExec(input, deps) {
39049
- const spawn2 = deps?.spawn ?? import_node_child_process3.spawn;
39373
+ const spawn3 = deps?.spawn ?? import_node_child_process5.spawn;
39050
39374
  const executable = input.codexExecutable ?? "codex";
39051
39375
  const sandbox = input.sandbox ?? "read-only";
39052
39376
  const fullPrompt = input.developerInstructions.trim() ? `${input.developerInstructions.trim()}
@@ -39078,7 +39402,7 @@ ${input.prompt}` : input.prompt;
39078
39402
  };
39079
39403
  let child;
39080
39404
  try {
39081
- child = spawn2(executable, args, options);
39405
+ child = spawn3(executable, args, options);
39082
39406
  } catch (err) {
39083
39407
  finish({ ok: false, error: `Failed to spawn codex exec: ${errMessage(err)}` });
39084
39408
  return;
@@ -39185,7 +39509,7 @@ function parseAcceptanceCriteria(markdown) {
39185
39509
  }
39186
39510
 
39187
39511
  // src/consensus/code-gate-git.ts
39188
- var import_node_child_process4 = require("node:child_process");
39512
+ var import_node_child_process6 = require("node:child_process");
39189
39513
  var DIFF_MAX_BYTES = 2e5;
39190
39514
  var FASTGATE_OUTPUT_MAX_BYTES = 16e3;
39191
39515
  var GIT_TIMEOUT_MS = 6e4;
@@ -39201,7 +39525,7 @@ var defaultRunCmd = (cmd, args, opts) => new Promise((resolve) => {
39201
39525
  };
39202
39526
  let child;
39203
39527
  try {
39204
- child = (0, import_node_child_process4.spawn)(cmd, args, {
39528
+ child = (0, import_node_child_process6.spawn)(cmd, args, {
39205
39529
  cwd: opts.cwd,
39206
39530
  env: process.env,
39207
39531
  shell: false,
@@ -39447,7 +39771,7 @@ function reviserIdentityInstructions(taskId, title) {
39447
39771
  }
39448
39772
  function buildSpecGateDeps(args) {
39449
39773
  const { client, projectSlug, specPageId, cwd, codexExecutable, extraHeadCount = 0 } = args;
39450
- const rounds = Number(process.env["MRRLIN_CONSENSUS_ROUNDS"] ?? 3);
39774
+ const rounds = Number(process.env["MRRLIN_CONSENSUS_ROUNDS"] ?? 5);
39451
39775
  const maxHeadCalls = rounds * (4 + extraHeadCount + 1);
39452
39776
  const timeoutMs = Number(process.env["MRRLIN_CONSENSUS_HEAD_TIMEOUT_MS"] ?? 15e4);
39453
39777
  let intentPromise = null;
@@ -39601,7 +39925,7 @@ ${artifact}`,
39601
39925
  }
39602
39926
  function buildCodeGateDeps(args) {
39603
39927
  const { client, projectSlug, baseRef, cwd, codexExecutable, extraHeads } = args;
39604
- const rounds = Number(process.env["MRRLIN_CONSENSUS_ROUNDS"] ?? 3);
39928
+ const rounds = Number(process.env["MRRLIN_CONSENSUS_ROUNDS"] ?? 5);
39605
39929
  const heads = ["code-reviewer", ...extraHeads ?? []];
39606
39930
  const maxHeadCalls = rounds * (heads.length + 1);
39607
39931
  const headTimeoutMs = Number(process.env["MRRLIN_CONSENSUS_HEAD_TIMEOUT_MS"] ?? 15e4);
@@ -39682,7 +40006,7 @@ function renderCriteriaBlock(criteria) {
39682
40006
  }
39683
40007
  async function buildDeliverableGateDeps(args) {
39684
40008
  const { client, projectSlug, deliverablePageId, cwd, codexExecutable, runId } = args;
39685
- const rounds = Number(process.env["MRRLIN_CONSENSUS_ROUNDS"] ?? 3);
40009
+ const rounds = Number(process.env["MRRLIN_CONSENSUS_ROUNDS"] ?? 5);
39686
40010
  const timeoutMs = Number(process.env["MRRLIN_CONSENSUS_HEAD_TIMEOUT_MS"] ?? 15e4);
39687
40011
  const page = await client.getWikiPage(projectSlug, deliverablePageId);
39688
40012
  const taskId = page.taskId ?? null;
@@ -40605,7 +40929,7 @@ async function awaitTurnWithDeadline(opts) {
40605
40929
  }
40606
40930
 
40607
40931
  // src/worktree.ts
40608
- var import_node_child_process5 = require("node:child_process");
40932
+ var import_node_child_process7 = require("node:child_process");
40609
40933
  var import_node_fs4 = require("node:fs");
40610
40934
  var import_node_os3 = require("node:os");
40611
40935
  var import_node_path5 = require("node:path");
@@ -40633,9 +40957,9 @@ async function withCheckoutLock(locksDir, slug, fn) {
40633
40957
  function worktreeBranch(runId) {
40634
40958
  return `mrrlin/run-${runId}`;
40635
40959
  }
40636
- var defaultGitExec = (args, env) => (0, import_node_child_process5.execFileSync)("git", args, { encoding: "utf8", timeout: 3e4, env });
40960
+ var defaultGitExec = (args, env) => (0, import_node_child_process7.execFileSync)("git", args, { encoding: "utf8", timeout: 3e4, env });
40637
40961
  function git(checkout, args) {
40638
- return (0, import_node_child_process5.execFileSync)("git", ["-C", checkout, ...args], {
40962
+ return (0, import_node_child_process7.execFileSync)("git", ["-C", checkout, ...args], {
40639
40963
  encoding: "utf8",
40640
40964
  timeout: 3e4,
40641
40965
  env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
@@ -40840,6 +41164,38 @@ function isExecutionTurnTimeoutReason(reason) {
40840
41164
  function contextMaxArtifacts() {
40841
41165
  return readPositiveIntEnv("MRRLIN_DIRECTOR_BRIDGE_CONTEXT_MAX_ARTIFACTS", DEFAULT_CONTEXT_MAX_ARTIFACTS);
40842
41166
  }
41167
+ var DEFAULT_COMPLETION_TURN_BUDGET_MS = 6e4;
41168
+ var DEFAULT_COMPLETION_TURN_MIN_BUDGET_MS = 1e4;
41169
+ function completionTurnBudgetMs() {
41170
+ return readPositiveIntEnv("MRRLIN_COMPLETION_TURN_BUDGET_MS", DEFAULT_COMPLETION_TURN_BUDGET_MS);
41171
+ }
41172
+ function completionTurnMinBudgetMs() {
41173
+ return readPositiveIntEnv("MRRLIN_COMPLETION_TURN_MIN_BUDGET_MS", DEFAULT_COMPLETION_TURN_MIN_BUDGET_MS);
41174
+ }
41175
+ function isCompletionTurnDisabled() {
41176
+ return (process.env.MRRLIN_COMPLETION_TURN_DISABLED ?? "").trim() === "1";
41177
+ }
41178
+ function buildCompletionTurnPrompt(taskId, currentStatus) {
41179
+ return [
41180
+ `Your work turn ended but task ${taskId} is still in status "${currentStatus}".`,
41181
+ "",
41182
+ "Decide honestly whether the work is complete:",
41183
+ "",
41184
+ "If the work IS genuinely complete:",
41185
+ "1. Update the task notes with a markdown summary of what you accomplished",
41186
+ " (see the notes format contract in your base instructions).",
41187
+ "2. Call update_task with status=closed_done.",
41188
+ "3. Append a completion-evidence artifact (checkpoint or diff_summary)",
41189
+ " to the open run if you haven't already.",
41190
+ "",
41191
+ "If the work is NOT complete \u2014 be honest, do not close incomplete work:",
41192
+ "1. Call update_task with the appropriate status (needs_human, awaiting_verification, etc.)",
41193
+ " and explain what remains in the notes.",
41194
+ "2. Append a handoff_judgement artifact explaining what the operator needs to do.",
41195
+ "",
41196
+ "You must pick one of these paths \u2014 do not leave the task in_progress."
41197
+ ].join("\n");
41198
+ }
40843
41199
  var BASE_INSTRUCTIONS_PREFIX = [
40844
41200
  "You are the Mrrlin Director driving a task toward completion autonomously.",
40845
41201
  "You can call MCP tools to read and write durable project state.",
@@ -40855,6 +41211,9 @@ var BASE_INSTRUCTIONS_PREFIX = [
40855
41211
  "- Close the task with `update_task` status=closed_done ONLY when it is genuinely complete",
40856
41212
  " AND you appended at least one completion-evidence artifact. Otherwise leave the task",
40857
41213
  " open so the run fails into an operator handoff instead of pretending success.",
41214
+ "- For a CODE task the run opens a draft PR for you after your turn; opening that PR is NOT",
41215
+ " completion. Do NOT set closed_done for code work \u2014 leave the task open; the run parks at",
41216
+ " `pull_request` (waiting for merge) and the operator merges. Closure happens after merge.",
40858
41217
  "",
40859
41218
  "File artifacts:",
40860
41219
  "- When your output is a file (markdown report, HTML, screenshot), upload it with",
@@ -40874,6 +41233,23 @@ var BASE_INSTRUCTIONS_PREFIX = [
40874
41233
  " and lose login/cookie state across runs.",
40875
41234
  "- If tool listings show duplicate names across servers, prefer the `mrrlin-browser` one",
40876
41235
  " unconditionally. Do not switch mid-run.",
41236
+ "",
41237
+ "Task description quality contract \u2014 every task you create or update via create_task or update_task:",
41238
+ "- Title: short, actionable, human-readable. Describe what needs to happen, not internal jargon.",
41239
+ ' Good: "Audit crawled-not-indexed pages and fix 404 errors"',
41240
+ ' Bad: "GSC coverage triage crawled-not-indexed + 404"',
41241
+ "- Notes (markdown): write for a human operator scanning a task list.",
41242
+ " First line: one plain-text sentence summarizing the task (no heading).",
41243
+ " Then scale the structure to complexity:",
41244
+ " For simple tasks \u2014 the one-line summary may be enough. No headings required.",
41245
+ " For non-trivial tasks, use these sections as needed:",
41246
+ " ## Context \u2014 why this task exists; link to parent/trigger task if follow-up.",
41247
+ " ## Scope \u2014 concrete actions and acceptance criteria.",
41248
+ " ## References \u2014 links, data, relevant findings (omit if nothing to reference).",
41249
+ " When closing a task (update_task status=closed_done), APPEND a Result section:",
41250
+ " ## Result \u2014 what was accomplished, key findings or metrics, follow-up tasks created.",
41251
+ " Do NOT remove earlier sections \u2014 they remain useful for context.",
41252
+ " Adapt depth to the task: a one-line fix needs one sentence, not four headings.",
40877
41253
  ""
40878
41254
  ];
40879
41255
  var CONSUMER_BASE_INSTRUCTIONS = [
@@ -40888,7 +41264,23 @@ var EXECUTOR_BASE_INSTRUCTIONS = [
40888
41264
  "files and running git/build/test commands WITHIN this worktree. Keep all changes inside the",
40889
41265
  "worktree and do not read the operator's personal secrets or files outside it \u2014 this is a rule",
40890
41266
  "you must follow, not something the environment enforces. Be concise. When you have made the",
40891
- "next increment of progress, stop the turn."
41267
+ "next increment of progress, stop the turn.",
41268
+ // ADR 0022 Phase 3: the executor is the orchestrator, not the sole worker. It has the
41269
+ // external-agents `pick`/`dispatch` MCP tools (a pool of cheap/free models) and should
41270
+ // delegate the bulk substantive work to them in parallel, keeping itself as judge. This
41271
+ // minimises the expensive default model's own token spend while the verify step preserves
41272
+ // quality. If external-agents isn't installed the tools are simply absent — these lines then
41273
+ // read as advice the model can't act on, and it does the work itself (graceful, no-op).
41274
+ "You are the ORCHESTRATOR and JUDGE, not the sole worker. If the external-agents `pick` and",
41275
+ "`dispatch` tools are available, delegate substantive, parallelizable subtasks \u2014 file edits,",
41276
+ "boilerplate, tests, research, mechanical refactors \u2014 to pool subagents via `dispatch`, several",
41277
+ "in parallel where possible, to minimise your own token spend. Keep for yourself only what needs",
41278
+ "your judgment: decomposition, integration, hard reasoning, and final decisions. You MUST verify",
41279
+ "every delegated result against the actual files and tests before it lands \u2014 pool models are",
41280
+ "lower-reliability and a wrong delegated edit is YOUR responsibility; never commit unverified",
41281
+ "delegated output. Delegation is the default for routine bulk work, but do trivial tasks yourself",
41282
+ "when dispatch overhead exceeds the work. If dispatch fails or the pool is unavailable, do the",
41283
+ "work yourself \u2014 never block the run on the pool."
40892
41284
  ].join("\n");
40893
41285
  function artifactKindForEvent(event) {
40894
41286
  switch (event.type) {
@@ -40924,10 +41316,10 @@ function newArtifactId() {
40924
41316
  return `EA-${import_node_crypto4.default.randomUUID()}`;
40925
41317
  }
40926
41318
  var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
40927
- function isBlastRadiusFloorPath(path16) {
40928
- return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path16));
41319
+ function isBlastRadiusFloorPath(path15) {
41320
+ return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path15));
40929
41321
  }
40930
- var execFileAsync = (0, import_node_util.promisify)(import_node_child_process6.execFile);
41322
+ var execFileAsync = (0, import_node_util.promisify)(import_node_child_process8.execFile);
40931
41323
  async function defaultListRunDiffPaths(opts) {
40932
41324
  const parse5 = (stdout) => stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
40933
41325
  try {
@@ -41307,10 +41699,44 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
41307
41699
  await failRun(deps, projectSlug, task, runId, leaseId, outcome.error);
41308
41700
  return;
41309
41701
  }
41310
- const readiness = await assertRunCompletionReady(deps, projectSlug, task.id, runId);
41702
+ let readiness = await assertRunCompletionReady(deps, projectSlug, task.id, runId);
41311
41703
  if (!readiness.ok) {
41312
- await failRun(deps, projectSlug, readiness.task, runId, leaseId, readiness.reason);
41313
- return;
41704
+ const completionBudget = Math.min(completionTurnBudgetMs(), remainingTurnBudgetMs());
41705
+ if (isCompletionTurnDisabled() || completionBudget < completionTurnMinBudgetMs()) {
41706
+ await failRun(deps, projectSlug, readiness.task, runId, leaseId, readiness.reason);
41707
+ return;
41708
+ }
41709
+ console.warn(
41710
+ JSON.stringify({
41711
+ event: "completion_turn_triggered",
41712
+ projectSlug,
41713
+ runId,
41714
+ taskId: task.id,
41715
+ previousStatus: readiness.task.status
41716
+ })
41717
+ );
41718
+ const completionPrompt = buildCompletionTurnPrompt(task.id, readiness.task.status);
41719
+ const completionOutcome = await driveTurn(
41720
+ deps,
41721
+ codex,
41722
+ projectSlug,
41723
+ runId,
41724
+ leaseId,
41725
+ threadId,
41726
+ completionPrompt,
41727
+ completionBudget,
41728
+ "completion"
41729
+ );
41730
+ if (!completionOutcome.ok) {
41731
+ await resetWedgedThread(deps, projectSlug, task.id, completionOutcome.interruptFailed);
41732
+ await failRun(deps, projectSlug, readiness.task, runId, leaseId, completionOutcome.error);
41733
+ return;
41734
+ }
41735
+ readiness = await assertRunCompletionReady(deps, projectSlug, task.id, runId);
41736
+ if (!readiness.ok) {
41737
+ await failRun(deps, projectSlug, readiness.task, runId, leaseId, readiness.reason);
41738
+ return;
41739
+ }
41314
41740
  }
41315
41741
  if (useExecutor) {
41316
41742
  if (!worktreePath) {
@@ -41402,6 +41828,13 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
41402
41828
  pullRequestUrl: pr.url,
41403
41829
  status: "pull_request"
41404
41830
  });
41831
+ await reconcileTaskAwaitingMerge(
41832
+ deps,
41833
+ projectSlug,
41834
+ readiness.task,
41835
+ runId,
41836
+ `PR opened (${pr.url}); autoDeploy is off \u2014 the operator merges when ready.`
41837
+ );
41405
41838
  return;
41406
41839
  }
41407
41840
  if (deps.deployGate) {
@@ -41416,7 +41849,7 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
41416
41849
  pullRequestUrl: pr.url,
41417
41850
  status: "pull_request"
41418
41851
  });
41419
- await notifyOperatorHandoff(
41852
+ await reconcileTaskAwaitingMerge(
41420
41853
  deps,
41421
41854
  projectSlug,
41422
41855
  readiness.task,
@@ -41708,6 +42141,34 @@ async function failRun(deps, projectSlug, task, runId, leaseId, reason) {
41708
42141
  await notifyOperatorHandoff(deps, projectSlug, task, runId, reason);
41709
42142
  }
41710
42143
  }
42144
+ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason) {
42145
+ if (task.status === "handoff_needed") return;
42146
+ await deps.client.appendExecutionArtifact(projectSlug, runId, {
42147
+ id: newArtifactId(),
42148
+ kind: "handoff_judgement",
42149
+ payload: {
42150
+ verdict: "approved",
42151
+ reason,
42152
+ summary: `Execution run ${runId} opened a PR and is awaiting operator action.`,
42153
+ operatorQuestion: `Task ${task.id} (${task.title}) has an open PR: ${reason}`,
42154
+ source: "execution-consumer"
42155
+ }
42156
+ }).catch(() => {
42157
+ });
42158
+ try {
42159
+ await deps.client.updateTask(projectSlug, task.id, { status: "handoff_needed" });
42160
+ } catch (error51) {
42161
+ console.warn(
42162
+ JSON.stringify({
42163
+ event: "reconcile_awaiting_merge_failed",
42164
+ projectSlug,
42165
+ taskId: task.id,
42166
+ runId,
42167
+ error: error51 instanceof Error ? error51.message : String(error51)
42168
+ })
42169
+ );
42170
+ }
42171
+ }
41711
42172
  async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
41712
42173
  try {
41713
42174
  await deps.client.appendExecutionArtifact(projectSlug, runId, {
@@ -41907,13 +42368,15 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
41907
42368
  }).catch(() => {
41908
42369
  });
41909
42370
  const delivery = descriptor2.onComplete(outcome, input);
41910
- await deps.client.createInboxItem(projectSlug, {
41911
- id: delivery.id ?? `II-${import_node_crypto5.default.randomUUID()}`,
41912
- kind: delivery.kind,
41913
- body: delivery.body,
41914
- ...delivery.taskId ? { taskId: delivery.taskId } : {}
41915
- }).catch(() => {
41916
- });
42371
+ if (!delivery.suppressInbox) {
42372
+ await deps.client.createInboxItem(projectSlug, {
42373
+ id: delivery.id ?? `II-${import_node_crypto5.default.randomUUID()}`,
42374
+ kind: delivery.kind,
42375
+ body: delivery.body,
42376
+ ...delivery.taskId ? { taskId: delivery.taskId } : {}
42377
+ }).catch(() => {
42378
+ });
42379
+ }
41917
42380
  if (descriptor2.wakeDirector) deps.wake(projectSlug, claimed.directorSessionId, delivery.body, delivery.kind);
41918
42381
  }
41919
42382
  function deriveHash() {
@@ -46018,9 +46481,9 @@ var DirectorRelay = class {
46018
46481
 
46019
46482
  // src/remote-phone-relay.ts
46020
46483
  function loadOrCreateAgentDeviceKey() {
46021
- const path16 = (0, import_node_path10.join)((0, import_node_os6.homedir)(), ".mrrlin", "agent-device-key");
46484
+ const path15 = (0, import_node_path10.join)((0, import_node_os6.homedir)(), ".mrrlin", "agent-device-key");
46022
46485
  try {
46023
- const raw = JSON.parse((0, import_node_fs8.readFileSync)(path16, "utf8"));
46486
+ const raw = JSON.parse((0, import_node_fs8.readFileSync)(path15, "utf8"));
46024
46487
  if (typeof raw.priv === "string" && typeof raw.pub === "string") {
46025
46488
  return { privateKey: fromBase64Url(raw.priv), publicKey: fromBase64Url(raw.pub) };
46026
46489
  }
@@ -46030,7 +46493,7 @@ function loadOrCreateAgentDeviceKey() {
46030
46493
  try {
46031
46494
  (0, import_node_fs8.mkdirSync)((0, import_node_path10.join)((0, import_node_os6.homedir)(), ".mrrlin"), { recursive: true });
46032
46495
  (0, import_node_fs8.writeFileSync)(
46033
- path16,
46496
+ path15,
46034
46497
  JSON.stringify({ priv: toBase64Url(kp.privateKey), pub: toBase64Url(kp.publicKey) }),
46035
46498
  { mode: 384 }
46036
46499
  );
@@ -46253,9 +46716,9 @@ var CheckoutRegistry = class {
46253
46716
  get(slug) {
46254
46717
  return this.read()[slug] ?? null;
46255
46718
  }
46256
- confirm(slug, path16, now) {
46719
+ confirm(slug, path15, now) {
46257
46720
  const all = this.read();
46258
- all[slug] = { path: path16, confirmedAt: now };
46721
+ all[slug] = { path: path15, confirmedAt: now };
46259
46722
  (0, import_node_fs9.writeFileSync)(this.file, JSON.stringify(all, null, 2));
46260
46723
  }
46261
46724
  };
@@ -46760,6 +47223,23 @@ function buildThreadStartParams(msg, config2, desiredModel) {
46760
47223
  'or "let me call the \u2026 tool" in ANY language. The operator already sees tool calls in the',
46761
47224
  "transcript. Just call the tools and reply with the outcome \u2014 start your reply with the result.",
46762
47225
  "When creating or updating tasks, always provide `autonomyLevel` and `autonomyReason`.",
47226
+ "",
47227
+ "Task description quality contract \u2014 every task you create or update via create_task or update_task:",
47228
+ "- Title: short, actionable, human-readable. Describe what needs to happen, not internal jargon.",
47229
+ ' Good: "Audit crawled-not-indexed pages and fix 404 errors"',
47230
+ ' Bad: "GSC coverage triage crawled-not-indexed + 404"',
47231
+ "- Notes (markdown): write for a human operator scanning a task list.",
47232
+ " First line: one plain-text sentence summarizing the task (no heading).",
47233
+ " Then scale the structure to complexity:",
47234
+ " For simple tasks \u2014 the one-line summary may be enough. No headings required.",
47235
+ " For non-trivial tasks, use these sections as needed:",
47236
+ " ## Context \u2014 why this task exists; link to parent/trigger task if follow-up.",
47237
+ " ## Scope \u2014 concrete actions and acceptance criteria.",
47238
+ " ## References \u2014 links, data, relevant findings (omit if nothing to reference).",
47239
+ " When closing a task (update_task status=closed_done), APPEND a Result section:",
47240
+ " ## Result \u2014 what was accomplished, key findings or metrics, follow-up tasks created.",
47241
+ " Do NOT remove earlier sections \u2014 they remain useful for context.",
47242
+ " Adapt depth to the task: a one-line fix needs one sentence, not four headings.",
46763
47243
  "When you create a task out of an operator request, set `operatorSeedRequest` to the operator's",
46764
47244
  "VERBATIM words (their request as they wrote it \u2014 NOT your paraphrase or synthesized notes). It is",
46765
47245
  "the spec gate's independent record of intent; omit it only when there is genuinely no operator",
@@ -47009,7 +47489,7 @@ function resolveDefaultBranch(checkoutPath) {
47009
47489
  if (!checkoutPath) return "main";
47010
47490
  const runGit = (args) => {
47011
47491
  try {
47012
- return (0, import_node_child_process7.execFileSync)("git", ["-C", checkoutPath, ...args], {
47492
+ return (0, import_node_child_process9.execFileSync)("git", ["-C", checkoutPath, ...args], {
47013
47493
  encoding: "utf8",
47014
47494
  stdio: ["ignore", "pipe", "ignore"],
47015
47495
  timeout: 15e3,
@@ -47168,7 +47648,7 @@ function sessionIdOf(msg) {
47168
47648
  return typeof id === "string" ? id : null;
47169
47649
  }
47170
47650
  function attachBridgeWss(server, opts) {
47171
- const { token, allowedOrigins, onReady, logger, onPaired, bridgeInstanceId, selfUpdate } = opts;
47651
+ const { token, allowedOrigins, onReady, logger, onPaired, bridgeInstanceId, selfUpdate, codex } = opts;
47172
47652
  const wss = new import_websocket_server.default({ server, path: "/ws" });
47173
47653
  wss.on("connection", (socket, request) => {
47174
47654
  const origin = request.headers.origin;
@@ -47233,7 +47713,15 @@ function attachBridgeWss(server, opts) {
47233
47713
  version: selfUpdate.version,
47234
47714
  binSha: selfUpdate.binSha,
47235
47715
  latestVersion: selfUpdate.getLatestVersion()
47236
- } : {}
47716
+ } : {},
47717
+ ...codex ? (() => {
47718
+ const st = codex.getState();
47719
+ return {
47720
+ codexVersion: st.version,
47721
+ codexLatestVersion: st.latestVersion,
47722
+ codexUpdateCommand: codex.getUpdateCommand()
47723
+ };
47724
+ })() : {}
47237
47725
  });
47238
47726
  onPaired?.();
47239
47727
  onReady?.(socket, request, send, logger ? { logger, span } : void 0);
@@ -47257,13 +47745,14 @@ async function waitFor(pred, timeoutMs) {
47257
47745
  return pred();
47258
47746
  }
47259
47747
  function attachSeqMetadata(msg, seq, turnId) {
47260
- if (msg.type === "event" || msg.type === "rateLimits" || msg.type === "error") {
47748
+ if (msg.type === "event" || msg.type === "rateLimits" || msg.type === "error" || msg.type === "turn-executing") {
47261
47749
  return { ...msg, seq, turnId };
47262
47750
  }
47263
47751
  return msg;
47264
47752
  }
47265
47753
  function createBridgeMessageHandler(deps) {
47266
47754
  const tombstones = deps.tombstones ?? /* @__PURE__ */ new Map();
47755
+ const pendingTurnSessions = /* @__PURE__ */ new Set();
47267
47756
  return (socket, _request, send, logCtx) => {
47268
47757
  const boundSessions = /* @__PURE__ */ new Set();
47269
47758
  socket.on("close", () => {
@@ -47515,6 +48004,14 @@ function createBridgeMessageHandler(deps) {
47515
48004
  interruptBuf.state = stopResult.next;
47516
48005
  recordInterrupted(interruptBuf, Date.now(), deps.suspendedMs?.() ?? 0);
47517
48006
  }
48007
+ } else if (interruptBuf && interruptBuf.state === "live" && !existing.cancel) {
48008
+ const stopResult = transition("live", { kind: "stop" });
48009
+ if (stopResult.next !== "invalid") {
48010
+ interruptBuf.state = stopResult.next;
48011
+ recordInterrupted(interruptBuf, Date.now(), deps.suspendedMs?.() ?? 0);
48012
+ existing.inFlight = false;
48013
+ pendingTurnSessions.delete(directorSessionId2);
48014
+ }
47518
48015
  }
47519
48016
  const codexClient2 = await deps.acquireCodex();
47520
48017
  try {
@@ -47573,6 +48070,18 @@ function createBridgeMessageHandler(deps) {
47573
48070
  sendForSpan({ type: "error", directorSessionId, error: "message is required." });
47574
48071
  return;
47575
48072
  }
48073
+ const busyThread = deps.threads.get(directorSessionId);
48074
+ if (msg.takeover !== true && (pendingTurnSessions.has(directorSessionId) || busyThread?.inFlight)) {
48075
+ sendForSpan({
48076
+ type: "error",
48077
+ directorSessionId,
48078
+ code: "busy",
48079
+ ...busyThread?.replay ? { inFlightTurnId: busyThread.replay.turnId } : {},
48080
+ error: "Director session is busy."
48081
+ });
48082
+ return;
48083
+ }
48084
+ pendingTurnSessions.add(directorSessionId);
47576
48085
  const codexClient = await deps.acquireCodex();
47577
48086
  let thread = deps.threads.get(directorSessionId);
47578
48087
  if (thread?.inFlight && msg.takeover === true) {
@@ -47658,6 +48167,7 @@ function createBridgeMessageHandler(deps) {
47658
48167
  if (/unauthor|not logged in|login|401|auth/i.test(acquireErrMsg)) {
47659
48168
  deps.setCodexAuth?.("expired");
47660
48169
  }
48170
+ pendingTurnSessions.delete(directorSessionId);
47661
48171
  deps.releaseCodex();
47662
48172
  return;
47663
48173
  }
@@ -47669,10 +48179,12 @@ function createBridgeMessageHandler(deps) {
47669
48179
  ...thread.replay ? { inFlightTurnId: thread.replay.turnId } : {},
47670
48180
  error: "Director session is busy."
47671
48181
  });
48182
+ pendingTurnSessions.delete(directorSessionId);
47672
48183
  deps.releaseCodex();
47673
48184
  return;
47674
48185
  }
47675
48186
  thread.inFlight = true;
48187
+ pendingTurnSessions.delete(directorSessionId);
47676
48188
  thread.replay = createReplayBuffer({
47677
48189
  turnId: (0, import_node_crypto7.randomUUID)(),
47678
48190
  spanId,
@@ -47681,6 +48193,7 @@ function createBridgeMessageHandler(deps) {
47681
48193
  });
47682
48194
  thread.lastUsedAt = Date.now();
47683
48195
  const threadId = thread.threadId;
48196
+ const currentReplayBuf = thread.replay;
47684
48197
  sendForSpan({
47685
48198
  type: "turn-started",
47686
48199
  directorSessionId,
@@ -47722,6 +48235,15 @@ function createBridgeMessageHandler(deps) {
47722
48235
  };
47723
48236
  try {
47724
48237
  await deps.runExclusive(async () => {
48238
+ if (currentReplayBuf.state === "interrupted" || currentReplayBuf.state === "completed") {
48239
+ logCtx?.logger.logOut({
48240
+ spanId,
48241
+ sessionId: directorSessionId,
48242
+ type: "<queued-turn-cancelled-drained>",
48243
+ payload: { sessionId: directorSessionId, turnId: currentReplayBuf.turnId }
48244
+ });
48245
+ return;
48246
+ }
47725
48247
  let resolveTurn = null;
47726
48248
  let rejectTurn = null;
47727
48249
  const turnFinished = new Promise((resolve, reject) => {
@@ -47828,6 +48350,7 @@ ${effectiveText}` : effectiveText;
47828
48350
  if (imageDataUri) {
47829
48351
  turnInput.push({ type: "image", url: imageDataUri });
47830
48352
  }
48353
+ sendInTurn({ type: "turn-executing", directorSessionId, turnId: currentReplayBuf.turnId });
47831
48354
  await codexClient.turn.start({
47832
48355
  threadId: thread.threadId,
47833
48356
  input: turnInput,
@@ -47883,7 +48406,9 @@ ${effectiveText}` : effectiveText;
47883
48406
  }
47884
48407
  }
47885
48408
  } finally {
47886
- thread.inFlight = false;
48409
+ if (thread.replay === currentReplayBuf) {
48410
+ thread.inFlight = false;
48411
+ }
47887
48412
  thread.lastUsedAt = Date.now();
47888
48413
  deps.persistThreads();
47889
48414
  deps.releaseCodex();
@@ -47923,7 +48448,7 @@ function parseConfig() {
47923
48448
  }
47924
48449
  function scanForOtherBridges() {
47925
48450
  try {
47926
- const result = (0, import_node_child_process7.spawnSync)("pgrep", ["-f", "mrrlin-mcp director-bridge"], {
48451
+ const result = (0, import_node_child_process9.spawnSync)("pgrep", ["-f", "mrrlin-mcp director-bridge"], {
47927
48452
  encoding: "utf8"
47928
48453
  });
47929
48454
  if (result.status !== 0) return [];
@@ -47976,6 +48501,7 @@ async function startDirectorBridge() {
47976
48501
  );
47977
48502
  }
47978
48503
  });
48504
+ const codexProbeHandle = startCodexProbe();
47979
48505
  const consumerState = { inFlightRunId: null, lastClaimAt: null };
47980
48506
  const health = createServiceHealth();
47981
48507
  const apiBaseUrl = readConfiguredApiBaseUrl();
@@ -48333,6 +48859,10 @@ async function startDirectorBridge() {
48333
48859
  version: PKG_VERSION,
48334
48860
  binSha: bridgeBinShaShort,
48335
48861
  getLatestVersion: () => selfUpdateHandle.getLatestVersion()
48862
+ },
48863
+ codex: {
48864
+ getState: () => codexProbeHandle.getState(),
48865
+ getUpdateCommand: () => codexProbeHandle.getUpdateCommand()
48336
48866
  }
48337
48867
  });
48338
48868
  if (agentSecret && relayUrl) {
@@ -48504,6 +49034,16 @@ async function startDirectorBridge() {
48504
49034
  "[mrrlin-mcp director-bridge] scheduler tick loop disabled (MRRLIN_BRIDGE_SCHEDULER_TICK_DISABLE=1).\n"
48505
49035
  );
48506
49036
  }
49037
+ let agentPoolLoopHandle = null;
49038
+ if (tokenProvider && !agentPoolLoopDisabled(process.env)) {
49039
+ agentPoolLoopHandle = startAgentPoolLoop({
49040
+ push: (snapshot) => client.putOperatorAgentPool(snapshot),
49041
+ onError: (err) => process.stderr.write(
49042
+ `[mrrlin-mcp director-bridge] agent-pool snapshot push failed: ${err instanceof Error ? err.message : String(err)}
49043
+ `
49044
+ )
49045
+ });
49046
+ }
48507
49047
  await new Promise((resolve, reject) => {
48508
49048
  server.on("error", (err) => {
48509
49049
  if (err.code === "EADDRINUSE") {
@@ -48545,8 +49085,10 @@ async function startDirectorBridge() {
48545
49085
  if (claimTimer) clearTimeout(claimTimer);
48546
49086
  },
48547
49087
  () => schedulerTickHandle?.stop(),
49088
+ () => agentPoolLoopHandle?.stop(),
48548
49089
  () => codexKeepalive.dropNow(),
48549
- () => selfUpdateHandle.stop()
49090
+ () => selfUpdateHandle.stop(),
49091
+ () => codexProbeHandle.stop()
48550
49092
  ],
48551
49093
  shutdownCodex: () => codexServerManager.shutdown(),
48552
49094
  exit: (code) => process.exit(code),
@@ -52073,7 +52615,7 @@ var import_promises3 = require("node:fs/promises");
52073
52615
  var import_node_fs12 = require("node:fs");
52074
52616
  var import_node_path15 = __toESM(require("node:path"), 1);
52075
52617
  var import_node_os8 = __toESM(require("node:os"), 1);
52076
- var import_node_child_process8 = require("node:child_process");
52618
+ var import_node_child_process11 = require("node:child_process");
52077
52619
 
52078
52620
  // ../../packages/wiki/dist/index.js
52079
52621
  var import_promises2 = __toESM(require("node:fs/promises"), 1);
@@ -52510,6 +53052,278 @@ async function runCodeGate(_target, deps) {
52510
53052
  }
52511
53053
  }
52512
53054
 
53055
+ // src/consensus/multi-llm-head.ts
53056
+ var import_node_child_process10 = require("node:child_process");
53057
+ function errMessage3(err) {
53058
+ return err instanceof Error ? err.message : String(err);
53059
+ }
53060
+ function runExternalAgents(bin, args, timeoutMs, spawn3) {
53061
+ return new Promise((resolve) => {
53062
+ let settled = false;
53063
+ const timerRef = { id: void 0 };
53064
+ const finish = (r) => {
53065
+ if (settled) return;
53066
+ settled = true;
53067
+ if (timerRef.id) clearTimeout(timerRef.id);
53068
+ resolve(r);
53069
+ };
53070
+ const options = {
53071
+ stdio: ["ignore", "pipe", "pipe"],
53072
+ env: process.env,
53073
+ shell: false
53074
+ // SECURITY: prompt is an argv element; never hand it to a shell.
53075
+ };
53076
+ let child;
53077
+ try {
53078
+ child = spawn3(bin, args, options);
53079
+ } catch (err) {
53080
+ finish({ code: null, stdout: "", error: `spawn ${bin} failed: ${errMessage3(err)}` });
53081
+ return;
53082
+ }
53083
+ let stdout = "";
53084
+ timerRef.id = setTimeout(() => {
53085
+ child.kill("SIGKILL");
53086
+ finish({ code: null, stdout, error: `external-agents ${args[0]} timed out after ${timeoutMs}ms` });
53087
+ }, timeoutMs);
53088
+ child.stdout?.on("data", (chunk) => {
53089
+ stdout += chunk.toString();
53090
+ });
53091
+ child.stderr?.on("data", () => {
53092
+ });
53093
+ child.on("error", (err) => finish({ code: null, stdout, error: `external-agents ${args[0]} error: ${errMessage3(err)}` }));
53094
+ child.on("close", (code) => finish({ code, stdout }));
53095
+ });
53096
+ }
53097
+ async function pickPanel(input, deps) {
53098
+ const spawn3 = deps?.spawn ?? import_node_child_process10.spawn;
53099
+ const bin = deps?.externalAgentsBin ?? "external-agents";
53100
+ const args = [
53101
+ "pick",
53102
+ "--tier-prefer",
53103
+ input.tierPrefer ?? "strong",
53104
+ "--n",
53105
+ String(input.n),
53106
+ "--min-distinct-providers",
53107
+ String(input.n),
53108
+ "--exclude-providers",
53109
+ input.excludeProvider
53110
+ ];
53111
+ const r = await runExternalAgents(bin, args, input.timeoutMs, spawn3);
53112
+ if (r.error) return { ok: false, error: r.error };
53113
+ if (r.code === 3) return { ok: true, agents: [] };
53114
+ if (r.code !== 0) return { ok: false, error: `external-agents pick exited ${r.code}` };
53115
+ const agents = r.stdout.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
53116
+ return { ok: true, agents };
53117
+ }
53118
+ async function dispatchHead(agentId, prompt, timeoutMs, deps) {
53119
+ const spawn3 = deps?.spawn ?? import_node_child_process10.spawn;
53120
+ const bin = deps?.externalAgentsBin ?? "external-agents";
53121
+ const args = ["dispatch", agentId, "--json", prompt];
53122
+ const r = await runExternalAgents(bin, args, timeoutMs, spawn3);
53123
+ if (r.error) return { ok: false, error: r.error };
53124
+ const lines2 = r.stdout.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
53125
+ const jsonLine = [...lines2].reverse().find((l) => l[0] === "{");
53126
+ if (!jsonLine) return { ok: false, error: `dispatch ${agentId}: no JSON on stdout (exit ${r.code})` };
53127
+ let parsed;
53128
+ try {
53129
+ parsed = JSON.parse(jsonLine);
53130
+ } catch (err) {
53131
+ return { ok: false, error: `dispatch ${agentId}: unparseable JSON (${errMessage3(err)})` };
53132
+ }
53133
+ if (parsed.outcome !== "success") {
53134
+ return { ok: false, error: `dispatch ${agentId}: outcome=${parsed.outcome} (exit ${parsed.exit_code})` };
53135
+ }
53136
+ if (typeof parsed.text !== "string" || parsed.text.trim() === "") {
53137
+ return { ok: false, error: `dispatch ${agentId}: empty text on success` };
53138
+ }
53139
+ return { ok: true, text: parsed.text };
53140
+ }
53141
+ async function buildMultiHeadRunner(input, deps) {
53142
+ const picked = await pickPanel(
53143
+ { n: input.personas.length, excludeProvider: input.excludeProvider, tierPrefer: input.tierPrefer, timeoutMs: input.pickTimeoutMs },
53144
+ deps
53145
+ );
53146
+ if (!picked.ok) return { ok: false, error: picked.error };
53147
+ if (picked.agents.length === 0) return { ok: false, error: "pick returned no agents" };
53148
+ const agents = picked.agents;
53149
+ const assignment = {};
53150
+ input.personas.forEach((persona, i) => {
53151
+ const agent = agents[i % agents.length];
53152
+ if (agent) assignment[persona] = agent;
53153
+ });
53154
+ const runHead = async (persona, artifact, dismissed) => {
53155
+ const agentId = assignment[persona];
53156
+ if (!agentId) return { ok: false, error: `no agent assigned for persona ${persona}` };
53157
+ const instructions = input.personaInstructions[persona] ?? "";
53158
+ const dismissedBlock = dismissed.trim() ? `
53159
+
53160
+ ${dismissed.trim()}` : "";
53161
+ const prompt = instructions.trim() ? `${instructions.trim()}
53162
+
53163
+ ${artifact}${dismissedBlock}` : `${artifact}${dismissedBlock}`;
53164
+ return dispatchHead(agentId, prompt, input.dispatchTimeoutMs, deps);
53165
+ };
53166
+ return { ok: true, runner: { agents, assignment, runHead } };
53167
+ }
53168
+
53169
+ // src/consensus/multi-llm-shadow.ts
53170
+ var SHADOW_LOG_PREFIX = "__MULTI_LLM_SHADOW__";
53171
+ function rollUpVerdict(verdicts) {
53172
+ if (verdicts.includes("REJECT")) return "REJECT";
53173
+ if (verdicts.includes("REQUEST_CHANGES")) return "REQUEST_CHANGES";
53174
+ return "APPROVE";
53175
+ }
53176
+ async function runShadowPanel(input, deps) {
53177
+ const base = { ran: false, correlationId: input.correlationId, productionVerdict: input.productionVerdict };
53178
+ const built = await buildMultiHeadRunner(
53179
+ {
53180
+ personas: input.heads,
53181
+ personaInstructions: input.personaInstructions,
53182
+ excludeProvider: input.excludeProvider,
53183
+ tierPrefer: "strong",
53184
+ pickTimeoutMs: input.pickTimeoutMs,
53185
+ dispatchTimeoutMs: input.dispatchTimeoutMs
53186
+ },
53187
+ deps
53188
+ );
53189
+ if (!built.ok) return { ...base, reason: built.error };
53190
+ const verdicts = [];
53191
+ const perHead = await Promise.all(
53192
+ input.heads.map(async (persona) => {
53193
+ const agent = built.runner.assignment[persona] ?? "(unassigned)";
53194
+ try {
53195
+ const res = await built.runner.runHead(persona, input.artifact, "");
53196
+ if (res.ok) {
53197
+ const parsed = parseVerdict(res.text);
53198
+ return { persona, agent, verdict: parsed.verdict, ok: true };
53199
+ }
53200
+ } catch {
53201
+ }
53202
+ return { persona, agent, verdict: "ERROR", ok: false };
53203
+ })
53204
+ );
53205
+ for (const h of perHead) {
53206
+ if (h.ok && h.verdict !== "ERROR") verdicts.push(h.verdict);
53207
+ }
53208
+ if (verdicts.length === 0) {
53209
+ return { ...base, agents: built.runner.agents, perHead, reason: "no head produced a parseable verdict" };
53210
+ }
53211
+ const shadowVerdict = rollUpVerdict(verdicts);
53212
+ return {
53213
+ ran: true,
53214
+ correlationId: input.correlationId,
53215
+ agents: built.runner.agents,
53216
+ perHead,
53217
+ shadowVerdict,
53218
+ productionVerdict: input.productionVerdict,
53219
+ agrees: shadowVerdict === input.productionVerdict
53220
+ };
53221
+ }
53222
+ async function runShadowPanelSafe(input, deps, logger = (line) => console.error(line)) {
53223
+ let record2;
53224
+ try {
53225
+ record2 = await runShadowPanel(input, deps);
53226
+ } catch (err) {
53227
+ record2 = {
53228
+ ran: false,
53229
+ correlationId: input.correlationId,
53230
+ productionVerdict: input.productionVerdict,
53231
+ reason: `shadow panel threw: ${err instanceof Error ? err.message : String(err)}`
53232
+ };
53233
+ }
53234
+ try {
53235
+ logger(`${SHADOW_LOG_PREFIX} ${JSON.stringify(record2)}`);
53236
+ } catch {
53237
+ }
53238
+ return record2;
53239
+ }
53240
+
53241
+ // src/consensus/multi-llm-shadow-hook.ts
53242
+ var SHADOW_ENV_FLAG = "MRRLIN_CONSENSUS_MULTI_LLM_SHADOW";
53243
+ var ORCHESTRATOR_PROVIDER = "openai";
53244
+ var PICK_TIMEOUT_MS = 15e3;
53245
+ var DISPATCH_TIMEOUT_MS = 6e4;
53246
+ function productionVerdictFromOutcome(outcome) {
53247
+ if (outcome === "CONVERGED") return "APPROVE";
53248
+ if (outcome === "CONSENSUS_BLOCKED") return "REQUEST_CHANGES";
53249
+ return null;
53250
+ }
53251
+ async function maybeRunShadow(input, deps, logger) {
53252
+ const env = input.env ?? process.env;
53253
+ if (!env[SHADOW_ENV_FLAG]) return false;
53254
+ const productionVerdict = productionVerdictFromOutcome(input.outcome);
53255
+ if (productionVerdict === null) return false;
53256
+ try {
53257
+ const heads = input.heads ?? [...resolveHeads(input.domain), ...input.extraHeads ?? []];
53258
+ const personaInstructions = {};
53259
+ for (const name of heads) {
53260
+ try {
53261
+ personaInstructions[name] = loadPersona(name);
53262
+ } catch {
53263
+ personaInstructions[name] = "";
53264
+ }
53265
+ }
53266
+ await runShadowPanelSafe(
53267
+ {
53268
+ heads,
53269
+ personaInstructions,
53270
+ artifact: input.artifact,
53271
+ productionVerdict,
53272
+ excludeProvider: ORCHESTRATOR_PROVIDER,
53273
+ pickTimeoutMs: PICK_TIMEOUT_MS,
53274
+ dispatchTimeoutMs: DISPATCH_TIMEOUT_MS,
53275
+ correlationId: input.correlationId
53276
+ },
53277
+ deps,
53278
+ logger
53279
+ );
53280
+ } catch {
53281
+ }
53282
+ return true;
53283
+ }
53284
+
53285
+ // src/consensus/multi-llm-activate.ts
53286
+ var MULTI_LLM_ENV_FLAG = "MRRLIN_CONSENSUS_MULTI_LLM";
53287
+ var ORCHESTRATOR_PROVIDER2 = "openai";
53288
+ var PICK_TIMEOUT_MS2 = 15e3;
53289
+ var DISPATCH_TIMEOUT_MS2 = 6e4;
53290
+ function multiLlmActive(env = process.env) {
53291
+ if (env["NODE_ENV"] === "production") return false;
53292
+ const flag = env[MULTI_LLM_ENV_FLAG];
53293
+ if (flag === "0" || flag === "false" || flag === "off") return false;
53294
+ return Boolean(flag) || env["MRRLIN_STAGING"] === "1";
53295
+ }
53296
+ async function resolveActiveRunHead(input, deps) {
53297
+ if (!multiLlmActive(input.env ?? process.env)) return null;
53298
+ try {
53299
+ const heads = input.heads ?? [...resolveHeads(input.domain), ...input.extraHeads ?? []];
53300
+ if (heads.length === 0) return null;
53301
+ const personaInstructions = {};
53302
+ for (const name of heads) {
53303
+ try {
53304
+ personaInstructions[name] = loadPersona(name);
53305
+ } catch {
53306
+ personaInstructions[name] = "";
53307
+ }
53308
+ }
53309
+ const built = await buildMultiHeadRunner(
53310
+ {
53311
+ personas: heads,
53312
+ personaInstructions,
53313
+ excludeProvider: ORCHESTRATOR_PROVIDER2,
53314
+ tierPrefer: "strong",
53315
+ pickTimeoutMs: PICK_TIMEOUT_MS2,
53316
+ dispatchTimeoutMs: DISPATCH_TIMEOUT_MS2
53317
+ },
53318
+ deps
53319
+ );
53320
+ if (!built.ok) return null;
53321
+ return built.runner.runHead;
53322
+ } catch {
53323
+ return null;
53324
+ }
53325
+ }
53326
+
52513
53327
  // src/async-tools/consensus.ts
52514
53328
  var import_node_crypto8 = require("node:crypto");
52515
53329
  function buildGateQuestionOptions(category) {
@@ -52573,13 +53387,37 @@ async function run(ctx, input) {
52573
53387
  codexExecutable: ctx.codexExecutable,
52574
53388
  extraHeadCount: input.extraHeads?.length ?? 0
52575
53389
  });
53390
+ const activeRunHead = await resolveActiveRunHead({
53391
+ heads: [...allReviewHeads(), ...input.extraHeads ?? []]
53392
+ });
53393
+ if (activeRunHead) deps.runHead = activeRunHead;
52576
53394
  const result = await runSpecGate(
52577
53395
  { projectSlug: input.projectSlug, specPageId: input.pageId },
52578
53396
  deps,
52579
53397
  input.extraHeads && input.extraHeads.length > 0 ? { extraHeads: input.extraHeads } : void 0
52580
53398
  );
53399
+ if (process.env[SHADOW_ENV_FLAG]) {
53400
+ try {
53401
+ const specPage = await ctx.client.getWikiPage(input.projectSlug, input.pageId);
53402
+ if (specPage) {
53403
+ const shadowDomain = await resolveSpecDomain(ctx.client, input.projectSlug, {
53404
+ id: specPage.id,
53405
+ taskId: specPage.taskId ?? null
53406
+ });
53407
+ await maybeRunShadow({
53408
+ outcome: result.outcome,
53409
+ artifact: specPage.markdownBody,
53410
+ domain: shadowDomain,
53411
+ extraHeads: input.extraHeads,
53412
+ correlationId: `Specs/${input.pageId}`
53413
+ });
53414
+ }
53415
+ } catch {
53416
+ }
53417
+ }
52581
53418
  if (result.outcome === "CONSENSUS_BLOCKED") {
52582
53419
  const clarifications = result.clarifications ?? [];
53420
+ let filedQuestionCount = 0;
52583
53421
  if (clarifications.length > 0) {
52584
53422
  const page = await ctx.client.getWikiPage(input.projectSlug, input.pageId);
52585
53423
  const taskId = page?.taskId ?? null;
@@ -52604,6 +53442,7 @@ async function run(ctx, input) {
52604
53442
  } catch {
52605
53443
  }
52606
53444
  }
53445
+ filedQuestionCount = clarifications.length;
52607
53446
  } else if (planId) {
52608
53447
  for (const clarification of clarifications) {
52609
53448
  const scopeId = planId;
@@ -52620,13 +53459,18 @@ async function run(ctx, input) {
52620
53459
  } catch {
52621
53460
  }
52622
53461
  }
53462
+ filedQuestionCount = clarifications.length;
52623
53463
  }
52624
53464
  }
52625
- return {
52626
- kind: "failed",
52627
- failureReason: "consensus_blocked",
52628
- error: clarifications.length > 0 ? `Consensus blocked on ${clarifications.length} clarification(s); filed as operator question(s).` : "Consensus blocked: reviewers did not converge within budget."
52629
- };
53465
+ let error51;
53466
+ if (filedQuestionCount > 0) {
53467
+ error51 = `Consensus blocked on ${filedQuestionCount} clarification(s); filed as operator question(s).`;
53468
+ } else if (clarifications.length > 0) {
53469
+ error51 = `Consensus blocked on ${clarifications.length} clarification(s), but the spec page is not linked to a task or plan, so none could be filed as questions.`;
53470
+ } else {
53471
+ error51 = "Consensus blocked: reviewers did not converge within budget.";
53472
+ }
53473
+ return { kind: "failed", failureReason: "consensus_blocked", error: error51, filedQuestionCount };
52630
53474
  }
52631
53475
  switch (result.outcome) {
52632
53476
  case "CONVERGED":
@@ -52662,6 +53506,14 @@ function onComplete2(outcome, input) {
52662
53506
  body: `Consensus CONVERGED for Specs/${input.pageId}; spec_ready set. Ready to create an execution run.`
52663
53507
  };
52664
53508
  }
53509
+ if (outcome.kind === "failed" && (outcome.filedQuestionCount ?? 0) > 0) {
53510
+ const n = outcome.filedQuestionCount ?? 0;
53511
+ return {
53512
+ kind: "info",
53513
+ suppressInbox: true,
53514
+ body: `Consensus blocked on Specs/${input.pageId}; filed ${n} clarifying question${n === 1 ? "" : "s"} \u2014 answer to unblock the run.`
53515
+ };
53516
+ }
52665
53517
  return {
52666
53518
  kind: "handoff",
52667
53519
  body: `Consensus could not complete for Specs/${input.pageId}: ${outcome.error} Needs operator attention.`
@@ -54162,7 +55014,24 @@ function createMrrlinTools(options) {
54162
55014
  codexExecutable: process.env.MRRLIN_DIRECTOR_BRIDGE_CODEX_BIN?.trim() || void 0,
54163
55015
  extraHeads
54164
55016
  });
54165
- return await runCodeGate({ projectSlug, baseRef }, deps);
55017
+ const activeCodeRunHead = await resolveActiveRunHead({
55018
+ heads: ["code-reviewer", ...extraHeads ?? []]
55019
+ });
55020
+ if (activeCodeRunHead) deps.runHead = activeCodeRunHead;
55021
+ const codeGateResult = await runCodeGate({ projectSlug, baseRef }, deps);
55022
+ if (process.env[SHADOW_ENV_FLAG]) {
55023
+ try {
55024
+ const diff = await readDiff({ cwd: process.cwd(), baseRef, run: defaultRunCmd });
55025
+ await maybeRunShadow({
55026
+ outcome: codeGateResult.outcome,
55027
+ artifact: diff,
55028
+ heads: ["code-reviewer", ...extraHeads ?? []],
55029
+ correlationId: `code:${baseRef}`
55030
+ });
55031
+ } catch {
55032
+ }
55033
+ }
55034
+ return codeGateResult;
54166
55035
  }
54167
55036
  ),
54168
55037
  [mcpToolNames.listExecutionRuns]: makeTool(
@@ -54413,7 +55282,7 @@ function createMrrlinTools(options) {
54413
55282
  }
54414
55283
  let remoteUrl;
54415
55284
  try {
54416
- remoteUrl = (0, import_node_child_process8.execFileSync)("git", ["-C", resolvedPath, "remote", "get-url", "origin"], {
55285
+ remoteUrl = (0, import_node_child_process11.execFileSync)("git", ["-C", resolvedPath, "remote", "get-url", "origin"], {
54417
55286
  encoding: "utf8",
54418
55287
  stdio: ["ignore", "pipe", "ignore"],
54419
55288
  timeout: 15e3,
@@ -54765,7 +55634,7 @@ async function pathExists3(target) {
54765
55634
  return false;
54766
55635
  }
54767
55636
  }
54768
- var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.mrrlin(?:-browser)?(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
55637
+ var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.(?:mrrlin(?:-browser)?|external-agents)(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
54769
55638
  async function uninstallCodex(options = {}) {
54770
55639
  const codexHome = resolveCodexHome2(options);
54771
55640
  const configPath = import_node_path18.default.join(codexHome, "config.toml");
@@ -54787,7 +55656,7 @@ async function uninstallCodex(options = {}) {
54787
55656
  };
54788
55657
  throw Object.assign(new Error(err.detail), err);
54789
55658
  }
54790
- if (parsed?.mcp_servers?.["mrrlin"] === void 0 && parsed?.mcp_servers?.["mrrlin-browser"] === void 0) {
55659
+ if (parsed?.mcp_servers?.["mrrlin"] === void 0 && parsed?.mcp_servers?.["mrrlin-browser"] === void 0 && parsed?.mcp_servers?.["external-agents"] === void 0) {
54791
55660
  return { action: "noop", configPath: realPath, prompts: await removePrompts() };
54792
55661
  }
54793
55662
  const stripped = existing.replace(MRRLIN_BLOCK_RE, (match) => match.startsWith("\n") ? "\n" : "").replace(/\n{3,}/g, "\n\n").replace(/^\n+/, "");
@@ -54796,10 +55665,10 @@ async function uninstallCodex(options = {}) {
54796
55665
  }
54797
55666
  async function uninstallPrompts(codexHome, names) {
54798
55667
  if (names.length === 0) return [];
54799
- const promptsDir2 = import_node_path18.default.join(codexHome, "prompts");
55668
+ const promptsDir = import_node_path18.default.join(codexHome, "prompts");
54800
55669
  const out = [];
54801
55670
  for (const name of names) {
54802
- const promptPath = import_node_path18.default.join(promptsDir2, `${name}.md`);
55671
+ const promptPath = import_node_path18.default.join(promptsDir, `${name}.md`);
54803
55672
  try {
54804
55673
  await import_promises4.default.unlink(promptPath);
54805
55674
  out.push({ name, action: "removed", promptPath });
@@ -54815,28 +55684,15 @@ async function uninstallPrompts(codexHome, names) {
54815
55684
  return out;
54816
55685
  }
54817
55686
 
54818
- // src/report-issue-prompt.ts
54819
- var import_node_fs13 = __toESM(require("node:fs"), 1);
54820
- var import_node_path19 = __toESM(require("node:path"), 1);
54821
- var import_node_url3 = require("node:url");
54822
- var import_meta3 = {};
54823
- function promptsDir() {
54824
- if (typeof __dirname !== "undefined") return import_node_path19.default.join(__dirname, "prompts");
54825
- return import_node_path19.default.join(import_node_path19.default.dirname((0, import_node_url3.fileURLToPath)(import_meta3.url)), "prompts");
54826
- }
54827
- function readReportIssuePrompt() {
54828
- return import_node_fs13.default.readFileSync(import_node_path19.default.join(promptsDir(), "report-issue.md"), "utf8");
54829
- }
54830
-
54831
55687
  // src/bin.ts
54832
55688
  function pm2Runner(args) {
54833
- const r = (0, import_node_child_process9.spawnSync)("pm2", args, { encoding: "utf8" });
55689
+ const r = (0, import_node_child_process12.spawnSync)("pm2", args, { encoding: "utf8" });
54834
55690
  process.stderr.write(r.stdout ?? "");
54835
55691
  process.stderr.write(r.stderr ?? "");
54836
55692
  return { code: r.status ?? 1, stdout: r.stdout ?? "" };
54837
55693
  }
54838
55694
  function whichBin(bin) {
54839
- const r = (0, import_node_child_process9.spawnSync)("which", [bin], { encoding: "utf8" });
55695
+ const r = (0, import_node_child_process12.spawnSync)("which", [bin], { encoding: "utf8" });
54840
55696
  const out = (r.stdout ?? "").trim();
54841
55697
  return r.status === 0 && out ? out.split("\n")[0] ?? null : null;
54842
55698
  }
@@ -54863,9 +55719,7 @@ Usage:
54863
55719
 
54864
55720
  mrrlin-mcp install-codex Idempotently register Mrrlin in
54865
55721
  [--force] ~/.codex/config.toml (or CODEX_HOME). Adds an
54866
- [--force-prompts] [mcp_servers.mrrlin] block AND drops the bundled
54867
- slash-command prompts (currently: /report-issue)
54868
- into <CODEX_HOME>/prompts/. Development
55722
+ [mcp_servers.mrrlin] block. Development
54869
55723
  checkouts register the local dist/bin.cjs;
54870
55724
  published npm installs register
54871
55725
  \`mrrlin-mcp serve\`.
@@ -54890,11 +55744,6 @@ Usage:
54890
55744
  To CHANGE or REMOVE the baked target, re-run with
54891
55745
  --force (or the new env vars).
54892
55746
  --force replaces an existing conflicting block.
54893
- --force-prompts overwrites prompt files that
54894
- already exist with different content. WITHOUT it,
54895
- local edits to <CODEX_HOME>/prompts/<name>.md are
54896
- preserved across patch releases (reported as
54897
- 'skipped-modified').
54898
55747
 
54899
55748
  mrrlin-mcp director-bridge Run a local ws://127.0.0.1 (plain HTTP +
54900
55749
  WebSocket) bridge that lets the web Director
@@ -54990,19 +55839,6 @@ Usage:
54990
55839
  support/debug packaging flow:
54991
55840
  printf %s "$HINT" | mrrlin-mcp redact
54992
55841
 
54993
- mrrlin-mcp report-issue Print the bundled compatibility prompt for the
54994
- legacy /report-issue slash command. Preferred
54995
- flows now live inside the Mrrlin UI:
54996
- - Director chat: /report-issue <what broke>
54997
- - Header menu: Report issue
54998
- Those flows package bridge logs, transcript
54999
- context, screenshots, and create a GitHub issue
55000
- in fnnzzz/mrrlin via local gh. This command is
55001
- mainly useful for inspecting or re-installing
55002
- the shipped prompt:
55003
- codex "$(mrrlin-mcp report-issue)"
55004
- mrrlin-mcp report-issue > ~/.codex/prompts/report-issue.md
55005
-
55006
55842
  mrrlin-mcp --help Show this help.
55007
55843
 
55008
55844
  Operator notes:
@@ -55032,13 +55868,12 @@ async function main() {
55032
55868
  }
55033
55869
  case "browser-serve": {
55034
55870
  const { command: command2, args, env } = browserServeArgs();
55035
- const r = (0, import_node_child_process9.spawnSync)(command2, args, { stdio: "inherit", env: { ...process.env, ...env } });
55871
+ const r = (0, import_node_child_process12.spawnSync)(command2, args, { stdio: "inherit", env: { ...process.env, ...env } });
55036
55872
  process.exitCode = r.status ?? 1;
55037
55873
  return;
55038
55874
  }
55039
55875
  case "install-codex": {
55040
55876
  const force = rest.includes("--force");
55041
- const forcePrompts = rest.includes("--force-prompts");
55042
55877
  const binPath = resolveSelfBinPath();
55043
55878
  try {
55044
55879
  const b = await installBrowser();
@@ -55055,9 +55890,7 @@ async function main() {
55055
55890
  const result = await installCodex({
55056
55891
  binPath,
55057
55892
  force,
55058
- forcePrompts,
55059
- serveEnv,
55060
- prompts: [{ name: "report-issue", content: readReportIssuePrompt() }]
55893
+ serveEnv
55061
55894
  });
55062
55895
  process.stderr.write(`[mrrlin-mcp install-codex] ${result.action} ${result.configPath}
55063
55896
  `);
@@ -55075,6 +55908,11 @@ async function main() {
55075
55908
  );
55076
55909
  }
55077
55910
  }
55911
+ try {
55912
+ const codexHome = process.env.CODEX_HOME ?? import_node_path20.default.join(process.env.HOME ?? (0, import_node_os11.homedir)(), ".codex");
55913
+ (0, import_node_fs13.rmSync)(import_node_path20.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
55914
+ } catch {
55915
+ }
55078
55916
  return;
55079
55917
  }
55080
55918
  case "redact": {
@@ -55086,10 +55924,6 @@ async function main() {
55086
55924
  process.stdout.write(redact(input));
55087
55925
  return;
55088
55926
  }
55089
- case "report-issue": {
55090
- process.stdout.write(readReportIssuePrompt());
55091
- return;
55092
- }
55093
55927
  case "director-bridge": {
55094
55928
  await startDirectorBridge();
55095
55929
  return;
@@ -55106,8 +55940,8 @@ async function main() {
55106
55940
  env: process.env,
55107
55941
  cwd: process.cwd(),
55108
55942
  writeFile: (p, c) => {
55109
- (0, import_node_fs14.mkdirSync)(import_node_path21.default.dirname(p), { recursive: true, mode: 448 });
55110
- (0, import_node_fs14.writeFileSync)(p, c, { mode: 384 });
55943
+ (0, import_node_fs13.mkdirSync)(import_node_path20.default.dirname(p), { recursive: true, mode: 448 });
55944
+ (0, import_node_fs13.writeFileSync)(p, c, { mode: 384 });
55111
55945
  },
55112
55946
  runPm2: pm2Runner,
55113
55947
  which: whichBin,
@@ -55124,14 +55958,14 @@ async function main() {
55124
55958
  runPm2: (a) => ({ code: pm2Runner(a).code }),
55125
55959
  removeFile: (p) => {
55126
55960
  try {
55127
- (0, import_node_fs14.rmSync)(p, { force: true });
55961
+ (0, import_node_fs13.rmSync)(p, { force: true });
55128
55962
  } catch {
55129
55963
  }
55130
55964
  },
55131
55965
  purgeSecret: purge,
55132
55966
  secretPath: agentCredentialPath(),
55133
55967
  tokenPath: operatorTokenPath(),
55134
- ecoPath: import_node_path21.default.join(process.env.HOME ?? (0, import_node_os11.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
55968
+ ecoPath: import_node_path20.default.join(process.env.HOME ?? (0, import_node_os11.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
55135
55969
  log: (m) => process.stderr.write(`[mrrlin-mcp uninstall-service] ${m}
55136
55970
  `)
55137
55971
  });
@@ -55145,14 +55979,14 @@ async function main() {
55145
55979
  runPm2: (a) => ({ code: pm2Runner(a).code }),
55146
55980
  removeFile: (p) => {
55147
55981
  try {
55148
- (0, import_node_fs14.rmSync)(p, { force: true });
55982
+ (0, import_node_fs13.rmSync)(p, { force: true });
55149
55983
  } catch {
55150
55984
  }
55151
55985
  },
55152
55986
  purgeSecret: true,
55153
55987
  secretPath: agentCredentialPath(),
55154
55988
  tokenPath: operatorTokenPath(),
55155
- ecoPath: import_node_path21.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
55989
+ ecoPath: import_node_path20.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
55156
55990
  log
55157
55991
  });
55158
55992
  let codexOk = true;
@@ -55172,7 +56006,7 @@ async function main() {
55172
56006
  log(`codex config NOT modified: ${error51 instanceof Error ? error51.message : String(error51)}`);
55173
56007
  }
55174
56008
  try {
55175
- (0, import_node_fs14.rmSync)(import_node_path21.default.join(home, ".mrrlin"), { recursive: true, force: true });
56009
+ (0, import_node_fs13.rmSync)(import_node_path20.default.join(home, ".mrrlin"), { recursive: true, force: true });
55176
56010
  } catch {
55177
56011
  }
55178
56012
  log("removed ~/.mrrlin");
@@ -55213,7 +56047,7 @@ ${HELP_TEXT}`);
55213
56047
  }
55214
56048
  }
55215
56049
  function resolveSelfBinPath() {
55216
- return import_node_path20.default.resolve(process.argv[1] ?? process.execPath);
56050
+ return import_node_path19.default.resolve(process.argv[1] ?? process.execPath);
55217
56051
  }
55218
56052
  main().catch((error51) => {
55219
56053
  process.stderr.write(`mrrlin-mcp fatal error: ${error51 instanceof Error ? error51.message : String(error51)}