@mrrlin-dev/mcp 0.4.115 → 0.4.117

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 +1073 -521
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -5258,8 +5258,8 @@ var require_utils = __commonJS({
5258
5258
  }
5259
5259
  return ind;
5260
5260
  }
5261
- function removeDotSegments(path31) {
5262
- let input = path31;
5261
+ function removeDotSegments(path33) {
5262
+ let input = path33;
5263
5263
  const output3 = [];
5264
5264
  let nextSlash = -1;
5265
5265
  let len = 0;
@@ -5668,8 +5668,8 @@ var require_schemes = __commonJS({
5668
5668
  }
5669
5669
  if (wsComponent.resourceName) {
5670
5670
  const queryIndex = wsComponent.resourceName.indexOf("?");
5671
- const path31 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
5672
- wsComponent.path = path31 && path31 !== "/" ? path31 : void 0;
5671
+ const path33 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
5672
+ wsComponent.path = path33 && path33 !== "/" ? path33 : void 0;
5673
5673
  wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
5674
5674
  wsComponent.resourceName = void 0;
5675
5675
  }
@@ -9305,7 +9305,7 @@ var require_windows = __commonJS({
9305
9305
  module2.exports = isexe;
9306
9306
  isexe.sync = sync;
9307
9307
  var fs16 = require("fs");
9308
- function checkPathExt(path31, options) {
9308
+ function checkPathExt(path33, options) {
9309
9309
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
9310
9310
  if (!pathext) {
9311
9311
  return true;
@@ -9316,25 +9316,25 @@ var require_windows = __commonJS({
9316
9316
  }
9317
9317
  for (var i = 0; i < pathext.length; i++) {
9318
9318
  var p = pathext[i].toLowerCase();
9319
- if (p && path31.substr(-p.length).toLowerCase() === p) {
9319
+ if (p && path33.substr(-p.length).toLowerCase() === p) {
9320
9320
  return true;
9321
9321
  }
9322
9322
  }
9323
9323
  return false;
9324
9324
  }
9325
- function checkStat(stat3, path31, options) {
9325
+ function checkStat(stat3, path33, options) {
9326
9326
  if (!stat3.isSymbolicLink() && !stat3.isFile()) {
9327
9327
  return false;
9328
9328
  }
9329
- return checkPathExt(path31, options);
9329
+ return checkPathExt(path33, options);
9330
9330
  }
9331
- function isexe(path31, options, cb) {
9332
- fs16.stat(path31, function(er, stat3) {
9333
- cb(er, er ? false : checkStat(stat3, path31, options));
9331
+ function isexe(path33, options, cb) {
9332
+ fs16.stat(path33, function(er, stat3) {
9333
+ cb(er, er ? false : checkStat(stat3, path33, options));
9334
9334
  });
9335
9335
  }
9336
- function sync(path31, options) {
9337
- return checkStat(fs16.statSync(path31), path31, options);
9336
+ function sync(path33, options) {
9337
+ return checkStat(fs16.statSync(path33), path33, options);
9338
9338
  }
9339
9339
  }
9340
9340
  });
@@ -9345,13 +9345,13 @@ var require_mode = __commonJS({
9345
9345
  module2.exports = isexe;
9346
9346
  isexe.sync = sync;
9347
9347
  var fs16 = require("fs");
9348
- function isexe(path31, options, cb) {
9349
- fs16.stat(path31, function(er, stat3) {
9348
+ function isexe(path33, options, cb) {
9349
+ fs16.stat(path33, function(er, stat3) {
9350
9350
  cb(er, er ? false : checkStat(stat3, options));
9351
9351
  });
9352
9352
  }
9353
- function sync(path31, options) {
9354
- return checkStat(fs16.statSync(path31), options);
9353
+ function sync(path33, options) {
9354
+ return checkStat(fs16.statSync(path33), options);
9355
9355
  }
9356
9356
  function checkStat(stat3, options) {
9357
9357
  return stat3.isFile() && checkMode(stat3, options);
@@ -9384,7 +9384,7 @@ var require_isexe = __commonJS({
9384
9384
  }
9385
9385
  module2.exports = isexe;
9386
9386
  isexe.sync = sync;
9387
- function isexe(path31, options, cb) {
9387
+ function isexe(path33, options, cb) {
9388
9388
  if (typeof options === "function") {
9389
9389
  cb = options;
9390
9390
  options = {};
@@ -9394,7 +9394,7 @@ var require_isexe = __commonJS({
9394
9394
  throw new TypeError("callback not provided");
9395
9395
  }
9396
9396
  return new Promise(function(resolve2, reject) {
9397
- isexe(path31, options || {}, function(er, is) {
9397
+ isexe(path33, options || {}, function(er, is) {
9398
9398
  if (er) {
9399
9399
  reject(er);
9400
9400
  } else {
@@ -9403,7 +9403,7 @@ var require_isexe = __commonJS({
9403
9403
  });
9404
9404
  });
9405
9405
  }
9406
- core(path31, options || {}, function(er, is) {
9406
+ core(path33, options || {}, function(er, is) {
9407
9407
  if (er) {
9408
9408
  if (er.code === "EACCES" || options && options.ignoreErrors) {
9409
9409
  er = null;
@@ -9413,9 +9413,9 @@ var require_isexe = __commonJS({
9413
9413
  cb(er, is);
9414
9414
  });
9415
9415
  }
9416
- function sync(path31, options) {
9416
+ function sync(path33, options) {
9417
9417
  try {
9418
- return core.sync(path31, options || {});
9418
+ return core.sync(path33, options || {});
9419
9419
  } catch (er) {
9420
9420
  if (options && options.ignoreErrors || er.code === "EACCES") {
9421
9421
  return false;
@@ -9431,7 +9431,7 @@ var require_isexe = __commonJS({
9431
9431
  var require_which = __commonJS({
9432
9432
  "../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports2, module2) {
9433
9433
  var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
9434
- var path31 = require("path");
9434
+ var path33 = require("path");
9435
9435
  var COLON = isWindows ? ";" : ":";
9436
9436
  var isexe = require_isexe();
9437
9437
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -9469,7 +9469,7 @@ var require_which = __commonJS({
9469
9469
  return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
9470
9470
  const ppRaw = pathEnv[i];
9471
9471
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
9472
- const pCmd = path31.join(pathPart, cmd);
9472
+ const pCmd = path33.join(pathPart, cmd);
9473
9473
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
9474
9474
  resolve2(subStep(p, i, 0));
9475
9475
  });
@@ -9496,7 +9496,7 @@ var require_which = __commonJS({
9496
9496
  for (let i = 0; i < pathEnv.length; i++) {
9497
9497
  const ppRaw = pathEnv[i];
9498
9498
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
9499
- const pCmd = path31.join(pathPart, cmd);
9499
+ const pCmd = path33.join(pathPart, cmd);
9500
9500
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
9501
9501
  for (let j = 0; j < pathExt.length; j++) {
9502
9502
  const cur = p + pathExt[j];
@@ -9544,7 +9544,7 @@ var require_path_key = __commonJS({
9544
9544
  var require_resolveCommand = __commonJS({
9545
9545
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
9546
9546
  "use strict";
9547
- var path31 = require("path");
9547
+ var path33 = require("path");
9548
9548
  var which = require_which();
9549
9549
  var getPathKey = require_path_key();
9550
9550
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -9562,7 +9562,7 @@ var require_resolveCommand = __commonJS({
9562
9562
  try {
9563
9563
  resolved = which.sync(parsed.command, {
9564
9564
  path: env[getPathKey({ env })],
9565
- pathExt: withoutPathExt ? path31.delimiter : void 0
9565
+ pathExt: withoutPathExt ? path33.delimiter : void 0
9566
9566
  });
9567
9567
  } catch (e) {
9568
9568
  } finally {
@@ -9571,7 +9571,7 @@ var require_resolveCommand = __commonJS({
9571
9571
  }
9572
9572
  }
9573
9573
  if (resolved) {
9574
- resolved = path31.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
9574
+ resolved = path33.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
9575
9575
  }
9576
9576
  return resolved;
9577
9577
  }
@@ -9625,8 +9625,8 @@ var require_shebang_command = __commonJS({
9625
9625
  if (!match) {
9626
9626
  return null;
9627
9627
  }
9628
- const [path31, argument] = match[0].replace(/#! ?/, "").split(" ");
9629
- const binary = path31.split("/").pop();
9628
+ const [path33, argument] = match[0].replace(/#! ?/, "").split(" ");
9629
+ const binary = path33.split("/").pop();
9630
9630
  if (binary === "env") {
9631
9631
  return argument;
9632
9632
  }
@@ -9661,7 +9661,7 @@ var require_readShebang = __commonJS({
9661
9661
  var require_parse2 = __commonJS({
9662
9662
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
9663
9663
  "use strict";
9664
- var path31 = require("path");
9664
+ var path33 = require("path");
9665
9665
  var resolveCommand = require_resolveCommand();
9666
9666
  var escape2 = require_escape();
9667
9667
  var readShebang = require_readShebang();
@@ -9686,7 +9686,7 @@ var require_parse2 = __commonJS({
9686
9686
  const needsShell = !isExecutableRegExp.test(commandFile);
9687
9687
  if (parsed.options.forceShell || needsShell) {
9688
9688
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
9689
- parsed.command = path31.normalize(parsed.command);
9689
+ parsed.command = path33.normalize(parsed.command);
9690
9690
  parsed.command = escape2.command(parsed.command);
9691
9691
  parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
9692
9692
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -9782,7 +9782,7 @@ var require_cross_spawn = __commonJS({
9782
9782
  enoent.hookChildProcess(spawned, parsed);
9783
9783
  return spawned;
9784
9784
  }
9785
- function spawnSync8(command, args, options) {
9785
+ function spawnSync9(command, args, options) {
9786
9786
  const parsed = parse8(command, args, options);
9787
9787
  const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
9788
9788
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
@@ -9790,7 +9790,7 @@ var require_cross_spawn = __commonJS({
9790
9790
  }
9791
9791
  module2.exports = spawn8;
9792
9792
  module2.exports.spawn = spawn8;
9793
- module2.exports.sync = spawnSync8;
9793
+ module2.exports.sync = spawnSync9;
9794
9794
  module2.exports._parse = parse8;
9795
9795
  module2.exports._enoent = enoent;
9796
9796
  }
@@ -14017,7 +14017,7 @@ var require_websocket = __commonJS({
14017
14017
  var http4 = require("http");
14018
14018
  var net3 = require("net");
14019
14019
  var tls2 = require("tls");
14020
- var { randomBytes: randomBytes5, createHash: createHash6 } = require("crypto");
14020
+ var { randomBytes: randomBytes5, createHash: createHash7 } = require("crypto");
14021
14021
  var { Duplex, Readable } = require("stream");
14022
14022
  var { URL: URL2 } = require("url");
14023
14023
  var PerMessageDeflate2 = require_permessage_deflate();
@@ -14685,7 +14685,7 @@ var require_websocket = __commonJS({
14685
14685
  abortHandshake(websocket, socket, "Invalid Upgrade header");
14686
14686
  return;
14687
14687
  }
14688
- const digest = createHash6("sha1").update(key + GUID).digest("base64");
14688
+ const digest = createHash7("sha1").update(key + GUID).digest("base64");
14689
14689
  if (res.headers["sec-websocket-accept"] !== digest) {
14690
14690
  abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
14691
14691
  return;
@@ -15054,7 +15054,7 @@ var require_websocket_server = __commonJS({
15054
15054
  var EventEmitter3 = require("events");
15055
15055
  var http4 = require("http");
15056
15056
  var { Duplex } = require("stream");
15057
- var { createHash: createHash6 } = require("crypto");
15057
+ var { createHash: createHash7 } = require("crypto");
15058
15058
  var extension2 = require_extension();
15059
15059
  var PerMessageDeflate2 = require_permessage_deflate();
15060
15060
  var subprotocol2 = require_subprotocol();
@@ -15361,7 +15361,7 @@ var require_websocket_server = __commonJS({
15361
15361
  );
15362
15362
  }
15363
15363
  if (this._state > RUNNING) return abortHandshake(socket, 503);
15364
- const digest = createHash6("sha1").update(key + GUID).digest("base64");
15364
+ const digest = createHash7("sha1").update(key + GUID).digest("base64");
15365
15365
  const headers = [
15366
15366
  "HTTP/1.1 101 Switching Protocols",
15367
15367
  "Upgrade: websocket",
@@ -15500,14 +15500,14 @@ var require_polyfills = __commonJS({
15500
15500
  fs16.fstatSync = statFixSync(fs16.fstatSync);
15501
15501
  fs16.lstatSync = statFixSync(fs16.lstatSync);
15502
15502
  if (fs16.chmod && !fs16.lchmod) {
15503
- fs16.lchmod = function(path31, mode, cb) {
15503
+ fs16.lchmod = function(path33, mode, cb) {
15504
15504
  if (cb) process.nextTick(cb);
15505
15505
  };
15506
15506
  fs16.lchmodSync = function() {
15507
15507
  };
15508
15508
  }
15509
15509
  if (fs16.chown && !fs16.lchown) {
15510
- fs16.lchown = function(path31, uid, gid, cb) {
15510
+ fs16.lchown = function(path33, uid, gid, cb) {
15511
15511
  if (cb) process.nextTick(cb);
15512
15512
  };
15513
15513
  fs16.lchownSync = function() {
@@ -15574,9 +15574,9 @@ var require_polyfills = __commonJS({
15574
15574
  };
15575
15575
  }(fs16.readSync);
15576
15576
  function patchLchmod(fs17) {
15577
- fs17.lchmod = function(path31, mode, callback) {
15577
+ fs17.lchmod = function(path33, mode, callback) {
15578
15578
  fs17.open(
15579
- path31,
15579
+ path33,
15580
15580
  constants2.O_WRONLY | constants2.O_SYMLINK,
15581
15581
  mode,
15582
15582
  function(err, fd) {
@@ -15592,8 +15592,8 @@ var require_polyfills = __commonJS({
15592
15592
  }
15593
15593
  );
15594
15594
  };
15595
- fs17.lchmodSync = function(path31, mode) {
15596
- var fd = fs17.openSync(path31, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
15595
+ fs17.lchmodSync = function(path33, mode) {
15596
+ var fd = fs17.openSync(path33, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
15597
15597
  var threw = true;
15598
15598
  var ret;
15599
15599
  try {
@@ -15614,8 +15614,8 @@ var require_polyfills = __commonJS({
15614
15614
  }
15615
15615
  function patchLutimes(fs17) {
15616
15616
  if (constants2.hasOwnProperty("O_SYMLINK") && fs17.futimes) {
15617
- fs17.lutimes = function(path31, at, mt, cb) {
15618
- fs17.open(path31, constants2.O_SYMLINK, function(er, fd) {
15617
+ fs17.lutimes = function(path33, at, mt, cb) {
15618
+ fs17.open(path33, constants2.O_SYMLINK, function(er, fd) {
15619
15619
  if (er) {
15620
15620
  if (cb) cb(er);
15621
15621
  return;
@@ -15627,8 +15627,8 @@ var require_polyfills = __commonJS({
15627
15627
  });
15628
15628
  });
15629
15629
  };
15630
- fs17.lutimesSync = function(path31, at, mt) {
15631
- var fd = fs17.openSync(path31, constants2.O_SYMLINK);
15630
+ fs17.lutimesSync = function(path33, at, mt) {
15631
+ var fd = fs17.openSync(path33, constants2.O_SYMLINK);
15632
15632
  var ret;
15633
15633
  var threw = true;
15634
15634
  try {
@@ -15746,11 +15746,11 @@ var require_legacy_streams = __commonJS({
15746
15746
  ReadStream,
15747
15747
  WriteStream
15748
15748
  };
15749
- function ReadStream(path31, options) {
15750
- if (!(this instanceof ReadStream)) return new ReadStream(path31, options);
15749
+ function ReadStream(path33, options) {
15750
+ if (!(this instanceof ReadStream)) return new ReadStream(path33, options);
15751
15751
  Stream.call(this);
15752
15752
  var self = this;
15753
- this.path = path31;
15753
+ this.path = path33;
15754
15754
  this.fd = null;
15755
15755
  this.readable = true;
15756
15756
  this.paused = false;
@@ -15795,10 +15795,10 @@ var require_legacy_streams = __commonJS({
15795
15795
  self._read();
15796
15796
  });
15797
15797
  }
15798
- function WriteStream(path31, options) {
15799
- if (!(this instanceof WriteStream)) return new WriteStream(path31, options);
15798
+ function WriteStream(path33, options) {
15799
+ if (!(this instanceof WriteStream)) return new WriteStream(path33, options);
15800
15800
  Stream.call(this);
15801
- this.path = path31;
15801
+ this.path = path33;
15802
15802
  this.fd = null;
15803
15803
  this.writable = true;
15804
15804
  this.flags = "w";
@@ -15909,14 +15909,14 @@ var require_graceful_fs = __commonJS({
15909
15909
  return close;
15910
15910
  }(fs16.close);
15911
15911
  fs16.closeSync = function(fs$closeSync) {
15912
- function closeSync(fd) {
15912
+ function closeSync2(fd) {
15913
15913
  fs$closeSync.apply(fs16, arguments);
15914
15914
  resetQueue();
15915
15915
  }
15916
- Object.defineProperty(closeSync, previousSymbol, {
15916
+ Object.defineProperty(closeSync2, previousSymbol, {
15917
15917
  value: fs$closeSync
15918
15918
  });
15919
- return closeSync;
15919
+ return closeSync2;
15920
15920
  }(fs16.closeSync);
15921
15921
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
15922
15922
  process.on("exit", function() {
@@ -15941,14 +15941,14 @@ var require_graceful_fs = __commonJS({
15941
15941
  fs17.createWriteStream = createWriteStream;
15942
15942
  var fs$readFile = fs17.readFile;
15943
15943
  fs17.readFile = readFile9;
15944
- function readFile9(path31, options, cb) {
15944
+ function readFile9(path33, options, cb) {
15945
15945
  if (typeof options === "function")
15946
15946
  cb = options, options = null;
15947
- return go$readFile(path31, options, cb);
15948
- function go$readFile(path32, options2, cb2, startTime) {
15949
- return fs$readFile(path32, options2, function(err) {
15947
+ return go$readFile(path33, options, cb);
15948
+ function go$readFile(path34, options2, cb2, startTime) {
15949
+ return fs$readFile(path34, options2, function(err) {
15950
15950
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
15951
- enqueue([go$readFile, [path32, options2, cb2], err, startTime || Date.now(), Date.now()]);
15951
+ enqueue([go$readFile, [path34, options2, cb2], err, startTime || Date.now(), Date.now()]);
15952
15952
  else {
15953
15953
  if (typeof cb2 === "function")
15954
15954
  cb2.apply(this, arguments);
@@ -15958,14 +15958,14 @@ var require_graceful_fs = __commonJS({
15958
15958
  }
15959
15959
  var fs$writeFile = fs17.writeFile;
15960
15960
  fs17.writeFile = writeFile5;
15961
- function writeFile5(path31, data, options, cb) {
15961
+ function writeFile5(path33, data, options, cb) {
15962
15962
  if (typeof options === "function")
15963
15963
  cb = options, options = null;
15964
- return go$writeFile(path31, data, options, cb);
15965
- function go$writeFile(path32, data2, options2, cb2, startTime) {
15966
- return fs$writeFile(path32, data2, options2, function(err) {
15964
+ return go$writeFile(path33, data, options, cb);
15965
+ function go$writeFile(path34, data2, options2, cb2, startTime) {
15966
+ return fs$writeFile(path34, data2, options2, function(err) {
15967
15967
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
15968
- enqueue([go$writeFile, [path32, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
15968
+ enqueue([go$writeFile, [path34, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
15969
15969
  else {
15970
15970
  if (typeof cb2 === "function")
15971
15971
  cb2.apply(this, arguments);
@@ -15976,14 +15976,14 @@ var require_graceful_fs = __commonJS({
15976
15976
  var fs$appendFile = fs17.appendFile;
15977
15977
  if (fs$appendFile)
15978
15978
  fs17.appendFile = appendFile2;
15979
- function appendFile2(path31, data, options, cb) {
15979
+ function appendFile2(path33, data, options, cb) {
15980
15980
  if (typeof options === "function")
15981
15981
  cb = options, options = null;
15982
- return go$appendFile(path31, data, options, cb);
15983
- function go$appendFile(path32, data2, options2, cb2, startTime) {
15984
- return fs$appendFile(path32, data2, options2, function(err) {
15982
+ return go$appendFile(path33, data, options, cb);
15983
+ function go$appendFile(path34, data2, options2, cb2, startTime) {
15984
+ return fs$appendFile(path34, data2, options2, function(err) {
15985
15985
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
15986
- enqueue([go$appendFile, [path32, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
15986
+ enqueue([go$appendFile, [path34, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
15987
15987
  else {
15988
15988
  if (typeof cb2 === "function")
15989
15989
  cb2.apply(this, arguments);
@@ -16014,31 +16014,31 @@ var require_graceful_fs = __commonJS({
16014
16014
  var fs$readdir = fs17.readdir;
16015
16015
  fs17.readdir = readdir5;
16016
16016
  var noReaddirOptionVersions = /^v[0-5]\./;
16017
- function readdir5(path31, options, cb) {
16017
+ function readdir5(path33, options, cb) {
16018
16018
  if (typeof options === "function")
16019
16019
  cb = options, options = null;
16020
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path32, options2, cb2, startTime) {
16021
- return fs$readdir(path32, fs$readdirCallback(
16022
- path32,
16020
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path34, options2, cb2, startTime) {
16021
+ return fs$readdir(path34, fs$readdirCallback(
16022
+ path34,
16023
16023
  options2,
16024
16024
  cb2,
16025
16025
  startTime
16026
16026
  ));
16027
- } : function go$readdir2(path32, options2, cb2, startTime) {
16028
- return fs$readdir(path32, options2, fs$readdirCallback(
16029
- path32,
16027
+ } : function go$readdir2(path34, options2, cb2, startTime) {
16028
+ return fs$readdir(path34, options2, fs$readdirCallback(
16029
+ path34,
16030
16030
  options2,
16031
16031
  cb2,
16032
16032
  startTime
16033
16033
  ));
16034
16034
  };
16035
- return go$readdir(path31, options, cb);
16036
- function fs$readdirCallback(path32, options2, cb2, startTime) {
16035
+ return go$readdir(path33, options, cb);
16036
+ function fs$readdirCallback(path34, options2, cb2, startTime) {
16037
16037
  return function(err, files) {
16038
16038
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
16039
16039
  enqueue([
16040
16040
  go$readdir,
16041
- [path32, options2, cb2],
16041
+ [path34, options2, cb2],
16042
16042
  err,
16043
16043
  startTime || Date.now(),
16044
16044
  Date.now()
@@ -16109,7 +16109,7 @@ var require_graceful_fs = __commonJS({
16109
16109
  enumerable: true,
16110
16110
  configurable: true
16111
16111
  });
16112
- function ReadStream(path31, options) {
16112
+ function ReadStream(path33, options) {
16113
16113
  if (this instanceof ReadStream)
16114
16114
  return fs$ReadStream.apply(this, arguments), this;
16115
16115
  else
@@ -16129,7 +16129,7 @@ var require_graceful_fs = __commonJS({
16129
16129
  }
16130
16130
  });
16131
16131
  }
16132
- function WriteStream(path31, options) {
16132
+ function WriteStream(path33, options) {
16133
16133
  if (this instanceof WriteStream)
16134
16134
  return fs$WriteStream.apply(this, arguments), this;
16135
16135
  else
@@ -16147,22 +16147,22 @@ var require_graceful_fs = __commonJS({
16147
16147
  }
16148
16148
  });
16149
16149
  }
16150
- function createReadStream2(path31, options) {
16151
- return new fs17.ReadStream(path31, options);
16150
+ function createReadStream2(path33, options) {
16151
+ return new fs17.ReadStream(path33, options);
16152
16152
  }
16153
- function createWriteStream(path31, options) {
16154
- return new fs17.WriteStream(path31, options);
16153
+ function createWriteStream(path33, options) {
16154
+ return new fs17.WriteStream(path33, options);
16155
16155
  }
16156
16156
  var fs$open = fs17.open;
16157
16157
  fs17.open = open;
16158
- function open(path31, flags, mode, cb) {
16158
+ function open(path33, flags, mode, cb) {
16159
16159
  if (typeof mode === "function")
16160
16160
  cb = mode, mode = null;
16161
- return go$open(path31, flags, mode, cb);
16162
- function go$open(path32, flags2, mode2, cb2, startTime) {
16163
- return fs$open(path32, flags2, mode2, function(err, fd) {
16161
+ return go$open(path33, flags, mode, cb);
16162
+ function go$open(path34, flags2, mode2, cb2, startTime) {
16163
+ return fs$open(path34, flags2, mode2, function(err, fd) {
16164
16164
  if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
16165
- enqueue([go$open, [path32, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
16165
+ enqueue([go$open, [path34, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
16166
16166
  else {
16167
16167
  if (typeof cb2 === "function")
16168
16168
  cb2.apply(this, arguments);
@@ -16691,7 +16691,7 @@ var require_mtime_precision = __commonJS({
16691
16691
  var require_lockfile = __commonJS({
16692
16692
  "../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/lockfile.js"(exports2, module2) {
16693
16693
  "use strict";
16694
- var path31 = require("path");
16694
+ var path33 = require("path");
16695
16695
  var fs16 = require_graceful_fs();
16696
16696
  var retry = require_retry2();
16697
16697
  var onExit = require_signal_exit();
@@ -16702,7 +16702,7 @@ var require_lockfile = __commonJS({
16702
16702
  }
16703
16703
  function resolveCanonicalPath(file2, options, callback) {
16704
16704
  if (!options.realpath) {
16705
- return callback(null, path31.resolve(file2));
16705
+ return callback(null, path33.resolve(file2));
16706
16706
  }
16707
16707
  options.fs.realpath(file2, callback);
16708
16708
  }
@@ -18566,10 +18566,10 @@ var require_segments = __commonJS({
18566
18566
  const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
18567
18567
  const nodes = buildNodes(segs);
18568
18568
  const graph = buildGraph(nodes, version2);
18569
- const path31 = dijkstra.find_path(graph.map, "start", "end");
18569
+ const path33 = dijkstra.find_path(graph.map, "start", "end");
18570
18570
  const optimizedSegs = [];
18571
- for (let i = 1; i < path31.length - 1; i++) {
18572
- optimizedSegs.push(graph.table[path31[i]].node);
18571
+ for (let i = 1; i < path33.length - 1; i++) {
18572
+ optimizedSegs.push(graph.table[path33[i]].node);
18573
18573
  }
18574
18574
  return exports2.fromArray(mergeSegments(optimizedSegs));
18575
18575
  };
@@ -21046,7 +21046,7 @@ var require_png2 = __commonJS({
21046
21046
  });
21047
21047
  png.pack();
21048
21048
  };
21049
- exports2.renderToFile = function renderToFile(path31, qrData, options, cb) {
21049
+ exports2.renderToFile = function renderToFile(path33, qrData, options, cb) {
21050
21050
  if (typeof cb === "undefined") {
21051
21051
  cb = options;
21052
21052
  options = void 0;
@@ -21057,7 +21057,7 @@ var require_png2 = __commonJS({
21057
21057
  called = true;
21058
21058
  cb.apply(null, args);
21059
21059
  };
21060
- const stream = fs16.createWriteStream(path31);
21060
+ const stream = fs16.createWriteStream(path33);
21061
21061
  stream.on("error", done);
21062
21062
  stream.on("close", done);
21063
21063
  exports2.renderToFileStream(stream, qrData, options);
@@ -21119,14 +21119,14 @@ var require_utf8 = __commonJS({
21119
21119
  }
21120
21120
  return output3;
21121
21121
  };
21122
- exports2.renderToFile = function renderToFile(path31, qrData, options, cb) {
21122
+ exports2.renderToFile = function renderToFile(path33, qrData, options, cb) {
21123
21123
  if (typeof cb === "undefined") {
21124
21124
  cb = options;
21125
21125
  options = void 0;
21126
21126
  }
21127
21127
  const fs16 = require("fs");
21128
21128
  const utf8 = exports2.render(qrData, options);
21129
- fs16.writeFile(path31, utf8, cb);
21129
+ fs16.writeFile(path33, utf8, cb);
21130
21130
  };
21131
21131
  }
21132
21132
  });
@@ -21247,7 +21247,7 @@ var require_svg_tag = __commonJS({
21247
21247
  return str;
21248
21248
  }
21249
21249
  function qrToPath(data, size, margin) {
21250
- let path31 = "";
21250
+ let path33 = "";
21251
21251
  let moveBy = 0;
21252
21252
  let newRow = false;
21253
21253
  let lineLength = 0;
@@ -21258,19 +21258,19 @@ var require_svg_tag = __commonJS({
21258
21258
  if (data[i]) {
21259
21259
  lineLength++;
21260
21260
  if (!(i > 0 && col > 0 && data[i - 1])) {
21261
- path31 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
21261
+ path33 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
21262
21262
  moveBy = 0;
21263
21263
  newRow = false;
21264
21264
  }
21265
21265
  if (!(col + 1 < size && data[i + 1])) {
21266
- path31 += svgCmd("h", lineLength);
21266
+ path33 += svgCmd("h", lineLength);
21267
21267
  lineLength = 0;
21268
21268
  }
21269
21269
  } else {
21270
21270
  moveBy++;
21271
21271
  }
21272
21272
  }
21273
- return path31;
21273
+ return path33;
21274
21274
  }
21275
21275
  exports2.render = function render(qrData, options, cb) {
21276
21276
  const opts = Utils.getOptions(options);
@@ -21278,10 +21278,10 @@ var require_svg_tag = __commonJS({
21278
21278
  const data = qrData.modules.data;
21279
21279
  const qrcodesize = size + opts.margin * 2;
21280
21280
  const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>';
21281
- const path31 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
21281
+ const path33 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
21282
21282
  const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"';
21283
21283
  const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" ';
21284
- const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path31 + "</svg>\n";
21284
+ const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path33 + "</svg>\n";
21285
21285
  if (typeof cb === "function") {
21286
21286
  cb(null, svgTag);
21287
21287
  }
@@ -21295,7 +21295,7 @@ var require_svg = __commonJS({
21295
21295
  "../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"(exports2) {
21296
21296
  var svgTagRenderer = require_svg_tag();
21297
21297
  exports2.render = svgTagRenderer.render;
21298
- exports2.renderToFile = function renderToFile(path31, qrData, options, cb) {
21298
+ exports2.renderToFile = function renderToFile(path33, qrData, options, cb) {
21299
21299
  if (typeof cb === "undefined") {
21300
21300
  cb = options;
21301
21301
  options = void 0;
@@ -21303,7 +21303,7 @@ var require_svg = __commonJS({
21303
21303
  const fs16 = require("fs");
21304
21304
  const svgTag = exports2.render(qrData, options);
21305
21305
  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;
21306
- fs16.writeFile(path31, xmlStr, cb);
21306
+ fs16.writeFile(path33, xmlStr, cb);
21307
21307
  };
21308
21308
  }
21309
21309
  });
@@ -21461,8 +21461,8 @@ var require_server = __commonJS({
21461
21461
  cb
21462
21462
  };
21463
21463
  }
21464
- function getTypeFromFilename(path31) {
21465
- return path31.slice((path31.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
21464
+ function getTypeFromFilename(path33) {
21465
+ return path33.slice((path33.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
21466
21466
  }
21467
21467
  function getRendererFromType(type) {
21468
21468
  switch (type) {
@@ -21526,17 +21526,17 @@ var require_server = __commonJS({
21526
21526
  const renderer = getRendererFromType(params.opts.type);
21527
21527
  return render(renderer.renderToBuffer, text, params);
21528
21528
  };
21529
- exports2.toFile = function toFile(path31, text, opts, cb) {
21530
- if (typeof path31 !== "string" || !(typeof text === "string" || typeof text === "object")) {
21529
+ exports2.toFile = function toFile(path33, text, opts, cb) {
21530
+ if (typeof path33 !== "string" || !(typeof text === "string" || typeof text === "object")) {
21531
21531
  throw new Error("Invalid argument");
21532
21532
  }
21533
21533
  if (arguments.length < 3 && !canPromise()) {
21534
21534
  throw new Error("Too few arguments provided");
21535
21535
  }
21536
21536
  const params = checkParams(text, opts, cb);
21537
- const type = params.opts.type || getTypeFromFilename(path31);
21537
+ const type = params.opts.type || getTypeFromFilename(path33);
21538
21538
  const renderer = getRendererFromType(type);
21539
- const renderToFile = renderer.renderToFile.bind(null, path31);
21539
+ const renderToFile = renderer.renderToFile.bind(null, path33);
21540
21540
  return render(renderToFile, text, params);
21541
21541
  };
21542
21542
  exports2.toFileStream = function toFileStream(stream, text, opts) {
@@ -21593,8 +21593,8 @@ args = ${JSON.stringify(expected.args)}
21593
21593
  return tomlStr;
21594
21594
  }
21595
21595
  async function installPublicMcpServerToConfigs(serverId, expected) {
21596
- const homeDir = import_node_os19.default.homedir();
21597
- const claudePath = import_node_path39.default.join(homeDir, ".claude.json");
21596
+ const homeDir = import_node_os20.default.homedir();
21597
+ const claudePath = import_node_path41.default.join(homeDir, ".claude.json");
21598
21598
  if (await pathExists5(claudePath)) {
21599
21599
  try {
21600
21600
  const content = await import_promises16.default.readFile(claudePath, "utf8");
@@ -21608,7 +21608,7 @@ async function installPublicMcpServerToConfigs(serverId, expected) {
21608
21608
  } else {
21609
21609
  await writeAtomic(claudePath, JSON.stringify({ mcpServers: { [serverId]: expected } }, null, 2) + "\n");
21610
21610
  }
21611
- const codexPath = import_node_path39.default.join(homeDir, ".codex", "config.toml");
21611
+ const codexPath = import_node_path41.default.join(homeDir, ".codex", "config.toml");
21612
21612
  if (await pathExists5(codexPath)) {
21613
21613
  try {
21614
21614
  const content = await import_promises16.default.readFile(codexPath, "utf8");
@@ -21623,11 +21623,11 @@ async function installPublicMcpServerToConfigs(serverId, expected) {
21623
21623
  console.error(`Failed to inject MCP server into ${codexPath}`, e);
21624
21624
  }
21625
21625
  } else {
21626
- await import_promises16.default.mkdir(import_node_path39.default.dirname(codexPath), { recursive: true, mode: 448 }).catch(() => {
21626
+ await import_promises16.default.mkdir(import_node_path41.default.dirname(codexPath), { recursive: true, mode: 448 }).catch(() => {
21627
21627
  });
21628
21628
  await writeAtomic(codexPath, renderTomlBlock(serverId, expected).trim() + "\n");
21629
21629
  }
21630
- const agyPath = import_node_path39.default.join(homeDir, ".gemini", "antigravity", "mcp_config.json");
21630
+ const agyPath = import_node_path41.default.join(homeDir, ".gemini", "antigravity", "mcp_config.json");
21631
21631
  if (await pathExists5(agyPath)) {
21632
21632
  try {
21633
21633
  const content = await import_promises16.default.readFile(agyPath, "utf8");
@@ -21639,18 +21639,18 @@ async function installPublicMcpServerToConfigs(serverId, expected) {
21639
21639
  console.error(`Failed to inject MCP server into ${agyPath}`, e);
21640
21640
  }
21641
21641
  } else {
21642
- await import_promises16.default.mkdir(import_node_path39.default.dirname(agyPath), { recursive: true, mode: 448 }).catch(() => {
21642
+ await import_promises16.default.mkdir(import_node_path41.default.dirname(agyPath), { recursive: true, mode: 448 }).catch(() => {
21643
21643
  });
21644
21644
  await writeAtomic(agyPath, JSON.stringify({ mcpServers: { [serverId]: expected } }, null, 2) + "\n");
21645
21645
  }
21646
21646
  }
21647
- var import_promises16, import_node_os19, import_node_path39, toml4;
21647
+ var import_promises16, import_node_os20, import_node_path41, toml4;
21648
21648
  var init_install_public_mcp = __esm({
21649
21649
  "src/install-public-mcp.ts"() {
21650
21650
  "use strict";
21651
21651
  import_promises16 = __toESM(require("node:fs/promises"), 1);
21652
- import_node_os19 = __toESM(require("node:os"), 1);
21653
- import_node_path39 = __toESM(require("node:path"), 1);
21652
+ import_node_os20 = __toESM(require("node:os"), 1);
21653
+ import_node_path41 = __toESM(require("node:path"), 1);
21654
21654
  toml4 = __toESM(require_toml(), 1);
21655
21655
  }
21656
21656
  });
@@ -21661,11 +21661,11 @@ __export(bin_exports, {
21661
21661
  augmentProcessPathWithCommonDirs: () => augmentProcessPathWithCommonDirs
21662
21662
  });
21663
21663
  module.exports = __toCommonJS(bin_exports);
21664
- var import_node_path44 = __toESM(require("node:path"), 1);
21665
- var import_node_child_process24 = require("node:child_process");
21666
- var import_node_fs27 = require("node:fs");
21667
- var import_node_os23 = require("node:os");
21668
- var import_node_path45 = __toESM(require("node:path"), 1);
21664
+ var import_node_path46 = __toESM(require("node:path"), 1);
21665
+ var import_node_child_process26 = require("node:child_process");
21666
+ var import_node_fs29 = require("node:fs");
21667
+ var import_node_os24 = require("node:os");
21668
+ var import_node_path47 = __toESM(require("node:path"), 1);
21669
21669
 
21670
21670
  // src/install-codex.ts
21671
21671
  var import_promises = __toESM(require("node:fs/promises"), 1);
@@ -22666,14 +22666,14 @@ async function installClaude(options) {
22666
22666
 
22667
22667
  // src/install-agy.ts
22668
22668
  var import_promises9 = __toESM(require("node:fs/promises"), 1);
22669
- var import_node_os11 = __toESM(require("node:os"), 1);
22670
- var import_node_path19 = __toESM(require("node:path"), 1);
22669
+ var import_node_os12 = __toESM(require("node:os"), 1);
22670
+ var import_node_path20 = __toESM(require("node:path"), 1);
22671
22671
 
22672
22672
  // src/tools.ts
22673
22673
  var import_node_crypto11 = require("node:crypto");
22674
22674
  var import_promises8 = require("node:fs/promises");
22675
- var import_node_path18 = __toESM(require("node:path"), 1);
22676
- var import_node_os10 = __toESM(require("node:os"), 1);
22675
+ var import_node_path19 = __toESM(require("node:path"), 1);
22676
+ var import_node_os11 = __toESM(require("node:os"), 1);
22677
22677
 
22678
22678
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
22679
22679
  var external_exports = {};
@@ -23441,10 +23441,10 @@ function mergeDefs(...defs) {
23441
23441
  function cloneDef(schema) {
23442
23442
  return mergeDefs(schema._zod.def);
23443
23443
  }
23444
- function getElementAtPath(obj, path31) {
23445
- if (!path31)
23444
+ function getElementAtPath(obj, path33) {
23445
+ if (!path33)
23446
23446
  return obj;
23447
- return path31.reduce((acc, key) => acc?.[key], obj);
23447
+ return path33.reduce((acc, key) => acc?.[key], obj);
23448
23448
  }
23449
23449
  function promiseAllObject(promisesObj) {
23450
23450
  const keys = Object.keys(promisesObj);
@@ -23853,11 +23853,11 @@ function explicitlyAborted(x, startIndex = 0) {
23853
23853
  }
23854
23854
  return false;
23855
23855
  }
23856
- function prefixIssues(path31, issues) {
23856
+ function prefixIssues(path33, issues) {
23857
23857
  return issues.map((iss) => {
23858
23858
  var _a3;
23859
23859
  (_a3 = iss).path ?? (_a3.path = []);
23860
- iss.path.unshift(path31);
23860
+ iss.path.unshift(path33);
23861
23861
  return iss;
23862
23862
  });
23863
23863
  }
@@ -24004,16 +24004,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
24004
24004
  }
24005
24005
  function formatError(error51, mapper = (issue2) => issue2.message) {
24006
24006
  const fieldErrors = { _errors: [] };
24007
- const processError = (error52, path31 = []) => {
24007
+ const processError = (error52, path33 = []) => {
24008
24008
  for (const issue2 of error52.issues) {
24009
24009
  if (issue2.code === "invalid_union" && issue2.errors.length) {
24010
- issue2.errors.map((issues) => processError({ issues }, [...path31, ...issue2.path]));
24010
+ issue2.errors.map((issues) => processError({ issues }, [...path33, ...issue2.path]));
24011
24011
  } else if (issue2.code === "invalid_key") {
24012
- processError({ issues: issue2.issues }, [...path31, ...issue2.path]);
24012
+ processError({ issues: issue2.issues }, [...path33, ...issue2.path]);
24013
24013
  } else if (issue2.code === "invalid_element") {
24014
- processError({ issues: issue2.issues }, [...path31, ...issue2.path]);
24014
+ processError({ issues: issue2.issues }, [...path33, ...issue2.path]);
24015
24015
  } else {
24016
- const fullpath = [...path31, ...issue2.path];
24016
+ const fullpath = [...path33, ...issue2.path];
24017
24017
  if (fullpath.length === 0) {
24018
24018
  fieldErrors._errors.push(mapper(issue2));
24019
24019
  } else {
@@ -24040,17 +24040,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
24040
24040
  }
24041
24041
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
24042
24042
  const result = { errors: [] };
24043
- const processError = (error52, path31 = []) => {
24043
+ const processError = (error52, path33 = []) => {
24044
24044
  var _a3, _b;
24045
24045
  for (const issue2 of error52.issues) {
24046
24046
  if (issue2.code === "invalid_union" && issue2.errors.length) {
24047
- issue2.errors.map((issues) => processError({ issues }, [...path31, ...issue2.path]));
24047
+ issue2.errors.map((issues) => processError({ issues }, [...path33, ...issue2.path]));
24048
24048
  } else if (issue2.code === "invalid_key") {
24049
- processError({ issues: issue2.issues }, [...path31, ...issue2.path]);
24049
+ processError({ issues: issue2.issues }, [...path33, ...issue2.path]);
24050
24050
  } else if (issue2.code === "invalid_element") {
24051
- processError({ issues: issue2.issues }, [...path31, ...issue2.path]);
24051
+ processError({ issues: issue2.issues }, [...path33, ...issue2.path]);
24052
24052
  } else {
24053
- const fullpath = [...path31, ...issue2.path];
24053
+ const fullpath = [...path33, ...issue2.path];
24054
24054
  if (fullpath.length === 0) {
24055
24055
  result.errors.push(mapper(issue2));
24056
24056
  continue;
@@ -24082,8 +24082,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
24082
24082
  }
24083
24083
  function toDotPath(_path) {
24084
24084
  const segs = [];
24085
- const path31 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
24086
- for (const seg of path31) {
24085
+ const path33 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
24086
+ for (const seg of path33) {
24087
24087
  if (typeof seg === "number")
24088
24088
  segs.push(`[${seg}]`);
24089
24089
  else if (typeof seg === "symbol")
@@ -36775,13 +36775,13 @@ function resolveRef(ref, ctx) {
36775
36775
  if (!ref.startsWith("#")) {
36776
36776
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
36777
36777
  }
36778
- const path31 = ref.slice(1).split("/").filter(Boolean);
36779
- if (path31.length === 0) {
36778
+ const path33 = ref.slice(1).split("/").filter(Boolean);
36779
+ if (path33.length === 0) {
36780
36780
  return ctx.rootSchema;
36781
36781
  }
36782
36782
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
36783
- if (path31[0] === defsKey) {
36784
- const key = path31[1];
36783
+ if (path33[0] === defsKey) {
36784
+ const key = path33[1];
36785
36785
  if (!key || !ctx.defs[key]) {
36786
36786
  throw new Error(`Reference not found: ${ref}`);
36787
36787
  }
@@ -37250,6 +37250,8 @@ var ARTIFACT_DESTINATIONS = {
37250
37250
  function resolveKindCapability(kind) {
37251
37251
  return ARTIFACT_DESTINATIONS[kind];
37252
37252
  }
37253
+ var BUILTIN_CAPABILITY_SERVER_ID = "mrrlin-builtin";
37254
+ var LOCAL_GIT_TOOL_NAME = "mrrlin.local-git";
37253
37255
 
37254
37256
  // ../../packages/schemas/dist/capability-refusal.js
37255
37257
  var REFUSAL_TEMPLATES = {
@@ -38515,6 +38517,46 @@ var mrrlinDeclaredOutcomeSchema = mrrlinDeclaredOutcomeShapeSchema.superRefine((
38515
38517
  });
38516
38518
  }
38517
38519
  });
38520
+ var MRRLIN_PROJECT_CODE_HOSTS = ["github", "gitlab", "local"];
38521
+ var mrrlinProjectCodeHostSchema = external_exports.enum(MRRLIN_PROJECT_CODE_HOSTS);
38522
+ var GIT_SHA_PATTERN = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
38523
+ var SHA256_HEX_PATTERN = /^[0-9a-f]{64}$/;
38524
+ var MRRLIN_LOCAL_DELIVERY_REF_PATTERN = /^git\+local:\/\/([^/\s@]+)\/(mrrlin\/run-ER-[A-Za-z0-9-]+)@([0-9a-f]{40}|[0-9a-f]{64})$/;
38525
+ var mrrlinLocalDeliveryRefSchema = external_exports.string().regex(MRRLIN_LOCAL_DELIVERY_REF_PATTERN, "deliveryRef must be git+local://<projectSlug>/mrrlin/run-<runId>@<sha>");
38526
+ function formatLocalDeliveryRef(input) {
38527
+ return mrrlinLocalDeliveryRefSchema.parse(`git+local://${input.projectSlug}/${input.branch}@${input.headSha}`);
38528
+ }
38529
+ var mrrlinLocalBuildStepSchema = external_exports.object({
38530
+ command: external_exports.string().trim().min(1).max(200),
38531
+ exitCode: external_exports.number().int(),
38532
+ logDigest: external_exports.string().regex(SHA256_HEX_PATTERN)
38533
+ });
38534
+ var mrrlinLocalBuildEvidenceSchema = external_exports.object({
38535
+ branch: external_exports.string().regex(/^mrrlin\/run-ER-[A-Za-z0-9-]+$/),
38536
+ baseSha: external_exports.string().regex(GIT_SHA_PATTERN),
38537
+ headSha: external_exports.string().regex(GIT_SHA_PATTERN),
38538
+ commitCount: external_exports.number().int(),
38539
+ steps: external_exports.array(mrrlinLocalBuildStepSchema).max(4),
38540
+ noBuildStep: external_exports.boolean(),
38541
+ checkoutDigest: external_exports.string().regex(SHA256_HEX_PATTERN)
38542
+ });
38543
+ function checkLocalBuildEvidence(evidence, local) {
38544
+ if (evidence.type !== "build")
38545
+ return `localBuild evidence requires evidence.type "build", got "${evidence.type}"`;
38546
+ if (evidence.value !== local.headSha)
38547
+ return "evidence.value must equal localBuild.headSha";
38548
+ if (local.commitCount <= 0)
38549
+ return "localBuild.commitCount must be > 0: a run with no commits never closes a task";
38550
+ if (local.headSha === local.baseSha)
38551
+ return "localBuild.headSha equals baseSha: nothing was committed";
38552
+ if (local.noBuildStep !== (local.steps.length === 0)) {
38553
+ return "localBuild.noBuildStep must be true exactly when no build/test command was detected";
38554
+ }
38555
+ const failed = local.steps.find((step) => step.exitCode !== 0);
38556
+ if (failed)
38557
+ return `localBuild step "${failed.command}" exited ${failed.exitCode}`;
38558
+ return null;
38559
+ }
38518
38560
  var mrrlinReceiptSchema = external_exports.object({
38519
38561
  kind: external_exports.enum(["outcome", "attempt"]),
38520
38562
  evidence: external_exports.object({
@@ -38522,8 +38564,19 @@ var mrrlinReceiptSchema = external_exports.object({
38522
38564
  value: external_exports.string().trim().min(1)
38523
38565
  }),
38524
38566
  observedAt: external_exports.string().datetime(),
38525
- requiresCovered: external_exports.array(artifactKindSchema)
38567
+ requiresCovered: external_exports.array(artifactKindSchema),
38568
+ // local-git-delivery: what the BRIDGE observed for a code_change delivered into a local git repo.
38569
+ // Optional, so every existing receipt is untouched; when present it is checked by
38570
+ // checkLocalBuildEvidence below, which is the single receipt rule of the design.
38571
+ localBuild: mrrlinLocalBuildEvidenceSchema.optional()
38572
+ }).superRefine((value, ctx) => {
38573
+ if (!value.localBuild)
38574
+ return;
38575
+ const problem = checkLocalBuildEvidence(value.evidence, value.localBuild);
38576
+ if (problem)
38577
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["localBuild"], message: problem });
38526
38578
  });
38579
+ var LOCAL_BUILD_RECEIPT_PAYLOAD_KEY = "localBuildReceipt";
38527
38580
  function buildReceipt(input) {
38528
38581
  return {
38529
38582
  kind: input.coveredKinds.length === 0 ? "attempt" : "outcome",
@@ -38982,7 +39035,10 @@ var mrrlinProjectSummarySchema = external_exports.object({
38982
39035
  // workspace-context-isolation (OQ-091): explicit client name and scope description
38983
39036
  // for multi-tenant workspace containment. Output-optional and nullable for backwards compatibility.
38984
39037
  clientName: external_exports.string().trim().max(80).nullable().optional(),
38985
- scopeDescription: external_exports.string().trim().max(240).nullable().optional()
39038
+ scopeDescription: external_exports.string().trim().max(240).nullable().optional(),
39039
+ // local-git-delivery: where this project's code lives. Null means "not asked yet" -- see
39040
+ // mrrlinProjectCodeHostSchema. Output-optional so existing fixtures need no churn.
39041
+ codeHost: mrrlinProjectCodeHostSchema.nullable().optional()
38986
39042
  });
38987
39043
  var mrrlinProjectOperatorInputSchema = external_exports.string().regex(/^@[!-~]+$/, "operator must be '@' followed by printable ASCII with no whitespace");
38988
39044
  var mrrlinProjectUpsertSchema = mrrlinProjectSummarySchema.omit({
@@ -38995,7 +39051,8 @@ var mrrlinProjectRenameSchema = external_exports.object({
38995
39051
  displayName: external_exports.string().trim().min(1).max(120).optional(),
38996
39052
  intentJudgeEnabled: external_exports.boolean().optional(),
38997
39053
  clientName: external_exports.string().trim().max(80).nullable().optional(),
38998
- scopeDescription: external_exports.string().trim().max(240).nullable().optional()
39054
+ scopeDescription: external_exports.string().trim().max(240).nullable().optional(),
39055
+ codeHost: mrrlinProjectCodeHostSchema.nullable().optional()
38999
39056
  });
39000
39057
  var ONBOARDING_KICKOFF_TRANSITIONS = [
39001
39058
  { from: null, to: "pending" },
@@ -39032,7 +39089,8 @@ var mrrlinProjectSnapshotSchema = external_exports.object({
39032
39089
  emoji: mrrlinProjectEmojiSchema,
39033
39090
  slug: mrrlinProjectSlugSchema,
39034
39091
  clientName: external_exports.string().trim().max(80).nullable().optional(),
39035
- scopeDescription: external_exports.string().trim().max(240).nullable().optional()
39092
+ scopeDescription: external_exports.string().trim().max(240).nullable().optional(),
39093
+ codeHost: mrrlinProjectCodeHostSchema.nullable().optional()
39036
39094
  }),
39037
39095
  taskDependencies: external_exports.array(mrrlinTaskDependencySchema).default([]),
39038
39096
  taskEvents: external_exports.array(mrrlinTaskEventSchema).default([]),
@@ -39552,6 +39610,9 @@ var mrrlinExecutionRunSchema = external_exports.object({
39552
39610
  projectSlug: mrrlinProjectSlugSchema,
39553
39611
  provider: external_exports.string().min(1),
39554
39612
  pullRequestUrl: external_exports.string().min(1).nullable(),
39613
+ // local-git-delivery: set instead of pullRequestUrl when a run delivered into a local git repo.
39614
+ // Optional + nullable: absent on every pre-existing run and on every GitHub run.
39615
+ deliveryRef: mrrlinLocalDeliveryRefSchema.nullable().optional(),
39555
39616
  startedAt: external_exports.string().datetime().nullable(),
39556
39617
  status: mrrlinExecutionRunStatusSchema,
39557
39618
  taskId: mrrlinTaskIdSchema,
@@ -39646,6 +39707,7 @@ var mrrlinExecutionRunUpdateSchema = external_exports.object({
39646
39707
  prodPublishRef: external_exports.string().min(1).nullable().optional(),
39647
39708
  prodWorkflowId: external_exports.number().int().positive().nullable().optional(),
39648
39709
  pullRequestUrl: external_exports.string().min(1).nullable().optional(),
39710
+ deliveryRef: mrrlinLocalDeliveryRefSchema.nullable().optional(),
39649
39711
  status: mrrlinExecutionRunStatusSchema.optional(),
39650
39712
  worktreeId: external_exports.string().min(1).nullable().optional(),
39651
39713
  // Slice 6 (cost telemetry) + Slice 7 (effort). All nullable and optional: per D6, NULL means
@@ -40632,18 +40694,18 @@ function createMrrlinClient(config2) {
40632
40694
  const customFetch = config2.fetch ?? globalThis.fetch;
40633
40695
  const baseUrl = config2.baseUrl.replace(/\/$/, "");
40634
40696
  const token = config2.token;
40635
- async function request(path31, init) {
40697
+ async function request(path33, init) {
40636
40698
  const method = init?.method ?? "GET";
40637
40699
  const headers = new Headers(init?.headers ?? {});
40638
40700
  if (token && !headers.has("authorization")) {
40639
40701
  headers.set("authorization", `Bearer ${token}`);
40640
40702
  }
40641
- const response = await customFetch(`${baseUrl}${path31}`, { ...init, headers });
40703
+ const response = await customFetch(`${baseUrl}${path33}`, { ...init, headers });
40642
40704
  if (!response.ok) {
40643
40705
  const body = await response.text();
40644
40706
  let code = `HTTP_${response.status}`;
40645
40707
  let violations = null;
40646
- let message = `Mrrlin API ${method} ${path31} failed: ${response.status}`;
40708
+ let message = `Mrrlin API ${method} ${path33} failed: ${response.status}`;
40647
40709
  try {
40648
40710
  const parsed = JSON.parse(body);
40649
40711
  const violationsParsed = apiViolationsErrorSchema.safeParse(parsed);
@@ -40663,7 +40725,7 @@ function createMrrlinClient(config2) {
40663
40725
  throw new MrrlinApiError({
40664
40726
  code,
40665
40727
  method,
40666
- path: path31,
40728
+ path: path33,
40667
40729
  responseBody: body,
40668
40730
  status: response.status,
40669
40731
  violations,
@@ -40672,18 +40734,18 @@ function createMrrlinClient(config2) {
40672
40734
  }
40673
40735
  return response.json();
40674
40736
  }
40675
- async function requestText(path31, init) {
40737
+ async function requestText(path33, init) {
40676
40738
  const method = init?.method ?? "GET";
40677
40739
  const headers = new Headers(init?.headers ?? {});
40678
40740
  if (token && !headers.has("authorization")) {
40679
40741
  headers.set("authorization", `Bearer ${token}`);
40680
40742
  }
40681
- const response = await customFetch(`${baseUrl}${path31}`, { ...init, headers });
40743
+ const response = await customFetch(`${baseUrl}${path33}`, { ...init, headers });
40682
40744
  if (!response.ok) {
40683
40745
  const body = await response.text();
40684
40746
  let code = `HTTP_${response.status}`;
40685
40747
  let violations = null;
40686
- let message = `Mrrlin API ${method} ${path31} failed: ${response.status}`;
40748
+ let message = `Mrrlin API ${method} ${path33} failed: ${response.status}`;
40687
40749
  try {
40688
40750
  const parsed = JSON.parse(body);
40689
40751
  const violationsParsed = apiViolationsErrorSchema.safeParse(parsed);
@@ -40703,7 +40765,7 @@ function createMrrlinClient(config2) {
40703
40765
  throw new MrrlinApiError({
40704
40766
  code,
40705
40767
  method,
40706
- path: path31,
40768
+ path: path33,
40707
40769
  responseBody: body,
40708
40770
  status: response.status,
40709
40771
  violations,
@@ -40871,16 +40933,16 @@ function createMrrlinClient(config2) {
40871
40933
  // rejected against the first, MrrlinTask[]-only overload) -- the `any` here is contained to
40872
40934
  // this one implementation signature; MrrlinClient's declared overloads keep callers precise.
40873
40935
  async listTasks(projectSlug, filters = {}, options) {
40874
- const path31 = buildTaskListPath(projectSlug, filters, options?.view);
40875
- const body = await request(path31, options?.signal ? { signal: options.signal } : void 0);
40936
+ const path33 = buildTaskListPath(projectSlug, filters, options?.view);
40937
+ const body = await request(path33, options?.signal ? { signal: options.signal } : void 0);
40876
40938
  if (options?.view === "summary") {
40877
40939
  return taskSummaryListResponseSchema.parse(body).data;
40878
40940
  }
40879
40941
  return taskListResponseSchema.parse(body).data;
40880
40942
  },
40881
40943
  async listTaskSummaries(projectSlug, filters = {}, options) {
40882
- const path31 = buildTaskListPath(projectSlug, filters, "summary");
40883
- const body = await request(path31, options?.signal ? { signal: options.signal } : void 0);
40944
+ const path33 = buildTaskListPath(projectSlug, filters, "summary");
40945
+ const body = await request(path33, options?.signal ? { signal: options.signal } : void 0);
40884
40946
  return taskSummaryListResponseSchema.parse(body).data;
40885
40947
  },
40886
40948
  async listTaxonomy(projectSlug) {
@@ -40889,7 +40951,7 @@ function createMrrlinClient(config2) {
40889
40951
  },
40890
40952
  async listWikiPages(projectSlug, filters = {}, options) {
40891
40953
  const view = options?.view ?? filters.view;
40892
- const path31 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
40954
+ const path33 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
40893
40955
  folder: filters.folder,
40894
40956
  id: filters.id,
40895
40957
  limit: filters.limit === void 0 ? void 0 : String(filters.limit),
@@ -40897,20 +40959,20 @@ function createMrrlinClient(config2) {
40897
40959
  taskId: filters.taskId,
40898
40960
  view
40899
40961
  });
40900
- const body = await request(path31, options?.signal ? { signal: options.signal } : void 0);
40962
+ const body = await request(path33, options?.signal ? { signal: options.signal } : void 0);
40901
40963
  if (view === "summary") {
40902
40964
  return wikiPageSummaryListResponseSchema.parse(body).data;
40903
40965
  }
40904
40966
  return wikiPageListResponseSchema.parse(body).data;
40905
40967
  },
40906
40968
  async searchWikiPages(projectSlug, query) {
40907
- const path31 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
40969
+ const path33 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
40908
40970
  folder: query.folder,
40909
40971
  limit: query.limit === void 0 ? void 0 : String(query.limit),
40910
40972
  pathPrefix: query.pathPrefix,
40911
40973
  q: query.q
40912
40974
  });
40913
- const body = await request(path31);
40975
+ const body = await request(path33);
40914
40976
  return wikiPageSearchResponseSchema.parse(body).data;
40915
40977
  },
40916
40978
  async updatePlan(projectSlug, planId, patch) {
@@ -57298,8 +57360,8 @@ async function findSessionDays(stateDir, sessionId) {
57298
57360
  function isRecord5(v) {
57299
57361
  return v !== null && typeof v === "object";
57300
57362
  }
57301
- function resolvePath(root, path31) {
57302
- const parts = path31.split(".");
57363
+ function resolvePath(root, path33) {
57364
+ const parts = path33.split(".");
57303
57365
  let cur = root;
57304
57366
  for (let i = 0; i < parts.length - 1; i += 1) {
57305
57367
  const part = parts[i];
@@ -57367,9 +57429,9 @@ async function gate(artifact, prose, ctx) {
57367
57429
  return { ok: true, gated: true, artifact: withheldExcerptClone(artifact) };
57368
57430
  }
57369
57431
  const maskedClone = typeof structuredClone === "function" ? structuredClone(artifact) : JSON.parse(JSON.stringify(artifact));
57370
- for (const { path: path31, masked } of fields) {
57371
- const target = resolvePath(maskedClone, path31);
57372
- if (!target) throw new Error(`pii-gate: path "${path31}" failed to resolve on the clone after validating on the original`);
57432
+ for (const { path: path33, masked } of fields) {
57433
+ const target = resolvePath(maskedClone, path33);
57434
+ if (!target) throw new Error(`pii-gate: path "${path33}" failed to resolve on the clone after validating on the original`);
57373
57435
  target.parent[target.key] = masked;
57374
57436
  }
57375
57437
  return { ok: true, gated: false, artifact: maskedClone };
@@ -57579,9 +57641,9 @@ var CheckoutRegistry = class {
57579
57641
  get(slug) {
57580
57642
  return this.read()[slug] ?? null;
57581
57643
  }
57582
- confirm(slug, path31, now) {
57644
+ confirm(slug, path33, now) {
57583
57645
  const all = this.read();
57584
- all[slug] = { path: path31, confirmedAt: now };
57646
+ all[slug] = { path: path33, confirmedAt: now };
57585
57647
  (0, import_node_fs7.writeFileSync)(this.file, JSON.stringify(all, null, 2));
57586
57648
  }
57587
57649
  /**
@@ -57719,20 +57781,113 @@ function checkoutStateData(projectSlug, entry, machineLabel) {
57719
57781
  };
57720
57782
  }
57721
57783
 
57722
- // src/operator-token.ts
57784
+ // src/local-checkout.ts
57785
+ var import_node_child_process14 = require("node:child_process");
57723
57786
  var import_node_fs9 = require("node:fs");
57724
- var import_node_os8 = __toESM(require("node:os"), 1);
57787
+ var import_node_os8 = require("node:os");
57725
57788
  var import_node_path16 = __toESM(require("node:path"), 1);
57789
+ var SYSTEM_PATH_PREFIXES = ["/etc", "/usr", "/bin", "/sbin", "/var", "/System", "/Library", "/opt", "/private"];
57790
+ function isUnder(child, parent) {
57791
+ return child === parent || child.startsWith(parent.endsWith(import_node_path16.default.sep) ? parent : `${parent}${import_node_path16.default.sep}`);
57792
+ }
57793
+ function checkLocalPathRules(input, options = {}) {
57794
+ const trimmed = input.trim();
57795
+ if (!import_node_path16.default.isAbsolute(trimmed)) return { ok: false, code: "not_absolute", detail: `Path must be absolute, got: ${trimmed}` };
57796
+ let realPath;
57797
+ try {
57798
+ realPath = (import_node_fs9.realpathSync.native ?? import_node_fs9.realpathSync)(trimmed);
57799
+ } catch {
57800
+ return { ok: false, code: "not_found", detail: `Path does not exist or is not accessible: ${trimmed}` };
57801
+ }
57802
+ const systemPrefixes = options.systemPrefixes ?? SYSTEM_PATH_PREFIXES;
57803
+ const home = options.homeDir ?? (0, import_node_os8.homedir)();
57804
+ let realHome = home;
57805
+ try {
57806
+ realHome = (import_node_fs9.realpathSync.native ?? import_node_fs9.realpathSync)(home);
57807
+ } catch {
57808
+ }
57809
+ if (realPath === import_node_path16.default.parse(realPath).root || realPath === realHome) {
57810
+ return { ok: false, code: "forbidden_path", detail: `Refusing the home directory or a filesystem root: ${realPath}` };
57811
+ }
57812
+ const prefix = systemPrefixes.find((candidate) => isUnder(realPath, candidate));
57813
+ if (prefix) {
57814
+ return { ok: false, code: "forbidden_path", detail: `Refusing a path under the system prefix ${prefix}: ${realPath}` };
57815
+ }
57816
+ const uid = options.uid ?? (typeof process.getuid === "function" ? process.getuid() : void 0);
57817
+ let fd;
57818
+ try {
57819
+ fd = (0, import_node_fs9.openSync)(realPath, import_node_fs9.constants.O_RDONLY | (import_node_fs9.constants.O_DIRECTORY ?? 0) | (import_node_fs9.constants.O_NOFOLLOW ?? 0));
57820
+ const stat3 = (0, import_node_fs9.fstatSync)(fd);
57821
+ if (!stat3.isDirectory()) return { ok: false, code: "not_a_directory", detail: `Not a directory: ${realPath}` };
57822
+ if (uid !== void 0 && stat3.uid !== uid) {
57823
+ return { ok: false, code: "not_owned", detail: `Directory is not owned by the bridge's user: ${realPath}` };
57824
+ }
57825
+ } catch (error51) {
57826
+ const code = error51.code;
57827
+ if (code === "ENOTDIR") return { ok: false, code: "not_a_directory", detail: `Not a directory: ${realPath}` };
57828
+ return { ok: false, code: "path_changed", detail: `Could not open ${realPath} without following links (${code ?? "error"})` };
57829
+ } finally {
57830
+ if (fd !== void 0) (0, import_node_fs9.closeSync)(fd);
57831
+ }
57832
+ return { ok: true, realPath };
57833
+ }
57834
+ function gitTopLevel(realPath) {
57835
+ try {
57836
+ return (0, import_node_child_process14.execFileSync)("git", ["-C", realPath, "rev-parse", "--show-toplevel"], {
57837
+ encoding: "utf8",
57838
+ stdio: ["ignore", "pipe", "ignore"],
57839
+ timeout: 15e3,
57840
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
57841
+ }).trim();
57842
+ } catch {
57843
+ return null;
57844
+ }
57845
+ }
57846
+ function validateLocalCheckoutPath(input, options = {}) {
57847
+ const checked = checkLocalPathRules(input, options);
57848
+ if (!checked.ok) return checked;
57849
+ const top = gitTopLevel(checked.realPath);
57850
+ if (!top) return { ok: false, code: "not_a_git_repo", detail: `Path is not inside a git repository: ${checked.realPath}` };
57851
+ const realTop = (import_node_fs9.realpathSync.native ?? import_node_fs9.realpathSync)(top);
57852
+ if (realTop !== checked.realPath) {
57853
+ return {
57854
+ ok: false,
57855
+ code: "not_a_git_repo",
57856
+ detail: `Path is inside the git repository at ${realTop}, not its top level; register ${realTop} instead.`
57857
+ };
57858
+ }
57859
+ return checked;
57860
+ }
57861
+ function registerLocalOnlyCheckout(registry3, input, machineLabel, options = {}, now = (/* @__PURE__ */ new Date()).toISOString()) {
57862
+ const codeHost = input.project.codeHost ?? null;
57863
+ const eligible = codeHost === "local" || codeHost === null && !input.project.githubRepo;
57864
+ if (!eligible) {
57865
+ return {
57866
+ ok: false,
57867
+ code: "not_local_project",
57868
+ detail: `Project ${input.projectSlug} keeps its code on ${codeHost ?? "GitHub"}; register its clone with \`repo\` instead.`
57869
+ };
57870
+ }
57871
+ const validated = validateLocalCheckoutPath(input.path, options);
57872
+ if (!validated.ok) return validated;
57873
+ registry3.confirm(input.projectSlug, validated.realPath, now);
57874
+ return { ok: true, data: { projectSlug: input.projectSlug, path: validated.realPath, confirmedAt: now, machineLabel } };
57875
+ }
57876
+
57877
+ // src/operator-token.ts
57878
+ var import_node_fs10 = require("node:fs");
57879
+ var import_node_os9 = __toESM(require("node:os"), 1);
57880
+ var import_node_path17 = __toESM(require("node:path"), 1);
57726
57881
  function operatorDir() {
57727
- const base = process.env.CODEX_HOME ? import_node_path16.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path16.default.join(import_node_os8.default.homedir(), ".mrrlin");
57882
+ const base = process.env.CODEX_HOME ? import_node_path17.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path17.default.join(import_node_os9.default.homedir(), ".mrrlin");
57728
57883
  return base;
57729
57884
  }
57730
57885
  function operatorTokenPath() {
57731
- return import_node_path16.default.join(operatorDir(), "operator-token");
57886
+ return import_node_path17.default.join(operatorDir(), "operator-token");
57732
57887
  }
57733
57888
  function readOperatorToken() {
57734
57889
  try {
57735
- const token = (0, import_node_fs9.readFileSync)(operatorTokenPath(), "utf8").trim();
57890
+ const token = (0, import_node_fs10.readFileSync)(operatorTokenPath(), "utf8").trim();
57736
57891
  return token.length > 0 ? token : null;
57737
57892
  } catch {
57738
57893
  return null;
@@ -57740,24 +57895,24 @@ function readOperatorToken() {
57740
57895
  }
57741
57896
  function persistOperatorToken(token) {
57742
57897
  const dir = operatorDir();
57743
- (0, import_node_fs9.mkdirSync)(dir, { recursive: true, mode: 448 });
57744
- (0, import_node_fs9.writeFileSync)(operatorTokenPath(), `${token.trim()}
57898
+ (0, import_node_fs10.mkdirSync)(dir, { recursive: true, mode: 448 });
57899
+ (0, import_node_fs10.writeFileSync)(operatorTokenPath(), `${token.trim()}
57745
57900
  `, { encoding: "utf8", mode: 384 });
57746
57901
  }
57747
57902
  function agentCredentialPath() {
57748
- return import_node_path16.default.join(operatorDir(), "agent-credential");
57903
+ return import_node_path17.default.join(operatorDir(), "agent-credential");
57749
57904
  }
57750
57905
  function persistAgentSecret(secret) {
57751
57906
  const dir = operatorDir();
57752
- (0, import_node_fs9.mkdirSync)(dir, { recursive: true, mode: 448 });
57753
- (0, import_node_fs9.writeFileSync)(agentCredentialPath(), `${secret.trim()}
57907
+ (0, import_node_fs10.mkdirSync)(dir, { recursive: true, mode: 448 });
57908
+ (0, import_node_fs10.writeFileSync)(agentCredentialPath(), `${secret.trim()}
57754
57909
  `, { encoding: "utf8", mode: 384 });
57755
57910
  }
57756
57911
  function readAgentSecret() {
57757
57912
  const fromEnv = process.env.MRRLIN_AGENT_SECRET?.trim();
57758
57913
  if (fromEnv) return fromEnv;
57759
57914
  try {
57760
- const raw = (0, import_node_fs9.readFileSync)(agentCredentialPath(), "utf8").trim();
57915
+ const raw = (0, import_node_fs10.readFileSync)(agentCredentialPath(), "utf8").trim();
57761
57916
  return raw || void 0;
57762
57917
  } catch {
57763
57918
  return void 0;
@@ -57766,9 +57921,9 @@ function readAgentSecret() {
57766
57921
 
57767
57922
  // src/worker-token.ts
57768
57923
  var import_node_crypto10 = require("node:crypto");
57769
- var import_node_fs10 = require("node:fs");
57770
- var import_node_os9 = __toESM(require("node:os"), 1);
57771
- var import_node_path17 = __toESM(require("node:path"), 1);
57924
+ var import_node_fs11 = require("node:fs");
57925
+ var import_node_os10 = __toESM(require("node:os"), 1);
57926
+ var import_node_path18 = __toESM(require("node:path"), 1);
57772
57927
  var DEFAULT_WORKER_PORT = 8792;
57773
57928
  function workerPort() {
57774
57929
  const raw = process.env.MRRLIN_WORKER_PORT;
@@ -57777,15 +57932,15 @@ function workerPort() {
57777
57932
  return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_WORKER_PORT;
57778
57933
  }
57779
57934
  function workerDir() {
57780
- const base = process.env.CODEX_HOME ? import_node_path17.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path17.default.join(import_node_os9.default.homedir(), ".mrrlin");
57781
- return import_node_path17.default.join(base, "worker");
57935
+ const base = process.env.CODEX_HOME ? import_node_path18.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path18.default.join(import_node_os10.default.homedir(), ".mrrlin");
57936
+ return import_node_path18.default.join(base, "worker");
57782
57937
  }
57783
57938
  function workerTokenPath() {
57784
- return import_node_path17.default.join(workerDir(), "token");
57939
+ return import_node_path18.default.join(workerDir(), "token");
57785
57940
  }
57786
57941
  function readWorkerToken() {
57787
57942
  try {
57788
- const token = (0, import_node_fs10.readFileSync)(workerTokenPath(), "utf8").trim();
57943
+ const token = (0, import_node_fs11.readFileSync)(workerTokenPath(), "utf8").trim();
57789
57944
  return token.length > 0 ? token : null;
57790
57945
  } catch {
57791
57946
  return null;
@@ -57795,9 +57950,9 @@ function readOrCreateWorkerToken() {
57795
57950
  const existing = readWorkerToken();
57796
57951
  if (existing) return existing;
57797
57952
  const dir = workerDir();
57798
- (0, import_node_fs10.mkdirSync)(dir, { recursive: true, mode: 448 });
57953
+ (0, import_node_fs11.mkdirSync)(dir, { recursive: true, mode: 448 });
57799
57954
  const token = (0, import_node_crypto10.randomBytes)(32).toString("hex");
57800
- (0, import_node_fs10.writeFileSync)(workerTokenPath(), `${token}
57955
+ (0, import_node_fs11.writeFileSync)(workerTokenPath(), `${token}
57801
57956
  `, { encoding: "utf8", mode: 384 });
57802
57957
  return token;
57803
57958
  }
@@ -58569,8 +58724,10 @@ var createInboxItemInputSchema = projectScopedSchema.merge(mrrlinInboxItemCreate
58569
58724
  var decideInboxItemInputSchema = projectScopedSchema.extend({ itemId: mrrlinInboxItemIdSchema }).merge(mrrlinInboxItemDecideSchema);
58570
58725
  var resolveHandoffInputSchema = projectScopedSchema.extend({ runId: mrrlinExecutionRunIdSchema }).merge(mrrlinResolveHandoffSchema);
58571
58726
  var registerLocalCheckoutInputSchema = projectScopedSchema.extend({
58572
- path: external_exports.string().min(1).describe("Absolute path to the local git checkout (must be a git repo whose origin matches `repo`)."),
58573
- repo: external_exports.string().min(1).describe("The project's bound GitHub repo full name in `owner/repo` form.")
58727
+ path: external_exports.string().min(1).describe("Absolute path to the local git checkout (must be a git repo whose origin matches `repo`, or, with no `repo`, the top of a git repo)."),
58728
+ repo: external_exports.string().min(1).optional().describe(
58729
+ "The project's bound GitHub repo full name in `owner/repo` form. Omit it for a project with no GitHub (its code lives only on this computer): the folder then only has to be a git repository the operator owns."
58730
+ )
58574
58731
  });
58575
58732
  var retrieveContextInputSchema = external_exports.object({
58576
58733
  handle: external_exports.string().min(1).describe(
@@ -58765,7 +58922,7 @@ var mcpToolDescriptions = {
58765
58922
  [mcpToolNames.restartExecutionRun]: "Restart a parked execution run (handoff_requested or handoff_queued) back to pending so the queue can resume it.",
58766
58923
  [mcpToolNames.stopExecutionRun]: "Operator stop: park an in-flight execution run at handoff_requested with blockingReason operator_stopped. Parks rather than cancels, so restart_execution_run can resume it later. Refuses (409) a run already at a terminal status.",
58767
58924
  [mcpToolNames.resolveHandoff]: "Resolve a tool_assisted handoff for an execution run (outcome success|failure). Success returns the task to the board; failure opens a new handoff cycle. Idempotent.",
58768
- [mcpToolNames.registerLocalCheckout]: "Register the operator-local git checkout path for `projectSlug` so execution-run workers run code on this machine instead of the cloud. Validates the path is a git repo whose `origin` remote matches `repo`, then writes the (slug -> absolute path) entry to the operator-local checkout registry. Call this after locating the checkout on disk (e.g. via filesystem search) and confirming the choice with the user in chat \u2014 they should NOT have to paste the path into Settings. Returns `{ projectSlug, path, confirmedAt }`. Idempotent: re-registering overwrites the prior entry.",
58925
+ [mcpToolNames.registerLocalCheckout]: "Register the operator-local git checkout path for `projectSlug` so execution-run workers run code on this machine instead of the cloud. Validates the path is a git repo whose `origin` remote matches `repo`, then writes the (slug -> absolute path) entry to the operator-local checkout registry. For a project with no GitHub (code kept only on this computer), omit `repo`: the path must then be the top of a git repository owned by the operator, not the home folder or a system folder. Call this after locating the checkout on disk (e.g. via filesystem search) and confirming the choice with the user in chat \u2014 they should NOT have to paste the path into Settings. Returns `{ projectSlug, path, confirmedAt }`. Idempotent: re-registering overwrites the prior entry.",
58769
58926
  [mcpToolNames.retrieveContext]: "Rehydrate a mrrlin:// handle emitted by the compact-context layer into the full canonical Mrrlin record (task/wiki page/project snapshot/execution run/artifacts). Use whenever you need the full source \u2014 irreversible decisions (closing tasks, dispatching deploys, writing specs) MUST call this first; never act on a compact envelope alone. Returns `{ kind, data }`. Invalid or unsupported handle \u2192 structured `HANDLE_INVALID` error."
58770
58927
  };
58771
58928
  var ARTIFACT_EXTENSION_TYPES = {
@@ -59737,7 +59894,7 @@ function createMrrlinTools(options) {
59737
59894
  "Unable to upload artifact file.",
59738
59895
  async (c, { projectSlug, path: filePath, class: artifactClass, taskId, runId, description }) => {
59739
59896
  await checkTenantBoundary(projectSlug, "artifact upload");
59740
- const extension2 = import_node_path18.default.extname(filePath).toLowerCase();
59897
+ const extension2 = import_node_path19.default.extname(filePath).toLowerCase();
59741
59898
  const contentType2 = ARTIFACT_EXTENSION_TYPES[extension2];
59742
59899
  if (!contentType2) {
59743
59900
  throw new McpToolCodedError(
@@ -59765,7 +59922,7 @@ function createMrrlinTools(options) {
59765
59922
  "Artifact exceeds 5MB; split or summarize instead."
59766
59923
  );
59767
59924
  }
59768
- const filename = import_node_path18.default.basename(filePath);
59925
+ const filename = import_node_path19.default.basename(filePath);
59769
59926
  return deliverBuiltIn(
59770
59927
  c,
59771
59928
  projectSlug,
@@ -59788,7 +59945,7 @@ function createMrrlinTools(options) {
59788
59945
  `Invalid filename '${filename}'; provide a bare filename with no path separators or '..'.`
59789
59946
  );
59790
59947
  }
59791
- const extension2 = import_node_path18.default.extname(filename).toLowerCase();
59948
+ const extension2 = import_node_path19.default.extname(filename).toLowerCase();
59792
59949
  const contentType2 = ARTIFACT_EXTENSION_TYPES[extension2];
59793
59950
  if (!contentType2) {
59794
59951
  throw new McpToolCodedError(
@@ -59873,10 +60030,37 @@ function createMrrlinTools(options) {
59873
60030
  mcpToolNames.registerLocalCheckout,
59874
60031
  "LOCAL_CHECKOUT_REGISTER_FAILED",
59875
60032
  "Unable to register local checkout.",
59876
- async (_c, { projectSlug, path: checkoutPath, repo }) => {
60033
+ async (c, { projectSlug, path: checkoutPath, repo }) => {
59877
60034
  await checkTenantBoundary(projectSlug, "local checkout");
59878
60035
  const registry3 = new CheckoutRegistry(resolveStateDir());
59879
- const result = registerCheckout(registry3, { projectSlug, path: checkoutPath, repo }, import_node_os10.default.hostname());
60036
+ if (!repo) {
60037
+ const snapshot = await c.getProjectSnapshot(projectSlug);
60038
+ const local = registerLocalOnlyCheckout(
60039
+ registry3,
60040
+ {
60041
+ projectSlug,
60042
+ path: checkoutPath,
60043
+ project: { codeHost: snapshot.project.codeHost ?? null, githubRepo: snapshot.github?.repo ?? null }
60044
+ },
60045
+ import_node_os11.default.hostname()
60046
+ );
60047
+ if (!local.ok) {
60048
+ const localCodeMap = {
60049
+ not_absolute: "LOCAL_CHECKOUT_PATH_NOT_ABSOLUTE",
60050
+ not_found: "LOCAL_CHECKOUT_PATH_NOT_FOUND",
60051
+ not_a_directory: "LOCAL_CHECKOUT_PATH_NOT_FOUND",
60052
+ not_owned: "LOCAL_CHECKOUT_PATH_FORBIDDEN",
60053
+ forbidden_path: "LOCAL_CHECKOUT_PATH_FORBIDDEN",
60054
+ path_changed: "LOCAL_CHECKOUT_PATH_FORBIDDEN",
60055
+ not_a_git_repo: "LOCAL_CHECKOUT_NOT_A_GIT_REPO",
60056
+ inside_git_repo: "LOCAL_CHECKOUT_NOT_A_GIT_REPO",
60057
+ not_local_project: "LOCAL_CHECKOUT_REPO_REQUIRED"
60058
+ };
60059
+ throw new McpToolCodedError(localCodeMap[local.code], local.detail);
60060
+ }
60061
+ return local.data;
60062
+ }
60063
+ const result = registerCheckout(registry3, { projectSlug, path: checkoutPath, repo }, import_node_os11.default.hostname());
59880
60064
  if (!result.ok) {
59881
60065
  const codeMap = {
59882
60066
  not_absolute: "LOCAL_CHECKOUT_PATH_NOT_ABSOLUTE",
@@ -59977,20 +60161,20 @@ function allAgyGrantStrings() {
59977
60161
  }
59978
60162
  function resolveAgyConfigPath(options) {
59979
60163
  if (options.agyConfigPath) return options.agyConfigPath;
59980
- return import_node_path19.default.join(options.homeDir ?? import_node_os11.default.homedir(), ".gemini", "config", "mcp_config.json");
60164
+ return import_node_path20.default.join(options.homeDir ?? import_node_os12.default.homedir(), ".gemini", "config", "mcp_config.json");
59981
60165
  }
59982
60166
  function resolveConfigJsonPath(options) {
59983
60167
  if (options.configJsonPath) return options.configJsonPath;
59984
- return import_node_path19.default.join(options.homeDir ?? import_node_os11.default.homedir(), ".gemini", "config", "config.json");
60168
+ return import_node_path20.default.join(options.homeDir ?? import_node_os12.default.homedir(), ".gemini", "config", "config.json");
59985
60169
  }
59986
60170
  async function detectInstallDistribution3(options) {
59987
60171
  if (options.distribution && options.distribution !== "auto") return options.distribution;
59988
- let current2 = import_node_path19.default.dirname(options.binPath);
60172
+ let current2 = import_node_path20.default.dirname(options.binPath);
59989
60173
  while (true) {
59990
- if (await pathExists4(import_node_path19.default.join(current2, "pnpm-workspace.yaml"))) {
60174
+ if (await pathExists4(import_node_path20.default.join(current2, "pnpm-workspace.yaml"))) {
59991
60175
  return "local";
59992
60176
  }
59993
- const parent = import_node_path19.default.dirname(current2);
60177
+ const parent = import_node_path20.default.dirname(current2);
59994
60178
  if (parent === current2) break;
59995
60179
  current2 = parent;
59996
60180
  }
@@ -60012,7 +60196,7 @@ function browserTable3(binPath, distribution, homeDir) {
60012
60196
  return { ...base, env: { PLAYWRIGHT_BROWSERS_PATH: browserPaths(homeDir).browsersPath } };
60013
60197
  }
60014
60198
  function managedEntries2(options, distribution) {
60015
- const homeDir = options.homeDir ?? import_node_os11.default.homedir();
60199
+ const homeDir = options.homeDir ?? import_node_os12.default.homedir();
60016
60200
  return [
60017
60201
  { id: "mrrlin", expected: mrrlinTable3(options.binPath, distribution, options.serveEnv) },
60018
60202
  { id: "mrrlin-browser", expected: browserTable3(options.binPath, distribution, homeDir) },
@@ -60032,8 +60216,8 @@ async function installAgy(options) {
60032
60216
  const configJsonPath = resolveConfigJsonPath(options);
60033
60217
  const distribution = await detectInstallDistribution3(options);
60034
60218
  const entries = managedEntries2(options, distribution);
60035
- await import_promises9.default.mkdir(import_node_path19.default.dirname(configPath), { recursive: true });
60036
- await import_promises9.default.mkdir(import_node_path19.default.dirname(configJsonPath), { recursive: true });
60219
+ await import_promises9.default.mkdir(import_node_path20.default.dirname(configPath), { recursive: true });
60220
+ await import_promises9.default.mkdir(import_node_path20.default.dirname(configJsonPath), { recursive: true });
60037
60221
  let action = "noop";
60038
60222
  const preservedEnvBlocks = [];
60039
60223
  if (!await pathExists4(configPath)) {
@@ -60149,14 +60333,14 @@ async function installAgy(options) {
60149
60333
 
60150
60334
  // src/provider-readiness.ts
60151
60335
  var import_promises10 = require("node:fs/promises");
60152
- var import_node_fs11 = require("node:fs");
60153
- var import_node_os12 = __toESM(require("node:os"), 1);
60154
- var import_node_path20 = __toESM(require("node:path"), 1);
60336
+ var import_node_fs12 = require("node:fs");
60337
+ var import_node_os13 = __toESM(require("node:os"), 1);
60338
+ var import_node_path21 = __toESM(require("node:path"), 1);
60155
60339
  var import_semver2 = __toESM(require_semver2(), 1);
60156
60340
  var toml3 = __toESM(require_toml(), 1);
60157
60341
 
60158
60342
  // src/agent-version.ts
60159
- var import_node_child_process14 = require("node:child_process");
60343
+ var import_node_child_process15 = require("node:child_process");
60160
60344
  var import_semver = __toESM(require_semver2(), 1);
60161
60345
  var SEMVER_RE = /\b\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?\b/;
60162
60346
  var CODEX_PACKAGE = process.env.MRRLIN_CODEX_PACKAGE?.trim() || "@openai/codex";
@@ -60166,7 +60350,7 @@ function parseCodexVersion(raw) {
60166
60350
  return m ? m[0] : null;
60167
60351
  }
60168
60352
  var defaultRun = (args) => {
60169
- const r = (0, import_node_child_process14.spawnSync)("codex", args, { encoding: "utf8", timeout: 8e3, shell: true });
60353
+ const r = (0, import_node_child_process15.spawnSync)("codex", args, { encoding: "utf8", timeout: 8e3, shell: true });
60170
60354
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
60171
60355
  };
60172
60356
  function getInstalledAgentVersion(provider, run3) {
@@ -60242,13 +60426,13 @@ function startCodexProbe(deps = {}) {
60242
60426
  // src/provider-readiness.ts
60243
60427
  function resolveCodexHome2(opts) {
60244
60428
  if (opts.codexHome) return opts.codexHome;
60245
- if (opts.homeDir) return import_node_path20.default.join(opts.homeDir, ".codex");
60429
+ if (opts.homeDir) return import_node_path21.default.join(opts.homeDir, ".codex");
60246
60430
  if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
60247
- return import_node_path20.default.join(import_node_os12.default.homedir(), ".codex");
60431
+ return import_node_path21.default.join(import_node_os13.default.homedir(), ".codex");
60248
60432
  }
60249
60433
  function resolveClaudeConfigPath2(opts) {
60250
60434
  if (opts.claudeConfigPath) return opts.claudeConfigPath;
60251
- return import_node_path20.default.join(opts.homeDir ?? import_node_os12.default.homedir(), ".claude.json");
60435
+ return import_node_path21.default.join(opts.homeDir ?? import_node_os13.default.homedir(), ".claude.json");
60252
60436
  }
60253
60437
  function isExternalAgentsWrapper(table) {
60254
60438
  if (!table) return false;
@@ -60317,9 +60501,9 @@ async function verifyProviderReadiness(provider, run3, opts = {}) {
60317
60501
  if (!checks.version) details.push(`version: ${version2 ?? "unparseable"} is below the required 2.1.232`);
60318
60502
  }
60319
60503
  if (provider === "codex") {
60320
- const authPath = import_node_path20.default.join(resolveCodexHome2(opts), "auth.json");
60504
+ const authPath = import_node_path21.default.join(resolveCodexHome2(opts), "auth.json");
60321
60505
  try {
60322
- await (0, import_promises10.access)(authPath, import_node_fs11.constants.F_OK);
60506
+ await (0, import_promises10.access)(authPath, import_node_fs12.constants.F_OK);
60323
60507
  checks.auth = true;
60324
60508
  } catch {
60325
60509
  details.push(`auth: ${authPath} not found`);
@@ -60334,7 +60518,7 @@ async function verifyProviderReadiness(provider, run3, opts = {}) {
60334
60518
  if (!checks.auth) details.push("auth: `claude auth status` failed");
60335
60519
  }
60336
60520
  if (provider === "codex") {
60337
- const configPath = import_node_path20.default.join(resolveCodexHome2(opts), "config.toml");
60521
+ const configPath = import_node_path21.default.join(resolveCodexHome2(opts), "config.toml");
60338
60522
  try {
60339
60523
  const raw = await (0, import_promises10.readFile)(configPath, "utf8");
60340
60524
  const parsed = toml3.parse(raw);
@@ -60385,9 +60569,9 @@ async function verifyProviderReadiness(provider, run3, opts = {}) {
60385
60569
  }
60386
60570
 
60387
60571
  // src/browser-interceptor.ts
60388
- var import_node_os13 = __toESM(require("node:os"), 1);
60572
+ var import_node_os14 = __toESM(require("node:os"), 1);
60389
60573
  var import_node_readline = __toESM(require("node:readline"), 1);
60390
- var import_node_child_process15 = require("node:child_process");
60574
+ var import_node_child_process16 = require("node:child_process");
60391
60575
  var INTERNAL_HOST_PATTERNS = [
60392
60576
  /^(?:.*\.)?mrrlin\.(?:com|internal|local)$/i,
60393
60577
  /^(?:localhost|127\.0\.0\.1)(?::\d+)?$/i
@@ -60559,7 +60743,7 @@ function wireBrowserServeProxy(streams) {
60559
60743
  }
60560
60744
  function signalToExitCode(signal) {
60561
60745
  if (!signal) return 1;
60562
- const sigNum = import_node_os13.default.constants.signals[signal];
60746
+ const sigNum = import_node_os14.default.constants.signals[signal];
60563
60747
  if (typeof sigNum === "number") {
60564
60748
  return 128 + sigNum;
60565
60749
  }
@@ -60568,7 +60752,7 @@ function signalToExitCode(signal) {
60568
60752
  async function runBrowserServeProxy(opts) {
60569
60753
  const input = opts.input ?? process.stdin;
60570
60754
  const output3 = opts.output ?? process.stdout;
60571
- const child = (0, import_node_child_process15.spawn)(opts.command, opts.args, {
60755
+ const child = (0, import_node_child_process16.spawn)(opts.command, opts.args, {
60572
60756
  stdio: ["pipe", "pipe", "inherit"],
60573
60757
  env: { ...process.env, ...opts.env }
60574
60758
  });
@@ -60615,12 +60799,12 @@ async function runBrowserServeProxy(opts) {
60615
60799
  }
60616
60800
 
60617
60801
  // src/director-bridge.ts
60618
- var import_node_fs25 = __toESM(require("node:fs"), 1);
60802
+ var import_node_fs27 = __toESM(require("node:fs"), 1);
60619
60803
  var import_node_http3 = __toESM(require("node:http"), 1);
60620
- var import_node_os20 = __toESM(require("node:os"), 1);
60621
- var import_node_path40 = __toESM(require("node:path"), 1);
60622
- var import_node_child_process23 = require("node:child_process");
60623
- var import_node_crypto20 = __toESM(require("node:crypto"), 1);
60804
+ var import_node_os21 = __toESM(require("node:os"), 1);
60805
+ var import_node_path42 = __toESM(require("node:path"), 1);
60806
+ var import_node_child_process25 = require("node:child_process");
60807
+ var import_node_crypto21 = __toESM(require("node:crypto"), 1);
60624
60808
 
60625
60809
  // src/turn-replay-buffer.ts
60626
60810
  var DEFAULT_MAX_EVENTS = 2e3;
@@ -61164,17 +61348,17 @@ function createTurnLock() {
61164
61348
  }
61165
61349
 
61166
61350
  // src/self-update.ts
61167
- var import_node_child_process17 = require("node:child_process");
61351
+ var import_node_child_process18 = require("node:child_process");
61168
61352
  var import_node_crypto12 = require("node:crypto");
61169
- var import_node_fs13 = require("node:fs");
61170
- var import_node_path22 = __toESM(require("node:path"), 1);
61353
+ var import_node_fs14 = require("node:fs");
61354
+ var import_node_path23 = __toESM(require("node:path"), 1);
61171
61355
  var import_semver3 = __toESM(require_semver2(), 1);
61172
61356
 
61173
61357
  // src/codex-auth-preflight.ts
61174
- var import_node_child_process16 = require("node:child_process");
61175
- var import_node_fs12 = require("node:fs");
61176
- var import_node_os14 = __toESM(require("node:os"), 1);
61177
- var import_node_path21 = __toESM(require("node:path"), 1);
61358
+ var import_node_child_process17 = require("node:child_process");
61359
+ var import_node_fs13 = require("node:fs");
61360
+ var import_node_os15 = __toESM(require("node:os"), 1);
61361
+ var import_node_path22 = __toESM(require("node:path"), 1);
61178
61362
  var DEFAULT_CODEX_AUTH_MIN_TTL_SECONDS = 15 * 60;
61179
61363
  var DEFAULT_CODEX_AUTH_SMOKE_TIMEOUT_MS = 2e4;
61180
61364
  var DEFAULT_CODEX_AUTH_SMOKE_MODEL = "gpt-5.4-mini";
@@ -61193,7 +61377,7 @@ function codexAuthSmokeTimeoutMs(env = process.env) {
61193
61377
  function resolveCodexAuthPath(opts = {}) {
61194
61378
  const env = opts.env ?? process.env;
61195
61379
  const codexHome = env.CODEX_HOME?.trim();
61196
- return import_node_path21.default.join(codexHome || import_node_path21.default.join(opts.homeDir ?? import_node_os14.default.homedir(), ".codex"), "auth.json");
61380
+ return import_node_path22.default.join(codexHome || import_node_path22.default.join(opts.homeDir ?? import_node_os15.default.homedir(), ".codex"), "auth.json");
61197
61381
  }
61198
61382
  function decodeJwtExpMs(token) {
61199
61383
  const parts = token.split(".");
@@ -61254,7 +61438,7 @@ function runCodexAuthRefreshSmokeForBridgeUpdate(opts = {}) {
61254
61438
  const configuredExecutable = opts.codexExecutable ?? env.MRRLIN_DIRECTOR_BRIDGE_CODEX_BIN?.trim();
61255
61439
  const executable = configuredExecutable || "codex";
61256
61440
  const timeoutMs = opts.timeoutMs ?? codexAuthSmokeTimeoutMs(env);
61257
- const cwd = opts.cwd ?? import_node_os14.default.tmpdir();
61441
+ const cwd = opts.cwd ?? import_node_os15.default.tmpdir();
61258
61442
  const args = [
61259
61443
  "exec",
61260
61444
  "--sandbox",
@@ -61265,9 +61449,9 @@ function runCodexAuthRefreshSmokeForBridgeUpdate(opts = {}) {
61265
61449
  CODEX_AUTH_SMOKE_PROMPT
61266
61450
  ];
61267
61451
  const command = commandForSmoke(executable, model);
61268
- const execFileSync5 = opts.execFileSyncImpl ?? import_node_child_process16.execFileSync;
61452
+ const execFileSync7 = opts.execFileSyncImpl ?? import_node_child_process17.execFileSync;
61269
61453
  try {
61270
- execFileSync5(executable, args, {
61454
+ execFileSync7(executable, args, {
61271
61455
  cwd,
61272
61456
  env,
61273
61457
  encoding: "utf8",
@@ -61314,7 +61498,7 @@ function inspectCodexAuthForBridgeUpdate(opts = {}) {
61314
61498
  const nowMs = opts.nowMs ?? Date.now();
61315
61499
  const minTtlSeconds = opts.minTtlSeconds ?? codexAuthMinTtlSeconds(env);
61316
61500
  const authPath = resolveCodexAuthPath({ env, homeDir: opts.homeDir });
61317
- const readFile9 = opts.readFileSyncImpl ?? ((p, encoding) => (0, import_node_fs12.readFileSync)(p, encoding));
61501
+ const readFile9 = opts.readFileSyncImpl ?? ((p, encoding) => (0, import_node_fs13.readFileSync)(p, encoding));
61318
61502
  let raw;
61319
61503
  try {
61320
61504
  raw = readFile9(authPath, "utf8");
@@ -61428,26 +61612,26 @@ function inspectCodexAuthForBridgeUpdate(opts = {}) {
61428
61612
  var BIN_NAME = "mrrlin-mcp";
61429
61613
  var SELF_UPDATE_AUTH_PREFLIGHT_OFFER_PREFIX = "[bridge:update:auth-preflight]";
61430
61614
  function resolveBinPath(opts) {
61431
- if (opts.argv1 && import_node_path22.default.basename(opts.argv1).includes("mrrlin")) {
61615
+ if (opts.argv1 && import_node_path23.default.basename(opts.argv1).includes("mrrlin")) {
61432
61616
  return { path: opts.argv1, source: "argv" };
61433
61617
  }
61434
61618
  const whichSync = opts.whichSync ?? ((name) => {
61435
61619
  try {
61436
- return (0, import_node_child_process17.execFileSync)("which", [name], { encoding: "utf8", timeout: 3e3 }).trim() || null;
61620
+ return (0, import_node_child_process18.execFileSync)("which", [name], { encoding: "utf8", timeout: 3e3 }).trim() || null;
61437
61621
  } catch {
61438
61622
  return null;
61439
61623
  }
61440
61624
  });
61441
- const existsSync5 = opts.existsSync ?? import_node_fs13.existsSync;
61625
+ const existsSync6 = opts.existsSync ?? import_node_fs14.existsSync;
61442
61626
  const resolved = whichSync(BIN_NAME);
61443
- if (resolved && existsSync5(resolved)) {
61627
+ if (resolved && existsSync6(resolved)) {
61444
61628
  return { path: resolved, source: "which" };
61445
61629
  }
61446
61630
  const envPath = (opts.env ?? process.env).PATH ?? "";
61447
- for (const dir of envPath.split(import_node_path22.default.delimiter)) {
61631
+ for (const dir of envPath.split(import_node_path23.default.delimiter)) {
61448
61632
  if (!dir) continue;
61449
- const candidate = import_node_path22.default.join(dir, BIN_NAME);
61450
- if (existsSync5(candidate)) {
61633
+ const candidate = import_node_path23.default.join(dir, BIN_NAME);
61634
+ if (existsSync6(candidate)) {
61451
61635
  return { path: candidate, source: "path-walk" };
61452
61636
  }
61453
61637
  }
@@ -61477,7 +61661,7 @@ function sha256(buf) {
61477
61661
  function startSelfUpdate(deps) {
61478
61662
  const log = deps.log ?? (() => {
61479
61663
  });
61480
- const readFile9 = deps.readFileSyncImpl ?? ((p) => (0, import_node_fs13.readFileSync)(p));
61664
+ const readFile9 = deps.readFileSyncImpl ?? ((p) => (0, import_node_fs14.readFileSync)(p));
61481
61665
  const setIntervalFn = deps.setIntervalImpl ?? setInterval;
61482
61666
  const clearIntervalFn = deps.clearIntervalImpl ?? clearInterval;
61483
61667
  const intervalMs = deps.intervalMs ?? readIntervalEnv("MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE_INTERVAL_MS", DEFAULT_INTERVAL_MS);
@@ -61764,7 +61948,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
61764
61948
  }
61765
61949
 
61766
61950
  // src/_generated/version.ts
61767
- var PKG_VERSION = "0.4.115";
61951
+ var PKG_VERSION = "0.4.117";
61768
61952
 
61769
61953
  // src/receipt-signing.ts
61770
61954
  var import_node_crypto13 = __toESM(require("node:crypto"), 1);
@@ -62648,14 +62832,14 @@ function parseLedger(value) {
62648
62832
  }
62649
62833
 
62650
62834
  // src/api-base-url-migrate.ts
62651
- var import_node_fs14 = __toESM(require("node:fs"), 1);
62652
- var import_node_os15 = __toESM(require("node:os"), 1);
62653
- var import_node_path24 = __toESM(require("node:path"), 1);
62835
+ var import_node_fs15 = __toESM(require("node:fs"), 1);
62836
+ var import_node_os16 = __toESM(require("node:os"), 1);
62837
+ var import_node_path25 = __toESM(require("node:path"), 1);
62654
62838
 
62655
62839
  // src/service-paths.ts
62656
- var import_node_path23 = __toESM(require("node:path"), 1);
62840
+ var import_node_path24 = __toESM(require("node:path"), 1);
62657
62841
  function isWorktreePath(p) {
62658
- const norm = import_node_path23.default.normalize(p).split(import_node_path23.default.sep).join("/");
62842
+ const norm = import_node_path24.default.normalize(p).split(import_node_path24.default.sep).join("/");
62659
62843
  return norm.includes("/.claude/worktrees/");
62660
62844
  }
62661
62845
  function resolveServiceCwd(opts) {
@@ -62727,20 +62911,20 @@ ${envLines}
62727
62911
 
62728
62912
  // src/api-base-url-migrate.ts
62729
62913
  function defaultDeps(deps) {
62730
- const home = deps.home ?? process.env.HOME ?? import_node_os15.default.homedir();
62914
+ const home = deps.home ?? process.env.HOME ?? import_node_os16.default.homedir();
62731
62915
  return {
62732
62916
  home,
62733
- codexHome: deps.codexHome ?? process.env.CODEX_HOME?.trim() ?? import_node_path24.default.join(home, ".codex"),
62734
- readFile: deps.readFile ?? ((p) => import_node_fs14.default.readFileSync(p, "utf8")),
62917
+ codexHome: deps.codexHome ?? process.env.CODEX_HOME?.trim() ?? import_node_path25.default.join(home, ".codex"),
62918
+ readFile: deps.readFile ?? ((p) => import_node_fs15.default.readFileSync(p, "utf8")),
62735
62919
  // Temp-file + atomic rename so a concurrent `serve` and `director-bridge` startup can never
62736
62920
  // interleave partial writes into a config the next start has to parse. Note this normalizes the
62737
62921
  // file to 0o600 — deliberate, since both files can carry a credential-bearing URL.
62738
62922
  writeFile: deps.writeFile ?? ((p, c) => {
62739
62923
  const tmp = `${p}.tmp-${process.pid}`;
62740
- import_node_fs14.default.writeFileSync(tmp, c, { mode: 384 });
62741
- import_node_fs14.default.renameSync(tmp, p);
62924
+ import_node_fs15.default.writeFileSync(tmp, c, { mode: 384 });
62925
+ import_node_fs15.default.renameSync(tmp, p);
62742
62926
  }),
62743
- exists: deps.exists ?? ((p) => import_node_fs14.default.existsSync(p)),
62927
+ exists: deps.exists ?? ((p) => import_node_fs15.default.existsSync(p)),
62744
62928
  log: deps.log ?? ((m) => process.stderr.write(`${m}
62745
62929
  `))
62746
62930
  };
@@ -62779,7 +62963,7 @@ function backupOnce(file2, text, deps) {
62779
62963
  }
62780
62964
  function migrateEcosystemConfig(deps = {}) {
62781
62965
  const d = defaultDeps(deps);
62782
- const file2 = import_node_path24.default.join(d.home, ".mrrlin", "ecosystem.config.cjs");
62966
+ const file2 = import_node_path25.default.join(d.home, ".mrrlin", "ecosystem.config.cjs");
62783
62967
  if (!d.exists(file2)) return { file: file2, status: "absent" };
62784
62968
  const text = d.readFile(file2);
62785
62969
  if (!findRetiredHost(text) && !hasLiveLegacyStagingFlag(text, "js"))
@@ -62929,7 +63113,7 @@ ${envLines}
62929
63113
  }
62930
63114
  function migrateCodexConfig(deps = {}) {
62931
63115
  const d = defaultDeps(deps);
62932
- const file2 = import_node_path24.default.join(d.codexHome, "config.toml");
63116
+ const file2 = import_node_path25.default.join(d.codexHome, "config.toml");
62933
63117
  if (!d.exists(file2)) return { file: file2, status: "absent" };
62934
63118
  const text = d.readFile(file2);
62935
63119
  const host = findRetiredHost(text);
@@ -63015,7 +63199,7 @@ $1`
63015
63199
  }
63016
63200
  function migrateClaudeConfig(deps = {}) {
63017
63201
  const d = defaultDeps(deps);
63018
- const file2 = import_node_path24.default.join(d.home, ".claude.json");
63202
+ const file2 = import_node_path25.default.join(d.home, ".claude.json");
63019
63203
  if (!d.exists(file2)) return { file: file2, status: "absent" };
63020
63204
  const text = d.readFile(file2);
63021
63205
  let parsed;
@@ -63065,9 +63249,9 @@ function migrateRetiredApiBaseUrls(deps = {}) {
63065
63249
  const d = defaultDeps(deps);
63066
63250
  const results = [];
63067
63251
  const steps = [
63068
- { run: migrateEcosystemConfig, file: import_node_path24.default.join(d.home, ".mrrlin", "ecosystem.config.cjs") },
63069
- { run: migrateCodexConfig, file: import_node_path24.default.join(d.codexHome, "config.toml") },
63070
- { run: migrateClaudeConfig, file: import_node_path24.default.join(d.home, ".claude.json") }
63252
+ { run: migrateEcosystemConfig, file: import_node_path25.default.join(d.home, ".mrrlin", "ecosystem.config.cjs") },
63253
+ { run: migrateCodexConfig, file: import_node_path25.default.join(d.codexHome, "config.toml") },
63254
+ { run: migrateClaudeConfig, file: import_node_path25.default.join(d.home, ".claude.json") }
63071
63255
  ];
63072
63256
  for (const step of steps) {
63073
63257
  try {
@@ -63093,8 +63277,8 @@ function migrateRetiredApiBaseUrls(deps = {}) {
63093
63277
  }
63094
63278
 
63095
63279
  // src/bridge-health.ts
63096
- var import_node_fs15 = require("node:fs");
63097
- var import_node_path25 = __toESM(require("node:path"), 1);
63280
+ var import_node_fs16 = require("node:fs");
63281
+ var import_node_path26 = __toESM(require("node:path"), 1);
63098
63282
  var SENTINEL_FILE_NAME = "bridge-health-circuit-breaker.json";
63099
63283
  var CRASH_WINDOW_MS = 60 * 60 * 1e3;
63100
63284
  var MAX_CRASHES_PER_WINDOW = 3;
@@ -63106,9 +63290,9 @@ function isCrashSentinel(value) {
63106
63290
  return typeof candidate.crashCount === "number" && Number.isInteger(candidate.crashCount) && candidate.crashCount >= 0 && typeof candidate.windowStartedAt === "string";
63107
63291
  }
63108
63292
  async function readCrashSentinel(stateDir, now = Date.now) {
63109
- const sentinelPath = import_node_path25.default.join(stateDir, SENTINEL_FILE_NAME);
63293
+ const sentinelPath = import_node_path26.default.join(stateDir, SENTINEL_FILE_NAME);
63110
63294
  try {
63111
- const raw = await import_node_fs15.promises.readFile(sentinelPath, "utf8");
63295
+ const raw = await import_node_fs16.promises.readFile(sentinelPath, "utf8");
63112
63296
  const parsed = JSON.parse(raw);
63113
63297
  if (isCrashSentinel(parsed)) return parsed;
63114
63298
  } catch {
@@ -63116,11 +63300,11 @@ async function readCrashSentinel(stateDir, now = Date.now) {
63116
63300
  return { crashCount: 0, windowStartedAt: new Date(now()).toISOString() };
63117
63301
  }
63118
63302
  async function writeCrashSentinel(stateDir, sentinel) {
63119
- await import_node_fs15.promises.mkdir(stateDir, { recursive: true });
63120
- const sentinelPath = import_node_path25.default.join(stateDir, SENTINEL_FILE_NAME);
63303
+ await import_node_fs16.promises.mkdir(stateDir, { recursive: true });
63304
+ const sentinelPath = import_node_path26.default.join(stateDir, SENTINEL_FILE_NAME);
63121
63305
  const tmpPath = `${sentinelPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
63122
- await import_node_fs15.promises.writeFile(tmpPath, JSON.stringify(sentinel), "utf8");
63123
- await import_node_fs15.promises.rename(tmpPath, sentinelPath);
63306
+ await import_node_fs16.promises.writeFile(tmpPath, JSON.stringify(sentinel), "utf8");
63307
+ await import_node_fs16.promises.rename(tmpPath, sentinelPath);
63124
63308
  }
63125
63309
  function withTimeout(fn, ms = DEFAULT_OPERATION_TIMEOUT_MS) {
63126
63310
  const controller = new AbortController();
@@ -63447,12 +63631,12 @@ function startSchedulerTickLoop(deps) {
63447
63631
 
63448
63632
  // src/retention/pruner.ts
63449
63633
  var import_promises11 = require("node:fs/promises");
63450
- var import_node_path26 = __toESM(require("node:path"), 1);
63634
+ var import_node_path27 = __toESM(require("node:path"), 1);
63451
63635
  function protectedDayFloor(protectedSinceMs) {
63452
63636
  return new Date(protectedSinceMs).toISOString().slice(0, 10);
63453
63637
  }
63454
63638
  async function prune(stateDir, bounds) {
63455
- const logsDir = import_node_path26.default.join(stateDir, "logs");
63639
+ const logsDir = import_node_path27.default.join(stateDir, "logs");
63456
63640
  let entries;
63457
63641
  try {
63458
63642
  entries = await (0, import_promises11.readdir)(logsDir);
@@ -63468,7 +63652,7 @@ async function prune(stateDir, bounds) {
63468
63652
  for (const entry of entries) {
63469
63653
  const m = bridgeRe.exec(entry);
63470
63654
  if (!m?.[1]) continue;
63471
- const fullPath = import_node_path26.default.join(logsDir, entry);
63655
+ const fullPath = import_node_path27.default.join(logsDir, entry);
63472
63656
  const s = await (0, import_promises11.stat)(fullPath);
63473
63657
  files.push({ day: m[1], size: s.size, fullPath });
63474
63658
  }
@@ -63477,7 +63661,7 @@ async function prune(stateDir, bounds) {
63477
63661
  const reasonByDay = {};
63478
63662
  let bytesRemoved = 0;
63479
63663
  async function isDaySafeToDelete(day) {
63480
- const telemetryDir = import_node_path26.default.join(stateDir, "telemetry");
63664
+ const telemetryDir = import_node_path27.default.join(stateDir, "telemetry");
63481
63665
  let telemetryEntries;
63482
63666
  try {
63483
63667
  telemetryEntries = await (0, import_promises11.readdir)(telemetryDir);
@@ -63493,7 +63677,7 @@ async function prune(stateDir, bounds) {
63493
63677
  }
63494
63678
  if (projectSlugs.length === 0) return true;
63495
63679
  for (const slug of projectSlugs) {
63496
- const markerPath = import_node_path26.default.join(telemetryDir, `.processed-${slug}-${day}`);
63680
+ const markerPath = import_node_path27.default.join(telemetryDir, `.processed-${slug}-${day}`);
63497
63681
  try {
63498
63682
  await (0, import_promises11.stat)(markerPath);
63499
63683
  } catch (err) {
@@ -63543,7 +63727,7 @@ async function prune(stateDir, bounds) {
63543
63727
  const budgetOvershootBytes = Math.max(0, totalSize2 - budgetBytes);
63544
63728
  await emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining);
63545
63729
  if (daysRemoved.length > 0) {
63546
- const sessionsPath = import_node_path26.default.join(logsDir, ".sessions.json");
63730
+ const sessionsPath = import_node_path27.default.join(logsDir, ".sessions.json");
63547
63731
  let sessionsObj = {};
63548
63732
  let fileExists = true;
63549
63733
  try {
@@ -63565,8 +63749,8 @@ async function prune(stateDir, bounds) {
63565
63749
  return { daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining, budgetOvershootBytes };
63566
63750
  }
63567
63751
  async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining) {
63568
- const logsDir = import_node_path26.default.join(stateDir, "logs");
63569
- const logPath = import_node_path26.default.join(logsDir, ".pruned.jsonl");
63752
+ const logsDir = import_node_path27.default.join(stateDir, "logs");
63753
+ const logPath = import_node_path27.default.join(logsDir, ".pruned.jsonl");
63570
63754
  await (0, import_promises11.mkdir)(logsDir, { recursive: true });
63571
63755
  const record2 = { ts: Date.now(), dir: "logs", daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining };
63572
63756
  await (0, import_promises11.appendFile)(logPath, `${JSON.stringify(record2)}
@@ -63576,7 +63760,7 @@ async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, ol
63576
63760
  // src/telemetry/turn-aggregator.ts
63577
63761
  var import_node_crypto14 = require("node:crypto");
63578
63762
  var import_promises12 = require("node:fs/promises");
63579
- var import_node_path27 = require("node:path");
63763
+ var import_node_path28 = require("node:path");
63580
63764
  var BRIDGE_FILE_RE = /^bridge-(\d{4}-\d{2}-\d{2})\.jsonl$/;
63581
63765
  var PLUMBING_COUNTER_KEY = {
63582
63766
  socket_close: "socketCloses",
@@ -63605,7 +63789,7 @@ function inheritSlug(seeds, index) {
63605
63789
  return (preceding ?? following)?.slug;
63606
63790
  }
63607
63791
  async function foldClosedDays(stateDir, today) {
63608
- const logsDir = (0, import_node_path27.join)(stateDir, "logs");
63792
+ const logsDir = (0, import_node_path28.join)(stateDir, "logs");
63609
63793
  let entries;
63610
63794
  try {
63611
63795
  entries = await (0, import_promises12.readdir)(logsDir);
@@ -63617,7 +63801,7 @@ async function foldClosedDays(stateDir, today) {
63617
63801
  if (!m) continue;
63618
63802
  const day = m[1];
63619
63803
  if (day === today) continue;
63620
- const raw = await (0, import_promises12.readFile)((0, import_node_path27.join)(logsDir, entry), "utf8");
63804
+ const raw = await (0, import_promises12.readFile)((0, import_node_path28.join)(logsDir, entry), "utf8");
63621
63805
  const groups = /* @__PURE__ */ new Map();
63622
63806
  let groupCounter = 0;
63623
63807
  for (const line of raw.split("\n")) {
@@ -63728,10 +63912,10 @@ async function foldClosedDays(stateDir, today) {
63728
63912
  rowsByProject.set(slug, rows);
63729
63913
  }
63730
63914
  if (rowsByProject.size === 0) continue;
63731
- const telemetryDir = (0, import_node_path27.join)(stateDir, "telemetry");
63915
+ const telemetryDir = (0, import_node_path28.join)(stateDir, "telemetry");
63732
63916
  await (0, import_promises12.mkdir)(telemetryDir, { recursive: true });
63733
63917
  for (const [slug, rows] of rowsByProject) {
63734
- const finalPath = (0, import_node_path27.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
63918
+ const finalPath = (0, import_node_path28.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
63735
63919
  const tmpPath = `${finalPath}.tmp-${process.pid}-${(0, import_node_crypto14.randomBytes)(6).toString("hex")}`;
63736
63920
  try {
63737
63921
  await (0, import_promises12.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
@@ -63746,27 +63930,27 @@ async function foldClosedDays(stateDir, today) {
63746
63930
 
63747
63931
  // src/telemetry/daily-uploader.ts
63748
63932
  var import_promises13 = require("node:fs/promises");
63749
- var import_node_path29 = require("node:path");
63933
+ var import_node_path30 = require("node:path");
63750
63934
 
63751
63935
  // src/telemetry/installation-id.ts
63752
63936
  var import_node_crypto15 = require("node:crypto");
63753
- var import_node_fs16 = require("node:fs");
63754
- var import_node_path28 = require("node:path");
63937
+ var import_node_fs17 = require("node:fs");
63938
+ var import_node_path29 = require("node:path");
63755
63939
  var FILE_NAME = "installation-id";
63756
63940
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
63757
63941
  var cache = /* @__PURE__ */ new Map();
63758
63942
  function resolveInstallationId(stateDir) {
63759
63943
  const cached2 = cache.get(stateDir);
63760
63944
  if (cached2 !== void 0) return cached2;
63761
- const path31 = (0, import_node_path28.join)(stateDir, FILE_NAME);
63945
+ const path33 = (0, import_node_path29.join)(stateDir, FILE_NAME);
63762
63946
  let id;
63763
63947
  try {
63764
- id = (0, import_node_fs16.readFileSync)(path31, "utf8").trim();
63948
+ id = (0, import_node_fs17.readFileSync)(path33, "utf8").trim();
63765
63949
  if (!UUID.test(id)) throw new Error("unusable");
63766
63950
  } catch {
63767
63951
  id = (0, import_node_crypto15.randomUUID)();
63768
- (0, import_node_fs16.mkdirSync)((0, import_node_path28.dirname)(path31), { recursive: true });
63769
- (0, import_node_fs16.writeFileSync)(path31, `${id}
63952
+ (0, import_node_fs17.mkdirSync)((0, import_node_path29.dirname)(path33), { recursive: true });
63953
+ (0, import_node_fs17.writeFileSync)(path33, `${id}
63770
63954
  `, "utf8");
63771
63955
  }
63772
63956
  cache.set(stateDir, id);
@@ -63783,7 +63967,7 @@ function truncateCause(err) {
63783
63967
  return `${message.slice(0, MAX_CAUSE_CHARS - 3)}...`;
63784
63968
  }
63785
63969
  async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
63786
- const telemetryDir = (0, import_node_path29.join)(stateDir, "telemetry");
63970
+ const telemetryDir = (0, import_node_path30.join)(stateDir, "telemetry");
63787
63971
  let files;
63788
63972
  try {
63789
63973
  files = await (0, import_promises13.readdir)(telemetryDir);
@@ -63799,14 +63983,14 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
63799
63983
  const [, projectSlug, day] = match;
63800
63984
  const key = `${projectSlug}\0${day}`;
63801
63985
  const entry = discovered.get(key) ?? { projectSlug, day, rowsPath: null };
63802
- if (rowsMatch) entry.rowsPath = (0, import_node_path29.join)(telemetryDir, file2);
63986
+ if (rowsMatch) entry.rowsPath = (0, import_node_path30.join)(telemetryDir, file2);
63803
63987
  discovered.set(key, entry);
63804
63988
  }
63805
63989
  const today = telemetryDay();
63806
63990
  const pending = [];
63807
63991
  const deferred = [];
63808
63992
  for (const { projectSlug, day, rowsPath } of discovered.values()) {
63809
- const markerPath = (0, import_node_path29.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
63993
+ const markerPath = (0, import_node_path30.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
63810
63994
  if (rowsPath === null && day >= today) {
63811
63995
  try {
63812
63996
  await (0, import_promises13.access)(markerPath);
@@ -63826,7 +64010,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
63826
64010
  const fullUnprocessed = [...pending.map((p) => ({ projectSlug: p.projectSlug, day: p.day })), ...deferred];
63827
64011
  pending.sort((a, b) => a.day.localeCompare(b.day));
63828
64012
  for (const cur of pending) {
63829
- const failurePath = (0, import_node_path29.join)(telemetryDir, `.failed-${cur.projectSlug}-${cur.day}.json`);
64013
+ const failurePath = (0, import_node_path30.join)(telemetryDir, `.failed-${cur.projectSlug}-${cur.day}.json`);
63830
64014
  let failureState = null;
63831
64015
  try {
63832
64016
  const data = await (0, import_promises13.readFile)(failurePath, "utf8");
@@ -63860,7 +64044,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
63860
64044
  }
63861
64045
  const gateCalls = [];
63862
64046
  try {
63863
- const rawGate = await (0, import_promises13.readFile)((0, import_node_path29.join)(telemetryDir, gateFileName(cur.projectSlug, cur.day)), "utf8");
64047
+ const rawGate = await (0, import_promises13.readFile)((0, import_node_path30.join)(telemetryDir, gateFileName(cur.projectSlug, cur.day)), "utf8");
63864
64048
  for (const line of rawGate.split("\n")) {
63865
64049
  if (!line.trim()) continue;
63866
64050
  try {
@@ -64062,7 +64246,7 @@ async function collectAgentPoolSnapshot(deps) {
64062
64246
  }
64063
64247
 
64064
64248
  // src/external-agents-spawn.ts
64065
- var import_node_child_process18 = require("node:child_process");
64249
+ var import_node_child_process19 = require("node:child_process");
64066
64250
  function runExternalAgentsCli(args, opts) {
64067
64251
  let command;
64068
64252
  let prefixArgs;
@@ -64093,7 +64277,7 @@ function runExternalAgentsCli(args, opts) {
64093
64277
  };
64094
64278
  let spawned;
64095
64279
  try {
64096
- spawned = (0, import_node_child_process18.spawn)(command, [...prefixArgs, ...args], { stdio: stdioConfig });
64280
+ spawned = (0, import_node_child_process19.spawn)(command, [...prefixArgs, ...args], { stdio: stdioConfig });
64097
64281
  } catch {
64098
64282
  done(1);
64099
64283
  return;
@@ -64205,14 +64389,14 @@ function startAgentPoolLoop(deps) {
64205
64389
  }
64206
64390
 
64207
64391
  // src/provider-readiness-loop.ts
64208
- var import_node_child_process19 = require("node:child_process");
64392
+ var import_node_child_process20 = require("node:child_process");
64209
64393
  var DEFAULT_INTERVAL_MS3 = 6e4;
64210
64394
  function providerReadinessLoopDisabled(env = process.env) {
64211
64395
  return env["MRRLIN_BRIDGE_PROVIDER_READINESS_DISABLE"] === "1";
64212
64396
  }
64213
64397
  function defaultRunnerFor(command) {
64214
64398
  return (args) => {
64215
- const r = (0, import_node_child_process19.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3 });
64399
+ const r = (0, import_node_child_process20.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3 });
64216
64400
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
64217
64401
  };
64218
64402
  }
@@ -64255,9 +64439,9 @@ function startProviderReadinessLoop(deps) {
64255
64439
  }
64256
64440
 
64257
64441
  // src/execution-consumer.ts
64258
- var import_node_child_process21 = require("node:child_process");
64259
- var import_node_crypto17 = __toESM(require("node:crypto"), 1);
64260
- var import_node_path32 = __toESM(require("node:path"), 1);
64442
+ var import_node_child_process23 = require("node:child_process");
64443
+ var import_node_crypto18 = __toESM(require("node:crypto"), 1);
64444
+ var import_node_path34 = __toESM(require("node:path"), 1);
64261
64445
  var import_node_util2 = require("node:util");
64262
64446
 
64263
64447
  // src/notify-templates.ts
@@ -65111,19 +65295,19 @@ async function awaitTurnWithDeadline(opts) {
65111
65295
  }
65112
65296
 
65113
65297
  // src/worktree.ts
65114
- var import_node_child_process20 = require("node:child_process");
65298
+ var import_node_child_process21 = require("node:child_process");
65115
65299
  var import_node_crypto16 = require("node:crypto");
65116
- var import_node_fs18 = require("node:fs");
65117
- var import_node_path31 = require("node:path");
65300
+ var import_node_fs19 = require("node:fs");
65301
+ var import_node_path32 = require("node:path");
65118
65302
 
65119
65303
  // src/checkout-lock.ts
65120
- var import_node_fs17 = require("node:fs");
65121
- var import_node_path30 = require("node:path");
65304
+ var import_node_fs18 = require("node:fs");
65305
+ var import_node_path31 = require("node:path");
65122
65306
  var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
65123
65307
  async function withCheckoutLock(locksDir, slug, fn) {
65124
- (0, import_node_fs17.mkdirSync)(locksDir, { recursive: true });
65125
- const target = (0, import_node_path30.join)(locksDir, `${slug}.lock`);
65126
- if (!(0, import_node_fs17.existsSync)(target)) (0, import_node_fs17.writeFileSync)(target, "");
65308
+ (0, import_node_fs18.mkdirSync)(locksDir, { recursive: true });
65309
+ const target = (0, import_node_path31.join)(locksDir, `${slug}.lock`);
65310
+ if (!(0, import_node_fs18.existsSync)(target)) (0, import_node_fs18.writeFileSync)(target, "");
65127
65311
  const release = await import_proper_lockfile.default.lock(target, {
65128
65312
  retries: { retries: 600, factor: 1, minTimeout: 100, maxTimeout: 100 },
65129
65313
  stale: 5 * 6e4
@@ -65139,28 +65323,28 @@ async function withCheckoutLock(locksDir, slug, fn) {
65139
65323
  function worktreeBranch(runId) {
65140
65324
  return `mrrlin/run-${runId}`;
65141
65325
  }
65142
- var defaultGitExec = (args, env) => (0, import_node_child_process20.execFileSync)("git", args, { encoding: "utf8", timeout: 3e4, env });
65326
+ var defaultGitExec = (args, env) => (0, import_node_child_process21.execFileSync)("git", args, { encoding: "utf8", timeout: 3e4, env });
65143
65327
  function disabledGitHooksPath(locksDir, scope) {
65144
65328
  const scopeKey = (0, import_node_crypto16.createHash)("sha256").update(scope).digest("hex").slice(0, 32);
65145
- return (0, import_node_path31.resolve)(locksDir, "..", "disabled-git-hooks", scopeKey);
65329
+ return (0, import_node_path32.resolve)(locksDir, "..", "disabled-git-hooks", scopeKey);
65146
65330
  }
65147
65331
  function prepareDisabledGitHooksDir(locksDir, scope) {
65148
65332
  const hooksDir = disabledGitHooksPath(locksDir, scope);
65149
- const hooksRoot = (0, import_node_path31.resolve)(hooksDir, "..");
65150
- (0, import_node_fs18.mkdirSync)(hooksRoot, { recursive: true, mode: 448 });
65151
- (0, import_node_fs18.mkdirSync)(hooksDir, { recursive: true, mode: 320 });
65152
- if ((0, import_node_fs18.readdirSync)(hooksDir).length > 0) {
65333
+ const hooksRoot = (0, import_node_path32.resolve)(hooksDir, "..");
65334
+ (0, import_node_fs19.mkdirSync)(hooksRoot, { recursive: true, mode: 448 });
65335
+ (0, import_node_fs19.mkdirSync)(hooksDir, { recursive: true, mode: 320 });
65336
+ if ((0, import_node_fs19.readdirSync)(hooksDir).length > 0) {
65153
65337
  throw new Error(`disabled_git_hooks_dir_not_empty: ${hooksDir}`);
65154
65338
  }
65155
65339
  try {
65156
- (0, import_node_fs18.chmodSync)(hooksDir, 320);
65340
+ (0, import_node_fs19.chmodSync)(hooksDir, 320);
65157
65341
  } catch {
65158
65342
  }
65159
65343
  return hooksDir;
65160
65344
  }
65161
65345
  function removeDisabledGitHooksDir(locksDir, scope) {
65162
65346
  try {
65163
- (0, import_node_fs18.rmdirSync)(disabledGitHooksPath(locksDir, scope));
65347
+ (0, import_node_fs19.rmdirSync)(disabledGitHooksPath(locksDir, scope));
65164
65348
  } catch {
65165
65349
  }
65166
65350
  }
@@ -65176,20 +65360,21 @@ function withDisabledGitHooksEnv(env, hooksDir) {
65176
65360
  };
65177
65361
  }
65178
65362
  function git(checkout, args, hooksDir) {
65179
- return (0, import_node_child_process20.execFileSync)("git", ["-C", checkout, "-c", `core.hooksPath=${hooksDir}`, ...args], {
65363
+ return (0, import_node_child_process21.execFileSync)("git", ["-C", checkout, "-c", `core.hooksPath=${hooksDir}`, ...args], {
65180
65364
  encoding: "utf8",
65181
65365
  timeout: 3e4,
65182
65366
  env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
65183
65367
  });
65184
65368
  }
65185
65369
  async function createRunWorktree(opts) {
65186
- const worktreePath = (0, import_node_path31.join)(opts.worktreeRoot, opts.slug, opts.runId);
65370
+ const worktreePath = (0, import_node_path32.join)(opts.worktreeRoot, opts.slug, opts.runId);
65187
65371
  const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, opts.runId);
65188
65372
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
65189
- (0, import_node_fs18.mkdirSync)(opts.worktreeRoot, { recursive: true });
65373
+ (0, import_node_fs19.mkdirSync)(opts.worktreeRoot, { recursive: true });
65374
+ const base = opts.local ? `refs/heads/${opts.defaultBranch}` : `origin/${opts.defaultBranch}`;
65190
65375
  try {
65191
- git(opts.checkout, ["fetch", "origin", opts.defaultBranch], hooksDir);
65192
- if (!(0, import_node_fs18.existsSync)(worktreePath)) {
65376
+ if (!opts.local) git(opts.checkout, ["fetch", "origin", opts.defaultBranch], hooksDir);
65377
+ if (!(0, import_node_fs19.existsSync)(worktreePath)) {
65193
65378
  git(opts.checkout, [
65194
65379
  "worktree",
65195
65380
  "add",
@@ -65197,27 +65382,27 @@ async function createRunWorktree(opts) {
65197
65382
  "-b",
65198
65383
  worktreeBranch(opts.runId),
65199
65384
  worktreePath,
65200
- `origin/${opts.defaultBranch}`
65385
+ base
65201
65386
  ], hooksDir);
65202
65387
  }
65203
65388
  } catch (error51) {
65204
65389
  const detail = error51 instanceof Error ? error51.message : String(error51);
65205
65390
  throw new Error(
65206
- `default_branch_unresolved: could not provision worktree off origin/${opts.defaultBranch} for ${opts.slug}/${opts.runId}: ${detail}`
65391
+ `default_branch_unresolved: could not provision worktree off ${base} for ${opts.slug}/${opts.runId}: ${detail}`
65207
65392
  );
65208
65393
  }
65209
65394
  });
65210
65395
  return worktreePath;
65211
65396
  }
65212
65397
  async function removeRunWorktree(opts) {
65213
- const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, (0, import_node_path31.basename)(opts.worktreePath));
65398
+ const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, (0, import_node_path32.basename)(opts.worktreePath));
65214
65399
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
65215
65400
  try {
65216
65401
  git(opts.checkout, ["worktree", "remove", "--force", opts.worktreePath], hooksDir);
65217
65402
  } catch {
65218
65403
  }
65219
65404
  git(opts.checkout, ["worktree", "prune"], hooksDir);
65220
- removeDisabledGitHooksDir(opts.locksDir, (0, import_node_path31.basename)(opts.worktreePath));
65405
+ removeDisabledGitHooksDir(opts.locksDir, (0, import_node_path32.basename)(opts.worktreePath));
65221
65406
  });
65222
65407
  }
65223
65408
  async function pushRunBranch(opts, execGit = defaultGitExec) {
@@ -65301,11 +65486,11 @@ async function sweepOrphanWorktrees(opts) {
65301
65486
  const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, `sweep:${opts.slug}`);
65302
65487
  const ownedPrefix = (() => {
65303
65488
  try {
65304
- return (import_node_fs18.realpathSync.native ?? import_node_fs18.realpathSync)(opts.worktreeRoot);
65489
+ return (import_node_fs19.realpathSync.native ?? import_node_fs19.realpathSync)(opts.worktreeRoot);
65305
65490
  } catch {
65306
65491
  return opts.worktreeRoot;
65307
65492
  }
65308
- })() + import_node_path31.sep + opts.slug + import_node_path31.sep;
65493
+ })() + import_node_path32.sep + opts.slug + import_node_path32.sep;
65309
65494
  try {
65310
65495
  await withCheckoutLock(opts.locksDir, opts.slug, async () => {
65311
65496
  const listing = git(opts.checkout, ["worktree", "list", "--porcelain"], hooksDir);
@@ -65315,18 +65500,18 @@ async function sweepOrphanWorktrees(opts) {
65315
65500
  if (!wt) continue;
65316
65501
  const canonicalWt = (() => {
65317
65502
  try {
65318
- return (import_node_fs18.realpathSync.native ?? import_node_fs18.realpathSync)(wt);
65503
+ return (import_node_fs19.realpathSync.native ?? import_node_fs19.realpathSync)(wt);
65319
65504
  } catch {
65320
65505
  return wt;
65321
65506
  }
65322
65507
  })();
65323
- const normWt = (0, import_node_path31.normalize)(canonicalWt);
65324
- const normPrefix = (0, import_node_path31.normalize)(ownedPrefix);
65508
+ const normWt = (0, import_node_path32.normalize)(canonicalWt);
65509
+ const normPrefix = (0, import_node_path32.normalize)(ownedPrefix);
65325
65510
  const isMatch = process.platform === "win32" ? normWt.toLowerCase().startsWith(normPrefix.toLowerCase()) : normWt.startsWith(normPrefix);
65326
65511
  if (isMatch && opts.isReapable(wt)) {
65327
65512
  try {
65328
65513
  git(opts.checkout, ["worktree", "remove", "--force", wt], hooksDir);
65329
- removeDisabledGitHooksDir(opts.locksDir, (0, import_node_path31.basename)(wt));
65514
+ removeDisabledGitHooksDir(opts.locksDir, (0, import_node_path32.basename)(wt));
65330
65515
  reaped.push(wt);
65331
65516
  } catch {
65332
65517
  }
@@ -65375,6 +65560,159 @@ function buildPullRequestBody(input) {
65375
65560
  ${lines2.join("\n")}`;
65376
65561
  }
65377
65562
 
65563
+ // src/delivery/local-git.ts
65564
+ var import_node_child_process22 = require("node:child_process");
65565
+ var import_node_crypto17 = require("node:crypto");
65566
+ var import_node_fs20 = require("node:fs");
65567
+ var import_node_path33 = __toESM(require("node:path"), 1);
65568
+ function isLocalGitRoute(route) {
65569
+ return Boolean(route && route.serverId === BUILTIN_CAPABILITY_SERVER_ID && route.operations.commit === LOCAL_GIT_TOOL_NAME);
65570
+ }
65571
+ function git2(repo, args) {
65572
+ return (0, import_node_child_process22.execFileSync)("git", ["-C", repo, ...args], {
65573
+ encoding: "utf8",
65574
+ timeout: 3e4,
65575
+ stdio: ["ignore", "pipe", "pipe"],
65576
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
65577
+ }).trim();
65578
+ }
65579
+ function branchExists(repo, branch) {
65580
+ try {
65581
+ git2(repo, ["rev-parse", "--verify", "--quiet", `refs/heads/${branch}`]);
65582
+ return true;
65583
+ } catch {
65584
+ return false;
65585
+ }
65586
+ }
65587
+ function resolveLocalDefaultBranch(checkout) {
65588
+ for (const candidate of ["main", "master"]) {
65589
+ if (branchExists(checkout, candidate)) return candidate;
65590
+ }
65591
+ try {
65592
+ const current2 = git2(checkout, ["symbolic-ref", "--quiet", "--short", "HEAD"]);
65593
+ if (current2 && branchExists(checkout, current2)) return current2;
65594
+ } catch {
65595
+ }
65596
+ throw new Error(`default_branch_unresolved: ${checkout} has no committed branch to branch a run from`);
65597
+ }
65598
+ var NPM_PLACEHOLDER_TEST = /no test specified/i;
65599
+ function detectBuildCommands(worktree) {
65600
+ const pkgPath = import_node_path33.default.join(worktree, "package.json");
65601
+ if ((0, import_node_fs20.existsSync)(pkgPath)) {
65602
+ let scripts = {};
65603
+ let hasDeps = false;
65604
+ try {
65605
+ const pkg = JSON.parse((0, import_node_fs20.readFileSync)(pkgPath, "utf8"));
65606
+ scripts = pkg.scripts ?? {};
65607
+ hasDeps = Boolean(pkg.dependencies || pkg.devDependencies);
65608
+ } catch {
65609
+ return [];
65610
+ }
65611
+ const pm = (0, import_node_fs20.existsSync)(import_node_path33.default.join(worktree, "pnpm-lock.yaml")) ? "pnpm" : (0, import_node_fs20.existsSync)(import_node_path33.default.join(worktree, "yarn.lock")) ? "yarn" : "npm";
65612
+ const commands = [];
65613
+ const wantsBuild = typeof scripts.build === "string" && scripts.build.trim().length > 0;
65614
+ const wantsTest = typeof scripts.test === "string" && scripts.test.trim().length > 0 && !NPM_PLACEHOLDER_TEST.test(scripts.test);
65615
+ if ((wantsBuild || wantsTest) && hasDeps && !(0, import_node_fs20.existsSync)(import_node_path33.default.join(worktree, "node_modules"))) {
65616
+ commands.push({ label: `${pm} install`, file: pm, args: ["install"] });
65617
+ }
65618
+ if (wantsBuild) commands.push({ label: `${pm} run build`, file: pm, args: ["run", "build"] });
65619
+ if (wantsTest) commands.push({ label: `${pm} run test`, file: pm, args: ["run", "test"] });
65620
+ return commands;
65621
+ }
65622
+ const makefile = ["Makefile", "makefile", "GNUmakefile"].map((name) => import_node_path33.default.join(worktree, name)).find(import_node_fs20.existsSync);
65623
+ if (makefile && /^test\s*:/m.test((0, import_node_fs20.readFileSync)(makefile, "utf8"))) {
65624
+ return [{ label: "make test", file: "make", args: ["test"] }];
65625
+ }
65626
+ return [];
65627
+ }
65628
+ var DEFAULT_STEP_TIMEOUT_MS = 15 * 6e4;
65629
+ var defaultStepRunner = (command, cwd) => {
65630
+ const result = (0, import_node_child_process22.spawnSync)(command.file, command.args, {
65631
+ cwd,
65632
+ encoding: "utf8",
65633
+ timeout: DEFAULT_STEP_TIMEOUT_MS,
65634
+ maxBuffer: 64 * 1024 * 1024,
65635
+ env: { ...process.env, CI: "1", GIT_TERMINAL_PROMPT: "0" }
65636
+ });
65637
+ const output3 = `${result.stdout ?? ""}${result.stderr ?? ""}${result.error ? `
65638
+ ${result.error.message}` : ""}`;
65639
+ return { exitCode: typeof result.status === "number" ? result.status : 1, output: output3 };
65640
+ };
65641
+ function sha2562(text) {
65642
+ return (0, import_node_crypto17.createHash)("sha256").update(text).digest("hex");
65643
+ }
65644
+ function deliverLocalGit(input) {
65645
+ const branch = `mrrlin/run-${input.runId}`;
65646
+ const currentBranch = git2(input.worktreePath, ["rev-parse", "--abbrev-ref", "HEAD"]);
65647
+ if (currentBranch !== branch) {
65648
+ throw new Error(`local_delivery_branch_mismatch: worktree is on ${currentBranch}, expected ${branch}`);
65649
+ }
65650
+ if (git2(input.worktreePath, ["status", "--porcelain"]).length > 0) {
65651
+ git2(input.worktreePath, ["add", "-A"]);
65652
+ git2(input.worktreePath, [
65653
+ "-c",
65654
+ "user.name=Mrrlin",
65655
+ "-c",
65656
+ "user.email=bridge@mrrlin.local",
65657
+ "commit",
65658
+ "--no-verify",
65659
+ "-m",
65660
+ `mrrlin: ${input.runId} work`
65661
+ ]);
65662
+ }
65663
+ const headSha = git2(input.worktreePath, ["rev-parse", "HEAD"]);
65664
+ const commitCount = Number(git2(input.worktreePath, ["rev-list", "--count", `${input.baseSha}..${headSha}`]));
65665
+ if (!Number.isInteger(commitCount) || commitCount < 0) {
65666
+ throw new Error(`local_delivery_commit_count_unreadable: git rev-list returned ${String(commitCount)}`);
65667
+ }
65668
+ const checkoutDigest = sha2562(input.checkoutRealPath);
65669
+ (0, import_node_fs20.mkdirSync)(input.evidenceDir, { recursive: true, mode: 448 });
65670
+ const evidenceFile = import_node_path33.default.join(input.evidenceDir, `${input.runId}.json`);
65671
+ if (!(commitCount > 0)) {
65672
+ (0, import_node_fs20.writeFileSync)(
65673
+ evidenceFile,
65674
+ JSON.stringify({ checkout: input.checkoutRealPath, branch, baseSha: input.baseSha, headSha, commitCount, steps: [] }, null, 2),
65675
+ { mode: 384 }
65676
+ );
65677
+ return {
65678
+ ok: false,
65679
+ reason: "no_commits",
65680
+ detail: `no_commits_to_deliver: run ${input.runId} has no commits on ${branch} ahead of ${input.baseSha.slice(0, 12)}`,
65681
+ evidence: null,
65682
+ evidenceFile
65683
+ };
65684
+ }
65685
+ const runStep = input.runStep ?? defaultStepRunner;
65686
+ const steps = [];
65687
+ const logs = [];
65688
+ for (const command of detectBuildCommands(input.worktreePath)) {
65689
+ const { exitCode, output: output3 } = runStep(command, input.worktreePath);
65690
+ steps.push({ command: command.label, exitCode, logDigest: sha2562(output3) });
65691
+ logs.push({ command: command.label, exitCode, output: output3.slice(-2e5) });
65692
+ if (exitCode !== 0) break;
65693
+ }
65694
+ const evidence = {
65695
+ branch,
65696
+ baseSha: input.baseSha,
65697
+ headSha,
65698
+ commitCount,
65699
+ steps,
65700
+ noBuildStep: steps.length === 0,
65701
+ checkoutDigest
65702
+ };
65703
+ (0, import_node_fs20.writeFileSync)(evidenceFile, JSON.stringify({ checkout: input.checkoutRealPath, ...evidence, logs }, null, 2), { mode: 384 });
65704
+ const problem = checkLocalBuildEvidence({ type: "build", value: headSha }, evidence);
65705
+ if (problem) {
65706
+ return { ok: false, reason: "build_failed", detail: `local_build_failed: ${problem}`, evidence, evidenceFile };
65707
+ }
65708
+ return {
65709
+ ok: true,
65710
+ evidence,
65711
+ deliveryRef: formatLocalDeliveryRef({ projectSlug: input.projectSlug, branch, headSha }),
65712
+ evidenceFile
65713
+ };
65714
+ }
65715
+
65378
65716
  // src/thread-retirement.ts
65379
65717
  function decideThreadRetirement(input) {
65380
65718
  if (input.disabled) return { retire: false };
@@ -65823,6 +66161,16 @@ var EXECUTOR_BASE_INSTRUCTIONS = [
65823
66161
  "commit unverified delegated output. If dispatch fails or the pool is unavailable, do the",
65824
66162
  "work yourself \u2014 never block the run on the pool."
65825
66163
  ].join("\n");
66164
+ var LOCAL_GIT_EXECUTOR_INSTRUCTIONS = [
66165
+ "",
66166
+ "This project's code lives only in a git repository on the operator's own computer; it has no",
66167
+ "remote. Your worktree is on the run branch. Commit your work on THIS branch. Never run `git push`,",
66168
+ "never add a remote, never open a pull request, and never switch to or merge into the default branch.",
66169
+ "When your turn ends, the bridge itself commits anything left uncommitted, runs the project's build",
66170
+ "and tests, and records the result \u2014 you do not need to report a link."
66171
+ ].join("\n");
66172
+ var EXECUTOR_LOCAL_GIT_BASE_INSTRUCTIONS = `${EXECUTOR_BASE_INSTRUCTIONS}
66173
+ ${LOCAL_GIT_EXECUTOR_INSTRUCTIONS}`;
65826
66174
  function artifactKindForEvent(event) {
65827
66175
  switch (event.type) {
65828
66176
  case "assistant":
@@ -65858,13 +66206,20 @@ function isBridgeGeneratedArtifact(artifact) {
65858
66206
  return typeof payload === "object" && payload !== null && "event" in payload;
65859
66207
  }
65860
66208
  function newArtifactId() {
65861
- return `EA-${import_node_crypto17.default.randomUUID()}`;
66209
+ return `EA-${import_node_crypto18.default.randomUUID()}`;
65862
66210
  }
65863
66211
  var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
65864
- function isBlastRadiusFloorPath(path31) {
65865
- return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path31));
66212
+ function isBlastRadiusFloorPath(path33) {
66213
+ return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path33));
66214
+ }
66215
+ var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process23.execFile);
66216
+ async function gitOutput(cwd, args) {
66217
+ const { stdout } = await execFileAsync2("git", ["-C", cwd, ...args], {
66218
+ timeout: 3e4,
66219
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
66220
+ });
66221
+ return String(stdout).trim();
65866
66222
  }
65867
- var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process21.execFile);
65868
66223
  async function defaultListRunDiffPaths(opts) {
65869
66224
  const parse8 = (stdout) => stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
65870
66225
  try {
@@ -66109,7 +66464,7 @@ async function driveRun(deps, projectSlug, runId) {
66109
66464
  if (!claimed) return;
66110
66465
  if (!claimed.leaseId) {
66111
66466
  await deps.client.createInboxItem(projectSlug, {
66112
- id: `II-${import_node_crypto17.default.randomUUID()}`,
66467
+ id: `II-${import_node_crypto18.default.randomUUID()}`,
66113
66468
  kind: "handoff",
66114
66469
  taskId: claimed.taskId,
66115
66470
  body: `Execution run ${runId} was claimed but returned no leaseId. This indicates DB/API corruption and requires operator attention.`
@@ -66126,6 +66481,7 @@ async function driveRun(deps, projectSlug, runId) {
66126
66481
  return legacy != null ? Math.min(legacy, remaining) : remaining;
66127
66482
  };
66128
66483
  const task = await deps.client.getTask(projectSlug, claimed.taskId);
66484
+ let localGitMode = null;
66129
66485
  if (task.declaredOutcome != null) {
66130
66486
  for (const kind of task.declaredOutcome.requires) {
66131
66487
  if (resolveKindCapability(kind) === null) {
@@ -66158,6 +66514,7 @@ async function driveRun(deps, projectSlug, runId) {
66158
66514
  );
66159
66515
  return;
66160
66516
  }
66517
+ if (kind === "code_change") localGitMode = isLocalGitRoute(routeResolution.route);
66161
66518
  }
66162
66519
  }
66163
66520
  const needsBrowser = claimed.prerequisites?.some((p) => p.mcp === "mrrlin-browser") || task.domains?.includes("browser");
@@ -66423,6 +66780,28 @@ ${renderTaskStateSection(taskState)}`;
66423
66780
  let codex;
66424
66781
  let disposeCodex = () => {
66425
66782
  };
66783
+ let localCheckoutRealPath = null;
66784
+ let localBaseSha = null;
66785
+ if (claimed.codeExecution && localGitMode === null) {
66786
+ try {
66787
+ const resolution = await deps.client.resolveArtifactKindRoute(projectSlug, "code_change", projectSlug);
66788
+ localGitMode = resolution.ok ? isLocalGitRoute(resolution.route) : false;
66789
+ } catch {
66790
+ localGitMode = false;
66791
+ }
66792
+ }
66793
+ if (claimed.codeExecution && localGitMode && !checkout) {
66794
+ await failRun(
66795
+ deps,
66796
+ projectSlug,
66797
+ task,
66798
+ runId,
66799
+ leaseId,
66800
+ `local_checkout_missing: run ${runId} needs code execution, but project ${projectSlug} keeps its code only on this computer and no project folder is registered for it yet. Explain this to the operator in plain, non-technical language, then ask which folder on their computer holds this project. When they confirm an absolute path, call register_local_checkout({ projectSlug: "${projectSlug}", path: "<absolute path>" }) WITHOUT a repo. If that folder is not a git repository yet, ask their explicit permission before turning it into one. Once a folder is registered, the run can be re-queued.`,
66801
+ "local_checkout_missing"
66802
+ );
66803
+ return;
66804
+ }
66426
66805
  if (claimed.codeExecution) {
66427
66806
  if (!checkout) {
66428
66807
  const reason = `local_checkout_missing: run ${runId} needs code execution, but project ${projectSlug} has no local git checkout registered on this machine, so there is nowhere to make the changes. Explain this to the operator in plain, non-technical language, then proactively help register one:
@@ -66438,22 +66817,46 @@ ${renderTaskStateSection(taskState)}`;
66438
66817
  await failRun(deps, projectSlug, task, runId, leaseId, reason);
66439
66818
  return;
66440
66819
  }
66820
+ if (localGitMode) {
66821
+ const validated = validateLocalCheckoutPath(checkout.path, deps.localCheckoutRules);
66822
+ if (!validated.ok) {
66823
+ await failRun(
66824
+ deps,
66825
+ projectSlug,
66826
+ task,
66827
+ runId,
66828
+ leaseId,
66829
+ `local_checkout_invalid: run ${runId} cannot use the folder registered for project ${projectSlug} (${validated.code}): ${validated.detail}. Ask the operator to confirm the project folder again and re-register it with register_local_checkout.`
66830
+ );
66831
+ return;
66832
+ }
66833
+ localCheckoutRealPath = validated.realPath;
66834
+ }
66441
66835
  try {
66442
66836
  const createWt = deps.createRunWorktree ?? createRunWorktree;
66443
- const getDefaultBranch = deps.getDefaultBranch ?? (async () => "main");
66444
- resolvedDefaultBranch = await getDefaultBranch(projectSlug);
66837
+ if (localGitMode && localCheckoutRealPath) {
66838
+ resolvedDefaultBranch = (deps.resolveLocalDefaultBranch ?? resolveLocalDefaultBranch)(localCheckoutRealPath);
66839
+ } else {
66840
+ const getDefaultBranch = deps.getDefaultBranch ?? (async () => "main");
66841
+ resolvedDefaultBranch = await getDefaultBranch(projectSlug);
66842
+ }
66445
66843
  worktreePath = await createWt({
66446
- checkout: checkout.path,
66844
+ checkout: localCheckoutRealPath ?? checkout.path,
66447
66845
  worktreeRoot: deps.worktreeRoot ?? "/tmp/mrrlin-worktrees",
66448
66846
  locksDir: deps.locksDir ?? "/tmp/mrrlin-locks",
66449
66847
  slug: projectSlug,
66450
66848
  runId,
66451
- defaultBranch: resolvedDefaultBranch
66849
+ defaultBranch: resolvedDefaultBranch,
66850
+ ...localGitMode ? { local: true } : {}
66452
66851
  });
66852
+ if (localGitMode) {
66853
+ localBaseSha = await gitOutput(worktreePath, ["merge-base", "HEAD", `refs/heads/${resolvedDefaultBranch}`]);
66854
+ }
66453
66855
  if (!await runHasLease(deps, projectSlug, runId, leaseId)) return;
66454
66856
  await deps.client.updateExecutionRun(projectSlug, runId, {
66455
66857
  worktreeId: worktreePath,
66456
- branch: worktreeBranch(runId)
66858
+ branch: worktreeBranch(runId),
66859
+ ...localBaseSha ? { baseSha: localBaseSha } : {}
66457
66860
  });
66458
66861
  sandbox = "danger-full-access";
66459
66862
  turnCwd = worktreePath;
@@ -66522,7 +66925,7 @@ ${renderTaskStateSection(taskState)}`;
66522
66925
  // write-authorized within its worktree, so it must NOT receive the
66523
66926
  // read-only-sandbox claim (which makes a write-authorized model
66524
66927
  // self-censor). The read-only path keeps the never-write restriction.
66525
- baseInstructions: useExecutor ? EXECUTOR_BASE_INSTRUCTIONS : CONSUMER_BASE_INSTRUCTIONS,
66928
+ baseInstructions: useExecutor ? localGitMode ? EXECUTOR_LOCAL_GIT_BASE_INSTRUCTIONS : EXECUTOR_BASE_INSTRUCTIONS : CONSUMER_BASE_INSTRUCTIONS,
66526
66929
  developerInstructions: null,
66527
66930
  ephemeral: null,
66528
66931
  mcpConfig: deps.mcpConfigPath
@@ -66734,7 +67137,7 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
66734
67137
  if (!await runHasLease(deps, projectSlug, runId, leaseId)) return;
66735
67138
  const hasCommitsFn = deps.hasCommitsToPush ?? hasCommitsToPush;
66736
67139
  const defaultBranchForPush = resolvedDefaultBranch ?? "main";
66737
- if (!await hasCommitsFn({ worktreePath, defaultBranch: defaultBranchForPush })) {
67140
+ if (!localGitMode && !await hasCommitsFn({ worktreePath, defaultBranch: defaultBranchForPush })) {
66738
67141
  await failRun(
66739
67142
  deps,
66740
67143
  projectSlug,
@@ -66767,6 +67170,18 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
66767
67170
  } else {
66768
67171
  console.warn(JSON.stringify({ event: "self_review_gate_skipped", projectSlug, runId, reason: "no selfReviewTurn dep" }));
66769
67172
  }
67173
+ if (localGitMode) {
67174
+ await deliverLocalRun(deps, {
67175
+ projectSlug,
67176
+ task: readiness.task,
67177
+ runId,
67178
+ leaseId,
67179
+ worktreePath,
67180
+ checkoutRealPath: localCheckoutRealPath ?? checkout?.path ?? worktreePath,
67181
+ baseSha: localBaseSha
67182
+ });
67183
+ return;
67184
+ }
66770
67185
  const snapshot = await deps.client.getProjectSnapshot(projectSlug);
66771
67186
  const expectedRepoFullName = snapshot.github?.repo ?? null;
66772
67187
  if (!expectedRepoFullName) {
@@ -66899,7 +67314,7 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
66899
67314
  taskId: task.id,
66900
67315
  runId,
66901
67316
  outcome: "completed",
66902
- nonce: import_node_crypto17.default.randomUUID(),
67317
+ nonce: import_node_crypto18.default.randomUUID(),
66903
67318
  artifacts: []
66904
67319
  }
66905
67320
  );
@@ -67387,7 +67802,7 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2,
67387
67802
  taskId: task.id,
67388
67803
  runId,
67389
67804
  outcome: parsedResult.outcome,
67390
- nonce: import_node_crypto17.default.randomUUID(),
67805
+ nonce: import_node_crypto18.default.randomUUID(),
67391
67806
  artifacts: [
67392
67807
  {
67393
67808
  artifactId: pageId,
@@ -67456,6 +67871,141 @@ async function resetWedgedThread(deps, projectSlug, taskId, interruptFailed) {
67456
67871
  await deps.client.resetDirectorThread(projectSlug, taskId).catch(() => {
67457
67872
  });
67458
67873
  }
67874
+ async function deliverLocalRun(deps, input) {
67875
+ const { projectSlug, task, runId, leaseId } = input;
67876
+ if (!input.baseSha) {
67877
+ await failRun(deps, projectSlug, task, runId, leaseId, `local_delivery_failed: run ${runId} has no recorded base commit.`);
67878
+ return;
67879
+ }
67880
+ if (!deps.localEvidenceDir) {
67881
+ await failRun(
67882
+ deps,
67883
+ projectSlug,
67884
+ task,
67885
+ runId,
67886
+ leaseId,
67887
+ `local_delivery_failed: run ${runId} has no bridge evidence directory configured (localEvidenceDir).`
67888
+ );
67889
+ return;
67890
+ }
67891
+ const evidenceDir = deps.localEvidenceDir;
67892
+ const deliver = deps.deliverLocalGit ?? deliverLocalGit;
67893
+ let outcome;
67894
+ try {
67895
+ outcome = deliver({
67896
+ projectSlug,
67897
+ runId,
67898
+ checkoutRealPath: input.checkoutRealPath,
67899
+ worktreePath: input.worktreePath,
67900
+ baseSha: input.baseSha,
67901
+ evidenceDir
67902
+ });
67903
+ } catch (error51) {
67904
+ await failRun(
67905
+ deps,
67906
+ projectSlug,
67907
+ task,
67908
+ runId,
67909
+ leaseId,
67910
+ `local_delivery_failed: ${error51 instanceof Error ? error51.message : String(error51)}`
67911
+ );
67912
+ return;
67913
+ }
67914
+ if (!outcome.ok) {
67915
+ if (outcome.evidence) {
67916
+ await deps.client.updateExecutionRun(projectSlug, runId, { headSha: outcome.evidence.headSha }).catch(() => {
67917
+ });
67918
+ }
67919
+ await failRun(deps, projectSlug, task, runId, leaseId, outcome.detail);
67920
+ return;
67921
+ }
67922
+ if (!await runHasLease(deps, projectSlug, runId, leaseId)) return;
67923
+ await deps.client.updateExecutionRun(projectSlug, runId, {
67924
+ headSha: outcome.evidence.headSha,
67925
+ deliveryRef: outcome.deliveryRef
67926
+ });
67927
+ const receipt = {
67928
+ ...buildReceipt({
67929
+ declaredOutcome: task.declaredOutcome ?? { sentence: task.title, requires: ["code_change"], verification: "machine" },
67930
+ evidenceType: "build",
67931
+ evidenceValue: outcome.evidence.headSha,
67932
+ coveredKinds: ["code_change"]
67933
+ }),
67934
+ localBuild: outcome.evidence
67935
+ };
67936
+ const artifactId = `EA-LG-${runId}-${outcome.evidence.headSha.slice(0, 12)}`;
67937
+ let artifact;
67938
+ try {
67939
+ artifact = await deps.client.appendExecutionArtifact(projectSlug, runId, {
67940
+ id: artifactId,
67941
+ kind: "verification",
67942
+ payload: { [LOCAL_BUILD_RECEIPT_PAYLOAD_KEY]: receipt, deliveryRef: outcome.deliveryRef }
67943
+ });
67944
+ } catch (error51) {
67945
+ const existing = await deps.client.listExecutionArtifacts(projectSlug, runId).catch(() => []);
67946
+ const found = existing.find((candidate) => candidate.id === artifactId);
67947
+ if (!found) {
67948
+ await failRun(
67949
+ deps,
67950
+ projectSlug,
67951
+ task,
67952
+ runId,
67953
+ leaseId,
67954
+ `local_delivery_failed: could not record the build receipt: ${error51 instanceof Error ? error51.message : String(error51)}`
67955
+ );
67956
+ return;
67957
+ }
67958
+ artifact = found;
67959
+ }
67960
+ if (!deps.signingProvider) {
67961
+ await failRun(
67962
+ deps,
67963
+ projectSlug,
67964
+ task,
67965
+ runId,
67966
+ leaseId,
67967
+ `closure_signing_unavailable: run ${runId} delivered ${outcome.deliveryRef} with a green bridge-run build, but this bridge has no receipt signing key (MRRLIN_SIGNING_KEY_ID / MRRLIN_SIGNING_PRIVATE_KEY), so the task cannot be closed. Configure signing and restart the run.`
67968
+ );
67969
+ return;
67970
+ }
67971
+ const stored = artifact?.payload ?? {};
67972
+ const contentHash = String(stored.contentHash ?? stored.content_hash ?? stored.hash ?? "");
67973
+ try {
67974
+ await orchestrateSettlementClosure(
67975
+ {
67976
+ prepareSettlementCandidate: (slug, params) => deps.client.prepareSettlementCandidate(slug, params),
67977
+ signingProvider: deps.signingProvider,
67978
+ finalizeSettlementReceipt: (slug, params) => deps.client.finalizeSettlementReceipt(slug, params)
67979
+ },
67980
+ {
67981
+ projectSlug,
67982
+ taskId: task.id,
67983
+ runId,
67984
+ outcome: "completed",
67985
+ nonce: import_node_crypto18.default.randomUUID(),
67986
+ artifacts: [{ artifactId: artifact?.id ?? artifactId, storageVersion: "1", contentHash, kind: "verification" }]
67987
+ }
67988
+ );
67989
+ } catch (error51) {
67990
+ await failRun(
67991
+ deps,
67992
+ projectSlug,
67993
+ task,
67994
+ runId,
67995
+ leaseId,
67996
+ `local_delivery_settlement_failed: ${error51 instanceof Error ? error51.message : String(error51)}`
67997
+ );
67998
+ return;
67999
+ }
68000
+ const removeWt = deps.removeRunWorktree ?? removeRunWorktree;
68001
+ await removeWt({
68002
+ checkout: input.checkoutRealPath,
68003
+ worktreePath: input.worktreePath,
68004
+ locksDir: deps.locksDir ?? "/tmp/mrrlin-locks",
68005
+ slug: projectSlug
68006
+ }).catch(() => {
68007
+ });
68008
+ }
67459
68009
  async function failRun(deps, projectSlug, task, runId, leaseId, reason, reasonCode) {
67460
68010
  let currentRun;
67461
68011
  try {
@@ -67617,7 +68167,7 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
67617
68167
  }
67618
68168
  try {
67619
68169
  await deps.client.createInboxItem(projectSlug, {
67620
- id: `II-${import_node_crypto17.default.randomUUID()}`,
68170
+ id: `II-${import_node_crypto18.default.randomUUID()}`,
67621
68171
  kind: "handoff",
67622
68172
  taskId: task.id,
67623
68173
  body: `Task ${task.id} (${task.title}) still needs operator follow-up: ${reason}. Mrrlin could not move the task back to Handoff needed automatically.`
@@ -67652,7 +68202,7 @@ async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
67652
68202
  }
67653
68203
  try {
67654
68204
  await deps.client.createInboxItem(projectSlug, {
67655
- id: `II-${import_node_crypto17.default.randomUUID()}`,
68205
+ id: `II-${import_node_crypto18.default.randomUUID()}`,
67656
68206
  kind: "handoff",
67657
68207
  taskId: task.id,
67658
68208
  body: `Execution run ${runId} for task ${task.id} (${task.title}) needs operator attention: ${reason}`
@@ -67794,8 +68344,8 @@ async function runBackstopSweep(deps, drive = (slug, id) => driveRun(deps, slug,
67794
68344
  function isRunRecoverableByThisBridge(run3, worktreeRoot) {
67795
68345
  if (!worktreeRoot) return true;
67796
68346
  if (!run3.worktreeId) return true;
67797
- const relative = import_node_path32.default.relative(import_node_path32.default.resolve(worktreeRoot), import_node_path32.default.resolve(run3.worktreeId));
67798
- return relative === "" || relative.length > 0 && !relative.startsWith("..") && !import_node_path32.default.isAbsolute(relative);
68347
+ const relative = import_node_path34.default.relative(import_node_path34.default.resolve(worktreeRoot), import_node_path34.default.resolve(run3.worktreeId));
68348
+ return relative === "" || relative.length > 0 && !relative.startsWith("..") && !import_node_path34.default.isAbsolute(relative);
67799
68349
  }
67800
68350
  async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId) {
67801
68351
  await deps.client.updateExecutionRun(projectSlug, runId, { status: "failed", finishedAt: (/* @__PURE__ */ new Date()).toISOString(), leaseId: leaseId ?? void 0 }).catch(() => {
@@ -67813,7 +68363,7 @@ async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId
67813
68363
  }).catch(() => {
67814
68364
  });
67815
68365
  await deps.client.createInboxItem(projectSlug, {
67816
- id: `II-${import_node_crypto17.default.randomUUID()}`,
68366
+ id: `II-${import_node_crypto18.default.randomUUID()}`,
67817
68367
  kind: "handoff",
67818
68368
  taskId: task.id,
67819
68369
  body: `Deploy gate for run ${runId} (task ${task.id} \u2014 ${task.title}) needs operator attention: ${reason}`
@@ -67832,7 +68382,7 @@ function maxLeaseReclaims() {
67832
68382
  }
67833
68383
 
67834
68384
  // src/async-job-consumer.ts
67835
- var import_node_crypto18 = __toESM(require("node:crypto"), 1);
68385
+ var import_node_crypto19 = __toESM(require("node:crypto"), 1);
67836
68386
  var ASYNC_JOB_MAX_ATTEMPTS = 2;
67837
68387
  function ASYNC_UNOWNED_TTL_DAYS() {
67838
68388
  const raw = Number(process.env.MRRLIN_ASYNC_UNOWNED_TTL_DAYS);
@@ -67957,7 +68507,7 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
67957
68507
  const delivery = descriptor2.onComplete(outcome, input);
67958
68508
  if (!delivery.suppressInbox) {
67959
68509
  await deps.client.createInboxItem(projectSlug, {
67960
- id: delivery.id ?? `II-${import_node_crypto18.default.randomUUID()}`,
68510
+ id: delivery.id ?? `II-${import_node_crypto19.default.randomUUID()}`,
67961
68511
  kind: delivery.kind,
67962
68512
  body: delivery.body,
67963
68513
  ...delivery.taskId ? { taskId: delivery.taskId } : {},
@@ -67975,13 +68525,13 @@ async function deriveRequestedHash(client, toolName2, input) {
67975
68525
  if (input.requestedHash) return input.requestedHash;
67976
68526
  if (toolName2 === "run_spec_consensus" && input.pageId) {
67977
68527
  const page = await client.getWikiPage(input.projectSlug, input.pageId);
67978
- return page.contentHash ?? import_node_crypto18.default.createHash("sha256").update(page.markdownBody).digest("hex");
68528
+ return page.contentHash ?? import_node_crypto19.default.createHash("sha256").update(page.markdownBody).digest("hex");
67979
68529
  }
67980
68530
  if (toolName2 === "draft_task_spec" && input.taskId) {
67981
68531
  const task = await client.getTask(input.projectSlug, input.taskId);
67982
- return task.updatedAt ?? import_node_crypto18.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
68532
+ return task.updatedAt ?? import_node_crypto19.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
67983
68533
  }
67984
- return import_node_crypto18.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
68534
+ return import_node_crypto19.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
67985
68535
  }
67986
68536
  async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId)) {
67987
68537
  const projects = await deps.client.listProjects();
@@ -68007,19 +68557,19 @@ async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJo
68007
68557
  }
68008
68558
 
68009
68559
  // src/bridge-artifacts.ts
68010
- var import_node_fs19 = __toESM(require("node:fs"), 1);
68560
+ var import_node_fs21 = __toESM(require("node:fs"), 1);
68011
68561
  var import_promises14 = __toESM(require("node:fs/promises"), 1);
68012
- var import_node_path33 = __toESM(require("node:path"), 1);
68562
+ var import_node_path35 = __toESM(require("node:path"), 1);
68013
68563
  var DEFAULT_MAX_ARTIFACTS_BYTES = 500 * 1024 * 1024;
68014
68564
  var DEFAULT_MAX_ARTIFACT_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
68015
68565
  function resolveArtifactsDir(baseStateDir) {
68016
68566
  const stateDir = baseStateDir ?? resolveStateDir();
68017
- return import_node_path33.default.join(stateDir, "artifacts");
68567
+ return import_node_path35.default.join(stateDir, "artifacts");
68018
68568
  }
68019
68569
  function ensureDir(dir) {
68020
- import_node_fs19.default.mkdirSync(dir, { recursive: true, mode: 448 });
68570
+ import_node_fs21.default.mkdirSync(dir, { recursive: true, mode: 448 });
68021
68571
  try {
68022
- import_node_fs19.default.chmodSync(dir, 448);
68572
+ import_node_fs21.default.chmodSync(dir, 448);
68023
68573
  } catch {
68024
68574
  }
68025
68575
  }
@@ -68027,7 +68577,7 @@ function safeArtifactPath(artifactsDir, id) {
68027
68577
  if (!id || typeof id !== "string" || !/^[a-zA-Z0-9_-]+$/.test(id)) {
68028
68578
  throw new Error("Invalid artifact id");
68029
68579
  }
68030
- return import_node_path33.default.join(artifactsDir, `${id}.json`);
68580
+ return import_node_path35.default.join(artifactsDir, `${id}.json`);
68031
68581
  }
68032
68582
  async function writeLocalArtifact(id, payload, baseStateDir) {
68033
68583
  const artifactsDir = resolveArtifactsDir(baseStateDir);
@@ -68070,7 +68620,7 @@ async function cleanArtifacts(baseStateDir, options) {
68070
68620
  let deletedBytes = 0;
68071
68621
  for (const name of entries) {
68072
68622
  if (!name.endsWith(".json")) continue;
68073
- const filePath = import_node_path33.default.join(artifactsDir, name);
68623
+ const filePath = import_node_path35.default.join(artifactsDir, name);
68074
68624
  try {
68075
68625
  const stat3 = await import_promises14.default.stat(filePath);
68076
68626
  if (now - stat3.mtimeMs > maxAgeMs) {
@@ -68297,16 +68847,16 @@ function agentIdleMs(provider) {
68297
68847
  }
68298
68848
 
68299
68849
  // src/thread-index.ts
68300
- var import_node_fs20 = require("node:fs");
68301
- var import_node_path34 = __toESM(require("node:path"), 1);
68850
+ var import_node_fs22 = require("node:fs");
68851
+ var import_node_path36 = __toESM(require("node:path"), 1);
68302
68852
  function threadIndexPath(stateDir) {
68303
- return import_node_path34.default.join(stateDir, "threads.json");
68853
+ return import_node_path36.default.join(stateDir, "threads.json");
68304
68854
  }
68305
68855
  function loadThreadIndex(stateDir, ttlMs, now) {
68306
68856
  const result = /* @__PURE__ */ new Map();
68307
68857
  let parsed;
68308
68858
  try {
68309
- parsed = JSON.parse((0, import_node_fs20.readFileSync)(threadIndexPath(stateDir), "utf8"));
68859
+ parsed = JSON.parse((0, import_node_fs22.readFileSync)(threadIndexPath(stateDir), "utf8"));
68310
68860
  } catch {
68311
68861
  return result;
68312
68862
  }
@@ -68331,8 +68881,8 @@ function loadThreadIndex(stateDir, ttlMs, now) {
68331
68881
  return result;
68332
68882
  }
68333
68883
  function saveThreadIndex(stateDir, entries) {
68334
- (0, import_node_fs20.mkdirSync)(stateDir, { recursive: true, mode: 448 });
68335
- (0, import_node_fs20.writeFileSync)(threadIndexPath(stateDir), `${JSON.stringify(Object.fromEntries(entries), null, 2)}
68884
+ (0, import_node_fs22.mkdirSync)(stateDir, { recursive: true, mode: 448 });
68885
+ (0, import_node_fs22.writeFileSync)(threadIndexPath(stateDir), `${JSON.stringify(Object.fromEntries(entries), null, 2)}
68336
68886
  `, {
68337
68887
  encoding: "utf8",
68338
68888
  mode: 384
@@ -68468,9 +69018,9 @@ function createToolBusyClock(opts) {
68468
69018
 
68469
69019
  // src/remote-phone-relay.ts
68470
69020
  var import_node_events3 = require("node:events");
68471
- var import_node_fs21 = require("node:fs");
68472
- var import_node_os16 = require("node:os");
68473
- var import_node_path35 = require("node:path");
69021
+ var import_node_fs23 = require("node:fs");
69022
+ var import_node_os17 = require("node:os");
69023
+ var import_node_path37 = require("node:path");
68474
69024
 
68475
69025
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/cryptoNode.js
68476
69026
  var nc = __toESM(require("node:crypto"), 1);
@@ -68933,7 +69483,7 @@ var SHA256 = class extends SHA2 {
68933
69483
  this.buffer.fill(0);
68934
69484
  }
68935
69485
  };
68936
- var sha2562 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
69486
+ var sha2563 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
68937
69487
 
68938
69488
  // ../../node_modules/.pnpm/@noble+curves@1.3.0/node_modules/@noble/curves/esm/abstract/utils.js
68939
69489
  var _0n = BigInt(0);
@@ -69077,7 +69627,7 @@ function validateObject(object3, validators, optValidators = {}) {
69077
69627
  // ../../packages/director-e2e/dist/verifier.js
69078
69628
  var RELAY_AUTH_LABEL = utf8ToBytes("relay-auth");
69079
69629
  function relayAuth(secret) {
69080
- return hmac(sha2562, secret, RELAY_AUTH_LABEL);
69630
+ return hmac(sha2563, secret, RELAY_AUTH_LABEL);
69081
69631
  }
69082
69632
 
69083
69633
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/_u64.js
@@ -70411,16 +70961,16 @@ var hkdf = (hash3, ikm, salt, info, length) => expand(hash3, extract(hash3, ikm,
70411
70961
 
70412
70962
  // ../../packages/director-e2e/dist/kdf.js
70413
70963
  function deriveMasterKey(ikm, salt, info) {
70414
- return hkdf(sha2562, ikm, salt, info, 32);
70964
+ return hkdf(sha2563, ikm, salt, info, 32);
70415
70965
  }
70416
70966
  function deriveDirectionKeys(masterKey) {
70417
70967
  return {
70418
- p2a: hkdf(sha2562, masterKey, void 0, utf8ToBytes("dir:phone->agent"), 32),
70419
- a2p: hkdf(sha2562, masterKey, void 0, utf8ToBytes("dir:agent->phone"), 32)
70968
+ p2a: hkdf(sha2563, masterKey, void 0, utf8ToBytes("dir:phone->agent"), 32),
70969
+ a2p: hkdf(sha2563, masterKey, void 0, utf8ToBytes("dir:agent->phone"), 32)
70420
70970
  };
70421
70971
  }
70422
70972
  function confirmationMac(masterKey, role, transcript) {
70423
- return hmac(sha2562, masterKey, concatBytes(utf8ToBytes(`confirm:${role}`), transcript));
70973
+ return hmac(sha2563, masterKey, concatBytes(utf8ToBytes(`confirm:${role}`), transcript));
70424
70974
  }
70425
70975
 
70426
70976
  // ../../node_modules/.pnpm/@noble+ciphers@0.4.1/node_modules/@noble/ciphers/esm/utils.js
@@ -72041,9 +72591,9 @@ var DirectorRelay = class {
72041
72591
 
72042
72592
  // src/remote-phone-relay.ts
72043
72593
  function loadOrCreateAgentDeviceKey() {
72044
- const path31 = (0, import_node_path35.join)((0, import_node_os16.homedir)(), ".mrrlin", "agent-device-key");
72594
+ const path33 = (0, import_node_path37.join)((0, import_node_os17.homedir)(), ".mrrlin", "agent-device-key");
72045
72595
  try {
72046
- const raw = JSON.parse((0, import_node_fs21.readFileSync)(path31, "utf8"));
72596
+ const raw = JSON.parse((0, import_node_fs23.readFileSync)(path33, "utf8"));
72047
72597
  if (typeof raw.priv === "string" && typeof raw.pub === "string") {
72048
72598
  return { privateKey: fromBase64Url(raw.priv), publicKey: fromBase64Url(raw.pub) };
72049
72599
  }
@@ -72051,9 +72601,9 @@ function loadOrCreateAgentDeviceKey() {
72051
72601
  }
72052
72602
  const kp = generateIdentityKeyPair();
72053
72603
  try {
72054
- (0, import_node_fs21.mkdirSync)((0, import_node_path35.join)((0, import_node_os16.homedir)(), ".mrrlin"), { recursive: true });
72055
- (0, import_node_fs21.writeFileSync)(
72056
- path31,
72604
+ (0, import_node_fs23.mkdirSync)((0, import_node_path37.join)((0, import_node_os17.homedir)(), ".mrrlin"), { recursive: true });
72605
+ (0, import_node_fs23.writeFileSync)(
72606
+ path33,
72057
72607
  JSON.stringify({ priv: toBase64Url(kp.privateKey), pub: toBase64Url(kp.publicKey) }),
72058
72608
  { mode: 384 }
72059
72609
  );
@@ -72061,10 +72611,10 @@ function loadOrCreateAgentDeviceKey() {
72061
72611
  }
72062
72612
  return kp;
72063
72613
  }
72064
- var AGENT_PAIRING_PATH = (0, import_node_path35.join)((0, import_node_os16.homedir)(), ".mrrlin", "agent-pairing.json");
72614
+ var AGENT_PAIRING_PATH = (0, import_node_path37.join)((0, import_node_os17.homedir)(), ".mrrlin", "agent-pairing.json");
72065
72615
  function loadAgentPairing() {
72066
72616
  try {
72067
- const raw = JSON.parse((0, import_node_fs21.readFileSync)(AGENT_PAIRING_PATH, "utf8"));
72617
+ const raw = JSON.parse((0, import_node_fs23.readFileSync)(AGENT_PAIRING_PATH, "utf8"));
72068
72618
  if (typeof raw.channelId === "string" && typeof raw.agentControlSecret === "string" && typeof raw.relayAuth === "string" && typeof raw.peerIdentityKey === "string") {
72069
72619
  return {
72070
72620
  channelId: raw.channelId,
@@ -72079,8 +72629,8 @@ function loadAgentPairing() {
72079
72629
  }
72080
72630
  function saveAgentPairing(record2) {
72081
72631
  try {
72082
- (0, import_node_fs21.mkdirSync)((0, import_node_path35.join)((0, import_node_os16.homedir)(), ".mrrlin"), { recursive: true });
72083
- (0, import_node_fs21.writeFileSync)(AGENT_PAIRING_PATH, JSON.stringify(record2), { mode: 384 });
72632
+ (0, import_node_fs23.mkdirSync)((0, import_node_path37.join)((0, import_node_os17.homedir)(), ".mrrlin"), { recursive: true });
72633
+ (0, import_node_fs23.writeFileSync)(AGENT_PAIRING_PATH, JSON.stringify(record2), { mode: 384 });
72084
72634
  } catch {
72085
72635
  }
72086
72636
  }
@@ -72258,14 +72808,14 @@ async function renderPairingQrSvg(payload) {
72258
72808
  }
72259
72809
 
72260
72810
  // src/executor-server.ts
72261
- var import_node_child_process22 = require("node:child_process");
72811
+ var import_node_child_process24 = require("node:child_process");
72262
72812
  function defaultReadinessRunner(provider) {
72263
72813
  if (provider !== "codex" && provider !== "claude" && provider !== "agy") {
72264
72814
  throw new Error(`unsupported executor provider: ${String(provider)}`);
72265
72815
  }
72266
72816
  const command = provider === "claude" ? "claude" : provider === "agy" ? "agy" : "codex";
72267
72817
  return (args) => {
72268
- const r = (0, import_node_child_process22.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3, shell: true });
72818
+ const r = (0, import_node_child_process24.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3, shell: true });
72269
72819
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
72270
72820
  };
72271
72821
  }
@@ -72319,7 +72869,7 @@ async function startExecutorServer(opts) {
72319
72869
  const rawBaseEnv = opts.env ?? (isVerification ? buildVerificationEnv(process.env) : process.env);
72320
72870
  const baseEnv = isVerification ? buildVerificationEnv(rawBaseEnv) : { ...rawBaseEnv };
72321
72871
  const childEnv = withDisabledGitHooksEnv(baseEnv, opts.disabledGitHooksDir);
72322
- const baseSpawn = opts.spawn ?? import_node_child_process22.spawn;
72872
+ const baseSpawn = opts.spawn ?? import_node_child_process24.spawn;
72323
72873
  const hasExtraFd = opts.brokerSocket != null || opts.brokerSocketFd != null;
72324
72874
  const spawnFn = (cmd, args = [], spawnOpts = {}) => {
72325
72875
  const argList = [...args];
@@ -72463,10 +73013,10 @@ var import_node_http2 = __toESM(require("node:http"), 1);
72463
73013
  var import_node_https2 = __toESM(require("node:https"), 1);
72464
73014
  var import_node_net2 = __toESM(require("node:net"), 1);
72465
73015
  var import_node_tls = __toESM(require("node:tls"), 1);
72466
- var import_node_fs22 = __toESM(require("node:fs"), 1);
72467
- var import_node_os17 = __toESM(require("node:os"), 1);
72468
- var import_node_path36 = __toESM(require("node:path"), 1);
72469
- var import_node_crypto19 = __toESM(require("node:crypto"), 1);
73016
+ var import_node_fs24 = __toESM(require("node:fs"), 1);
73017
+ var import_node_os18 = __toESM(require("node:os"), 1);
73018
+ var import_node_path38 = __toESM(require("node:path"), 1);
73019
+ var import_node_crypto20 = __toESM(require("node:crypto"), 1);
72470
73020
  var import_node_zlib = __toESM(require("node:zlib"), 1);
72471
73021
 
72472
73022
  // src/verification-egress-policy.ts
@@ -72804,20 +73354,20 @@ function reauthorizeRedirect(params) {
72804
73354
  // src/verification-broker.ts
72805
73355
  var TEST_CONNECT_OVERRIDE_SYMBOL = Symbol.for("mrrlin.test.connectOverride");
72806
73356
  async function createVerificationBrokerSession(options) {
72807
- const nonce = import_node_crypto19.default.randomBytes(16).toString("hex");
73357
+ const nonce = import_node_crypto20.default.randomBytes(16).toString("hex");
72808
73358
  let createdDir = null;
72809
73359
  let socketPath = options.socketPath;
72810
73360
  if (!socketPath) {
72811
- createdDir = import_node_fs22.default.mkdtempSync(import_node_path36.default.join(import_node_os17.default.tmpdir(), "mrrlin-broker-"));
72812
- import_node_fs22.default.chmodSync(createdDir, 448);
72813
- socketPath = import_node_path36.default.join(
73361
+ createdDir = import_node_fs24.default.mkdtempSync(import_node_path38.default.join(import_node_os18.default.tmpdir(), "mrrlin-broker-"));
73362
+ import_node_fs24.default.chmodSync(createdDir, 448);
73363
+ socketPath = import_node_path38.default.join(
72814
73364
  createdDir,
72815
73365
  `broker-${options.runId.replace(/[^a-zA-Z0-9_-]/g, "")}-${nonce}.sock`
72816
73366
  );
72817
73367
  }
72818
73368
  try {
72819
- if (import_node_fs22.default.existsSync(socketPath)) {
72820
- import_node_fs22.default.unlinkSync(socketPath);
73369
+ if (import_node_fs24.default.existsSync(socketPath)) {
73370
+ import_node_fs24.default.unlinkSync(socketPath);
72821
73371
  }
72822
73372
  } catch {
72823
73373
  }
@@ -73105,12 +73655,12 @@ async function createVerificationBrokerSession(options) {
73105
73655
  } catch (err) {
73106
73656
  server.close();
73107
73657
  try {
73108
- if (import_node_fs22.default.existsSync(socketPath)) import_node_fs22.default.unlinkSync(socketPath);
73658
+ if (import_node_fs24.default.existsSync(socketPath)) import_node_fs24.default.unlinkSync(socketPath);
73109
73659
  } catch (error51) {
73110
73660
  }
73111
73661
  if (createdDir) {
73112
73662
  try {
73113
- import_node_fs22.default.rmSync(createdDir, { recursive: true, force: true });
73663
+ import_node_fs24.default.rmSync(createdDir, { recursive: true, force: true });
73114
73664
  } catch (error51) {
73115
73665
  }
73116
73666
  }
@@ -73138,14 +73688,14 @@ async function createVerificationBrokerSession(options) {
73138
73688
  server.close(() => resolve2());
73139
73689
  });
73140
73690
  try {
73141
- if (import_node_fs22.default.existsSync(socketPath)) {
73142
- import_node_fs22.default.unlinkSync(socketPath);
73691
+ if (import_node_fs24.default.existsSync(socketPath)) {
73692
+ import_node_fs24.default.unlinkSync(socketPath);
73143
73693
  }
73144
73694
  } catch {
73145
73695
  }
73146
73696
  if (createdDir) {
73147
73697
  try {
73148
- import_node_fs22.default.rmSync(createdDir, { recursive: true, force: true });
73698
+ import_node_fs24.default.rmSync(createdDir, { recursive: true, force: true });
73149
73699
  } catch {
73150
73700
  }
73151
73701
  }
@@ -73641,9 +74191,9 @@ function extractVerificationSection(markdown) {
73641
74191
  }
73642
74192
 
73643
74193
  // src/director-reseed.ts
73644
- var import_node_fs23 = require("node:fs");
74194
+ var import_node_fs25 = require("node:fs");
73645
74195
  var import_node_readline2 = require("node:readline");
73646
- var import_node_path37 = require("node:path");
74196
+ var import_node_path39 = require("node:path");
73647
74197
  function estimateTokens(s) {
73648
74198
  return Buffer.byteLength(s, "utf8");
73649
74199
  }
@@ -73792,9 +74342,9 @@ async function readSessionRows(logsDir, files, sessionIds) {
73792
74342
  const lines2 = [];
73793
74343
  let missingFiles = 0;
73794
74344
  for (const f of files) {
73795
- const filePath = (0, import_node_path37.join)(logsDir, f);
74345
+ const filePath = (0, import_node_path39.join)(logsDir, f);
73796
74346
  try {
73797
- const stream = (0, import_node_fs23.createReadStream)(filePath, { encoding: "utf8" });
74347
+ const stream = (0, import_node_fs25.createReadStream)(filePath, { encoding: "utf8" });
73798
74348
  const rl = (0, import_node_readline2.createInterface)({ input: stream, crlfDelay: Infinity });
73799
74349
  try {
73800
74350
  for await (const line of rl) {
@@ -73818,18 +74368,18 @@ async function readSessionRows(logsDir, files, sessionIds) {
73818
74368
  }
73819
74369
 
73820
74370
  // src/external-agents-scrub.ts
73821
- var import_node_fs24 = __toESM(require("node:fs"), 1);
73822
- var import_node_os18 = __toESM(require("node:os"), 1);
73823
- var import_node_path38 = __toESM(require("node:path"), 1);
74371
+ var import_node_fs26 = __toESM(require("node:fs"), 1);
74372
+ var import_node_os19 = __toESM(require("node:os"), 1);
74373
+ var import_node_path40 = __toESM(require("node:path"), 1);
73824
74374
  var REDACTION = "[REDACTED]";
73825
74375
  var SHORT_VALUE_THRESHOLD = 8;
73826
- var KEYS_ENV_PATH = () => import_node_path38.default.join(import_node_os18.default.homedir(), ".local", "state", "external-agents", "keys.env");
74376
+ var KEYS_ENV_PATH = () => import_node_path40.default.join(import_node_os19.default.homedir(), ".local", "state", "external-agents", "keys.env");
73827
74377
  var keysEnvCache = null;
73828
74378
  function readKeysEnv() {
73829
74379
  const filePath = KEYS_ENV_PATH();
73830
74380
  let mtimeMs = 0;
73831
74381
  try {
73832
- mtimeMs = import_node_fs24.default.statSync(filePath).mtimeMs;
74382
+ mtimeMs = import_node_fs26.default.statSync(filePath).mtimeMs;
73833
74383
  } catch {
73834
74384
  mtimeMs = 0;
73835
74385
  }
@@ -73838,7 +74388,7 @@ function readKeysEnv() {
73838
74388
  }
73839
74389
  const map2 = /* @__PURE__ */ new Map();
73840
74390
  try {
73841
- const content = import_node_fs24.default.readFileSync(filePath, "utf8");
74391
+ const content = import_node_fs26.default.readFileSync(filePath, "utf8");
73842
74392
  for (const rawLine of content.split(/\r?\n/)) {
73843
74393
  const line = rawLine.trim();
73844
74394
  if (line === "" || line.startsWith("#")) continue;
@@ -74256,7 +74806,7 @@ function addBridgeModel(target, model) {
74256
74806
  }
74257
74807
  function readTextIfExists(filePath) {
74258
74808
  try {
74259
- return import_node_fs25.default.readFileSync(filePath, "utf8");
74809
+ return import_node_fs27.default.readFileSync(filePath, "utf8");
74260
74810
  } catch {
74261
74811
  return null;
74262
74812
  }
@@ -74267,9 +74817,9 @@ function readKnownGptSlugsFromTomlFile(filePath) {
74267
74817
  return Array.from(raw.matchAll(/^\s*model\s*=\s*"([^"]+)"/gm)).map((match) => match[1]?.trim() ?? "").filter(isSelectableModelSlug);
74268
74818
  }
74269
74819
  function readCodexFallbackModels() {
74270
- const codexHome = process.env.CODEX_HOME?.trim() || import_node_path40.default.join(import_node_os20.default.homedir(), ".codex");
74820
+ const codexHome = process.env.CODEX_HOME?.trim() || import_node_path42.default.join(import_node_os21.default.homedir(), ".codex");
74271
74821
  const models = /* @__PURE__ */ new Map();
74272
- const cachePath = import_node_path40.default.join(codexHome, "models_cache.json");
74822
+ const cachePath = import_node_path42.default.join(codexHome, "models_cache.json");
74273
74823
  const cacheRaw = readTextIfExists(cachePath);
74274
74824
  if (cacheRaw) {
74275
74825
  try {
@@ -74319,7 +74869,7 @@ function readCodexFallbackModels() {
74319
74869
  );
74320
74870
  }
74321
74871
  }
74322
- for (const slug of readKnownGptSlugsFromTomlFile(import_node_path40.default.join(codexHome, "config.toml"))) {
74872
+ for (const slug of readKnownGptSlugsFromTomlFile(import_node_path42.default.join(codexHome, "config.toml"))) {
74323
74873
  addBridgeModel(
74324
74874
  models,
74325
74875
  mapBridgeModel({
@@ -74333,11 +74883,11 @@ function readCodexFallbackModels() {
74333
74883
  })
74334
74884
  );
74335
74885
  }
74336
- const automationsDir = import_node_path40.default.join(codexHome, "automations");
74886
+ const automationsDir = import_node_path42.default.join(codexHome, "automations");
74337
74887
  try {
74338
- for (const entry of import_node_fs25.default.readdirSync(automationsDir, { withFileTypes: true })) {
74888
+ for (const entry of import_node_fs27.default.readdirSync(automationsDir, { withFileTypes: true })) {
74339
74889
  if (!entry.isDirectory()) continue;
74340
- for (const slug of readKnownGptSlugsFromTomlFile(import_node_path40.default.join(automationsDir, entry.name, "automation.toml"))) {
74890
+ for (const slug of readKnownGptSlugsFromTomlFile(import_node_path42.default.join(automationsDir, entry.name, "automation.toml"))) {
74341
74891
  addBridgeModel(
74342
74892
  models,
74343
74893
  mapBridgeModel({
@@ -74357,18 +74907,18 @@ function readCodexFallbackModels() {
74357
74907
  return [...models.values()];
74358
74908
  }
74359
74909
  function selfUpdateInboxItemId(offeredVersion) {
74360
- if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto20.randomUUID)()}`;
74910
+ if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto21.randomUUID)()}`;
74361
74911
  if (/^[A-Za-z0-9._-]+$/.test(offeredVersion)) return `II-MCPUPD-${offeredVersion}`;
74362
- const hash3 = import_node_crypto20.default.createHash("sha256").update(offeredVersion).digest("hex").slice(0, 10);
74912
+ const hash3 = import_node_crypto21.default.createHash("sha256").update(offeredVersion).digest("hex").slice(0, 10);
74363
74913
  return `II-MCPUPD-${offeredVersion.replace(/[^A-Za-z0-9._-]/g, "-")}-${hash3}`;
74364
74914
  }
74365
74915
  function neutralCheckoutCwd(stateDir) {
74366
- const dir = import_node_path40.default.join(stateDir, "no-checkout");
74916
+ const dir = import_node_path42.default.join(stateDir, "no-checkout");
74367
74917
  try {
74368
- import_node_fs25.default.mkdirSync(dir, { recursive: true });
74369
- if (!import_node_fs25.default.existsSync(import_node_path40.default.join(dir, ".git"))) {
74918
+ import_node_fs27.default.mkdirSync(dir, { recursive: true });
74919
+ if (!import_node_fs27.default.existsSync(import_node_path42.default.join(dir, ".git"))) {
74370
74920
  try {
74371
- (0, import_node_child_process23.spawnSync)("git", ["init", "-b", "main"], { cwd: dir, stdio: "ignore" });
74921
+ (0, import_node_child_process25.spawnSync)("git", ["init", "-b", "main"], { cwd: dir, stdio: "ignore" });
74372
74922
  } catch {
74373
74923
  }
74374
74924
  }
@@ -74891,7 +75441,7 @@ function resolveDefaultBranch(checkoutPath) {
74891
75441
  if (!checkoutPath) return "main";
74892
75442
  const runGit = (args) => {
74893
75443
  try {
74894
- return (0, import_node_child_process23.execFileSync)("git", ["-C", checkoutPath, ...args], {
75444
+ return (0, import_node_child_process25.execFileSync)("git", ["-C", checkoutPath, ...args], {
74895
75445
  encoding: "utf8",
74896
75446
  stdio: ["ignore", "pipe", "ignore"],
74897
75447
  timeout: 15e3,
@@ -74927,7 +75477,7 @@ async function runOrphanWorktreeSweep(client, opts) {
74927
75477
  const cutoff = Date.now() - worktreeRetentionMs();
74928
75478
  const isReapable = (worktreePath) => {
74929
75479
  try {
74930
- return import_node_fs25.default.statSync(worktreePath).mtimeMs < cutoff;
75480
+ return import_node_fs27.default.statSync(worktreePath).mtimeMs < cutoff;
74931
75481
  } catch {
74932
75482
  return false;
74933
75483
  }
@@ -75079,7 +75629,7 @@ function createBridgeRequestListener(opts) {
75079
75629
  res.end(JSON.stringify({ ok: false, error: "Origin not allowed." }));
75080
75630
  return;
75081
75631
  }
75082
- const nonce = import_node_crypto20.default.randomBytes(16).toString("base64url");
75632
+ const nonce = import_node_crypto21.default.randomBytes(16).toString("base64url");
75083
75633
  res.writeHead(200, { "content-type": "application/json" });
75084
75634
  const publicHost = host === "0.0.0.0" ? "127.0.0.1" : host;
75085
75635
  res.end(JSON.stringify({ ok: true, wsUrl: `ws://${publicHost}:${port}/ws`, token, nonce }));
@@ -75383,7 +75933,7 @@ function createBridgeMessageHandler(deps) {
75383
75933
  }
75384
75934
  }
75385
75935
  socket.on("message", async (data) => {
75386
- const spanId = import_node_crypto20.default.randomUUID();
75936
+ const spanId = import_node_crypto21.default.randomUUID();
75387
75937
  if (logCtx) {
75388
75938
  logCtx.span.id = spanId;
75389
75939
  logCtx.span.at = Date.now();
@@ -75445,7 +75995,7 @@ function createBridgeMessageHandler(deps) {
75445
75995
  sendForSpan({ type: "checkout-state", ok: false, error: { code: "invalid_input", fields: { projectSlug: "required" } } });
75446
75996
  return;
75447
75997
  }
75448
- const state = readCheckoutState(deps.checkoutRegistry, projectSlug, import_node_os20.default.hostname());
75998
+ const state = readCheckoutState(deps.checkoutRegistry, projectSlug, import_node_os21.default.hostname());
75449
75999
  if (!state) {
75450
76000
  sendForSpan({ type: "checkout-state", ok: false, error: { code: "checkout_missing" } });
75451
76001
  return;
@@ -75477,7 +76027,7 @@ function createBridgeMessageHandler(deps) {
75477
76027
  const result = registerCheckout(
75478
76028
  deps.checkoutRegistry,
75479
76029
  { projectSlug, path: typeof msg.path === "string" ? msg.path : "", repo },
75480
- import_node_os20.default.hostname()
76030
+ import_node_os21.default.hostname()
75481
76031
  );
75482
76032
  if (!result.ok) {
75483
76033
  sendForSpan({ type: "checkout-register", ok: false, error: { code: result.code, detail: result.detail } });
@@ -75990,7 +76540,7 @@ function createBridgeMessageHandler(deps) {
75990
76540
  let desiredInstructionHash = null;
75991
76541
  try {
75992
76542
  const startParams = deps.buildStartParams(msg, desiredModel);
75993
- desiredInstructionHash = import_node_crypto20.default.createHash("sha256").update(startParams.baseInstructions ?? "").digest("hex");
76543
+ desiredInstructionHash = import_node_crypto21.default.createHash("sha256").update(startParams.baseInstructions ?? "").digest("hex");
75994
76544
  if (!thread) {
75995
76545
  const newThread = {
75996
76546
  threadId: "",
@@ -76067,7 +76617,7 @@ function createBridgeMessageHandler(deps) {
76067
76617
  thread.inFlight = true;
76068
76618
  pendingTurnSessions.delete(directorSessionId);
76069
76619
  thread.replay = createReplayBuffer({
76070
- turnId: (0, import_node_crypto20.randomUUID)(),
76620
+ turnId: (0, import_node_crypto21.randomUUID)(),
76071
76621
  spanId,
76072
76622
  ...deps.retentionMs !== void 0 ? { retentionMs: deps.retentionMs } : {},
76073
76623
  ...deps.ackLingerMs !== void 0 ? { ackLingerMs: deps.ackLingerMs } : {}
@@ -76682,7 +77232,7 @@ function parseConfig() {
76682
77232
  }
76683
77233
  function scanForOtherBridges() {
76684
77234
  try {
76685
- const result = (0, import_node_child_process23.spawnSync)("pgrep", ["-f", "mrrlin-mcp director-bridge"], {
77235
+ const result = (0, import_node_child_process25.spawnSync)("pgrep", ["-f", "mrrlin-mcp director-bridge"], {
76686
77236
  encoding: "utf8"
76687
77237
  });
76688
77238
  if (result.status !== 0) return [];
@@ -76878,8 +77428,10 @@ async function startDirectorBridge() {
76878
77428
  codexCwd: config2.codexCwd,
76879
77429
  codexExecutable: config2.codexExecutable,
76880
77430
  checkoutRegistry,
76881
- worktreeRoot: import_node_path40.default.join(config2.stateDir, "worktrees"),
76882
- locksDir: import_node_path40.default.join(config2.stateDir, "locks"),
77431
+ worktreeRoot: import_node_path42.default.join(config2.stateDir, "worktrees"),
77432
+ locksDir: import_node_path42.default.join(config2.stateDir, "locks"),
77433
+ // local-git-delivery: bridge-local evidence (checkout realpath, build logs) that never leaves this machine.
77434
+ localEvidenceDir: import_node_path42.default.join(config2.stateDir, "local-evidence"),
76883
77435
  // Wire the executor server for code-execution runs. Each run gets its own provider process
76884
77436
  // (app-server for codex, a resident CLI child for claude) at the run worktree, running
76885
77437
  // UNRESTRICTED from the real operator config (owner no-sandbox decision — auth + mrrlin MCP
@@ -76896,7 +77448,7 @@ async function startDirectorBridge() {
76896
77448
  // The run's provider process carries exactly its own project (or none), so its Mrrlin MCP
76897
77449
  // server is bound to it and never to whatever the bridge's environment names.
76898
77450
  env: threadProcessEnv(process.env, directorThreadEnv(projectSlug)),
76899
- disabledGitHooksDir: prepareDisabledGitHooksDir(import_node_path40.default.join(config2.stateDir, "locks"), import_node_path40.default.basename(worktreePath)),
77451
+ disabledGitHooksDir: prepareDisabledGitHooksDir(import_node_path42.default.join(config2.stateDir, "locks"), import_node_path42.default.basename(worktreePath)),
76900
77452
  provider: providerId
76901
77453
  });
76902
77454
  return { handle: executor.handle, dispose: executor.dispose };
@@ -76927,10 +77479,10 @@ async function startDirectorBridge() {
76927
77479
  runVerificationTurn: createRunVerificationTurn({
76928
77480
  startSandbox: async (egressDomains, providerId, opts) => {
76929
77481
  opts?.wrapCommand?.(["node"]);
76930
- const scratchDir = import_node_fs25.default.mkdtempSync(import_node_path40.default.join(import_node_os20.default.tmpdir(), "mrrlin-verify-"));
77482
+ const scratchDir = import_node_fs27.default.mkdtempSync(import_node_path42.default.join(import_node_os21.default.tmpdir(), "mrrlin-verify-"));
76931
77483
  const executor = await startExecutorServer({
76932
77484
  worktree: scratchDir,
76933
- disabledGitHooksDir: prepareDisabledGitHooksDir(import_node_path40.default.join(config2.stateDir, "locks"), import_node_path40.default.basename(scratchDir)),
77485
+ disabledGitHooksDir: prepareDisabledGitHooksDir(import_node_path42.default.join(config2.stateDir, "locks"), import_node_path42.default.basename(scratchDir)),
76934
77486
  provider: providerId,
76935
77487
  wrapCommand: opts?.wrapCommand,
76936
77488
  brokerSocket: opts?.brokerSocket,
@@ -76943,7 +77495,7 @@ async function startDirectorBridge() {
76943
77495
  dispose: () => {
76944
77496
  executor.dispose();
76945
77497
  try {
76946
- import_node_fs25.default.rmSync(scratchDir, { recursive: true, force: true });
77498
+ import_node_fs27.default.rmSync(scratchDir, { recursive: true, force: true });
76947
77499
  } catch {
76948
77500
  }
76949
77501
  },
@@ -76976,7 +77528,7 @@ async function startDirectorBridge() {
76976
77528
  };
76977
77529
  const sessionSinks = createSessionSinkRegistry();
76978
77530
  const tombstones = /* @__PURE__ */ new Map();
76979
- const bridgeInstanceId = (0, import_node_crypto20.randomUUID)();
77531
+ const bridgeInstanceId = (0, import_node_crypto21.randomUUID)();
76980
77532
  const asyncConsumerDeps = {
76981
77533
  client,
76982
77534
  run: wrappedTurnLock.run,
@@ -77154,7 +77706,7 @@ async function startDirectorBridge() {
77154
77706
  const files = dayFilesInWindow(/* @__PURE__ */ new Date(), reseedWindowMs);
77155
77707
  filesCount = files.length;
77156
77708
  const sessionIds = [args.directorSessionId, ...args.priorSessionIds];
77157
- const { lines: lines2, missingFiles } = await readSessionRows(import_node_path40.default.join(config2.stateDir, "logs"), files, sessionIds);
77709
+ const { lines: lines2, missingFiles } = await readSessionRows(import_node_path42.default.join(config2.stateDir, "logs"), files, sessionIds);
77158
77710
  missingFilesCount = missingFiles;
77159
77711
  const extracted = extractItems(lines2, sessionIds);
77160
77712
  items = extracted.items;
@@ -77303,7 +77855,7 @@ async function startDirectorBridge() {
77303
77855
  const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
77304
77856
  let bridgeBinShaShort = "unknown00000";
77305
77857
  try {
77306
- bridgeBinShaShort = import_node_crypto20.default.createHash("sha256").update(import_node_fs25.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
77858
+ bridgeBinShaShort = import_node_crypto21.default.createHash("sha256").update(import_node_fs27.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
77307
77859
  } catch {
77308
77860
  }
77309
77861
  attachBridgeWss(server, {
@@ -77439,8 +77991,8 @@ async function startDirectorBridge() {
77439
77991
  );
77440
77992
  void runOrphanWorktreeSweep(client, {
77441
77993
  checkoutRegistry,
77442
- worktreeRoot: import_node_path40.default.join(config2.stateDir, "worktrees"),
77443
- locksDir: import_node_path40.default.join(config2.stateDir, "locks")
77994
+ worktreeRoot: import_node_path42.default.join(config2.stateDir, "worktrees"),
77995
+ locksDir: import_node_path42.default.join(config2.stateDir, "locks")
77444
77996
  });
77445
77997
  {
77446
77998
  const { retainedBuffers, retainedBytes, tombstonesRemoved } = sweepReplayBuffers(threads, tombstones, {
@@ -77744,7 +78296,7 @@ function timingSafeTokenEqual(provided, expected) {
77744
78296
  const a = Buffer.from(provided);
77745
78297
  const b = Buffer.from(expected);
77746
78298
  if (a.length !== b.length) return false;
77747
- return import_node_crypto20.default.timingSafeEqual(a, b);
78299
+ return import_node_crypto21.default.timingSafeEqual(a, b);
77748
78300
  }
77749
78301
  function readDispatchBody(req) {
77750
78302
  return new Promise((resolve2, reject) => {
@@ -77766,15 +78318,15 @@ function readDispatchBody(req) {
77766
78318
  function readOrCreateBridgeToken(stateDir) {
77767
78319
  const explicit = (process.env.MRRLIN_DIRECTOR_BRIDGE_TOKEN ?? "").trim();
77768
78320
  if (explicit) return explicit;
77769
- const tokenPath = import_node_path40.default.join(stateDir, "token.txt");
78321
+ const tokenPath = import_node_path42.default.join(stateDir, "token.txt");
77770
78322
  try {
77771
- const existing = import_node_fs25.default.readFileSync(tokenPath, "utf8").trim();
78323
+ const existing = import_node_fs27.default.readFileSync(tokenPath, "utf8").trim();
77772
78324
  if (existing) return existing;
77773
78325
  } catch {
77774
78326
  }
77775
- import_node_fs25.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
77776
- const token = import_node_crypto20.default.randomBytes(32).toString("base64url");
77777
- import_node_fs25.default.writeFileSync(tokenPath, `${token}
78327
+ import_node_fs27.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
78328
+ const token = import_node_crypto21.default.randomBytes(32).toString("base64url");
78329
+ import_node_fs27.default.writeFileSync(tokenPath, `${token}
77778
78330
  `, { mode: 384 });
77779
78331
  return token;
77780
78332
  }
@@ -78682,9 +79234,9 @@ function runSetCredential(args) {
78682
79234
  }
78683
79235
 
78684
79236
  // src/install-service.ts
78685
- var import_node_os21 = __toESM(require("node:os"), 1);
78686
- var import_node_fs26 = require("node:fs");
78687
- var import_node_path41 = __toESM(require("node:path"), 1);
79237
+ var import_node_os22 = __toESM(require("node:os"), 1);
79238
+ var import_node_fs28 = require("node:fs");
79239
+ var import_node_path43 = __toESM(require("node:path"), 1);
78688
79240
  function parseEnvLine(line, env) {
78689
79241
  const trimmed = line.trim();
78690
79242
  if (!trimmed || trimmed === "}" || trimmed === "},") return;
@@ -79073,7 +79625,7 @@ function performConfigBackup(deps, ecoPath, existingText) {
79073
79625
  deps.log("Service config backup failed.");
79074
79626
  return;
79075
79627
  }
79076
- const dir = import_node_path41.default.dirname(ecoPath);
79628
+ const dir = import_node_path43.default.dirname(ecoPath);
79077
79629
  let files;
79078
79630
  try {
79079
79631
  files = deps.listDir(dir);
@@ -79085,7 +79637,7 @@ function performConfigBackup(deps, ecoPath, existingText) {
79085
79637
  deps.log("Service config backup failed.");
79086
79638
  return;
79087
79639
  }
79088
- const base = import_node_path41.default.basename(ecoPath);
79640
+ const base = import_node_path43.default.basename(ecoPath);
79089
79641
  const backupRegex = new RegExp(`^${escapeRegex2(base)}\\.bak-\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}-\\d{3}Z$`);
79090
79642
  const existingBackups = files.filter((f) => backupRegex.test(f));
79091
79643
  if (existingBackups.length >= 10) {
@@ -79120,7 +79672,7 @@ function performConfigBackup(deps, ecoPath, existingText) {
79120
79672
  var SYSTEM_PATH_DIRS = ["/usr/bin", "/bin", "/usr/sbin", "/sbin"];
79121
79673
  function defaultHomeOwnerUid(home) {
79122
79674
  try {
79123
- return (0, import_node_fs26.statSync)(home).uid;
79675
+ return (0, import_node_fs28.statSync)(home).uid;
79124
79676
  } catch {
79125
79677
  return null;
79126
79678
  }
@@ -79161,11 +79713,11 @@ function installService(deps) {
79161
79713
  deps.log(resolved.reason);
79162
79714
  return { ok: false };
79163
79715
  }
79164
- const home = deps.env.HOME ?? import_node_os21.default.homedir();
79716
+ const home = deps.env.HOME ?? import_node_os22.default.homedir();
79165
79717
  const user = resolveBridgeUser({
79166
79718
  env: deps.env,
79167
79719
  home,
79168
- userInfo: deps.userInfo ?? (() => import_node_os21.default.userInfo()),
79720
+ userInfo: deps.userInfo ?? (() => import_node_os22.default.userInfo()),
79169
79721
  homeOwnerUid: deps.homeOwnerUid ?? defaultHomeOwnerUid,
79170
79722
  log: deps.log
79171
79723
  });
@@ -79186,12 +79738,12 @@ function installService(deps) {
79186
79738
  const claudeBin = deps.which("claude");
79187
79739
  const agyBin = deps.which("agy");
79188
79740
  const resolvedBins = [...bins, claudeBin, agyBin].filter((b) => b !== null);
79189
- const isWin = import_node_os21.default.platform() === "win32";
79190
- const systemDirs = isWin ? (deps.env.PATH || "").split(import_node_path41.default.delimiter).filter(Boolean) : SYSTEM_PATH_DIRS;
79741
+ const isWin = import_node_os22.default.platform() === "win32";
79742
+ const systemDirs = isWin ? (deps.env.PATH || "").split(import_node_path43.default.delimiter).filter(Boolean) : SYSTEM_PATH_DIRS;
79191
79743
  const pathEnv = Array.from(
79192
- /* @__PURE__ */ new Set([...resolvedBins.map((b) => import_node_path41.default.dirname(b)), ...systemDirs])
79193
- ).join(import_node_path41.default.delimiter);
79194
- const ecoPath = import_node_path41.default.join(home, ".mrrlin", "ecosystem.config.cjs");
79744
+ /* @__PURE__ */ new Set([...resolvedBins.map((b) => import_node_path43.default.dirname(b)), ...systemDirs])
79745
+ ).join(import_node_path43.default.delimiter);
79746
+ const ecoPath = import_node_path43.default.join(home, ".mrrlin", "ecosystem.config.cjs");
79195
79747
  const existingText = deps.readFile ? deps.readFile(ecoPath) : null;
79196
79748
  const parseResult = parseExistingEcosystemConfig(existingText);
79197
79749
  if (parseResult.kind === "rejected") {
@@ -79269,14 +79821,14 @@ function uninstallService(deps) {
79269
79821
 
79270
79822
  // src/uninstall-codex.ts
79271
79823
  var import_promises17 = __toESM(require("node:fs/promises"), 1);
79272
- var import_node_os22 = __toESM(require("node:os"), 1);
79273
- var import_node_path42 = __toESM(require("node:path"), 1);
79824
+ var import_node_os23 = __toESM(require("node:os"), 1);
79825
+ var import_node_path44 = __toESM(require("node:path"), 1);
79274
79826
  var toml5 = __toESM(require_toml(), 1);
79275
79827
  function resolveCodexHome3(options) {
79276
79828
  if (options.codexHome) return options.codexHome;
79277
- if (options.homeDir) return import_node_path42.default.join(options.homeDir, ".codex");
79829
+ if (options.homeDir) return import_node_path44.default.join(options.homeDir, ".codex");
79278
79830
  if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
79279
- return import_node_path42.default.join(import_node_os22.default.homedir(), ".codex");
79831
+ return import_node_path44.default.join(import_node_os23.default.homedir(), ".codex");
79280
79832
  }
79281
79833
  async function pathExists6(target) {
79282
79834
  try {
@@ -79289,7 +79841,7 @@ async function pathExists6(target) {
79289
79841
  var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.(?:mrrlin(?:-browser)?|external-agents)(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
79290
79842
  async function uninstallCodex(options = {}) {
79291
79843
  const codexHome = resolveCodexHome3(options);
79292
- const configPath = import_node_path42.default.join(codexHome, "config.toml");
79844
+ const configPath = import_node_path44.default.join(codexHome, "config.toml");
79293
79845
  const removePrompts = async () => uninstallPrompts(codexHome, options.promptNames ?? []);
79294
79846
  if (!await pathExists6(configPath)) {
79295
79847
  return { action: "missing", configPath, prompts: await removePrompts() };
@@ -79317,10 +79869,10 @@ async function uninstallCodex(options = {}) {
79317
79869
  }
79318
79870
  async function uninstallPrompts(codexHome, names) {
79319
79871
  if (names.length === 0) return [];
79320
- const promptsDir = import_node_path42.default.join(codexHome, "prompts");
79872
+ const promptsDir = import_node_path44.default.join(codexHome, "prompts");
79321
79873
  const out = [];
79322
79874
  for (const name of names) {
79323
- const promptPath = import_node_path42.default.join(promptsDir, `${name}.md`);
79875
+ const promptPath = import_node_path44.default.join(promptsDir, `${name}.md`);
79324
79876
  try {
79325
79877
  await import_promises17.default.unlink(promptPath);
79326
79878
  out.push({ name, action: "removed", promptPath });
@@ -79338,7 +79890,7 @@ async function uninstallPrompts(codexHome, names) {
79338
79890
 
79339
79891
  // src/extract/command.ts
79340
79892
  var import_promises18 = require("node:fs/promises");
79341
- var import_node_path43 = require("node:path");
79893
+ var import_node_path45 = require("node:path");
79342
79894
  function parseArgs(args) {
79343
79895
  const map2 = /* @__PURE__ */ new Map();
79344
79896
  for (let i = 0; i < args.length; i++) {
@@ -79375,7 +79927,7 @@ Missing required flag(s): ${missing.join(
79375
79927
  const days = await findSessionDays(deps.stateDir, sessionId);
79376
79928
  const matchingLines = [];
79377
79929
  for (const day of days) {
79378
- const logPath = (0, import_node_path43.join)(deps.stateDir, "logs", `bridge-${day}.jsonl`);
79930
+ const logPath = (0, import_node_path45.join)(deps.stateDir, "logs", `bridge-${day}.jsonl`);
79379
79931
  let raw;
79380
79932
  try {
79381
79933
  raw = await (0, import_promises18.readFile)(logPath, "utf8");
@@ -79463,29 +80015,29 @@ Missing required flag(s): ${missing.join(
79463
80015
  function augmentProcessPathWithCommonDirs() {
79464
80016
  const isWin = process.platform === "win32";
79465
80017
  if (isWin) return;
79466
- const home = process.env.HOME || (0, import_node_os23.homedir)();
80018
+ const home = process.env.HOME || (0, import_node_os24.homedir)();
79467
80019
  const candidates = [
79468
- import_node_path45.default.join(home, ".local", "bin"),
79469
- import_node_path45.default.join(home, ".cargo", "bin"),
80020
+ import_node_path47.default.join(home, ".local", "bin"),
80021
+ import_node_path47.default.join(home, ".cargo", "bin"),
79470
80022
  "/usr/local/bin",
79471
80023
  "/opt/homebrew/bin"
79472
80024
  ];
79473
- const existing = (process.env.PATH || "").split(import_node_path45.default.delimiter).filter(Boolean);
80025
+ const existing = (process.env.PATH || "").split(import_node_path47.default.delimiter).filter(Boolean);
79474
80026
  const existingSet = new Set(existing);
79475
- const toAdd = candidates.filter((d) => !existingSet.has(d) && (0, import_node_fs27.existsSync)(d));
80027
+ const toAdd = candidates.filter((d) => !existingSet.has(d) && (0, import_node_fs29.existsSync)(d));
79476
80028
  if (toAdd.length > 0) {
79477
- process.env.PATH = [...existing, ...toAdd].join(import_node_path45.default.delimiter);
80029
+ process.env.PATH = [...existing, ...toAdd].join(import_node_path47.default.delimiter);
79478
80030
  }
79479
80031
  }
79480
80032
  augmentProcessPathWithCommonDirs();
79481
80033
  function pm2Runner(args) {
79482
- const r = (0, import_node_child_process24.spawnSync)("pm2", args, { encoding: "utf8" });
80034
+ const r = (0, import_node_child_process26.spawnSync)("pm2", args, { encoding: "utf8" });
79483
80035
  process.stderr.write(r.stdout ?? "");
79484
80036
  process.stderr.write(r.stderr ?? "");
79485
80037
  return { code: r.status ?? 1, stdout: r.stdout ?? "" };
79486
80038
  }
79487
80039
  function whichBin(bin) {
79488
- const r = (0, import_node_child_process24.spawnSync)("which", [bin], { encoding: "utf8" });
80040
+ const r = (0, import_node_child_process26.spawnSync)("which", [bin], { encoding: "utf8" });
79489
80041
  const out = (r.stdout ?? "").trim();
79490
80042
  return r.status === 0 && out ? out.split("\n")[0] ?? null : null;
79491
80043
  }
@@ -79493,16 +80045,16 @@ function bootHookStatus() {
79493
80045
  if (process.platform !== "darwin") return { status: "unknown" };
79494
80046
  const uid = process.getuid?.();
79495
80047
  if (uid === void 0 || uid === 0) return { status: "unknown" };
79496
- const home = process.env.HOME ?? (0, import_node_os23.homedir)();
79497
- const agents = import_node_path45.default.join(home, "Library", "LaunchAgents");
80048
+ const home = process.env.HOME ?? (0, import_node_os24.homedir)();
80049
+ const agents = import_node_path47.default.join(home, "Library", "LaunchAgents");
79498
80050
  const candidates = [
79499
- { label: "com.mrrlin.director-bridge", plist: import_node_path45.default.join(agents, "com.mrrlin.director-bridge.plist") },
79500
- { label: "com.PM2", plist: import_node_path45.default.join(agents, `pm2.${(0, import_node_os23.userInfo)().username}.plist`) }
80051
+ { label: "com.mrrlin.director-bridge", plist: import_node_path47.default.join(agents, "com.mrrlin.director-bridge.plist") },
80052
+ { label: "com.PM2", plist: import_node_path47.default.join(agents, `pm2.${(0, import_node_os24.userInfo)().username}.plist`) }
79501
80053
  ];
79502
80054
  for (const candidate of candidates) {
79503
- const printed = (0, import_node_child_process24.spawnSync)("launchctl", ["print", `gui/${uid}/${candidate.label}`], { encoding: "utf8" });
80055
+ const printed = (0, import_node_child_process26.spawnSync)("launchctl", ["print", `gui/${uid}/${candidate.label}`], { encoding: "utf8" });
79504
80056
  if (printed.status !== 0) continue;
79505
- if (!(0, import_node_fs27.existsSync)(candidate.plist)) continue;
80057
+ if (!(0, import_node_fs29.existsSync)(candidate.plist)) continue;
79506
80058
  const out = printed.stdout ?? "";
79507
80059
  const runs = /^\s*runs\s*=\s*(\d+)/m.exec(out);
79508
80060
  const exitCode = /^\s*last exit code\s*=\s*(-?\d+)/m.exec(out);
@@ -79725,7 +80277,7 @@ async function main() {
79725
80277
  }
79726
80278
  case "external-agents-serve": {
79727
80279
  const { command: command2, args } = externalAgentsServeArgs();
79728
- const r = (0, import_node_child_process24.spawnSync)(command2, args, { stdio: "inherit", env: process.env });
80280
+ const r = (0, import_node_child_process26.spawnSync)(command2, args, { stdio: "inherit", env: process.env });
79729
80281
  process.exitCode = r.status ?? 1;
79730
80282
  return;
79731
80283
  }
@@ -79779,8 +80331,8 @@ async function main() {
79779
80331
  }
79780
80332
  }
79781
80333
  try {
79782
- const codexHome = process.env.CODEX_HOME ?? import_node_path45.default.join(process.env.HOME ?? (0, import_node_os23.homedir)(), ".codex");
79783
- (0, import_node_fs27.rmSync)(import_node_path45.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
80334
+ const codexHome = process.env.CODEX_HOME ?? import_node_path47.default.join(process.env.HOME ?? (0, import_node_os24.homedir)(), ".codex");
80335
+ (0, import_node_fs29.rmSync)(import_node_path47.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
79784
80336
  } catch {
79785
80337
  }
79786
80338
  const claudeResult = await installClaude({ binPath, force, serveEnv });
@@ -79802,7 +80354,7 @@ async function main() {
79802
80354
  );
79803
80355
  }
79804
80356
  const realProviderRunner = (command2) => (args) => {
79805
- const r = (0, import_node_child_process24.spawnSync)(command2, args, { encoding: "utf8", timeout: 8e3 });
80357
+ const r = (0, import_node_child_process26.spawnSync)(command2, args, { encoding: "utf8", timeout: 8e3 });
79806
80358
  return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
79807
80359
  };
79808
80360
  for (const provider of ["codex", "claude", "agy"]) {
@@ -79850,13 +80402,13 @@ async function main() {
79850
80402
  env: process.env,
79851
80403
  cwd: process.cwd(),
79852
80404
  writeFile: (p, c) => {
79853
- (0, import_node_fs27.mkdirSync)(import_node_path45.default.dirname(p), { recursive: true, mode: 448 });
79854
- (0, import_node_fs27.writeFileSync)(p, c, { mode: 384 });
80405
+ (0, import_node_fs29.mkdirSync)(import_node_path47.default.dirname(p), { recursive: true, mode: 448 });
80406
+ (0, import_node_fs29.writeFileSync)(p, c, { mode: 384 });
79855
80407
  },
79856
- writeExclusiveFile: (p, c) => (0, import_node_fs27.writeFileSync)(p, c, { flag: "wx", mode: 384 }),
80408
+ writeExclusiveFile: (p, c) => (0, import_node_fs29.writeFileSync)(p, c, { flag: "wx", mode: 384 }),
79857
80409
  listDir: (p) => {
79858
80410
  try {
79859
- return (0, import_node_fs27.readdirSync)(p);
80411
+ return (0, import_node_fs29.readdirSync)(p);
79860
80412
  } catch {
79861
80413
  return null;
79862
80414
  }
@@ -79867,7 +80419,7 @@ async function main() {
79867
80419
  // value", never a failed install. See readExistingTelemetryDefaultProject.
79868
80420
  readFile: (p) => {
79869
80421
  try {
79870
- return (0, import_node_fs27.readFileSync)(p, "utf8");
80422
+ return (0, import_node_fs29.readFileSync)(p, "utf8");
79871
80423
  } catch {
79872
80424
  return null;
79873
80425
  }
@@ -79888,35 +80440,35 @@ async function main() {
79888
80440
  runPm2: (a) => ({ code: pm2Runner(a).code }),
79889
80441
  removeFile: (p) => {
79890
80442
  try {
79891
- (0, import_node_fs27.rmSync)(p, { force: true });
80443
+ (0, import_node_fs29.rmSync)(p, { force: true });
79892
80444
  } catch {
79893
80445
  }
79894
80446
  },
79895
80447
  purgeSecret: purge,
79896
80448
  secretPath: agentCredentialPath(),
79897
80449
  tokenPath: operatorTokenPath(),
79898
- ecoPath: import_node_path45.default.join(process.env.HOME ?? (0, import_node_os23.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
80450
+ ecoPath: import_node_path47.default.join(process.env.HOME ?? (0, import_node_os24.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
79899
80451
  log: (m) => process.stderr.write(`[mrrlin-mcp uninstall-service] ${m}
79900
80452
  `)
79901
80453
  });
79902
80454
  return;
79903
80455
  }
79904
80456
  case "uninstall": {
79905
- const home = process.env.HOME ?? (0, import_node_os23.homedir)();
80457
+ const home = process.env.HOME ?? (0, import_node_os24.homedir)();
79906
80458
  const log = (m) => process.stderr.write(`[mrrlin-mcp uninstall] ${m}
79907
80459
  `);
79908
80460
  uninstallService({
79909
80461
  runPm2: (a) => ({ code: pm2Runner(a).code }),
79910
80462
  removeFile: (p) => {
79911
80463
  try {
79912
- (0, import_node_fs27.rmSync)(p, { force: true });
80464
+ (0, import_node_fs29.rmSync)(p, { force: true });
79913
80465
  } catch {
79914
80466
  }
79915
80467
  },
79916
80468
  purgeSecret: true,
79917
80469
  secretPath: agentCredentialPath(),
79918
80470
  tokenPath: operatorTokenPath(),
79919
- ecoPath: import_node_path45.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
80471
+ ecoPath: import_node_path47.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
79920
80472
  log
79921
80473
  });
79922
80474
  let codexOk = true;
@@ -79936,7 +80488,7 @@ async function main() {
79936
80488
  log(`codex config NOT modified: ${error51 instanceof Error ? error51.message : String(error51)}`);
79937
80489
  }
79938
80490
  try {
79939
- (0, import_node_fs27.rmSync)(import_node_path45.default.join(home, ".mrrlin"), { recursive: true, force: true });
80491
+ (0, import_node_fs29.rmSync)(import_node_path47.default.join(home, ".mrrlin"), { recursive: true, force: true });
79940
80492
  } catch {
79941
80493
  }
79942
80494
  log("removed ~/.mrrlin");
@@ -79977,7 +80529,7 @@ ${HELP_TEXT}`);
79977
80529
  }
79978
80530
  }
79979
80531
  function resolveSelfBinPath() {
79980
- return import_node_path44.default.resolve(process.argv[1] ?? process.execPath);
80532
+ return import_node_path46.default.resolve(process.argv[1] ?? process.execPath);
79981
80533
  }
79982
80534
  main().catch((error51) => {
79983
80535
  process.stderr.write(`mrrlin-mcp fatal error: ${error51 instanceof Error ? error51.message : String(error51)}