@mrrlin-dev/mcp 0.4.59 → 0.4.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bin.cjs +558 -383
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -7729,14 +7729,14 @@ var require_polyfills = __commonJS({
7729
7729
  fs11.fstatSync = statFixSync(fs11.fstatSync);
7730
7730
  fs11.lstatSync = statFixSync(fs11.lstatSync);
7731
7731
  if (fs11.chmod && !fs11.lchmod) {
7732
- fs11.lchmod = function(path24, mode, cb) {
7732
+ fs11.lchmod = function(path25, mode, cb) {
7733
7733
  if (cb) process.nextTick(cb);
7734
7734
  };
7735
7735
  fs11.lchmodSync = function() {
7736
7736
  };
7737
7737
  }
7738
7738
  if (fs11.chown && !fs11.lchown) {
7739
- fs11.lchown = function(path24, uid, gid, cb) {
7739
+ fs11.lchown = function(path25, uid, gid, cb) {
7740
7740
  if (cb) process.nextTick(cb);
7741
7741
  };
7742
7742
  fs11.lchownSync = function() {
@@ -7803,9 +7803,9 @@ var require_polyfills = __commonJS({
7803
7803
  };
7804
7804
  }(fs11.readSync);
7805
7805
  function patchLchmod(fs12) {
7806
- fs12.lchmod = function(path24, mode, callback) {
7806
+ fs12.lchmod = function(path25, mode, callback) {
7807
7807
  fs12.open(
7808
- path24,
7808
+ path25,
7809
7809
  constants2.O_WRONLY | constants2.O_SYMLINK,
7810
7810
  mode,
7811
7811
  function(err, fd) {
@@ -7821,8 +7821,8 @@ var require_polyfills = __commonJS({
7821
7821
  }
7822
7822
  );
7823
7823
  };
7824
- fs12.lchmodSync = function(path24, mode) {
7825
- var fd = fs12.openSync(path24, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
7824
+ fs12.lchmodSync = function(path25, mode) {
7825
+ var fd = fs12.openSync(path25, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
7826
7826
  var threw = true;
7827
7827
  var ret;
7828
7828
  try {
@@ -7843,8 +7843,8 @@ var require_polyfills = __commonJS({
7843
7843
  }
7844
7844
  function patchLutimes(fs12) {
7845
7845
  if (constants2.hasOwnProperty("O_SYMLINK") && fs12.futimes) {
7846
- fs12.lutimes = function(path24, at, mt, cb) {
7847
- fs12.open(path24, constants2.O_SYMLINK, function(er, fd) {
7846
+ fs12.lutimes = function(path25, at, mt, cb) {
7847
+ fs12.open(path25, constants2.O_SYMLINK, function(er, fd) {
7848
7848
  if (er) {
7849
7849
  if (cb) cb(er);
7850
7850
  return;
@@ -7856,8 +7856,8 @@ var require_polyfills = __commonJS({
7856
7856
  });
7857
7857
  });
7858
7858
  };
7859
- fs12.lutimesSync = function(path24, at, mt) {
7860
- var fd = fs12.openSync(path24, constants2.O_SYMLINK);
7859
+ fs12.lutimesSync = function(path25, at, mt) {
7860
+ var fd = fs12.openSync(path25, constants2.O_SYMLINK);
7861
7861
  var ret;
7862
7862
  var threw = true;
7863
7863
  try {
@@ -7975,11 +7975,11 @@ var require_legacy_streams = __commonJS({
7975
7975
  ReadStream,
7976
7976
  WriteStream
7977
7977
  };
7978
- function ReadStream(path24, options) {
7979
- if (!(this instanceof ReadStream)) return new ReadStream(path24, options);
7978
+ function ReadStream(path25, options) {
7979
+ if (!(this instanceof ReadStream)) return new ReadStream(path25, options);
7980
7980
  Stream.call(this);
7981
7981
  var self = this;
7982
- this.path = path24;
7982
+ this.path = path25;
7983
7983
  this.fd = null;
7984
7984
  this.readable = true;
7985
7985
  this.paused = false;
@@ -8024,10 +8024,10 @@ var require_legacy_streams = __commonJS({
8024
8024
  self._read();
8025
8025
  });
8026
8026
  }
8027
- function WriteStream(path24, options) {
8028
- if (!(this instanceof WriteStream)) return new WriteStream(path24, options);
8027
+ function WriteStream(path25, options) {
8028
+ if (!(this instanceof WriteStream)) return new WriteStream(path25, options);
8029
8029
  Stream.call(this);
8030
- this.path = path24;
8030
+ this.path = path25;
8031
8031
  this.fd = null;
8032
8032
  this.writable = true;
8033
8033
  this.flags = "w";
@@ -8170,14 +8170,14 @@ var require_graceful_fs = __commonJS({
8170
8170
  fs12.createWriteStream = createWriteStream;
8171
8171
  var fs$readFile = fs12.readFile;
8172
8172
  fs12.readFile = readFile9;
8173
- function readFile9(path24, options, cb) {
8173
+ function readFile9(path25, options, cb) {
8174
8174
  if (typeof options === "function")
8175
8175
  cb = options, options = null;
8176
- return go$readFile(path24, options, cb);
8177
- function go$readFile(path25, options2, cb2, startTime) {
8178
- return fs$readFile(path25, options2, function(err) {
8176
+ return go$readFile(path25, options, cb);
8177
+ function go$readFile(path26, options2, cb2, startTime) {
8178
+ return fs$readFile(path26, options2, function(err) {
8179
8179
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
8180
- enqueue([go$readFile, [path25, options2, cb2], err, startTime || Date.now(), Date.now()]);
8180
+ enqueue([go$readFile, [path26, options2, cb2], err, startTime || Date.now(), Date.now()]);
8181
8181
  else {
8182
8182
  if (typeof cb2 === "function")
8183
8183
  cb2.apply(this, arguments);
@@ -8187,14 +8187,14 @@ var require_graceful_fs = __commonJS({
8187
8187
  }
8188
8188
  var fs$writeFile = fs12.writeFile;
8189
8189
  fs12.writeFile = writeFile5;
8190
- function writeFile5(path24, data, options, cb) {
8190
+ function writeFile5(path25, data, options, cb) {
8191
8191
  if (typeof options === "function")
8192
8192
  cb = options, options = null;
8193
- return go$writeFile(path24, data, options, cb);
8194
- function go$writeFile(path25, data2, options2, cb2, startTime) {
8195
- return fs$writeFile(path25, data2, options2, function(err) {
8193
+ return go$writeFile(path25, data, options, cb);
8194
+ function go$writeFile(path26, data2, options2, cb2, startTime) {
8195
+ return fs$writeFile(path26, data2, options2, function(err) {
8196
8196
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
8197
- enqueue([go$writeFile, [path25, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
8197
+ enqueue([go$writeFile, [path26, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
8198
8198
  else {
8199
8199
  if (typeof cb2 === "function")
8200
8200
  cb2.apply(this, arguments);
@@ -8205,14 +8205,14 @@ var require_graceful_fs = __commonJS({
8205
8205
  var fs$appendFile = fs12.appendFile;
8206
8206
  if (fs$appendFile)
8207
8207
  fs12.appendFile = appendFile2;
8208
- function appendFile2(path24, data, options, cb) {
8208
+ function appendFile2(path25, data, options, cb) {
8209
8209
  if (typeof options === "function")
8210
8210
  cb = options, options = null;
8211
- return go$appendFile(path24, data, options, cb);
8212
- function go$appendFile(path25, data2, options2, cb2, startTime) {
8213
- return fs$appendFile(path25, data2, options2, function(err) {
8211
+ return go$appendFile(path25, data, options, cb);
8212
+ function go$appendFile(path26, data2, options2, cb2, startTime) {
8213
+ return fs$appendFile(path26, data2, options2, function(err) {
8214
8214
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
8215
- enqueue([go$appendFile, [path25, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
8215
+ enqueue([go$appendFile, [path26, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
8216
8216
  else {
8217
8217
  if (typeof cb2 === "function")
8218
8218
  cb2.apply(this, arguments);
@@ -8243,31 +8243,31 @@ var require_graceful_fs = __commonJS({
8243
8243
  var fs$readdir = fs12.readdir;
8244
8244
  fs12.readdir = readdir5;
8245
8245
  var noReaddirOptionVersions = /^v[0-5]\./;
8246
- function readdir5(path24, options, cb) {
8246
+ function readdir5(path25, 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(path25, options2, cb2, startTime) {
8250
- return fs$readdir(path25, fs$readdirCallback(
8251
- path25,
8249
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path26, options2, cb2, startTime) {
8250
+ return fs$readdir(path26, fs$readdirCallback(
8251
+ path26,
8252
8252
  options2,
8253
8253
  cb2,
8254
8254
  startTime
8255
8255
  ));
8256
- } : function go$readdir2(path25, options2, cb2, startTime) {
8257
- return fs$readdir(path25, options2, fs$readdirCallback(
8258
- path25,
8256
+ } : function go$readdir2(path26, options2, cb2, startTime) {
8257
+ return fs$readdir(path26, options2, fs$readdirCallback(
8258
+ path26,
8259
8259
  options2,
8260
8260
  cb2,
8261
8261
  startTime
8262
8262
  ));
8263
8263
  };
8264
- return go$readdir(path24, options, cb);
8265
- function fs$readdirCallback(path25, options2, cb2, startTime) {
8264
+ return go$readdir(path25, options, cb);
8265
+ function fs$readdirCallback(path26, 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
- [path25, options2, cb2],
8270
+ [path26, options2, cb2],
8271
8271
  err,
8272
8272
  startTime || Date.now(),
8273
8273
  Date.now()
@@ -8338,7 +8338,7 @@ var require_graceful_fs = __commonJS({
8338
8338
  enumerable: true,
8339
8339
  configurable: true
8340
8340
  });
8341
- function ReadStream(path24, options) {
8341
+ function ReadStream(path25, 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(path24, options) {
8361
+ function WriteStream(path25, 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 createReadStream2(path24, options) {
8380
- return new fs12.ReadStream(path24, options);
8379
+ function createReadStream2(path25, options) {
8380
+ return new fs12.ReadStream(path25, options);
8381
8381
  }
8382
- function createWriteStream(path24, options) {
8383
- return new fs12.WriteStream(path24, options);
8382
+ function createWriteStream(path25, options) {
8383
+ return new fs12.WriteStream(path25, options);
8384
8384
  }
8385
8385
  var fs$open = fs12.open;
8386
8386
  fs12.open = open;
8387
- function open(path24, flags, mode, cb) {
8387
+ function open(path25, flags, mode, cb) {
8388
8388
  if (typeof mode === "function")
8389
8389
  cb = mode, mode = null;
8390
- return go$open(path24, flags, mode, cb);
8391
- function go$open(path25, flags2, mode2, cb2, startTime) {
8392
- return fs$open(path25, flags2, mode2, function(err, fd) {
8390
+ return go$open(path25, flags, mode, cb);
8391
+ function go$open(path26, flags2, mode2, cb2, startTime) {
8392
+ return fs$open(path26, flags2, mode2, function(err, fd) {
8393
8393
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
8394
- enqueue([go$open, [path25, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
8394
+ enqueue([go$open, [path26, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
8395
8395
  else {
8396
8396
  if (typeof cb2 === "function")
8397
8397
  cb2.apply(this, arguments);
@@ -8920,7 +8920,7 @@ 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 path24 = require("path");
8923
+ var path25 = require("path");
8924
8924
  var fs11 = require_graceful_fs();
8925
8925
  var retry = require_retry2();
8926
8926
  var onExit = require_signal_exit();
@@ -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, path24.resolve(file2));
8934
+ return callback(null, path25.resolve(file2));
8935
8935
  }
8936
8936
  options.fs.realpath(file2, callback);
8937
8937
  }
@@ -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 path24 = dijkstra.find_path(graph.map, "start", "end");
10798
+ const path25 = dijkstra.find_path(graph.map, "start", "end");
10799
10799
  const optimizedSegs = [];
10800
- for (let i = 1; i < path24.length - 1; i++) {
10801
- optimizedSegs.push(graph.table[path24[i]].node);
10800
+ for (let i = 1; i < path25.length - 1; i++) {
10801
+ optimizedSegs.push(graph.table[path25[i]].node);
10802
10802
  }
10803
10803
  return exports2.fromArray(mergeSegments(optimizedSegs));
10804
10804
  };
@@ -13275,7 +13275,7 @@ var require_png2 = __commonJS({
13275
13275
  });
13276
13276
  png.pack();
13277
13277
  };
13278
- exports2.renderToFile = function renderToFile(path24, qrData, options, cb) {
13278
+ exports2.renderToFile = function renderToFile(path25, 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 = fs11.createWriteStream(path24);
13289
+ const stream = fs11.createWriteStream(path25);
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(path24, qrData, options, cb) {
13351
+ exports2.renderToFile = function renderToFile(path25, qrData, options, cb) {
13352
13352
  if (typeof cb === "undefined") {
13353
13353
  cb = options;
13354
13354
  options = void 0;
13355
13355
  }
13356
13356
  const fs11 = require("fs");
13357
13357
  const utf8 = exports2.render(qrData, options);
13358
- fs11.writeFile(path24, utf8, cb);
13358
+ fs11.writeFile(path25, 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 path24 = "";
13479
+ let path25 = "";
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
- path24 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
13490
+ path25 += 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
- path24 += svgCmd("h", lineLength);
13495
+ path25 += svgCmd("h", lineLength);
13496
13496
  lineLength = 0;
13497
13497
  }
13498
13498
  } else {
13499
13499
  moveBy++;
13500
13500
  }
13501
13501
  }
13502
- return path24;
13502
+ return path25;
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 path24 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
13510
+ const path25 = "<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 + path24 + "</svg>\n";
13513
+ const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path25 + "</svg>\n";
13514
13514
  if (typeof cb === "function") {
13515
13515
  cb(null, svgTag);
13516
13516
  }
@@ -13524,7 +13524,7 @@ 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(path24, qrData, options, cb) {
13527
+ exports2.renderToFile = function renderToFile(path25, qrData, options, cb) {
13528
13528
  if (typeof cb === "undefined") {
13529
13529
  cb = options;
13530
13530
  options = void 0;
@@ -13532,7 +13532,7 @@ var require_svg = __commonJS({
13532
13532
  const fs11 = 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
- fs11.writeFile(path24, xmlStr, cb);
13535
+ fs11.writeFile(path25, 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(path24) {
13694
- return path24.slice((path24.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
13693
+ function getTypeFromFilename(path25) {
13694
+ return path25.slice((path25.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(path24, text, opts, cb) {
13759
- if (typeof path24 !== "string" || !(typeof text === "string" || typeof text === "object")) {
13758
+ exports2.toFile = function toFile(path25, text, opts, cb) {
13759
+ if (typeof path25 !== "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(path24);
13766
+ const type = params.opts.type || getTypeFromFilename(path25);
13767
13767
  const renderer = getRendererFromType(type);
13768
- const renderToFile = renderer.renderToFile.bind(null, path24);
13768
+ const renderToFile = renderer.renderToFile.bind(null, path25);
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(path24) {
16987
- let input = path24;
16986
+ function removeDotSegments(path25) {
16987
+ let input = path25;
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 [path24, query] = wsComponent.resourceName.split("?");
17240
- wsComponent.path = path24 && path24 !== "/" ? path24 : void 0;
17239
+ const [path25, query] = wsComponent.resourceName.split("?");
17240
+ wsComponent.path = path25 && path25 !== "/" ? path25 : void 0;
17241
17241
  wsComponent.query = query;
17242
17242
  wsComponent.resourceName = void 0;
17243
17243
  }
@@ -20644,11 +20644,11 @@ var require_dist = __commonJS({
20644
20644
  });
20645
20645
 
20646
20646
  // src/bin.ts
20647
- var import_node_path36 = __toESM(require("node:path"), 1);
20648
- var import_node_child_process18 = require("node:child_process");
20649
- var import_node_fs23 = require("node:fs");
20650
- var import_node_os18 = require("node:os");
20651
20647
  var import_node_path37 = __toESM(require("node:path"), 1);
20648
+ var import_node_child_process18 = require("node:child_process");
20649
+ var import_node_fs24 = require("node:fs");
20650
+ var import_node_os19 = require("node:os");
20651
+ var import_node_path38 = __toESM(require("node:path"), 1);
20652
20652
 
20653
20653
  // src/install-codex.ts
20654
20654
  var import_promises = __toESM(require("node:fs/promises"), 1);
@@ -20669,9 +20669,7 @@ var RETIRED_API_BASE_URLS = {
20669
20669
  "mrrlin-api-fnnzzz-fnnzzzs-projects.vercel.app": STAGING_API_BASE_URL,
20670
20670
  // Retired 2026-08-14 when staging decoupled onto the stable custom domain api-staging.mrrlin.com.
20671
20671
  // A persisted operator configuration may still pin the mrrlin3 Vercel alias; retarget it in one hop.
20672
- "mrrlin-api-mrrlin3.vercel.app": STAGING_API_BASE_URL,
20673
- // Retired 2026-09-07 when production moved from the transitional api-prod host to api.mrrlin.com.
20674
- "api-prod.mrrlin.com": PRODUCTION_API_BASE_URL
20672
+ "mrrlin-api-mrrlin3.vercel.app": STAGING_API_BASE_URL
20675
20673
  };
20676
20674
  function isSameApiHost(a, b) {
20677
20675
  const origin = (value) => {
@@ -21636,10 +21634,10 @@ async function verifyProviderReadiness(provider, run3, opts = {}) {
21636
21634
  }
21637
21635
 
21638
21636
  // src/director-bridge.ts
21639
- var import_node_fs21 = __toESM(require("node:fs"), 1);
21637
+ var import_node_fs22 = __toESM(require("node:fs"), 1);
21640
21638
  var import_node_http = __toESM(require("node:http"), 1);
21641
- var import_node_os14 = __toESM(require("node:os"), 1);
21642
- var import_node_path29 = __toESM(require("node:path"), 1);
21639
+ var import_node_os15 = __toESM(require("node:os"), 1);
21640
+ var import_node_path30 = __toESM(require("node:path"), 1);
21643
21641
  var import_node_child_process15 = require("node:child_process");
21644
21642
  var import_node_crypto11 = __toESM(require("node:crypto"), 1);
21645
21643
 
@@ -23201,10 +23199,10 @@ function mergeDefs(...defs) {
23201
23199
  function cloneDef(schema) {
23202
23200
  return mergeDefs(schema._zod.def);
23203
23201
  }
23204
- function getElementAtPath(obj, path24) {
23205
- if (!path24)
23202
+ function getElementAtPath(obj, path25) {
23203
+ if (!path25)
23206
23204
  return obj;
23207
- return path24.reduce((acc, key) => acc?.[key], obj);
23205
+ return path25.reduce((acc, key) => acc?.[key], obj);
23208
23206
  }
23209
23207
  function promiseAllObject(promisesObj) {
23210
23208
  const keys = Object.keys(promisesObj);
@@ -23613,11 +23611,11 @@ function explicitlyAborted(x, startIndex = 0) {
23613
23611
  }
23614
23612
  return false;
23615
23613
  }
23616
- function prefixIssues(path24, issues) {
23614
+ function prefixIssues(path25, issues) {
23617
23615
  return issues.map((iss) => {
23618
23616
  var _a3;
23619
23617
  (_a3 = iss).path ?? (_a3.path = []);
23620
- iss.path.unshift(path24);
23618
+ iss.path.unshift(path25);
23621
23619
  return iss;
23622
23620
  });
23623
23621
  }
@@ -23764,16 +23762,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
23764
23762
  }
23765
23763
  function formatError(error51, mapper = (issue2) => issue2.message) {
23766
23764
  const fieldErrors = { _errors: [] };
23767
- const processError = (error52, path24 = []) => {
23765
+ const processError = (error52, path25 = []) => {
23768
23766
  for (const issue2 of error52.issues) {
23769
23767
  if (issue2.code === "invalid_union" && issue2.errors.length) {
23770
- issue2.errors.map((issues) => processError({ issues }, [...path24, ...issue2.path]));
23768
+ issue2.errors.map((issues) => processError({ issues }, [...path25, ...issue2.path]));
23771
23769
  } else if (issue2.code === "invalid_key") {
23772
- processError({ issues: issue2.issues }, [...path24, ...issue2.path]);
23770
+ processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
23773
23771
  } else if (issue2.code === "invalid_element") {
23774
- processError({ issues: issue2.issues }, [...path24, ...issue2.path]);
23772
+ processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
23775
23773
  } else {
23776
- const fullpath = [...path24, ...issue2.path];
23774
+ const fullpath = [...path25, ...issue2.path];
23777
23775
  if (fullpath.length === 0) {
23778
23776
  fieldErrors._errors.push(mapper(issue2));
23779
23777
  } else {
@@ -23800,17 +23798,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
23800
23798
  }
23801
23799
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
23802
23800
  const result = { errors: [] };
23803
- const processError = (error52, path24 = []) => {
23801
+ const processError = (error52, path25 = []) => {
23804
23802
  var _a3, _b;
23805
23803
  for (const issue2 of error52.issues) {
23806
23804
  if (issue2.code === "invalid_union" && issue2.errors.length) {
23807
- issue2.errors.map((issues) => processError({ issues }, [...path24, ...issue2.path]));
23805
+ issue2.errors.map((issues) => processError({ issues }, [...path25, ...issue2.path]));
23808
23806
  } else if (issue2.code === "invalid_key") {
23809
- processError({ issues: issue2.issues }, [...path24, ...issue2.path]);
23807
+ processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
23810
23808
  } else if (issue2.code === "invalid_element") {
23811
- processError({ issues: issue2.issues }, [...path24, ...issue2.path]);
23809
+ processError({ issues: issue2.issues }, [...path25, ...issue2.path]);
23812
23810
  } else {
23813
- const fullpath = [...path24, ...issue2.path];
23811
+ const fullpath = [...path25, ...issue2.path];
23814
23812
  if (fullpath.length === 0) {
23815
23813
  result.errors.push(mapper(issue2));
23816
23814
  continue;
@@ -23842,8 +23840,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
23842
23840
  }
23843
23841
  function toDotPath(_path) {
23844
23842
  const segs = [];
23845
- const path24 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
23846
- for (const seg of path24) {
23843
+ const path25 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
23844
+ for (const seg of path25) {
23847
23845
  if (typeof seg === "number")
23848
23846
  segs.push(`[${seg}]`);
23849
23847
  else if (typeof seg === "symbol")
@@ -36535,13 +36533,13 @@ function resolveRef(ref, ctx) {
36535
36533
  if (!ref.startsWith("#")) {
36536
36534
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
36537
36535
  }
36538
- const path24 = ref.slice(1).split("/").filter(Boolean);
36539
- if (path24.length === 0) {
36536
+ const path25 = ref.slice(1).split("/").filter(Boolean);
36537
+ if (path25.length === 0) {
36540
36538
  return ctx.rootSchema;
36541
36539
  }
36542
36540
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
36543
- if (path24[0] === defsKey) {
36544
- const key = path24[1];
36541
+ if (path25[0] === defsKey) {
36542
+ const key = path25[1];
36545
36543
  if (!key || !ctx.defs[key]) {
36546
36544
  throw new Error(`Reference not found: ${ref}`);
36547
36545
  }
@@ -40901,18 +40899,18 @@ function createMrrlinClient(config2) {
40901
40899
  const customFetch = config2.fetch ?? globalThis.fetch;
40902
40900
  const baseUrl = config2.baseUrl.replace(/\/$/, "");
40903
40901
  const token = config2.token;
40904
- async function request(path24, init) {
40902
+ async function request(path25, init) {
40905
40903
  const method = init?.method ?? "GET";
40906
40904
  const headers = new Headers(init?.headers ?? {});
40907
40905
  if (token && !headers.has("authorization")) {
40908
40906
  headers.set("authorization", `Bearer ${token}`);
40909
40907
  }
40910
- const response = await customFetch(`${baseUrl}${path24}`, { ...init, headers });
40908
+ const response = await customFetch(`${baseUrl}${path25}`, { ...init, headers });
40911
40909
  if (!response.ok) {
40912
40910
  const body = await response.text();
40913
40911
  let code = `HTTP_${response.status}`;
40914
40912
  let violations = null;
40915
- let message = `Mrrlin API ${method} ${path24} failed: ${response.status}`;
40913
+ let message = `Mrrlin API ${method} ${path25} failed: ${response.status}`;
40916
40914
  try {
40917
40915
  const parsed = JSON.parse(body);
40918
40916
  const violationsParsed = apiViolationsErrorSchema.safeParse(parsed);
@@ -40932,7 +40930,7 @@ function createMrrlinClient(config2) {
40932
40930
  throw new MrrlinApiError({
40933
40931
  code,
40934
40932
  method,
40935
- path: path24,
40933
+ path: path25,
40936
40934
  responseBody: body,
40937
40935
  status: response.status,
40938
40936
  violations,
@@ -40941,18 +40939,18 @@ function createMrrlinClient(config2) {
40941
40939
  }
40942
40940
  return response.json();
40943
40941
  }
40944
- async function requestText(path24, init) {
40942
+ async function requestText(path25, init) {
40945
40943
  const method = init?.method ?? "GET";
40946
40944
  const headers = new Headers(init?.headers ?? {});
40947
40945
  if (token && !headers.has("authorization")) {
40948
40946
  headers.set("authorization", `Bearer ${token}`);
40949
40947
  }
40950
- const response = await customFetch(`${baseUrl}${path24}`, { ...init, headers });
40948
+ const response = await customFetch(`${baseUrl}${path25}`, { ...init, headers });
40951
40949
  if (!response.ok) {
40952
40950
  const body = await response.text();
40953
40951
  let code = `HTTP_${response.status}`;
40954
40952
  let violations = null;
40955
- let message = `Mrrlin API ${method} ${path24} failed: ${response.status}`;
40953
+ let message = `Mrrlin API ${method} ${path25} failed: ${response.status}`;
40956
40954
  try {
40957
40955
  const parsed = JSON.parse(body);
40958
40956
  const violationsParsed = apiViolationsErrorSchema.safeParse(parsed);
@@ -40972,7 +40970,7 @@ function createMrrlinClient(config2) {
40972
40970
  throw new MrrlinApiError({
40973
40971
  code,
40974
40972
  method,
40975
- path: path24,
40973
+ path: path25,
40976
40974
  responseBody: body,
40977
40975
  status: response.status,
40978
40976
  violations,
@@ -41237,16 +41235,16 @@ function createMrrlinClient(config2) {
41237
41235
  // rejected against the first, MrrlinTask[]-only overload) -- the `any` here is contained to
41238
41236
  // this one implementation signature; MrrlinClient's declared overloads keep callers precise.
41239
41237
  async listTasks(projectSlug, filters = {}, options) {
41240
- const path24 = buildTaskListPath(projectSlug, filters, options?.view);
41241
- const body = await request(path24);
41238
+ const path25 = buildTaskListPath(projectSlug, filters, options?.view);
41239
+ const body = await request(path25);
41242
41240
  if (options?.view === "summary") {
41243
41241
  return taskSummaryListResponseSchema.parse(body).data;
41244
41242
  }
41245
41243
  return taskListResponseSchema.parse(body).data;
41246
41244
  },
41247
41245
  async listTaskSummaries(projectSlug, filters = {}) {
41248
- const path24 = buildTaskListPath(projectSlug, filters, "summary");
41249
- const body = await request(path24);
41246
+ const path25 = buildTaskListPath(projectSlug, filters, "summary");
41247
+ const body = await request(path25);
41250
41248
  return taskSummaryListResponseSchema.parse(body).data;
41251
41249
  },
41252
41250
  async listTaxonomy(projectSlug) {
@@ -41254,22 +41252,22 @@ function createMrrlinClient(config2) {
41254
41252
  return taxonomyListResponseSchema.parse(body).data;
41255
41253
  },
41256
41254
  async listWikiPages(projectSlug, filters = {}) {
41257
- const path24 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
41255
+ const path25 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
41258
41256
  folder: filters.folder,
41259
41257
  q: filters.q,
41260
41258
  taskId: filters.taskId
41261
41259
  });
41262
- const body = await request(path24);
41260
+ const body = await request(path25);
41263
41261
  return wikiPageListResponseSchema.parse(body).data;
41264
41262
  },
41265
41263
  async searchWikiPages(projectSlug, query) {
41266
- const path24 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
41264
+ const path25 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
41267
41265
  folder: query.folder,
41268
41266
  limit: query.limit === void 0 ? void 0 : String(query.limit),
41269
41267
  pathPrefix: query.pathPrefix,
41270
41268
  q: query.q
41271
41269
  });
41272
- const body = await request(path24);
41270
+ const body = await request(path25);
41273
41271
  return wikiPageSearchResponseSchema.parse(body).data;
41274
41272
  },
41275
41273
  async updatePlan(projectSlug, planId, patch) {
@@ -42260,12 +42258,150 @@ function createTurnLock() {
42260
42258
  // src/self-update.ts
42261
42259
  var import_node_child_process7 = require("node:child_process");
42262
42260
  var import_node_crypto2 = require("node:crypto");
42261
+ var import_node_fs4 = require("node:fs");
42262
+ var import_node_path7 = __toESM(require("node:path"), 1);
42263
+ var import_semver3 = __toESM(require_semver2(), 1);
42264
+
42265
+ // src/codex-auth-preflight.ts
42263
42266
  var import_node_fs3 = require("node:fs");
42267
+ var import_node_os6 = __toESM(require("node:os"), 1);
42264
42268
  var import_node_path6 = __toESM(require("node:path"), 1);
42265
- var import_semver3 = __toESM(require_semver2(), 1);
42269
+ var DEFAULT_CODEX_AUTH_MIN_TTL_SECONDS = 15 * 60;
42270
+ function positiveInt(raw) {
42271
+ if (!raw) return null;
42272
+ const parsed = Number.parseInt(raw, 10);
42273
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
42274
+ }
42275
+ function codexAuthMinTtlSeconds(env = process.env) {
42276
+ return positiveInt(env.MRRLIN_DIRECTOR_BRIDGE_UPDATE_AUTH_MIN_TTL_SECONDS) ?? DEFAULT_CODEX_AUTH_MIN_TTL_SECONDS;
42277
+ }
42278
+ function resolveCodexAuthPath(opts = {}) {
42279
+ const env = opts.env ?? process.env;
42280
+ const codexHome = env.CODEX_HOME?.trim();
42281
+ return import_node_path6.default.join(codexHome || import_node_path6.default.join(opts.homeDir ?? import_node_os6.default.homedir(), ".codex"), "auth.json");
42282
+ }
42283
+ function decodeJwtExpMs(token) {
42284
+ const parts = token.split(".");
42285
+ if (parts.length < 2 || !parts[1]) return null;
42286
+ try {
42287
+ const payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
42288
+ return typeof payload.exp === "number" && Number.isFinite(payload.exp) ? payload.exp * 1e3 : null;
42289
+ } catch {
42290
+ return null;
42291
+ }
42292
+ }
42293
+ function inspectCodexAuthForBridgeUpdate(opts = {}) {
42294
+ const env = opts.env ?? process.env;
42295
+ const nowMs = opts.nowMs ?? Date.now();
42296
+ const minTtlSeconds = opts.minTtlSeconds ?? codexAuthMinTtlSeconds(env);
42297
+ const authPath = resolveCodexAuthPath({ env, homeDir: opts.homeDir });
42298
+ const readFile9 = opts.readFileSyncImpl ?? ((p, encoding) => (0, import_node_fs3.readFileSync)(p, encoding));
42299
+ let raw;
42300
+ try {
42301
+ raw = readFile9(authPath, "utf8");
42302
+ } catch (e) {
42303
+ const code = typeof e === "object" && e !== null && "code" in e ? String(e.code) : "";
42304
+ const status = code === "ENOENT" ? "missing" : "unreadable";
42305
+ return {
42306
+ ok: false,
42307
+ status,
42308
+ authPath,
42309
+ checkedAtMs: nowMs,
42310
+ minTtlSeconds,
42311
+ tokenKinds: [],
42312
+ expiresAtMs: null,
42313
+ expiresInSeconds: null,
42314
+ detail: status === "missing" ? "Codex CLI auth file is missing." : "Codex CLI auth file could not be read."
42315
+ };
42316
+ }
42317
+ let parsed;
42318
+ try {
42319
+ parsed = JSON.parse(raw);
42320
+ } catch {
42321
+ return {
42322
+ ok: false,
42323
+ status: "malformed",
42324
+ authPath,
42325
+ checkedAtMs: nowMs,
42326
+ minTtlSeconds,
42327
+ tokenKinds: [],
42328
+ expiresAtMs: null,
42329
+ expiresInSeconds: null,
42330
+ detail: "Codex CLI auth file is not valid JSON."
42331
+ };
42332
+ }
42333
+ const tokenEntries = [
42334
+ ["access_token", parsed.tokens?.access_token],
42335
+ ["id_token", parsed.tokens?.id_token]
42336
+ ];
42337
+ const expiries = tokenEntries.flatMap(([kind, token]) => {
42338
+ if (typeof token !== "string" || token.trim() === "") return [];
42339
+ const expMs = decodeJwtExpMs(token);
42340
+ return expMs === null ? [] : [{ kind, expMs }];
42341
+ });
42342
+ const earliest = expiries.reduce(
42343
+ (current2, entry) => current2 === null || entry.expMs < current2.expMs ? entry : current2,
42344
+ null
42345
+ );
42346
+ if (earliest === null) {
42347
+ return {
42348
+ ok: false,
42349
+ status: "no_usable_jwt_exp",
42350
+ authPath,
42351
+ checkedAtMs: nowMs,
42352
+ minTtlSeconds,
42353
+ tokenKinds: [],
42354
+ expiresAtMs: null,
42355
+ expiresInSeconds: null,
42356
+ detail: "Codex CLI auth file has no access_token or id_token JWT expiry to verify."
42357
+ };
42358
+ }
42359
+ const expiresInSeconds = Math.floor((earliest.expMs - nowMs) / 1e3);
42360
+ const tokenKinds = expiries.map((entry) => entry.kind).sort();
42361
+ if (expiresInSeconds <= 0) {
42362
+ return {
42363
+ ok: false,
42364
+ status: "expired",
42365
+ authPath,
42366
+ checkedAtMs: nowMs,
42367
+ minTtlSeconds,
42368
+ tokenKinds,
42369
+ expiresAtMs: earliest.expMs,
42370
+ expiresInSeconds,
42371
+ detail: `Codex CLI ${earliest.kind} JWT is expired.`
42372
+ };
42373
+ }
42374
+ if (expiresInSeconds < minTtlSeconds) {
42375
+ return {
42376
+ ok: false,
42377
+ status: "expiring_soon",
42378
+ authPath,
42379
+ checkedAtMs: nowMs,
42380
+ minTtlSeconds,
42381
+ tokenKinds,
42382
+ expiresAtMs: earliest.expMs,
42383
+ expiresInSeconds,
42384
+ detail: `Codex CLI ${earliest.kind} JWT expires too soon for a bridge update restart.`
42385
+ };
42386
+ }
42387
+ return {
42388
+ ok: true,
42389
+ status: "ok",
42390
+ authPath,
42391
+ checkedAtMs: nowMs,
42392
+ minTtlSeconds,
42393
+ tokenKinds,
42394
+ expiresAtMs: earliest.expMs,
42395
+ expiresInSeconds,
42396
+ detail: "Codex CLI JWT expiry is far enough in the future for a bridge update restart."
42397
+ };
42398
+ }
42399
+
42400
+ // src/self-update.ts
42266
42401
  var BIN_NAME = "mrrlin-mcp";
42402
+ var SELF_UPDATE_AUTH_PREFLIGHT_OFFER_PREFIX = "[bridge:update:auth-preflight]";
42267
42403
  function resolveBinPath(opts) {
42268
- if (opts.argv1 && import_node_path6.default.basename(opts.argv1).includes("mrrlin")) {
42404
+ if (opts.argv1 && import_node_path7.default.basename(opts.argv1).includes("mrrlin")) {
42269
42405
  return { path: opts.argv1, source: "argv" };
42270
42406
  }
42271
42407
  const whichSync = opts.whichSync ?? ((name) => {
@@ -42275,15 +42411,15 @@ function resolveBinPath(opts) {
42275
42411
  return null;
42276
42412
  }
42277
42413
  });
42278
- const existsSync5 = opts.existsSync ?? import_node_fs3.existsSync;
42414
+ const existsSync5 = opts.existsSync ?? import_node_fs4.existsSync;
42279
42415
  const resolved = whichSync(BIN_NAME);
42280
42416
  if (resolved && existsSync5(resolved)) {
42281
42417
  return { path: resolved, source: "which" };
42282
42418
  }
42283
42419
  const envPath = (opts.env ?? process.env).PATH ?? "";
42284
- for (const dir of envPath.split(import_node_path6.default.delimiter)) {
42420
+ for (const dir of envPath.split(import_node_path7.default.delimiter)) {
42285
42421
  if (!dir) continue;
42286
- const candidate = import_node_path6.default.join(dir, BIN_NAME);
42422
+ const candidate = import_node_path7.default.join(dir, BIN_NAME);
42287
42423
  if (existsSync5(candidate)) {
42288
42424
  return { path: candidate, source: "path-walk" };
42289
42425
  }
@@ -42295,6 +42431,7 @@ var DEFAULT_IDLE_MS = 2e3;
42295
42431
  var DEFAULT_REGISTRY_POLL_MS = 6 * 60 * 60 * 1e3;
42296
42432
  var DEFAULT_STARTUP_JITTER_MS = 30 * 1e3;
42297
42433
  var DEFAULT_COOLDOWN_MS = 48 * 60 * 60 * 1e3;
42434
+ var DEFAULT_AUTH_BLOCK_COOLDOWN_MS = 15 * 60 * 1e3;
42298
42435
  var REGISTRY_URL_DEFAULT = "https://registry.npmjs.org/@mrrlin-dev/mcp/latest";
42299
42436
  var STRICT_SEMVER = /^\d+\.\d+\.\d+(-[A-Za-z0-9.-]+)?(\+[A-Za-z0-9.-]+)?$/;
42300
42437
  var UPDATE_INBOX_BODY = "A newer version of the mrrlin bridge is available. Updating pulls the latest fixes and improvements. Changelog: https://mrrlin-changelog.s3.eu-central-1.amazonaws.com/index.html . Ask the Director to update, or run `npm install -g @mrrlin-dev/mcp@latest` yourself.";
@@ -42313,7 +42450,7 @@ function sha256(buf) {
42313
42450
  function startSelfUpdate(deps) {
42314
42451
  const log = deps.log ?? (() => {
42315
42452
  });
42316
- const readFile9 = deps.readFileSyncImpl ?? ((p) => (0, import_node_fs3.readFileSync)(p));
42453
+ const readFile9 = deps.readFileSyncImpl ?? ((p) => (0, import_node_fs4.readFileSync)(p));
42317
42454
  const setIntervalFn = deps.setIntervalImpl ?? setInterval;
42318
42455
  const clearIntervalFn = deps.clearIntervalImpl ?? clearInterval;
42319
42456
  const intervalMs = deps.intervalMs ?? readIntervalEnv("MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE_INTERVAL_MS", DEFAULT_INTERVAL_MS);
@@ -42326,17 +42463,55 @@ function startSelfUpdate(deps) {
42326
42463
  const registryPollIntervalMs = deps.registryPollIntervalMs ?? readIntervalEnv("MRRLIN_DIRECTOR_BRIDGE_REGISTRY_POLL_INTERVAL_MS", DEFAULT_REGISTRY_POLL_MS);
42327
42464
  const startupJitterMs = deps.startupJitterMs ?? DEFAULT_STARTUP_JITTER_MS;
42328
42465
  const cooldownMs = deps.cooldownMs ?? readIntervalEnv("MRRLIN_DIRECTOR_BRIDGE_UPDATE_COOLDOWN_MS", DEFAULT_COOLDOWN_MS);
42466
+ const authBlockCooldownMs = deps.authBlockCooldownMs ?? readIntervalEnv("MRRLIN_DIRECTOR_BRIDGE_UPDATE_AUTH_BLOCK_COOLDOWN_MS", DEFAULT_AUTH_BLOCK_COOLDOWN_MS);
42329
42467
  const nowFn = deps.now ?? (() => Date.now());
42468
+ const codexAuthPreflight = deps.codexAuthPreflight ?? (() => inspectCodexAuthForBridgeUpdate({
42469
+ nowMs: nowFn()
42470
+ }));
42330
42471
  const disabled = isDisabled();
42331
42472
  let drainOnQuiet = false;
42332
42473
  let drainSource = null;
42333
42474
  let shutdownCalled = false;
42334
42475
  let latestVersion = null;
42335
42476
  let lastUpdateMentionAt = null;
42477
+ let lastAuthBlockMentionAt = null;
42478
+ function blockedAuthOffer(auth2) {
42479
+ const expires = auth2.expiresInSeconds === null ? "unknown" : `${auth2.expiresInSeconds}s`;
42480
+ return `${SELF_UPDATE_AUTH_PREFLIGHT_OFFER_PREFIX} An update for @mrrlin-dev/mcp is available: ${pkgVersion} -> ${latestVersion}.
42481
+
42482
+ Do NOT install it yet. The local Codex CLI auth that the restarted bridge will use is not update-safe:
42483
+ - status: ${auth2.status}
42484
+ - auth file: ${auth2.authPath}
42485
+ - nearest JWT expiry: ${expires}
42486
+ - detail: ${auth2.detail}
42487
+
42488
+ Tell the operator, in their language, that the bridge update is ready but the Codex CLI session should be refreshed first because the update restarts the bridge and starts a fresh headless Codex process.
42489
+
42490
+ Ask the operator to run \`codex login\` as the re-auth action only. Do not present \`codex login\` as a readiness check; it opens the login flow even when auth is already fine.
42491
+
42492
+ After the operator re-authenticates, ask them to verify the CLI with:
42493
+ \`codex exec --model gpt-5.4-mini 'Reply with exactly: OK'\`
42494
+
42495
+ Once that returns OK, they can ask again and you may offer the normal update command \`npm install -g @mrrlin-dev/mcp@latest\`.`;
42496
+ }
42336
42497
  function maybeUpdateOffer() {
42337
42498
  if (disabled) return null;
42338
42499
  if (latestVersion === null) return null;
42339
42500
  if (!import_semver3.default.gt(latestVersion, pkgVersion)) return null;
42501
+ const auth2 = codexAuthPreflight();
42502
+ if (!auth2.ok) {
42503
+ if (lastAuthBlockMentionAt !== null && nowFn() - lastAuthBlockMentionAt < authBlockCooldownMs) return null;
42504
+ lastAuthBlockMentionAt = nowFn();
42505
+ log("warn", "bridge.self_update.auth_preflight_blocked", {
42506
+ version: pkgVersion,
42507
+ latestVersion,
42508
+ status: auth2.status,
42509
+ authPath: auth2.authPath,
42510
+ expiresInSeconds: auth2.expiresInSeconds,
42511
+ minTtlSeconds: auth2.minTtlSeconds
42512
+ });
42513
+ return blockedAuthOffer(auth2);
42514
+ }
42340
42515
  if (lastUpdateMentionAt !== null && nowFn() - lastUpdateMentionAt < cooldownMs) return null;
42341
42516
  lastUpdateMentionAt = nowFn();
42342
42517
  log("info", "bridge.self_update.hint_injected", {
@@ -42534,17 +42709,17 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
42534
42709
  }
42535
42710
 
42536
42711
  // src/_generated/version.ts
42537
- var PKG_VERSION = "0.4.59";
42712
+ var PKG_VERSION = "0.4.61";
42538
42713
 
42539
42714
  // src/api-base-url-migrate.ts
42540
- var import_node_fs4 = __toESM(require("node:fs"), 1);
42541
- var import_node_os6 = __toESM(require("node:os"), 1);
42542
- var import_node_path8 = __toESM(require("node:path"), 1);
42715
+ var import_node_fs5 = __toESM(require("node:fs"), 1);
42716
+ var import_node_os7 = __toESM(require("node:os"), 1);
42717
+ var import_node_path9 = __toESM(require("node:path"), 1);
42543
42718
 
42544
42719
  // src/service-paths.ts
42545
- var import_node_path7 = __toESM(require("node:path"), 1);
42720
+ var import_node_path8 = __toESM(require("node:path"), 1);
42546
42721
  function isWorktreePath(p) {
42547
- const norm = import_node_path7.default.normalize(p).split(import_node_path7.default.sep).join("/");
42722
+ const norm = import_node_path8.default.normalize(p).split(import_node_path8.default.sep).join("/");
42548
42723
  return norm.includes("/.claude/worktrees/");
42549
42724
  }
42550
42725
  function resolveServiceCwd(opts) {
@@ -42597,20 +42772,20 @@ ${envLines}
42597
42772
 
42598
42773
  // src/api-base-url-migrate.ts
42599
42774
  function defaultDeps(deps) {
42600
- const home = deps.home ?? process.env.HOME ?? import_node_os6.default.homedir();
42775
+ const home = deps.home ?? process.env.HOME ?? import_node_os7.default.homedir();
42601
42776
  return {
42602
42777
  home,
42603
- codexHome: deps.codexHome ?? process.env.CODEX_HOME?.trim() ?? import_node_path8.default.join(home, ".codex"),
42604
- readFile: deps.readFile ?? ((p) => import_node_fs4.default.readFileSync(p, "utf8")),
42778
+ codexHome: deps.codexHome ?? process.env.CODEX_HOME?.trim() ?? import_node_path9.default.join(home, ".codex"),
42779
+ readFile: deps.readFile ?? ((p) => import_node_fs5.default.readFileSync(p, "utf8")),
42605
42780
  // Temp-file + atomic rename so a concurrent `serve` and `director-bridge` startup can never
42606
42781
  // interleave partial writes into a config the next start has to parse. Note this normalizes the
42607
42782
  // file to 0o600 — deliberate, since both files can carry a credential-bearing URL.
42608
42783
  writeFile: deps.writeFile ?? ((p, c) => {
42609
42784
  const tmp = `${p}.tmp-${process.pid}`;
42610
- import_node_fs4.default.writeFileSync(tmp, c, { mode: 384 });
42611
- import_node_fs4.default.renameSync(tmp, p);
42785
+ import_node_fs5.default.writeFileSync(tmp, c, { mode: 384 });
42786
+ import_node_fs5.default.renameSync(tmp, p);
42612
42787
  }),
42613
- exists: deps.exists ?? ((p) => import_node_fs4.default.existsSync(p)),
42788
+ exists: deps.exists ?? ((p) => import_node_fs5.default.existsSync(p)),
42614
42789
  log: deps.log ?? ((m) => process.stderr.write(`${m}
42615
42790
  `))
42616
42791
  };
@@ -42649,7 +42824,7 @@ function backupOnce(file2, text, deps) {
42649
42824
  }
42650
42825
  function migrateEcosystemConfig(deps = {}) {
42651
42826
  const d = defaultDeps(deps);
42652
- const file2 = import_node_path8.default.join(d.home, ".mrrlin", "ecosystem.config.cjs");
42827
+ const file2 = import_node_path9.default.join(d.home, ".mrrlin", "ecosystem.config.cjs");
42653
42828
  if (!d.exists(file2)) return { file: file2, status: "absent" };
42654
42829
  const text = d.readFile(file2);
42655
42830
  if (!findRetiredHost(text) && !hasLiveLegacyStagingFlag(text, "js"))
@@ -42799,7 +42974,7 @@ ${envLines}
42799
42974
  }
42800
42975
  function migrateCodexConfig(deps = {}) {
42801
42976
  const d = defaultDeps(deps);
42802
- const file2 = import_node_path8.default.join(d.codexHome, "config.toml");
42977
+ const file2 = import_node_path9.default.join(d.codexHome, "config.toml");
42803
42978
  if (!d.exists(file2)) return { file: file2, status: "absent" };
42804
42979
  const text = d.readFile(file2);
42805
42980
  const host = findRetiredHost(text);
@@ -42885,7 +43060,7 @@ $1`
42885
43060
  }
42886
43061
  function migrateClaudeConfig(deps = {}) {
42887
43062
  const d = defaultDeps(deps);
42888
- const file2 = import_node_path8.default.join(d.home, ".claude.json");
43063
+ const file2 = import_node_path9.default.join(d.home, ".claude.json");
42889
43064
  if (!d.exists(file2)) return { file: file2, status: "absent" };
42890
43065
  const text = d.readFile(file2);
42891
43066
  let parsed;
@@ -42935,9 +43110,9 @@ function migrateRetiredApiBaseUrls(deps = {}) {
42935
43110
  const d = defaultDeps(deps);
42936
43111
  const results = [];
42937
43112
  const steps = [
42938
- { run: migrateEcosystemConfig, file: import_node_path8.default.join(d.home, ".mrrlin", "ecosystem.config.cjs") },
42939
- { run: migrateCodexConfig, file: import_node_path8.default.join(d.codexHome, "config.toml") },
42940
- { run: migrateClaudeConfig, file: import_node_path8.default.join(d.home, ".claude.json") }
43113
+ { run: migrateEcosystemConfig, file: import_node_path9.default.join(d.home, ".mrrlin", "ecosystem.config.cjs") },
43114
+ { run: migrateCodexConfig, file: import_node_path9.default.join(d.codexHome, "config.toml") },
43115
+ { run: migrateClaudeConfig, file: import_node_path9.default.join(d.home, ".claude.json") }
42941
43116
  ];
42942
43117
  for (const step of steps) {
42943
43118
  try {
@@ -42963,8 +43138,8 @@ function migrateRetiredApiBaseUrls(deps = {}) {
42963
43138
  }
42964
43139
 
42965
43140
  // src/bridge-health.ts
42966
- var import_node_fs5 = require("node:fs");
42967
- var import_node_path9 = __toESM(require("node:path"), 1);
43141
+ var import_node_fs6 = require("node:fs");
43142
+ var import_node_path10 = __toESM(require("node:path"), 1);
42968
43143
  var SENTINEL_FILE_NAME = "bridge-health-circuit-breaker.json";
42969
43144
  var CRASH_WINDOW_MS = 60 * 60 * 1e3;
42970
43145
  var MAX_CRASHES_PER_WINDOW = 3;
@@ -42976,9 +43151,9 @@ function isCrashSentinel(value) {
42976
43151
  return typeof candidate.crashCount === "number" && Number.isInteger(candidate.crashCount) && candidate.crashCount >= 0 && typeof candidate.windowStartedAt === "string";
42977
43152
  }
42978
43153
  async function readCrashSentinel(stateDir, now = Date.now) {
42979
- const sentinelPath = import_node_path9.default.join(stateDir, SENTINEL_FILE_NAME);
43154
+ const sentinelPath = import_node_path10.default.join(stateDir, SENTINEL_FILE_NAME);
42980
43155
  try {
42981
- const raw = await import_node_fs5.promises.readFile(sentinelPath, "utf8");
43156
+ const raw = await import_node_fs6.promises.readFile(sentinelPath, "utf8");
42982
43157
  const parsed = JSON.parse(raw);
42983
43158
  if (isCrashSentinel(parsed)) return parsed;
42984
43159
  } catch {
@@ -42986,11 +43161,11 @@ async function readCrashSentinel(stateDir, now = Date.now) {
42986
43161
  return { crashCount: 0, windowStartedAt: new Date(now()).toISOString() };
42987
43162
  }
42988
43163
  async function writeCrashSentinel(stateDir, sentinel) {
42989
- await import_node_fs5.promises.mkdir(stateDir, { recursive: true });
42990
- const sentinelPath = import_node_path9.default.join(stateDir, SENTINEL_FILE_NAME);
43164
+ await import_node_fs6.promises.mkdir(stateDir, { recursive: true });
43165
+ const sentinelPath = import_node_path10.default.join(stateDir, SENTINEL_FILE_NAME);
42991
43166
  const tmpPath = `${sentinelPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
42992
- await import_node_fs5.promises.writeFile(tmpPath, JSON.stringify(sentinel), "utf8");
42993
- await import_node_fs5.promises.rename(tmpPath, sentinelPath);
43167
+ await import_node_fs6.promises.writeFile(tmpPath, JSON.stringify(sentinel), "utf8");
43168
+ await import_node_fs6.promises.rename(tmpPath, sentinelPath);
42994
43169
  }
42995
43170
  function withTimeout(fn, ms = DEFAULT_OPERATION_TIMEOUT_MS) {
42996
43171
  const controller = new AbortController();
@@ -43317,12 +43492,12 @@ function startSchedulerTickLoop(deps) {
43317
43492
 
43318
43493
  // src/retention/pruner.ts
43319
43494
  var import_promises4 = require("node:fs/promises");
43320
- var import_node_path10 = __toESM(require("node:path"), 1);
43495
+ var import_node_path11 = __toESM(require("node:path"), 1);
43321
43496
  function protectedDayFloor(protectedSinceMs) {
43322
43497
  return new Date(protectedSinceMs).toISOString().slice(0, 10);
43323
43498
  }
43324
43499
  async function prune(stateDir, bounds) {
43325
- const logsDir = import_node_path10.default.join(stateDir, "logs");
43500
+ const logsDir = import_node_path11.default.join(stateDir, "logs");
43326
43501
  let entries;
43327
43502
  try {
43328
43503
  entries = await (0, import_promises4.readdir)(logsDir);
@@ -43338,7 +43513,7 @@ async function prune(stateDir, bounds) {
43338
43513
  for (const entry of entries) {
43339
43514
  const m = bridgeRe.exec(entry);
43340
43515
  if (!m?.[1]) continue;
43341
- const fullPath = import_node_path10.default.join(logsDir, entry);
43516
+ const fullPath = import_node_path11.default.join(logsDir, entry);
43342
43517
  const s = await (0, import_promises4.stat)(fullPath);
43343
43518
  files.push({ day: m[1], size: s.size, fullPath });
43344
43519
  }
@@ -43347,7 +43522,7 @@ async function prune(stateDir, bounds) {
43347
43522
  const reasonByDay = {};
43348
43523
  let bytesRemoved = 0;
43349
43524
  async function isDaySafeToDelete(day) {
43350
- const telemetryDir = import_node_path10.default.join(stateDir, "telemetry");
43525
+ const telemetryDir = import_node_path11.default.join(stateDir, "telemetry");
43351
43526
  let telemetryEntries;
43352
43527
  try {
43353
43528
  telemetryEntries = await (0, import_promises4.readdir)(telemetryDir);
@@ -43363,7 +43538,7 @@ async function prune(stateDir, bounds) {
43363
43538
  }
43364
43539
  if (projectSlugs.length === 0) return true;
43365
43540
  for (const slug of projectSlugs) {
43366
- const markerPath = import_node_path10.default.join(telemetryDir, `.processed-${slug}-${day}`);
43541
+ const markerPath = import_node_path11.default.join(telemetryDir, `.processed-${slug}-${day}`);
43367
43542
  try {
43368
43543
  await (0, import_promises4.stat)(markerPath);
43369
43544
  } catch (err) {
@@ -43413,7 +43588,7 @@ async function prune(stateDir, bounds) {
43413
43588
  const budgetOvershootBytes = Math.max(0, totalSize2 - budgetBytes);
43414
43589
  await emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining);
43415
43590
  if (daysRemoved.length > 0) {
43416
- const sessionsPath = import_node_path10.default.join(logsDir, ".sessions.json");
43591
+ const sessionsPath = import_node_path11.default.join(logsDir, ".sessions.json");
43417
43592
  let sessionsObj = {};
43418
43593
  let fileExists = true;
43419
43594
  try {
@@ -43435,8 +43610,8 @@ async function prune(stateDir, bounds) {
43435
43610
  return { daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining, budgetOvershootBytes };
43436
43611
  }
43437
43612
  async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining) {
43438
- const logsDir = import_node_path10.default.join(stateDir, "logs");
43439
- const logPath = import_node_path10.default.join(logsDir, ".pruned.jsonl");
43613
+ const logsDir = import_node_path11.default.join(stateDir, "logs");
43614
+ const logPath = import_node_path11.default.join(logsDir, ".pruned.jsonl");
43440
43615
  await (0, import_promises4.mkdir)(logsDir, { recursive: true });
43441
43616
  const record2 = { ts: Date.now(), dir: "logs", daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining };
43442
43617
  await (0, import_promises4.appendFile)(logPath, `${JSON.stringify(record2)}
@@ -43446,7 +43621,7 @@ async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, ol
43446
43621
  // src/telemetry/turn-aggregator.ts
43447
43622
  var import_node_crypto3 = require("node:crypto");
43448
43623
  var import_promises5 = require("node:fs/promises");
43449
- var import_node_path11 = require("node:path");
43624
+ var import_node_path12 = require("node:path");
43450
43625
  var BRIDGE_FILE_RE = /^bridge-(\d{4}-\d{2}-\d{2})\.jsonl$/;
43451
43626
  var PLUMBING_COUNTER_KEY = {
43452
43627
  socket_close: "socketCloses",
@@ -43475,7 +43650,7 @@ function inheritSlug(seeds, index) {
43475
43650
  return (preceding ?? following)?.slug;
43476
43651
  }
43477
43652
  async function foldClosedDays(stateDir, today) {
43478
- const logsDir = (0, import_node_path11.join)(stateDir, "logs");
43653
+ const logsDir = (0, import_node_path12.join)(stateDir, "logs");
43479
43654
  let entries;
43480
43655
  try {
43481
43656
  entries = await (0, import_promises5.readdir)(logsDir);
@@ -43487,7 +43662,7 @@ async function foldClosedDays(stateDir, today) {
43487
43662
  if (!m) continue;
43488
43663
  const day = m[1];
43489
43664
  if (day === today) continue;
43490
- const raw = await (0, import_promises5.readFile)((0, import_node_path11.join)(logsDir, entry), "utf8");
43665
+ const raw = await (0, import_promises5.readFile)((0, import_node_path12.join)(logsDir, entry), "utf8");
43491
43666
  const groups = /* @__PURE__ */ new Map();
43492
43667
  let groupCounter = 0;
43493
43668
  for (const line of raw.split("\n")) {
@@ -43598,10 +43773,10 @@ async function foldClosedDays(stateDir, today) {
43598
43773
  rowsByProject.set(slug, rows);
43599
43774
  }
43600
43775
  if (rowsByProject.size === 0) continue;
43601
- const telemetryDir = (0, import_node_path11.join)(stateDir, "telemetry");
43776
+ const telemetryDir = (0, import_node_path12.join)(stateDir, "telemetry");
43602
43777
  await (0, import_promises5.mkdir)(telemetryDir, { recursive: true });
43603
43778
  for (const [slug, rows] of rowsByProject) {
43604
- const finalPath = (0, import_node_path11.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
43779
+ const finalPath = (0, import_node_path12.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
43605
43780
  const tmpPath = `${finalPath}.tmp-${process.pid}-${(0, import_node_crypto3.randomBytes)(6).toString("hex")}`;
43606
43781
  try {
43607
43782
  await (0, import_promises5.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
@@ -43616,22 +43791,22 @@ async function foldClosedDays(stateDir, today) {
43616
43791
 
43617
43792
  // src/telemetry/daily-uploader.ts
43618
43793
  var import_promises6 = require("node:fs/promises");
43619
- var import_node_path16 = require("node:path");
43794
+ var import_node_path17 = require("node:path");
43620
43795
 
43621
43796
  // src/consensus/wiring.ts
43622
43797
  var import_node_crypto4 = __toESM(require("node:crypto"), 1);
43623
- var import_node_fs8 = __toESM(require("node:fs"), 1);
43624
- var import_node_path14 = __toESM(require("node:path"), 1);
43798
+ var import_node_fs9 = __toESM(require("node:fs"), 1);
43799
+ var import_node_path15 = __toESM(require("node:path"), 1);
43625
43800
  var import_node_url2 = require("node:url");
43626
43801
 
43627
43802
  // src/consensus/gate-usage-log.ts
43628
- var import_node_fs6 = require("node:fs");
43629
- var import_node_path12 = require("node:path");
43803
+ var import_node_fs7 = require("node:fs");
43804
+ var import_node_path13 = require("node:path");
43630
43805
  function recordGateCall(stateDir, projectSlug, record2) {
43631
43806
  try {
43632
- const dir = (0, import_node_path12.join)(stateDir, "telemetry");
43633
- (0, import_node_fs6.mkdirSync)(dir, { recursive: true });
43634
- (0, import_node_fs6.appendFileSync)((0, import_node_path12.join)(dir, gateFileName(projectSlug, record2.day)), `${JSON.stringify(record2)}
43807
+ const dir = (0, import_node_path13.join)(stateDir, "telemetry");
43808
+ (0, import_node_fs7.mkdirSync)(dir, { recursive: true });
43809
+ (0, import_node_fs7.appendFileSync)((0, import_node_path13.join)(dir, gateFileName(projectSlug, record2.day)), `${JSON.stringify(record2)}
43635
43810
  `, "utf8");
43636
43811
  } catch {
43637
43812
  }
@@ -44497,12 +44672,12 @@ ${issuesBlock}`,
44497
44672
  }
44498
44673
 
44499
44674
  // src/consensus/sterile-cwd.ts
44500
- var import_node_fs7 = require("node:fs");
44501
- var import_node_os7 = require("node:os");
44502
- var import_node_path13 = require("node:path");
44675
+ var import_node_fs8 = require("node:fs");
44676
+ var import_node_os8 = require("node:os");
44677
+ var import_node_path14 = require("node:path");
44503
44678
  var sterileDir = null;
44504
44679
  function sterileCwd() {
44505
- sterileDir ??= (0, import_node_fs7.mkdtempSync)((0, import_node_path13.join)((0, import_node_os7.tmpdir)(), "mrrlin-gate-"));
44680
+ sterileDir ??= (0, import_node_fs8.mkdtempSync)((0, import_node_path14.join)((0, import_node_os8.tmpdir)(), "mrrlin-gate-"));
44506
44681
  return sterileDir;
44507
44682
  }
44508
44683
 
@@ -44738,15 +44913,15 @@ ${res.stdout}${res.stderr}`);
44738
44913
  var import_meta2 = {};
44739
44914
  function getPersonasDir() {
44740
44915
  if (typeof __dirname !== "undefined") {
44741
- return import_node_path14.default.join(__dirname, "consensus", "personas");
44916
+ return import_node_path15.default.join(__dirname, "consensus", "personas");
44742
44917
  }
44743
- return import_node_path14.default.join(import_node_path14.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)), "personas");
44918
+ return import_node_path15.default.join(import_node_path15.default.dirname((0, import_node_url2.fileURLToPath)(import_meta2.url)), "personas");
44744
44919
  }
44745
44920
  var personaCache = /* @__PURE__ */ new Map();
44746
44921
  function loadPersona(name) {
44747
44922
  const cached2 = personaCache.get(name);
44748
44923
  if (cached2 !== void 0) return cached2;
44749
- const content = import_node_fs8.default.readFileSync(import_node_path14.default.join(getPersonasDir(), `${name}.md`), "utf8");
44924
+ const content = import_node_fs9.default.readFileSync(import_node_path15.default.join(getPersonasDir(), `${name}.md`), "utf8");
44750
44925
  personaCache.set(name, content);
44751
44926
  return content;
44752
44927
  }
@@ -45335,8 +45510,8 @@ You revise a deliverable to address the accepted issues so it satisfies the acce
45335
45510
  function isRecord2(v) {
45336
45511
  return v !== null && typeof v === "object";
45337
45512
  }
45338
- function resolvePath(root, path24) {
45339
- const parts = path24.split(".");
45513
+ function resolvePath(root, path25) {
45514
+ const parts = path25.split(".");
45340
45515
  let cur = root;
45341
45516
  for (let i = 0; i < parts.length - 1; i += 1) {
45342
45517
  const part = parts[i];
@@ -45404,9 +45579,9 @@ async function gate(artifact, prose, ctx) {
45404
45579
  return { ok: true, gated: true, artifact: withheldExcerptClone(artifact) };
45405
45580
  }
45406
45581
  const maskedClone = typeof structuredClone === "function" ? structuredClone(artifact) : JSON.parse(JSON.stringify(artifact));
45407
- for (const { path: path24, masked } of fields) {
45408
- const target = resolvePath(maskedClone, path24);
45409
- if (!target) throw new Error(`pii-gate: path "${path24}" failed to resolve on the clone after validating on the original`);
45582
+ for (const { path: path25, masked } of fields) {
45583
+ const target = resolvePath(maskedClone, path25);
45584
+ if (!target) throw new Error(`pii-gate: path "${path25}" failed to resolve on the clone after validating on the original`);
45410
45585
  target.parent[target.key] = masked;
45411
45586
  }
45412
45587
  return { ok: true, gated: false, artifact: maskedClone };
@@ -45414,23 +45589,23 @@ async function gate(artifact, prose, ctx) {
45414
45589
 
45415
45590
  // src/telemetry/installation-id.ts
45416
45591
  var import_node_crypto5 = require("node:crypto");
45417
- var import_node_fs9 = require("node:fs");
45418
- var import_node_path15 = require("node:path");
45592
+ var import_node_fs10 = require("node:fs");
45593
+ var import_node_path16 = require("node:path");
45419
45594
  var FILE_NAME = "installation-id";
45420
45595
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
45421
45596
  var cache = /* @__PURE__ */ new Map();
45422
45597
  function resolveInstallationId(stateDir) {
45423
45598
  const cached2 = cache.get(stateDir);
45424
45599
  if (cached2 !== void 0) return cached2;
45425
- const path24 = (0, import_node_path15.join)(stateDir, FILE_NAME);
45600
+ const path25 = (0, import_node_path16.join)(stateDir, FILE_NAME);
45426
45601
  let id;
45427
45602
  try {
45428
- id = (0, import_node_fs9.readFileSync)(path24, "utf8").trim();
45603
+ id = (0, import_node_fs10.readFileSync)(path25, "utf8").trim();
45429
45604
  if (!UUID.test(id)) throw new Error("unusable");
45430
45605
  } catch {
45431
45606
  id = (0, import_node_crypto5.randomUUID)();
45432
- (0, import_node_fs9.mkdirSync)((0, import_node_path15.dirname)(path24), { recursive: true });
45433
- (0, import_node_fs9.writeFileSync)(path24, `${id}
45607
+ (0, import_node_fs10.mkdirSync)((0, import_node_path16.dirname)(path25), { recursive: true });
45608
+ (0, import_node_fs10.writeFileSync)(path25, `${id}
45434
45609
  `, "utf8");
45435
45610
  }
45436
45611
  cache.set(stateDir, id);
@@ -45447,7 +45622,7 @@ function truncateCause(err) {
45447
45622
  return `${message.slice(0, MAX_CAUSE_CHARS - 3)}...`;
45448
45623
  }
45449
45624
  async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45450
- const telemetryDir = (0, import_node_path16.join)(stateDir, "telemetry");
45625
+ const telemetryDir = (0, import_node_path17.join)(stateDir, "telemetry");
45451
45626
  let files;
45452
45627
  try {
45453
45628
  files = await (0, import_promises6.readdir)(telemetryDir);
@@ -45463,14 +45638,14 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45463
45638
  const [, projectSlug, day] = match;
45464
45639
  const key = `${projectSlug}\0${day}`;
45465
45640
  const entry = discovered.get(key) ?? { projectSlug, day, rowsPath: null };
45466
- if (rowsMatch) entry.rowsPath = (0, import_node_path16.join)(telemetryDir, file2);
45641
+ if (rowsMatch) entry.rowsPath = (0, import_node_path17.join)(telemetryDir, file2);
45467
45642
  discovered.set(key, entry);
45468
45643
  }
45469
45644
  const today = telemetryDay();
45470
45645
  const pending = [];
45471
45646
  const deferred = [];
45472
45647
  for (const { projectSlug, day, rowsPath } of discovered.values()) {
45473
- const markerPath = (0, import_node_path16.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
45648
+ const markerPath = (0, import_node_path17.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
45474
45649
  if (rowsPath === null && day >= today) {
45475
45650
  try {
45476
45651
  await (0, import_promises6.access)(markerPath);
@@ -45490,7 +45665,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45490
45665
  const fullUnprocessed = [...pending.map((p) => ({ projectSlug: p.projectSlug, day: p.day })), ...deferred];
45491
45666
  pending.sort((a, b) => a.day.localeCompare(b.day));
45492
45667
  for (const cur of pending) {
45493
- const failurePath = (0, import_node_path16.join)(telemetryDir, `.failed-${cur.projectSlug}-${cur.day}.json`);
45668
+ const failurePath = (0, import_node_path17.join)(telemetryDir, `.failed-${cur.projectSlug}-${cur.day}.json`);
45494
45669
  let failureState = null;
45495
45670
  try {
45496
45671
  const data = await (0, import_promises6.readFile)(failurePath, "utf8");
@@ -45524,7 +45699,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
45524
45699
  }
45525
45700
  const gateCalls = [];
45526
45701
  try {
45527
- const rawGate = await (0, import_promises6.readFile)((0, import_node_path16.join)(telemetryDir, gateFileName(cur.projectSlug, cur.day)), "utf8");
45702
+ const rawGate = await (0, import_promises6.readFile)((0, import_node_path17.join)(telemetryDir, gateFileName(cur.projectSlug, cur.day)), "utf8");
45528
45703
  for (const line of rawGate.split("\n")) {
45529
45704
  if (!line.trim()) continue;
45530
45705
  try {
@@ -45946,7 +46121,7 @@ function setSelectedProvider(value) {
45946
46121
  // src/execution-consumer.ts
45947
46122
  var import_node_child_process12 = require("node:child_process");
45948
46123
  var import_node_crypto7 = __toESM(require("node:crypto"), 1);
45949
- var import_node_path19 = __toESM(require("node:path"), 1);
46124
+ var import_node_path20 = __toESM(require("node:path"), 1);
45950
46125
  var import_node_util = require("node:util");
45951
46126
 
45952
46127
  // src/consensus/deliverable-gate-outcome.ts
@@ -47242,18 +47417,18 @@ async function awaitTurnWithDeadline(opts) {
47242
47417
 
47243
47418
  // src/worktree.ts
47244
47419
  var import_node_child_process11 = require("node:child_process");
47245
- var import_node_fs11 = require("node:fs");
47246
- var import_node_os8 = require("node:os");
47247
- var import_node_path18 = require("node:path");
47420
+ var import_node_fs12 = require("node:fs");
47421
+ var import_node_os9 = require("node:os");
47422
+ var import_node_path19 = require("node:path");
47248
47423
 
47249
47424
  // src/checkout-lock.ts
47250
- var import_node_fs10 = require("node:fs");
47251
- var import_node_path17 = require("node:path");
47425
+ var import_node_fs11 = require("node:fs");
47426
+ var import_node_path18 = require("node:path");
47252
47427
  var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
47253
47428
  async function withCheckoutLock(locksDir, slug, fn) {
47254
- (0, import_node_fs10.mkdirSync)(locksDir, { recursive: true });
47255
- const target = (0, import_node_path17.join)(locksDir, `${slug}.lock`);
47256
- if (!(0, import_node_fs10.existsSync)(target)) (0, import_node_fs10.writeFileSync)(target, "");
47429
+ (0, import_node_fs11.mkdirSync)(locksDir, { recursive: true });
47430
+ const target = (0, import_node_path18.join)(locksDir, `${slug}.lock`);
47431
+ if (!(0, import_node_fs11.existsSync)(target)) (0, import_node_fs11.writeFileSync)(target, "");
47257
47432
  const release = await import_proper_lockfile.default.lock(target, {
47258
47433
  retries: { retries: 600, factor: 1, minTimeout: 100, maxTimeout: 100 },
47259
47434
  stale: 5 * 6e4
@@ -47278,12 +47453,12 @@ function git(checkout, args) {
47278
47453
  });
47279
47454
  }
47280
47455
  async function createRunWorktree(opts) {
47281
- const worktreePath = (0, import_node_path18.join)(opts.worktreeRoot, opts.slug, opts.runId);
47456
+ const worktreePath = (0, import_node_path19.join)(opts.worktreeRoot, opts.slug, opts.runId);
47282
47457
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
47283
- (0, import_node_fs11.mkdirSync)(opts.worktreeRoot, { recursive: true });
47458
+ (0, import_node_fs12.mkdirSync)(opts.worktreeRoot, { recursive: true });
47284
47459
  try {
47285
47460
  git(opts.checkout, ["fetch", "origin", opts.defaultBranch]);
47286
- if (!(0, import_node_fs11.existsSync)(worktreePath)) {
47461
+ if (!(0, import_node_fs12.existsSync)(worktreePath)) {
47287
47462
  git(opts.checkout, [
47288
47463
  "worktree",
47289
47464
  "add",
@@ -47355,15 +47530,15 @@ async function doPushRunBranch(opts, execGit) {
47355
47530
  if (localConfig.trim()) {
47356
47531
  throw new Error(`push aborted: agent-controlled git config present in worktree: ${localConfig.trim().split("\n")[0]}`);
47357
47532
  }
47358
- const dir = (0, import_node_fs11.mkdtempSync)((0, import_node_path18.join)((0, import_node_os8.tmpdir)(), "mrrlin-push-"));
47359
- const askpass = (0, import_node_path18.join)(dir, "askpass");
47533
+ const dir = (0, import_node_fs12.mkdtempSync)((0, import_node_path19.join)((0, import_node_os9.tmpdir)(), "mrrlin-push-"));
47534
+ const askpass = (0, import_node_path19.join)(dir, "askpass");
47360
47535
  try {
47361
- (0, import_node_fs11.writeFileSync)(
47536
+ (0, import_node_fs12.writeFileSync)(
47362
47537
  askpass,
47363
47538
  '#!/bin/sh\ncase "$1" in *[Uu]sername*) printf %s "x-access-token" ;; *) printf %s "$MRRLIN_PUSH_TOKEN" ;; esac\n',
47364
47539
  { mode: 320 }
47365
47540
  );
47366
- (0, import_node_fs11.chmodSync)(askpass, 320);
47541
+ (0, import_node_fs12.chmodSync)(askpass, 320);
47367
47542
  execGit(
47368
47543
  [
47369
47544
  "-C",
@@ -47382,18 +47557,18 @@ async function doPushRunBranch(opts, execGit) {
47382
47557
  );
47383
47558
  return { pushedSha: localSha };
47384
47559
  } finally {
47385
- (0, import_node_fs11.rmSync)(dir, { recursive: true, force: true });
47560
+ (0, import_node_fs12.rmSync)(dir, { recursive: true, force: true });
47386
47561
  }
47387
47562
  }
47388
47563
  async function sweepOrphanWorktrees(opts) {
47389
47564
  const reaped = [];
47390
47565
  const ownedPrefix = (() => {
47391
47566
  try {
47392
- return (0, import_node_fs11.realpathSync)(opts.worktreeRoot);
47567
+ return (0, import_node_fs12.realpathSync)(opts.worktreeRoot);
47393
47568
  } catch {
47394
47569
  return opts.worktreeRoot;
47395
47570
  }
47396
- })() + import_node_path18.sep + opts.slug + import_node_path18.sep;
47571
+ })() + import_node_path19.sep + opts.slug + import_node_path19.sep;
47397
47572
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
47398
47573
  const listing = git(opts.checkout, ["worktree", "list", "--porcelain"]);
47399
47574
  for (const block of listing.split("\n\n")) {
@@ -47916,8 +48091,8 @@ function newArtifactId() {
47916
48091
  return `EA-${import_node_crypto7.default.randomUUID()}`;
47917
48092
  }
47918
48093
  var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
47919
- function isBlastRadiusFloorPath(path24) {
47920
- return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path24));
48094
+ function isBlastRadiusFloorPath(path25) {
48095
+ return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path25));
47921
48096
  }
47922
48097
  var execFileAsync = (0, import_node_util.promisify)(import_node_child_process12.execFile);
47923
48098
  async function defaultListRunDiffPaths(opts) {
@@ -49547,8 +49722,8 @@ async function runBackstopSweep(deps, drive = (slug, id) => driveRun(deps, slug,
49547
49722
  function isRunRecoverableByThisBridge(run3, worktreeRoot) {
49548
49723
  if (!worktreeRoot) return true;
49549
49724
  if (!run3.worktreeId) return false;
49550
- const relative = import_node_path19.default.relative(import_node_path19.default.resolve(worktreeRoot), import_node_path19.default.resolve(run3.worktreeId));
49551
- return relative === "" || relative.length > 0 && !relative.startsWith("..") && !import_node_path19.default.isAbsolute(relative);
49725
+ const relative = import_node_path20.default.relative(import_node_path20.default.resolve(worktreeRoot), import_node_path20.default.resolve(run3.worktreeId));
49726
+ return relative === "" || relative.length > 0 && !relative.startsWith("..") && !import_node_path20.default.isAbsolute(relative);
49552
49727
  }
49553
49728
  async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId) {
49554
49729
  await deps.client.updateExecutionRun(projectSlug, runId, { status: "failed", finishedAt: (/* @__PURE__ */ new Date()).toISOString(), leaseId: leaseId ?? void 0 }).catch(() => {
@@ -49597,9 +49772,9 @@ function getAsyncToolDescriptor(toolName) {
49597
49772
  }
49598
49773
 
49599
49774
  // src/bridge-log.ts
49600
- var import_node_fs12 = require("node:fs");
49775
+ var import_node_fs13 = require("node:fs");
49601
49776
  var import_promises7 = require("node:fs/promises");
49602
- var import_node_path20 = require("node:path");
49777
+ var import_node_path21 = require("node:path");
49603
49778
 
49604
49779
  // src/redact.ts
49605
49780
  var REDACTED = "[REDACTED]";
@@ -49875,14 +50050,14 @@ function resolvePromptsEnabled(env = process.env) {
49875
50050
  }
49876
50051
  function createBridgeLogger(stateDir, env = process.env) {
49877
50052
  if (!resolveBridgeLogEnabled(env)) return NOOP_LOGGER;
49878
- const logsDir = (0, import_node_path20.join)(stateDir, "logs");
50053
+ const logsDir = (0, import_node_path21.join)(stateDir, "logs");
49879
50054
  try {
49880
- (0, import_node_fs12.mkdirSync)(logsDir, { recursive: true });
50055
+ (0, import_node_fs13.mkdirSync)(logsDir, { recursive: true });
49881
50056
  } catch {
49882
50057
  return NOOP_LOGGER;
49883
50058
  }
49884
50059
  const includePrompts = resolvePromptsEnabled(env);
49885
- const fileFor = () => (0, import_node_path20.join)(logsDir, `bridge-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.jsonl`);
50060
+ const fileFor = () => (0, import_node_path21.join)(logsDir, `bridge-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.jsonl`);
49886
50061
  const MAX_TRACKED_SESSIONS = 64;
49887
50062
  const contextSlugBySession = /* @__PURE__ */ new Map();
49888
50063
  const rememberContextSlug = (sessionId, payload) => {
@@ -49923,10 +50098,10 @@ function createBridgeLogger(stateDir, env = process.env) {
49923
50098
  return { isGap, isNewTurn };
49924
50099
  };
49925
50100
  const gainDay = (sessionId) => {
49926
- const sessionsPath = (0, import_node_path20.join)(logsDir, ".sessions.json");
50101
+ const sessionsPath = (0, import_node_path21.join)(logsDir, ".sessions.json");
49927
50102
  let sessionsObj = {};
49928
50103
  try {
49929
- const parsed = JSON.parse((0, import_node_fs12.readFileSync)(sessionsPath, "utf8"));
50104
+ const parsed = JSON.parse((0, import_node_fs13.readFileSync)(sessionsPath, "utf8"));
49930
50105
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) sessionsObj = parsed;
49931
50106
  } catch {
49932
50107
  sessionsObj = {};
@@ -49936,8 +50111,8 @@ function createBridgeLogger(stateDir, env = process.env) {
49936
50111
  if (idsToday.includes(sessionId)) return;
49937
50112
  sessionsObj[day] = [...idsToday, sessionId];
49938
50113
  const tmpPath = `${sessionsPath}.tmp`;
49939
- (0, import_node_fs12.writeFileSync)(tmpPath, JSON.stringify(sessionsObj));
49940
- (0, import_node_fs12.renameSync)(tmpPath, sessionsPath);
50114
+ (0, import_node_fs13.writeFileSync)(tmpPath, JSON.stringify(sessionsObj));
50115
+ (0, import_node_fs13.renameSync)(tmpPath, sessionsPath);
49941
50116
  };
49942
50117
  const write = (dir, rec) => {
49943
50118
  try {
@@ -50028,7 +50203,7 @@ function createBridgeLogger(stateDir, env = process.env) {
50028
50203
  ...recordingObligationUnresolved ? { recordingObligationUnresolved } : {},
50029
50204
  ...recordingObligationMultiResolve ? { recordingObligationMultiResolve } : {}
50030
50205
  }) + "\n";
50031
- (0, import_node_fs12.appendFileSync)(fileFor(), line);
50206
+ (0, import_node_fs13.appendFileSync)(fileFor(), line);
50032
50207
  if (rec.sessionId !== null) gainDay(rec.sessionId);
50033
50208
  } catch {
50034
50209
  }
@@ -50041,7 +50216,7 @@ function createBridgeLogger(stateDir, env = process.env) {
50041
50216
  };
50042
50217
  }
50043
50218
  async function findSessionDays(stateDir, sessionId) {
50044
- const sessionsPath = (0, import_node_path20.join)(stateDir, "logs", ".sessions.json");
50219
+ const sessionsPath = (0, import_node_path21.join)(stateDir, "logs", ".sessions.json");
50045
50220
  let sessionsObj;
50046
50221
  try {
50047
50222
  const parsed = JSON.parse(await (0, import_promises7.readFile)(sessionsPath, "utf8"));
@@ -50223,12 +50398,12 @@ async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJo
50223
50398
  }
50224
50399
 
50225
50400
  // src/state-dir.ts
50226
- var import_node_os9 = __toESM(require("node:os"), 1);
50227
- var import_node_path21 = __toESM(require("node:path"), 1);
50401
+ var import_node_os10 = __toESM(require("node:os"), 1);
50402
+ var import_node_path22 = __toESM(require("node:path"), 1);
50228
50403
  function resolveStateDir(env = process.env) {
50229
50404
  const codexHome = env.CODEX_HOME;
50230
- if (codexHome) return import_node_path21.default.join(codexHome, "mrrlin", "director-bridge");
50231
- return import_node_path21.default.join(import_node_os9.default.homedir(), ".mrrlin", "director-bridge");
50405
+ if (codexHome) return import_node_path22.default.join(codexHome, "mrrlin", "director-bridge");
50406
+ return import_node_path22.default.join(import_node_os10.default.homedir(), ".mrrlin", "director-bridge");
50232
50407
  }
50233
50408
 
50234
50409
  // src/consensus/deliverable-gate.ts
@@ -50484,19 +50659,19 @@ function agentIdleMs(provider) {
50484
50659
  }
50485
50660
 
50486
50661
  // src/operator-token.ts
50487
- var import_node_fs13 = require("node:fs");
50488
- var import_node_os10 = __toESM(require("node:os"), 1);
50489
- var import_node_path22 = __toESM(require("node:path"), 1);
50662
+ var import_node_fs14 = require("node:fs");
50663
+ var import_node_os11 = __toESM(require("node:os"), 1);
50664
+ var import_node_path23 = __toESM(require("node:path"), 1);
50490
50665
  function operatorDir() {
50491
- const base = process.env.CODEX_HOME ? import_node_path22.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path22.default.join(import_node_os10.default.homedir(), ".mrrlin");
50666
+ const base = process.env.CODEX_HOME ? import_node_path23.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path23.default.join(import_node_os11.default.homedir(), ".mrrlin");
50492
50667
  return base;
50493
50668
  }
50494
50669
  function operatorTokenPath() {
50495
- return import_node_path22.default.join(operatorDir(), "operator-token");
50670
+ return import_node_path23.default.join(operatorDir(), "operator-token");
50496
50671
  }
50497
50672
  function readOperatorToken() {
50498
50673
  try {
50499
- const token = (0, import_node_fs13.readFileSync)(operatorTokenPath(), "utf8").trim();
50674
+ const token = (0, import_node_fs14.readFileSync)(operatorTokenPath(), "utf8").trim();
50500
50675
  return token.length > 0 ? token : null;
50501
50676
  } catch {
50502
50677
  return null;
@@ -50504,24 +50679,24 @@ function readOperatorToken() {
50504
50679
  }
50505
50680
  function persistOperatorToken(token) {
50506
50681
  const dir = operatorDir();
50507
- (0, import_node_fs13.mkdirSync)(dir, { recursive: true, mode: 448 });
50508
- (0, import_node_fs13.writeFileSync)(operatorTokenPath(), `${token.trim()}
50682
+ (0, import_node_fs14.mkdirSync)(dir, { recursive: true, mode: 448 });
50683
+ (0, import_node_fs14.writeFileSync)(operatorTokenPath(), `${token.trim()}
50509
50684
  `, { encoding: "utf8", mode: 384 });
50510
50685
  }
50511
50686
  function agentCredentialPath() {
50512
- return import_node_path22.default.join(operatorDir(), "agent-credential");
50687
+ return import_node_path23.default.join(operatorDir(), "agent-credential");
50513
50688
  }
50514
50689
  function persistAgentSecret(secret) {
50515
50690
  const dir = operatorDir();
50516
- (0, import_node_fs13.mkdirSync)(dir, { recursive: true, mode: 448 });
50517
- (0, import_node_fs13.writeFileSync)(agentCredentialPath(), `${secret.trim()}
50691
+ (0, import_node_fs14.mkdirSync)(dir, { recursive: true, mode: 448 });
50692
+ (0, import_node_fs14.writeFileSync)(agentCredentialPath(), `${secret.trim()}
50518
50693
  `, { encoding: "utf8", mode: 384 });
50519
50694
  }
50520
50695
  function readAgentSecret() {
50521
50696
  const fromEnv = process.env.MRRLIN_AGENT_SECRET?.trim();
50522
50697
  if (fromEnv) return fromEnv;
50523
50698
  try {
50524
- const raw = (0, import_node_fs13.readFileSync)(agentCredentialPath(), "utf8").trim();
50699
+ const raw = (0, import_node_fs14.readFileSync)(agentCredentialPath(), "utf8").trim();
50525
50700
  return raw || void 0;
50526
50701
  } catch {
50527
50702
  return void 0;
@@ -50529,16 +50704,16 @@ function readAgentSecret() {
50529
50704
  }
50530
50705
 
50531
50706
  // src/thread-index.ts
50532
- var import_node_fs14 = require("node:fs");
50533
- var import_node_path23 = __toESM(require("node:path"), 1);
50707
+ var import_node_fs15 = require("node:fs");
50708
+ var import_node_path24 = __toESM(require("node:path"), 1);
50534
50709
  function threadIndexPath(stateDir) {
50535
- return import_node_path23.default.join(stateDir, "threads.json");
50710
+ return import_node_path24.default.join(stateDir, "threads.json");
50536
50711
  }
50537
50712
  function loadThreadIndex(stateDir, ttlMs, now) {
50538
50713
  const result = /* @__PURE__ */ new Map();
50539
50714
  let parsed;
50540
50715
  try {
50541
- parsed = JSON.parse((0, import_node_fs14.readFileSync)(threadIndexPath(stateDir), "utf8"));
50716
+ parsed = JSON.parse((0, import_node_fs15.readFileSync)(threadIndexPath(stateDir), "utf8"));
50542
50717
  } catch {
50543
50718
  return result;
50544
50719
  }
@@ -50561,8 +50736,8 @@ function loadThreadIndex(stateDir, ttlMs, now) {
50561
50736
  return result;
50562
50737
  }
50563
50738
  function saveThreadIndex(stateDir, entries) {
50564
- (0, import_node_fs14.mkdirSync)(stateDir, { recursive: true, mode: 448 });
50565
- (0, import_node_fs14.writeFileSync)(threadIndexPath(stateDir), `${JSON.stringify(Object.fromEntries(entries), null, 2)}
50739
+ (0, import_node_fs15.mkdirSync)(stateDir, { recursive: true, mode: 448 });
50740
+ (0, import_node_fs15.writeFileSync)(threadIndexPath(stateDir), `${JSON.stringify(Object.fromEntries(entries), null, 2)}
50566
50741
  `, {
50567
50742
  encoding: "utf8",
50568
50743
  mode: 384
@@ -50698,9 +50873,9 @@ function createToolBusyClock(opts) {
50698
50873
 
50699
50874
  // src/worker-token.ts
50700
50875
  var import_node_crypto10 = require("node:crypto");
50701
- var import_node_fs15 = require("node:fs");
50702
- var import_node_os11 = __toESM(require("node:os"), 1);
50703
- var import_node_path24 = __toESM(require("node:path"), 1);
50876
+ var import_node_fs16 = require("node:fs");
50877
+ var import_node_os12 = __toESM(require("node:os"), 1);
50878
+ var import_node_path25 = __toESM(require("node:path"), 1);
50704
50879
  var DEFAULT_WORKER_PORT = 8792;
50705
50880
  function workerPort() {
50706
50881
  const raw = process.env.MRRLIN_WORKER_PORT;
@@ -50709,15 +50884,15 @@ function workerPort() {
50709
50884
  return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_WORKER_PORT;
50710
50885
  }
50711
50886
  function workerDir() {
50712
- const base = process.env.CODEX_HOME ? import_node_path24.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path24.default.join(import_node_os11.default.homedir(), ".mrrlin");
50713
- return import_node_path24.default.join(base, "worker");
50887
+ const base = process.env.CODEX_HOME ? import_node_path25.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path25.default.join(import_node_os12.default.homedir(), ".mrrlin");
50888
+ return import_node_path25.default.join(base, "worker");
50714
50889
  }
50715
50890
  function workerTokenPath() {
50716
- return import_node_path24.default.join(workerDir(), "token");
50891
+ return import_node_path25.default.join(workerDir(), "token");
50717
50892
  }
50718
50893
  function readWorkerToken() {
50719
50894
  try {
50720
- const token = (0, import_node_fs15.readFileSync)(workerTokenPath(), "utf8").trim();
50895
+ const token = (0, import_node_fs16.readFileSync)(workerTokenPath(), "utf8").trim();
50721
50896
  return token.length > 0 ? token : null;
50722
50897
  } catch {
50723
50898
  return null;
@@ -50727,18 +50902,18 @@ function readOrCreateWorkerToken() {
50727
50902
  const existing = readWorkerToken();
50728
50903
  if (existing) return existing;
50729
50904
  const dir = workerDir();
50730
- (0, import_node_fs15.mkdirSync)(dir, { recursive: true, mode: 448 });
50905
+ (0, import_node_fs16.mkdirSync)(dir, { recursive: true, mode: 448 });
50731
50906
  const token = (0, import_node_crypto10.randomBytes)(32).toString("hex");
50732
- (0, import_node_fs15.writeFileSync)(workerTokenPath(), `${token}
50907
+ (0, import_node_fs16.writeFileSync)(workerTokenPath(), `${token}
50733
50908
  `, { encoding: "utf8", mode: 384 });
50734
50909
  return token;
50735
50910
  }
50736
50911
 
50737
50912
  // src/remote-phone-relay.ts
50738
50913
  var import_node_events2 = require("node:events");
50739
- var import_node_fs16 = require("node:fs");
50740
- var import_node_os12 = require("node:os");
50741
- var import_node_path25 = require("node:path");
50914
+ var import_node_fs17 = require("node:fs");
50915
+ var import_node_os13 = require("node:os");
50916
+ var import_node_path26 = require("node:path");
50742
50917
 
50743
50918
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/cryptoNode.js
50744
50919
  var nc = __toESM(require("node:crypto"), 1);
@@ -54309,9 +54484,9 @@ var DirectorRelay = class {
54309
54484
 
54310
54485
  // src/remote-phone-relay.ts
54311
54486
  function loadOrCreateAgentDeviceKey() {
54312
- const path24 = (0, import_node_path25.join)((0, import_node_os12.homedir)(), ".mrrlin", "agent-device-key");
54487
+ const path25 = (0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin", "agent-device-key");
54313
54488
  try {
54314
- const raw = JSON.parse((0, import_node_fs16.readFileSync)(path24, "utf8"));
54489
+ const raw = JSON.parse((0, import_node_fs17.readFileSync)(path25, "utf8"));
54315
54490
  if (typeof raw.priv === "string" && typeof raw.pub === "string") {
54316
54491
  return { privateKey: fromBase64Url(raw.priv), publicKey: fromBase64Url(raw.pub) };
54317
54492
  }
@@ -54319,9 +54494,9 @@ function loadOrCreateAgentDeviceKey() {
54319
54494
  }
54320
54495
  const kp = generateIdentityKeyPair();
54321
54496
  try {
54322
- (0, import_node_fs16.mkdirSync)((0, import_node_path25.join)((0, import_node_os12.homedir)(), ".mrrlin"), { recursive: true });
54323
- (0, import_node_fs16.writeFileSync)(
54324
- path24,
54497
+ (0, import_node_fs17.mkdirSync)((0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin"), { recursive: true });
54498
+ (0, import_node_fs17.writeFileSync)(
54499
+ path25,
54325
54500
  JSON.stringify({ priv: toBase64Url(kp.privateKey), pub: toBase64Url(kp.publicKey) }),
54326
54501
  { mode: 384 }
54327
54502
  );
@@ -54329,10 +54504,10 @@ function loadOrCreateAgentDeviceKey() {
54329
54504
  }
54330
54505
  return kp;
54331
54506
  }
54332
- var AGENT_PAIRING_PATH = (0, import_node_path25.join)((0, import_node_os12.homedir)(), ".mrrlin", "agent-pairing.json");
54507
+ var AGENT_PAIRING_PATH = (0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin", "agent-pairing.json");
54333
54508
  function loadAgentPairing() {
54334
54509
  try {
54335
- const raw = JSON.parse((0, import_node_fs16.readFileSync)(AGENT_PAIRING_PATH, "utf8"));
54510
+ const raw = JSON.parse((0, import_node_fs17.readFileSync)(AGENT_PAIRING_PATH, "utf8"));
54336
54511
  if (typeof raw.channelId === "string" && typeof raw.agentControlSecret === "string" && typeof raw.relayAuth === "string" && typeof raw.peerIdentityKey === "string") {
54337
54512
  return {
54338
54513
  channelId: raw.channelId,
@@ -54347,8 +54522,8 @@ function loadAgentPairing() {
54347
54522
  }
54348
54523
  function saveAgentPairing(record2) {
54349
54524
  try {
54350
- (0, import_node_fs16.mkdirSync)((0, import_node_path25.join)((0, import_node_os12.homedir)(), ".mrrlin"), { recursive: true });
54351
- (0, import_node_fs16.writeFileSync)(AGENT_PAIRING_PATH, JSON.stringify(record2), { mode: 384 });
54525
+ (0, import_node_fs17.mkdirSync)((0, import_node_path26.join)((0, import_node_os13.homedir)(), ".mrrlin"), { recursive: true });
54526
+ (0, import_node_fs17.writeFileSync)(AGENT_PAIRING_PATH, JSON.stringify(record2), { mode: 384 });
54352
54527
  } catch {
54353
54528
  }
54354
54529
  }
@@ -54526,18 +54701,18 @@ async function renderPairingQrSvg(payload) {
54526
54701
  }
54527
54702
 
54528
54703
  // src/checkout-registry.ts
54529
- var import_node_fs17 = require("node:fs");
54530
- var import_node_path26 = require("node:path");
54704
+ var import_node_fs18 = require("node:fs");
54705
+ var import_node_path27 = require("node:path");
54531
54706
  var CheckoutRegistry = class {
54532
54707
  file;
54533
54708
  constructor(stateDir) {
54534
- this.file = (0, import_node_path26.join)(stateDir, "checkouts.json");
54535
- (0, import_node_fs17.mkdirSync)(stateDir, { recursive: true });
54709
+ this.file = (0, import_node_path27.join)(stateDir, "checkouts.json");
54710
+ (0, import_node_fs18.mkdirSync)(stateDir, { recursive: true });
54536
54711
  }
54537
54712
  read() {
54538
- if (!(0, import_node_fs17.existsSync)(this.file)) return {};
54713
+ if (!(0, import_node_fs18.existsSync)(this.file)) return {};
54539
54714
  try {
54540
- return JSON.parse((0, import_node_fs17.readFileSync)(this.file, "utf8"));
54715
+ return JSON.parse((0, import_node_fs18.readFileSync)(this.file, "utf8"));
54541
54716
  } catch {
54542
54717
  return {};
54543
54718
  }
@@ -54545,10 +54720,10 @@ var CheckoutRegistry = class {
54545
54720
  get(slug) {
54546
54721
  return this.read()[slug] ?? null;
54547
54722
  }
54548
- confirm(slug, path24, now) {
54723
+ confirm(slug, path25, now) {
54549
54724
  const all = this.read();
54550
- all[slug] = { path: path24, confirmedAt: now };
54551
- (0, import_node_fs17.writeFileSync)(this.file, JSON.stringify(all, null, 2));
54725
+ all[slug] = { path: path25, confirmedAt: now };
54726
+ (0, import_node_fs18.writeFileSync)(this.file, JSON.stringify(all, null, 2));
54552
54727
  }
54553
54728
  /**
54554
54729
  * Task 5.2 (github-via-capabilities): another slug whose registered path resolves, via
@@ -54571,14 +54746,14 @@ var CheckoutRegistry = class {
54571
54746
  if (!own) return null;
54572
54747
  let ownReal;
54573
54748
  try {
54574
- ownReal = (0, import_node_fs17.realpathSync)(own.path);
54749
+ ownReal = (0, import_node_fs18.realpathSync)(own.path);
54575
54750
  } catch {
54576
54751
  return null;
54577
54752
  }
54578
54753
  for (const [otherSlug, entry] of Object.entries(this.read())) {
54579
54754
  if (otherSlug === slug) continue;
54580
54755
  try {
54581
- if ((0, import_node_fs17.realpathSync)(entry.path) === ownReal) return otherSlug;
54756
+ if ((0, import_node_fs18.realpathSync)(entry.path) === ownReal) return otherSlug;
54582
54757
  } catch {
54583
54758
  continue;
54584
54759
  }
@@ -54589,7 +54764,7 @@ var CheckoutRegistry = class {
54589
54764
 
54590
54765
  // src/checkout-handlers.ts
54591
54766
  var import_node_child_process13 = require("node:child_process");
54592
- var import_node_fs18 = require("node:fs");
54767
+ var import_node_fs19 = require("node:fs");
54593
54768
 
54594
54769
  // src/git-remote-match.ts
54595
54770
  function normalizeRemote(url2) {
@@ -54624,7 +54799,7 @@ function validateCheckoutPath(checkoutPath, repo) {
54624
54799
  }
54625
54800
  let resolvedPath;
54626
54801
  try {
54627
- resolvedPath = (0, import_node_fs18.realpathSync)(trimmedPath);
54802
+ resolvedPath = (0, import_node_fs19.realpathSync)(trimmedPath);
54628
54803
  } catch {
54629
54804
  return {
54630
54805
  ok: false,
@@ -54930,9 +55105,9 @@ function extractVerificationSection(markdown) {
54930
55105
  }
54931
55106
 
54932
55107
  // src/director-reseed.ts
54933
- var import_node_fs19 = require("node:fs");
55108
+ var import_node_fs20 = require("node:fs");
54934
55109
  var import_node_readline = require("node:readline");
54935
- var import_node_path27 = require("node:path");
55110
+ var import_node_path28 = require("node:path");
54936
55111
  function estimateTokens(s) {
54937
55112
  return Buffer.byteLength(s, "utf8");
54938
55113
  }
@@ -55064,9 +55239,9 @@ async function readSessionRows(logsDir, files, sessionIds) {
55064
55239
  const lines2 = [];
55065
55240
  let missingFiles = 0;
55066
55241
  for (const f of files) {
55067
- const filePath = (0, import_node_path27.join)(logsDir, f);
55242
+ const filePath = (0, import_node_path28.join)(logsDir, f);
55068
55243
  try {
55069
- const stream = (0, import_node_fs19.createReadStream)(filePath, { encoding: "utf8" });
55244
+ const stream = (0, import_node_fs20.createReadStream)(filePath, { encoding: "utf8" });
55070
55245
  const rl = (0, import_node_readline.createInterface)({ input: stream, crlfDelay: Infinity });
55071
55246
  try {
55072
55247
  for await (const line of rl) {
@@ -55090,18 +55265,18 @@ async function readSessionRows(logsDir, files, sessionIds) {
55090
55265
  }
55091
55266
 
55092
55267
  // src/external-agents-scrub.ts
55093
- var import_node_fs20 = __toESM(require("node:fs"), 1);
55094
- var import_node_os13 = __toESM(require("node:os"), 1);
55095
- var import_node_path28 = __toESM(require("node:path"), 1);
55268
+ var import_node_fs21 = __toESM(require("node:fs"), 1);
55269
+ var import_node_os14 = __toESM(require("node:os"), 1);
55270
+ var import_node_path29 = __toESM(require("node:path"), 1);
55096
55271
  var REDACTION = "[REDACTED]";
55097
55272
  var SHORT_VALUE_THRESHOLD = 8;
55098
- var KEYS_ENV_PATH = () => import_node_path28.default.join(import_node_os13.default.homedir(), ".local", "state", "external-agents", "keys.env");
55273
+ var KEYS_ENV_PATH = () => import_node_path29.default.join(import_node_os14.default.homedir(), ".local", "state", "external-agents", "keys.env");
55099
55274
  var keysEnvCache = null;
55100
55275
  function readKeysEnv() {
55101
55276
  const filePath = KEYS_ENV_PATH();
55102
55277
  let mtimeMs = 0;
55103
55278
  try {
55104
- mtimeMs = import_node_fs20.default.statSync(filePath).mtimeMs;
55279
+ mtimeMs = import_node_fs21.default.statSync(filePath).mtimeMs;
55105
55280
  } catch {
55106
55281
  mtimeMs = 0;
55107
55282
  }
@@ -55110,7 +55285,7 @@ function readKeysEnv() {
55110
55285
  }
55111
55286
  const map2 = /* @__PURE__ */ new Map();
55112
55287
  try {
55113
- const content = import_node_fs20.default.readFileSync(filePath, "utf8");
55288
+ const content = import_node_fs21.default.readFileSync(filePath, "utf8");
55114
55289
  for (const rawLine of content.split(/\r?\n/)) {
55115
55290
  const line = rawLine.trim();
55116
55291
  if (line === "" || line.startsWith("#")) continue;
@@ -55528,7 +55703,7 @@ function addBridgeModel(target, model) {
55528
55703
  }
55529
55704
  function readTextIfExists(filePath) {
55530
55705
  try {
55531
- return import_node_fs21.default.readFileSync(filePath, "utf8");
55706
+ return import_node_fs22.default.readFileSync(filePath, "utf8");
55532
55707
  } catch {
55533
55708
  return null;
55534
55709
  }
@@ -55539,9 +55714,9 @@ function readKnownGptSlugsFromTomlFile(filePath) {
55539
55714
  return Array.from(raw.matchAll(/^\s*model\s*=\s*"([^"]+)"/gm)).map((match) => match[1]?.trim() ?? "").filter(isSelectableModelSlug);
55540
55715
  }
55541
55716
  function readCodexFallbackModels() {
55542
- const codexHome = process.env.CODEX_HOME?.trim() || import_node_path29.default.join(import_node_os14.default.homedir(), ".codex");
55717
+ const codexHome = process.env.CODEX_HOME?.trim() || import_node_path30.default.join(import_node_os15.default.homedir(), ".codex");
55543
55718
  const models = /* @__PURE__ */ new Map();
55544
- const cachePath = import_node_path29.default.join(codexHome, "models_cache.json");
55719
+ const cachePath = import_node_path30.default.join(codexHome, "models_cache.json");
55545
55720
  const cacheRaw = readTextIfExists(cachePath);
55546
55721
  if (cacheRaw) {
55547
55722
  try {
@@ -55591,7 +55766,7 @@ function readCodexFallbackModels() {
55591
55766
  );
55592
55767
  }
55593
55768
  }
55594
- for (const slug of readKnownGptSlugsFromTomlFile(import_node_path29.default.join(codexHome, "config.toml"))) {
55769
+ for (const slug of readKnownGptSlugsFromTomlFile(import_node_path30.default.join(codexHome, "config.toml"))) {
55595
55770
  addBridgeModel(
55596
55771
  models,
55597
55772
  mapBridgeModel({
@@ -55605,11 +55780,11 @@ function readCodexFallbackModels() {
55605
55780
  })
55606
55781
  );
55607
55782
  }
55608
- const automationsDir = import_node_path29.default.join(codexHome, "automations");
55783
+ const automationsDir = import_node_path30.default.join(codexHome, "automations");
55609
55784
  try {
55610
- for (const entry of import_node_fs21.default.readdirSync(automationsDir, { withFileTypes: true })) {
55785
+ for (const entry of import_node_fs22.default.readdirSync(automationsDir, { withFileTypes: true })) {
55611
55786
  if (!entry.isDirectory()) continue;
55612
- for (const slug of readKnownGptSlugsFromTomlFile(import_node_path29.default.join(automationsDir, entry.name, "automation.toml"))) {
55787
+ for (const slug of readKnownGptSlugsFromTomlFile(import_node_path30.default.join(automationsDir, entry.name, "automation.toml"))) {
55613
55788
  addBridgeModel(
55614
55789
  models,
55615
55790
  mapBridgeModel({
@@ -55635,9 +55810,9 @@ function selfUpdateInboxItemId(offeredVersion) {
55635
55810
  return `II-MCPUPD-${offeredVersion.replace(/[^A-Za-z0-9._-]/g, "-")}-${hash3}`;
55636
55811
  }
55637
55812
  function neutralCheckoutCwd(stateDir) {
55638
- const dir = import_node_path29.default.join(stateDir, "no-checkout");
55813
+ const dir = import_node_path30.default.join(stateDir, "no-checkout");
55639
55814
  try {
55640
- import_node_fs21.default.mkdirSync(dir, { recursive: true });
55815
+ import_node_fs22.default.mkdirSync(dir, { recursive: true });
55641
55816
  } catch {
55642
55817
  }
55643
55818
  return dir;
@@ -56147,7 +56322,7 @@ async function runOrphanWorktreeSweep(client, opts) {
56147
56322
  const cutoff = Date.now() - worktreeRetentionMs();
56148
56323
  const isReapable = (worktreePath) => {
56149
56324
  try {
56150
- return import_node_fs21.default.statSync(worktreePath).mtimeMs < cutoff;
56325
+ return import_node_fs22.default.statSync(worktreePath).mtimeMs < cutoff;
56151
56326
  } catch {
56152
56327
  return false;
56153
56328
  }
@@ -56623,7 +56798,7 @@ function createBridgeMessageHandler(deps) {
56623
56798
  sendForSpan({ type: "checkout-state", ok: false, error: { code: "invalid_input", fields: { projectSlug: "required" } } });
56624
56799
  return;
56625
56800
  }
56626
- const state = readCheckoutState(deps.checkoutRegistry, projectSlug, import_node_os14.default.hostname());
56801
+ const state = readCheckoutState(deps.checkoutRegistry, projectSlug, import_node_os15.default.hostname());
56627
56802
  if (!state) {
56628
56803
  sendForSpan({ type: "checkout-state", ok: false, error: { code: "checkout_missing" } });
56629
56804
  return;
@@ -56655,7 +56830,7 @@ function createBridgeMessageHandler(deps) {
56655
56830
  const result = registerCheckout(
56656
56831
  deps.checkoutRegistry,
56657
56832
  { projectSlug, path: typeof msg.path === "string" ? msg.path : "", repo },
56658
- import_node_os14.default.hostname()
56833
+ import_node_os15.default.hostname()
56659
56834
  );
56660
56835
  if (!result.ok) {
56661
56836
  sendForSpan({ type: "checkout-register", ok: false, error: { code: result.code, detail: result.detail } });
@@ -57371,7 +57546,7 @@ function createBridgeMessageHandler(deps) {
57371
57546
  if (effectiveText.length > 0) {
57372
57547
  const updateOffer = deps.maybeUpdateOffer ? deps.maybeUpdateOffer() : null;
57373
57548
  const updateOfferProjectSlug = msg.context?.projectSlug?.trim();
57374
- if (updateOffer !== null && updateOfferProjectSlug && deps.fileUpdateInboxItem) {
57549
+ if (updateOffer !== null && !updateOffer.startsWith(SELF_UPDATE_AUTH_PREFLIGHT_OFFER_PREFIX) && updateOfferProjectSlug && deps.fileUpdateInboxItem) {
57375
57550
  void deps.fileUpdateInboxItem(updateOfferProjectSlug);
57376
57551
  }
57377
57552
  let reseedPrefix = null;
@@ -57757,8 +57932,8 @@ async function startDirectorBridge() {
57757
57932
  codexCwd: config2.codexCwd,
57758
57933
  codexExecutable: config2.codexExecutable,
57759
57934
  checkoutRegistry,
57760
- worktreeRoot: import_node_path29.default.join(config2.stateDir, "worktrees"),
57761
- locksDir: import_node_path29.default.join(config2.stateDir, "locks"),
57935
+ worktreeRoot: import_node_path30.default.join(config2.stateDir, "worktrees"),
57936
+ locksDir: import_node_path30.default.join(config2.stateDir, "locks"),
57762
57937
  // Wire the executor server for code-execution runs. Each run gets its own provider process
57763
57938
  // (app-server for codex, a resident CLI child for claude) at the run worktree, running
57764
57939
  // UNRESTRICTED from the real operator config (owner no-sandbox decision — auth + mrrlin MCP
@@ -57802,13 +57977,13 @@ async function startDirectorBridge() {
57802
57977
  // egressDomains is retained in the seam signature (verification-turn.ts still computes the
57803
57978
  // env host) but no longer constrains anything — the executor is unrestricted.
57804
57979
  startSandbox: async (_egressDomains, providerId) => {
57805
- const cwd = import_node_fs21.default.mkdtempSync(import_node_path29.default.join(import_node_os14.default.tmpdir(), "mrrlin-verify-"));
57980
+ const cwd = import_node_fs22.default.mkdtempSync(import_node_path30.default.join(import_node_os15.default.tmpdir(), "mrrlin-verify-"));
57806
57981
  let executor;
57807
57982
  try {
57808
57983
  executor = await startExecutorServer({ worktree: cwd, provider: providerId });
57809
57984
  } catch (error51) {
57810
57985
  try {
57811
- import_node_fs21.default.rmSync(cwd, { recursive: true, force: true });
57986
+ import_node_fs22.default.rmSync(cwd, { recursive: true, force: true });
57812
57987
  } catch {
57813
57988
  }
57814
57989
  throw error51;
@@ -57819,7 +57994,7 @@ async function startDirectorBridge() {
57819
57994
  dispose: () => {
57820
57995
  executor.dispose();
57821
57996
  try {
57822
- import_node_fs21.default.rmSync(cwd, { recursive: true, force: true });
57997
+ import_node_fs22.default.rmSync(cwd, { recursive: true, force: true });
57823
57998
  } catch {
57824
57999
  }
57825
58000
  }
@@ -58030,7 +58205,7 @@ async function startDirectorBridge() {
58030
58205
  }
58031
58206
  const files = dayFilesInWindow(/* @__PURE__ */ new Date(), reseedWindowMs);
58032
58207
  const sessionIds = [args.directorSessionId, ...args.priorSessionIds];
58033
- const { lines: lines2, missingFiles } = await readSessionRows(import_node_path29.default.join(config2.stateDir, "logs"), files, sessionIds);
58208
+ const { lines: lines2, missingFiles } = await readSessionRows(import_node_path30.default.join(config2.stateDir, "logs"), files, sessionIds);
58034
58209
  const { items, skipped: skipped2 } = extractItems(lines2, sessionIds);
58035
58210
  if (items.length === 0) return refuse2("no-rows");
58036
58211
  const budget = Math.max(0, Math.min(config2.reseedMaxTokens, config2.turnMaxTokens - args.otherBytes));
@@ -58137,7 +58312,7 @@ async function startDirectorBridge() {
58137
58312
  const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
58138
58313
  let bridgeBinShaShort = "unknown00000";
58139
58314
  try {
58140
- bridgeBinShaShort = import_node_crypto11.default.createHash("sha256").update(import_node_fs21.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
58315
+ bridgeBinShaShort = import_node_crypto11.default.createHash("sha256").update(import_node_fs22.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
58141
58316
  } catch {
58142
58317
  }
58143
58318
  attachBridgeWss(server, {
@@ -58273,8 +58448,8 @@ async function startDirectorBridge() {
58273
58448
  );
58274
58449
  void runOrphanWorktreeSweep(client, {
58275
58450
  checkoutRegistry,
58276
- worktreeRoot: import_node_path29.default.join(config2.stateDir, "worktrees"),
58277
- locksDir: import_node_path29.default.join(config2.stateDir, "locks")
58451
+ worktreeRoot: import_node_path30.default.join(config2.stateDir, "worktrees"),
58452
+ locksDir: import_node_path30.default.join(config2.stateDir, "locks")
58278
58453
  });
58279
58454
  {
58280
58455
  const { retainedBuffers, retainedBytes, tombstonesRemoved } = sweepReplayBuffers(threads, tombstones, {
@@ -58599,15 +58774,15 @@ function readDispatchBody(req) {
58599
58774
  function readOrCreateBridgeToken(stateDir) {
58600
58775
  const explicit = (process.env.MRRLIN_DIRECTOR_BRIDGE_TOKEN ?? "").trim();
58601
58776
  if (explicit) return explicit;
58602
- const tokenPath = import_node_path29.default.join(stateDir, "token.txt");
58777
+ const tokenPath = import_node_path30.default.join(stateDir, "token.txt");
58603
58778
  try {
58604
- const existing = import_node_fs21.default.readFileSync(tokenPath, "utf8").trim();
58779
+ const existing = import_node_fs22.default.readFileSync(tokenPath, "utf8").trim();
58605
58780
  if (existing) return existing;
58606
58781
  } catch {
58607
58782
  }
58608
- import_node_fs21.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
58783
+ import_node_fs22.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
58609
58784
  const token = import_node_crypto11.default.randomBytes(32).toString("base64url");
58610
- import_node_fs21.default.writeFileSync(tokenPath, `${token}
58785
+ import_node_fs22.default.writeFileSync(tokenPath, `${token}
58611
58786
  `, { mode: 384 });
58612
58787
  return token;
58613
58788
  }
@@ -61998,15 +62173,15 @@ var StdioServerTransport = class {
61998
62173
  // src/tools.ts
61999
62174
  var import_node_crypto14 = require("node:crypto");
62000
62175
  var import_promises10 = require("node:fs/promises");
62001
- var import_node_path32 = __toESM(require("node:path"), 1);
62002
- var import_node_os15 = __toESM(require("node:os"), 1);
62176
+ var import_node_path33 = __toESM(require("node:path"), 1);
62177
+ var import_node_os16 = __toESM(require("node:os"), 1);
62003
62178
 
62004
62179
  // ../../packages/wiki/dist/index.js
62005
62180
  var import_promises8 = __toESM(require("node:fs/promises"), 1);
62006
- var import_node_path30 = __toESM(require("node:path"), 1);
62181
+ var import_node_path31 = __toESM(require("node:path"), 1);
62007
62182
  var INCLUDED_DOC_FOLDERS = /* @__PURE__ */ new Set(["_meta", "explanation", "how-to", "reference", "sdd", "tutorials"]);
62008
62183
  function toPosixPath(input) {
62009
- return input.split(import_node_path30.default.sep).join("/");
62184
+ return input.split(import_node_path31.default.sep).join("/");
62010
62185
  }
62011
62186
  function slugifyWikiSegment(input) {
62012
62187
  return input.trim().toLowerCase().replace(/`/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
@@ -62020,12 +62195,12 @@ async function pathExists3(input) {
62020
62195
  }
62021
62196
  }
62022
62197
  async function findWorkspaceRoot(start = process.cwd()) {
62023
- let current2 = import_node_path30.default.resolve(start);
62198
+ let current2 = import_node_path31.default.resolve(start);
62024
62199
  while (true) {
62025
- if (await pathExists3(import_node_path30.default.join(current2, "pnpm-workspace.yaml")) && await pathExists3(import_node_path30.default.join(current2, "docs"))) {
62200
+ if (await pathExists3(import_node_path31.default.join(current2, "pnpm-workspace.yaml")) && await pathExists3(import_node_path31.default.join(current2, "docs"))) {
62026
62201
  return current2;
62027
62202
  }
62028
- const parent = import_node_path30.default.dirname(current2);
62203
+ const parent = import_node_path31.default.dirname(current2);
62029
62204
  if (parent === current2) {
62030
62205
  throw new Error(`Unable to find Mrrlin workspace root from ${start}`);
62031
62206
  }
@@ -62034,28 +62209,28 @@ async function findWorkspaceRoot(start = process.cwd()) {
62034
62209
  }
62035
62210
  async function resolveDocsRoot(input) {
62036
62211
  if (input) {
62037
- return import_node_path30.default.resolve(input);
62212
+ return import_node_path31.default.resolve(input);
62038
62213
  }
62039
62214
  if (process.env.MRRLIN_DOCS_ROOT) {
62040
- return import_node_path30.default.resolve(process.env.MRRLIN_DOCS_ROOT);
62215
+ return import_node_path31.default.resolve(process.env.MRRLIN_DOCS_ROOT);
62041
62216
  }
62042
- return import_node_path30.default.join(await findWorkspaceRoot(), "docs");
62217
+ return import_node_path31.default.join(await findWorkspaceRoot(), "docs");
62043
62218
  }
62044
62219
  async function resolveIndexPath(input) {
62045
62220
  if (input) {
62046
- return import_node_path30.default.resolve(input);
62221
+ return import_node_path31.default.resolve(input);
62047
62222
  }
62048
62223
  if (process.env.MRRLIN_WIKI_INDEX_PATH) {
62049
- return import_node_path30.default.resolve(process.env.MRRLIN_WIKI_INDEX_PATH);
62224
+ return import_node_path31.default.resolve(process.env.MRRLIN_WIKI_INDEX_PATH);
62050
62225
  }
62051
62226
  const workspaceRoot = await findWorkspaceRoot();
62052
- return import_node_path30.default.join(workspaceRoot, "apps", "web", "public", "wiki-index.json");
62227
+ return import_node_path31.default.join(workspaceRoot, "apps", "web", "public", "wiki-index.json");
62053
62228
  }
62054
62229
  async function walkMarkdownFiles(root, dir = root) {
62055
62230
  const entries = await import_promises8.default.readdir(dir, { withFileTypes: true });
62056
62231
  const files = [];
62057
62232
  for (const entry of entries) {
62058
- const absolute = import_node_path30.default.join(dir, entry.name);
62233
+ const absolute = import_node_path31.default.join(dir, entry.name);
62059
62234
  if (entry.isDirectory()) {
62060
62235
  files.push(...await walkMarkdownFiles(root, absolute));
62061
62236
  continue;
@@ -62074,7 +62249,7 @@ function parseTitle(markdown, sourcePath) {
62074
62249
  return title;
62075
62250
  }
62076
62251
  function documentFromFile(docsRoot, absolutePath, markdown) {
62077
- const relativePath = toPosixPath(import_node_path30.default.relative(docsRoot, absolutePath));
62252
+ const relativePath = toPosixPath(import_node_path31.default.relative(docsRoot, absolutePath));
62078
62253
  const [section, fileName] = relativePath.split("/");
62079
62254
  if (!section || !fileName || !INCLUDED_DOC_FOLDERS.has(section)) {
62080
62255
  return null;
@@ -66340,7 +66515,7 @@ var intentCheckDescriptor = createIntentCheckDescriptor();
66340
66515
 
66341
66516
  // src/evidence/assembler.ts
66342
66517
  var import_promises9 = require("node:fs/promises");
66343
- var import_node_path31 = require("node:path");
66518
+ var import_node_path32 = require("node:path");
66344
66519
  function evidenceDedupKey(sessionId, reportId) {
66345
66520
  return `${sessionId}:${reportId}`;
66346
66521
  }
@@ -66350,7 +66525,7 @@ function isRecord7(v) {
66350
66525
  async function readDayLines(stateDir, day, sessionId) {
66351
66526
  let raw;
66352
66527
  try {
66353
- raw = await (0, import_promises9.readFile)((0, import_node_path31.join)(stateDir, "logs", `bridge-${day}.jsonl`), "utf8");
66528
+ raw = await (0, import_promises9.readFile)((0, import_node_path32.join)(stateDir, "logs", `bridge-${day}.jsonl`), "utf8");
66354
66529
  } catch {
66355
66530
  return [];
66356
66531
  }
@@ -66424,7 +66599,7 @@ async function assembleEvidence(stateDir, sessionId, reportId, gateCtx) {
66424
66599
  }
66425
66600
  let windowPruned = false;
66426
66601
  try {
66427
- const raw = await (0, import_promises9.readFile)((0, import_node_path31.join)(stateDir, "logs", ".pruned.jsonl"), "utf8");
66602
+ const raw = await (0, import_promises9.readFile)((0, import_node_path32.join)(stateDir, "logs", ".pruned.jsonl"), "utf8");
66428
66603
  outer: for (const line of raw.split("\n")) {
66429
66604
  if (!line.trim()) continue;
66430
66605
  let rec;
@@ -68237,7 +68412,7 @@ function createMrrlinTools(options) {
68237
68412
  "ARTIFACT_FILE_UPLOAD_FAILED",
68238
68413
  "Unable to upload artifact file.",
68239
68414
  async (c, { projectSlug, path: filePath, class: artifactClass, taskId, runId, description }) => {
68240
- const extension2 = import_node_path32.default.extname(filePath).toLowerCase();
68415
+ const extension2 = import_node_path33.default.extname(filePath).toLowerCase();
68241
68416
  const contentType = ARTIFACT_EXTENSION_TYPES[extension2];
68242
68417
  if (!contentType) {
68243
68418
  throw new McpToolCodedError(
@@ -68265,7 +68440,7 @@ function createMrrlinTools(options) {
68265
68440
  "Artifact exceeds 5MB; split or summarize instead."
68266
68441
  );
68267
68442
  }
68268
- const filename = import_node_path32.default.basename(filePath);
68443
+ const filename = import_node_path33.default.basename(filePath);
68269
68444
  return deliverBuiltIn(
68270
68445
  c,
68271
68446
  projectSlug,
@@ -68287,7 +68462,7 @@ function createMrrlinTools(options) {
68287
68462
  `Invalid filename '${filename}'; provide a bare filename with no path separators or '..'.`
68288
68463
  );
68289
68464
  }
68290
- const extension2 = import_node_path32.default.extname(filename).toLowerCase();
68465
+ const extension2 = import_node_path33.default.extname(filename).toLowerCase();
68291
68466
  const contentType = ARTIFACT_EXTENSION_TYPES[extension2];
68292
68467
  if (!contentType) {
68293
68468
  throw new McpToolCodedError(
@@ -68359,7 +68534,7 @@ function createMrrlinTools(options) {
68359
68534
  "Unable to register local checkout.",
68360
68535
  async (_c, { projectSlug, path: checkoutPath, repo }) => {
68361
68536
  const registry3 = new CheckoutRegistry(resolveStateDir());
68362
- const result = registerCheckout(registry3, { projectSlug, path: checkoutPath, repo }, import_node_os15.default.hostname());
68537
+ const result = registerCheckout(registry3, { projectSlug, path: checkoutPath, repo }, import_node_os16.default.hostname());
68363
68538
  if (!result.ok) {
68364
68539
  const codeMap = {
68365
68540
  not_absolute: "LOCAL_CHECKOUT_PATH_NOT_ABSOLUTE",
@@ -68596,9 +68771,9 @@ function runSetCredential(args) {
68596
68771
  }
68597
68772
 
68598
68773
  // src/install-service.ts
68599
- var import_node_os16 = __toESM(require("node:os"), 1);
68600
- var import_node_fs22 = require("node:fs");
68601
- var import_node_path33 = __toESM(require("node:path"), 1);
68774
+ var import_node_os17 = __toESM(require("node:os"), 1);
68775
+ var import_node_fs23 = require("node:fs");
68776
+ var import_node_path34 = __toESM(require("node:path"), 1);
68602
68777
  function readExistingTelemetryDefaultProject(deps, ecoPath) {
68603
68778
  try {
68604
68779
  const existing = deps.readFile?.(ecoPath);
@@ -68658,7 +68833,7 @@ function deriveServiceApiTarget(deps, ecoPath) {
68658
68833
  var SYSTEM_PATH_DIRS = ["/usr/bin", "/bin", "/usr/sbin", "/sbin"];
68659
68834
  function defaultHomeOwnerUid(home) {
68660
68835
  try {
68661
- return (0, import_node_fs22.statSync)(home).uid;
68836
+ return (0, import_node_fs23.statSync)(home).uid;
68662
68837
  } catch {
68663
68838
  return null;
68664
68839
  }
@@ -68699,11 +68874,11 @@ function installService(deps) {
68699
68874
  deps.log(resolved.reason);
68700
68875
  return { ok: false };
68701
68876
  }
68702
- const home = deps.env.HOME ?? import_node_os16.default.homedir();
68877
+ const home = deps.env.HOME ?? import_node_os17.default.homedir();
68703
68878
  const user = resolveBridgeUser({
68704
68879
  env: deps.env,
68705
68880
  home,
68706
- userInfo: deps.userInfo ?? (() => import_node_os16.default.userInfo()),
68881
+ userInfo: deps.userInfo ?? (() => import_node_os17.default.userInfo()),
68707
68882
  homeOwnerUid: deps.homeOwnerUid ?? defaultHomeOwnerUid,
68708
68883
  log: deps.log
68709
68884
  });
@@ -68719,9 +68894,9 @@ function installService(deps) {
68719
68894
  const claudeBin = deps.which("claude");
68720
68895
  const resolvedBins = [...bins, claudeBin].filter((b) => b !== null);
68721
68896
  const pathEnv = Array.from(
68722
- /* @__PURE__ */ new Set([...resolvedBins.map((b) => import_node_path33.default.dirname(b)), ...SYSTEM_PATH_DIRS])
68897
+ /* @__PURE__ */ new Set([...resolvedBins.map((b) => import_node_path34.default.dirname(b)), ...SYSTEM_PATH_DIRS])
68723
68898
  ).join(":");
68724
- const ecoPath = import_node_path33.default.join(home, ".mrrlin", "ecosystem.config.cjs");
68899
+ const ecoPath = import_node_path34.default.join(home, ".mrrlin", "ecosystem.config.cjs");
68725
68900
  const apiTarget = deriveServiceApiTarget(deps, ecoPath);
68726
68901
  const telemetryDefaultProject = "MRRLIN_TELEMETRY_DEFAULT_PROJECT" in deps.env ? deps.env.MRRLIN_TELEMETRY_DEFAULT_PROJECT?.trim() || void 0 : readExistingTelemetryDefaultProject(deps, ecoPath);
68727
68902
  const text = renderEcosystemConfig({
@@ -68785,13 +68960,13 @@ function uninstallService(deps) {
68785
68960
 
68786
68961
  // src/uninstall-codex.ts
68787
68962
  var import_promises11 = __toESM(require("node:fs/promises"), 1);
68788
- var import_node_os17 = __toESM(require("node:os"), 1);
68789
- var import_node_path34 = __toESM(require("node:path"), 1);
68963
+ var import_node_os18 = __toESM(require("node:os"), 1);
68964
+ var import_node_path35 = __toESM(require("node:path"), 1);
68790
68965
  var toml3 = __toESM(require_toml(), 1);
68791
68966
  function resolveCodexHome3(options) {
68792
68967
  if (options.codexHome) return options.codexHome;
68793
68968
  if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
68794
- return import_node_path34.default.join(options.homeDir ?? import_node_os17.default.homedir(), ".codex");
68969
+ return import_node_path35.default.join(options.homeDir ?? import_node_os18.default.homedir(), ".codex");
68795
68970
  }
68796
68971
  async function pathExists4(target) {
68797
68972
  try {
@@ -68804,7 +68979,7 @@ async function pathExists4(target) {
68804
68979
  var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.(?:mrrlin(?:-browser)?|external-agents)(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
68805
68980
  async function uninstallCodex(options = {}) {
68806
68981
  const codexHome = resolveCodexHome3(options);
68807
- const configPath = import_node_path34.default.join(codexHome, "config.toml");
68982
+ const configPath = import_node_path35.default.join(codexHome, "config.toml");
68808
68983
  const removePrompts = async () => uninstallPrompts(codexHome, options.promptNames ?? []);
68809
68984
  if (!await pathExists4(configPath)) {
68810
68985
  return { action: "missing", configPath, prompts: await removePrompts() };
@@ -68832,10 +69007,10 @@ async function uninstallCodex(options = {}) {
68832
69007
  }
68833
69008
  async function uninstallPrompts(codexHome, names) {
68834
69009
  if (names.length === 0) return [];
68835
- const promptsDir = import_node_path34.default.join(codexHome, "prompts");
69010
+ const promptsDir = import_node_path35.default.join(codexHome, "prompts");
68836
69011
  const out = [];
68837
69012
  for (const name of names) {
68838
- const promptPath = import_node_path34.default.join(promptsDir, `${name}.md`);
69013
+ const promptPath = import_node_path35.default.join(promptsDir, `${name}.md`);
68839
69014
  try {
68840
69015
  await import_promises11.default.unlink(promptPath);
68841
69016
  out.push({ name, action: "removed", promptPath });
@@ -68853,7 +69028,7 @@ async function uninstallPrompts(codexHome, names) {
68853
69028
 
68854
69029
  // src/extract/command.ts
68855
69030
  var import_promises12 = require("node:fs/promises");
68856
- var import_node_path35 = require("node:path");
69031
+ var import_node_path36 = require("node:path");
68857
69032
  function parseArgs(args) {
68858
69033
  const map2 = /* @__PURE__ */ new Map();
68859
69034
  for (let i = 0; i < args.length; i++) {
@@ -68890,7 +69065,7 @@ Missing required flag(s): ${missing.join(
68890
69065
  const days = await findSessionDays(deps.stateDir, sessionId);
68891
69066
  const matchingLines = [];
68892
69067
  for (const day of days) {
68893
- const logPath = (0, import_node_path35.join)(deps.stateDir, "logs", `bridge-${day}.jsonl`);
69068
+ const logPath = (0, import_node_path36.join)(deps.stateDir, "logs", `bridge-${day}.jsonl`);
68894
69069
  let raw;
68895
69070
  try {
68896
69071
  raw = await (0, import_promises12.readFile)(logPath, "utf8");
@@ -68990,16 +69165,16 @@ function bootHookStatus() {
68990
69165
  if (process.platform !== "darwin") return { status: "unknown" };
68991
69166
  const uid = process.getuid?.();
68992
69167
  if (uid === void 0 || uid === 0) return { status: "unknown" };
68993
- const home = process.env.HOME ?? (0, import_node_os18.homedir)();
68994
- const agents = import_node_path37.default.join(home, "Library", "LaunchAgents");
69168
+ const home = process.env.HOME ?? (0, import_node_os19.homedir)();
69169
+ const agents = import_node_path38.default.join(home, "Library", "LaunchAgents");
68995
69170
  const candidates = [
68996
- { label: "com.mrrlin.director-bridge", plist: import_node_path37.default.join(agents, "com.mrrlin.director-bridge.plist") },
68997
- { label: "com.PM2", plist: import_node_path37.default.join(agents, `pm2.${(0, import_node_os18.userInfo)().username}.plist`) }
69171
+ { label: "com.mrrlin.director-bridge", plist: import_node_path38.default.join(agents, "com.mrrlin.director-bridge.plist") },
69172
+ { label: "com.PM2", plist: import_node_path38.default.join(agents, `pm2.${(0, import_node_os19.userInfo)().username}.plist`) }
68998
69173
  ];
68999
69174
  for (const candidate of candidates) {
69000
69175
  const printed = (0, import_node_child_process18.spawnSync)("launchctl", ["print", `gui/${uid}/${candidate.label}`], { encoding: "utf8" });
69001
69176
  if (printed.status !== 0) continue;
69002
- if (!(0, import_node_fs23.existsSync)(candidate.plist)) continue;
69177
+ if (!(0, import_node_fs24.existsSync)(candidate.plist)) continue;
69003
69178
  const out = printed.stdout ?? "";
69004
69179
  const runs = /^\s*runs\s*=\s*(\d+)/m.exec(out);
69005
69180
  const exitCode = /^\s*last exit code\s*=\s*(-?\d+)/m.exec(out);
@@ -69284,8 +69459,8 @@ async function main() {
69284
69459
  }
69285
69460
  }
69286
69461
  try {
69287
- const codexHome = process.env.CODEX_HOME ?? import_node_path37.default.join(process.env.HOME ?? (0, import_node_os18.homedir)(), ".codex");
69288
- (0, import_node_fs23.rmSync)(import_node_path37.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
69462
+ const codexHome = process.env.CODEX_HOME ?? import_node_path38.default.join(process.env.HOME ?? (0, import_node_os19.homedir)(), ".codex");
69463
+ (0, import_node_fs24.rmSync)(import_node_path38.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
69289
69464
  } catch {
69290
69465
  }
69291
69466
  const claudeResult = await installClaude({ binPath, force, serveEnv });
@@ -69346,15 +69521,15 @@ async function main() {
69346
69521
  env: process.env,
69347
69522
  cwd: process.cwd(),
69348
69523
  writeFile: (p, c) => {
69349
- (0, import_node_fs23.mkdirSync)(import_node_path37.default.dirname(p), { recursive: true, mode: 448 });
69350
- (0, import_node_fs23.writeFileSync)(p, c, { mode: 384 });
69524
+ (0, import_node_fs24.mkdirSync)(import_node_path38.default.dirname(p), { recursive: true, mode: 448 });
69525
+ (0, import_node_fs24.writeFileSync)(p, c, { mode: 384 });
69351
69526
  },
69352
69527
  // Swallows every error on purpose — the only caller uses this to recover settings from the
69353
69528
  // config it is about to overwrite, and a missing or unreadable file means "no previous
69354
69529
  // value", never a failed install. See readExistingTelemetryDefaultProject.
69355
69530
  readFile: (p) => {
69356
69531
  try {
69357
- return (0, import_node_fs23.readFileSync)(p, "utf8");
69532
+ return (0, import_node_fs24.readFileSync)(p, "utf8");
69358
69533
  } catch {
69359
69534
  return null;
69360
69535
  }
@@ -69375,35 +69550,35 @@ async function main() {
69375
69550
  runPm2: (a) => ({ code: pm2Runner(a).code }),
69376
69551
  removeFile: (p) => {
69377
69552
  try {
69378
- (0, import_node_fs23.rmSync)(p, { force: true });
69553
+ (0, import_node_fs24.rmSync)(p, { force: true });
69379
69554
  } catch {
69380
69555
  }
69381
69556
  },
69382
69557
  purgeSecret: purge,
69383
69558
  secretPath: agentCredentialPath(),
69384
69559
  tokenPath: operatorTokenPath(),
69385
- ecoPath: import_node_path37.default.join(process.env.HOME ?? (0, import_node_os18.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
69560
+ ecoPath: import_node_path38.default.join(process.env.HOME ?? (0, import_node_os19.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
69386
69561
  log: (m) => process.stderr.write(`[mrrlin-mcp uninstall-service] ${m}
69387
69562
  `)
69388
69563
  });
69389
69564
  return;
69390
69565
  }
69391
69566
  case "uninstall": {
69392
- const home = process.env.HOME ?? (0, import_node_os18.homedir)();
69567
+ const home = process.env.HOME ?? (0, import_node_os19.homedir)();
69393
69568
  const log = (m) => process.stderr.write(`[mrrlin-mcp uninstall] ${m}
69394
69569
  `);
69395
69570
  uninstallService({
69396
69571
  runPm2: (a) => ({ code: pm2Runner(a).code }),
69397
69572
  removeFile: (p) => {
69398
69573
  try {
69399
- (0, import_node_fs23.rmSync)(p, { force: true });
69574
+ (0, import_node_fs24.rmSync)(p, { force: true });
69400
69575
  } catch {
69401
69576
  }
69402
69577
  },
69403
69578
  purgeSecret: true,
69404
69579
  secretPath: agentCredentialPath(),
69405
69580
  tokenPath: operatorTokenPath(),
69406
- ecoPath: import_node_path37.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
69581
+ ecoPath: import_node_path38.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
69407
69582
  log
69408
69583
  });
69409
69584
  let codexOk = true;
@@ -69423,7 +69598,7 @@ async function main() {
69423
69598
  log(`codex config NOT modified: ${error51 instanceof Error ? error51.message : String(error51)}`);
69424
69599
  }
69425
69600
  try {
69426
- (0, import_node_fs23.rmSync)(import_node_path37.default.join(home, ".mrrlin"), { recursive: true, force: true });
69601
+ (0, import_node_fs24.rmSync)(import_node_path38.default.join(home, ".mrrlin"), { recursive: true, force: true });
69427
69602
  } catch {
69428
69603
  }
69429
69604
  log("removed ~/.mrrlin");
@@ -69464,7 +69639,7 @@ ${HELP_TEXT}`);
69464
69639
  }
69465
69640
  }
69466
69641
  function resolveSelfBinPath() {
69467
- return import_node_path36.default.resolve(process.argv[1] ?? process.execPath);
69642
+ return import_node_path37.default.resolve(process.argv[1] ?? process.execPath);
69468
69643
  }
69469
69644
  main().catch((error51) => {
69470
69645
  process.stderr.write(`mrrlin-mcp fatal error: ${error51 instanceof Error ? error51.message : String(error51)}