@mrrlin-dev/mcp 0.4.116 → 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.
- package/dist/bin.cjs +1013 -517
- 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(
|
|
5262
|
-
let input =
|
|
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
|
|
5672
|
-
wsComponent.path =
|
|
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(
|
|
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 &&
|
|
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,
|
|
9325
|
+
function checkStat(stat3, path33, options) {
|
|
9326
9326
|
if (!stat3.isSymbolicLink() && !stat3.isFile()) {
|
|
9327
9327
|
return false;
|
|
9328
9328
|
}
|
|
9329
|
-
return checkPathExt(
|
|
9329
|
+
return checkPathExt(path33, options);
|
|
9330
9330
|
}
|
|
9331
|
-
function isexe(
|
|
9332
|
-
fs16.stat(
|
|
9333
|
-
cb(er, er ? false : checkStat(stat3,
|
|
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(
|
|
9337
|
-
return checkStat(fs16.statSync(
|
|
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(
|
|
9349
|
-
fs16.stat(
|
|
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(
|
|
9354
|
-
return checkStat(fs16.statSync(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
9416
|
+
function sync(path33, options) {
|
|
9417
9417
|
try {
|
|
9418
|
-
return core.sync(
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
|
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 ?
|
|
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 =
|
|
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 [
|
|
9629
|
-
const binary =
|
|
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
|
|
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 =
|
|
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
|
|
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 =
|
|
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:
|
|
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 =
|
|
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:
|
|
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 =
|
|
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(
|
|
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(
|
|
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(
|
|
15577
|
+
fs17.lchmod = function(path33, mode, callback) {
|
|
15578
15578
|
fs17.open(
|
|
15579
|
-
|
|
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(
|
|
15596
|
-
var fd = fs17.openSync(
|
|
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(
|
|
15618
|
-
fs17.open(
|
|
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(
|
|
15631
|
-
var fd = fs17.openSync(
|
|
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(
|
|
15750
|
-
if (!(this instanceof ReadStream)) return new ReadStream(
|
|
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 =
|
|
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(
|
|
15799
|
-
if (!(this instanceof WriteStream)) return new WriteStream(
|
|
15798
|
+
function WriteStream(path33, options) {
|
|
15799
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path33, options);
|
|
15800
15800
|
Stream.call(this);
|
|
15801
|
-
this.path =
|
|
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
|
|
15912
|
+
function closeSync2(fd) {
|
|
15913
15913
|
fs$closeSync.apply(fs16, arguments);
|
|
15914
15914
|
resetQueue();
|
|
15915
15915
|
}
|
|
15916
|
-
Object.defineProperty(
|
|
15916
|
+
Object.defineProperty(closeSync2, previousSymbol, {
|
|
15917
15917
|
value: fs$closeSync
|
|
15918
15918
|
});
|
|
15919
|
-
return
|
|
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(
|
|
15944
|
+
function readFile9(path33, options, cb) {
|
|
15945
15945
|
if (typeof options === "function")
|
|
15946
15946
|
cb = options, options = null;
|
|
15947
|
-
return go$readFile(
|
|
15948
|
-
function go$readFile(
|
|
15949
|
-
return fs$readFile(
|
|
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, [
|
|
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(
|
|
15961
|
+
function writeFile5(path33, data, options, cb) {
|
|
15962
15962
|
if (typeof options === "function")
|
|
15963
15963
|
cb = options, options = null;
|
|
15964
|
-
return go$writeFile(
|
|
15965
|
-
function go$writeFile(
|
|
15966
|
-
return fs$writeFile(
|
|
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, [
|
|
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(
|
|
15979
|
+
function appendFile2(path33, data, options, cb) {
|
|
15980
15980
|
if (typeof options === "function")
|
|
15981
15981
|
cb = options, options = null;
|
|
15982
|
-
return go$appendFile(
|
|
15983
|
-
function go$appendFile(
|
|
15984
|
-
return fs$appendFile(
|
|
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, [
|
|
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(
|
|
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(
|
|
16021
|
-
return fs$readdir(
|
|
16022
|
-
|
|
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(
|
|
16028
|
-
return fs$readdir(
|
|
16029
|
-
|
|
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(
|
|
16036
|
-
function fs$readdirCallback(
|
|
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
|
-
[
|
|
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(
|
|
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(
|
|
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(
|
|
16151
|
-
return new fs17.ReadStream(
|
|
16150
|
+
function createReadStream2(path33, options) {
|
|
16151
|
+
return new fs17.ReadStream(path33, options);
|
|
16152
16152
|
}
|
|
16153
|
-
function createWriteStream(
|
|
16154
|
-
return new fs17.WriteStream(
|
|
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(
|
|
16158
|
+
function open(path33, flags, mode, cb) {
|
|
16159
16159
|
if (typeof mode === "function")
|
|
16160
16160
|
cb = mode, mode = null;
|
|
16161
|
-
return go$open(
|
|
16162
|
-
function go$open(
|
|
16163
|
-
return fs$open(
|
|
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, [
|
|
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
|
|
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,
|
|
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
|
|
18569
|
+
const path33 = dijkstra.find_path(graph.map, "start", "end");
|
|
18570
18570
|
const optimizedSegs = [];
|
|
18571
|
-
for (let i = 1; i <
|
|
18572
|
-
optimizedSegs.push(graph.table[
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
21266
|
+
path33 += svgCmd("h", lineLength);
|
|
21267
21267
|
lineLength = 0;
|
|
21268
21268
|
}
|
|
21269
21269
|
} else {
|
|
21270
21270
|
moveBy++;
|
|
21271
21271
|
}
|
|
21272
21272
|
}
|
|
21273
|
-
return
|
|
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
|
|
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 +
|
|
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(
|
|
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(
|
|
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(
|
|
21465
|
-
return
|
|
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(
|
|
21530
|
-
if (typeof
|
|
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(
|
|
21537
|
+
const type = params.opts.type || getTypeFromFilename(path33);
|
|
21538
21538
|
const renderer = getRendererFromType(type);
|
|
21539
|
-
const renderToFile = renderer.renderToFile.bind(null,
|
|
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 =
|
|
21597
|
-
const claudePath =
|
|
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 =
|
|
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(
|
|
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 =
|
|
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(
|
|
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,
|
|
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
|
-
|
|
21653
|
-
|
|
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
|
|
21665
|
-
var
|
|
21666
|
-
var
|
|
21667
|
-
var
|
|
21668
|
-
var
|
|
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
|
|
22670
|
-
var
|
|
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
|
|
22676
|
-
var
|
|
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,
|
|
23445
|
-
if (!
|
|
23444
|
+
function getElementAtPath(obj, path33) {
|
|
23445
|
+
if (!path33)
|
|
23446
23446
|
return obj;
|
|
23447
|
-
return
|
|
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(
|
|
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(
|
|
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,
|
|
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 }, [...
|
|
24010
|
+
issue2.errors.map((issues) => processError({ issues }, [...path33, ...issue2.path]));
|
|
24011
24011
|
} else if (issue2.code === "invalid_key") {
|
|
24012
|
-
processError({ issues: issue2.issues }, [...
|
|
24012
|
+
processError({ issues: issue2.issues }, [...path33, ...issue2.path]);
|
|
24013
24013
|
} else if (issue2.code === "invalid_element") {
|
|
24014
|
-
processError({ issues: issue2.issues }, [...
|
|
24014
|
+
processError({ issues: issue2.issues }, [...path33, ...issue2.path]);
|
|
24015
24015
|
} else {
|
|
24016
|
-
const fullpath = [...
|
|
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,
|
|
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 }, [...
|
|
24047
|
+
issue2.errors.map((issues) => processError({ issues }, [...path33, ...issue2.path]));
|
|
24048
24048
|
} else if (issue2.code === "invalid_key") {
|
|
24049
|
-
processError({ issues: issue2.issues }, [...
|
|
24049
|
+
processError({ issues: issue2.issues }, [...path33, ...issue2.path]);
|
|
24050
24050
|
} else if (issue2.code === "invalid_element") {
|
|
24051
|
-
processError({ issues: issue2.issues }, [...
|
|
24051
|
+
processError({ issues: issue2.issues }, [...path33, ...issue2.path]);
|
|
24052
24052
|
} else {
|
|
24053
|
-
const fullpath = [...
|
|
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
|
|
24086
|
-
for (const seg of
|
|
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
|
|
36779
|
-
if (
|
|
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 (
|
|
36784
|
-
const key =
|
|
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 = {
|
|
@@ -38521,6 +38523,9 @@ var GIT_SHA_PATTERN = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/;
|
|
|
38521
38523
|
var SHA256_HEX_PATTERN = /^[0-9a-f]{64}$/;
|
|
38522
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})$/;
|
|
38523
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
|
+
}
|
|
38524
38529
|
var mrrlinLocalBuildStepSchema = external_exports.object({
|
|
38525
38530
|
command: external_exports.string().trim().min(1).max(200),
|
|
38526
38531
|
exitCode: external_exports.number().int(),
|
|
@@ -38571,6 +38576,7 @@ var mrrlinReceiptSchema = external_exports.object({
|
|
|
38571
38576
|
if (problem)
|
|
38572
38577
|
ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["localBuild"], message: problem });
|
|
38573
38578
|
});
|
|
38579
|
+
var LOCAL_BUILD_RECEIPT_PAYLOAD_KEY = "localBuildReceipt";
|
|
38574
38580
|
function buildReceipt(input) {
|
|
38575
38581
|
return {
|
|
38576
38582
|
kind: input.coveredKinds.length === 0 ? "attempt" : "outcome",
|
|
@@ -40688,18 +40694,18 @@ function createMrrlinClient(config2) {
|
|
|
40688
40694
|
const customFetch = config2.fetch ?? globalThis.fetch;
|
|
40689
40695
|
const baseUrl = config2.baseUrl.replace(/\/$/, "");
|
|
40690
40696
|
const token = config2.token;
|
|
40691
|
-
async function request(
|
|
40697
|
+
async function request(path33, init) {
|
|
40692
40698
|
const method = init?.method ?? "GET";
|
|
40693
40699
|
const headers = new Headers(init?.headers ?? {});
|
|
40694
40700
|
if (token && !headers.has("authorization")) {
|
|
40695
40701
|
headers.set("authorization", `Bearer ${token}`);
|
|
40696
40702
|
}
|
|
40697
|
-
const response = await customFetch(`${baseUrl}${
|
|
40703
|
+
const response = await customFetch(`${baseUrl}${path33}`, { ...init, headers });
|
|
40698
40704
|
if (!response.ok) {
|
|
40699
40705
|
const body = await response.text();
|
|
40700
40706
|
let code = `HTTP_${response.status}`;
|
|
40701
40707
|
let violations = null;
|
|
40702
|
-
let message = `Mrrlin API ${method} ${
|
|
40708
|
+
let message = `Mrrlin API ${method} ${path33} failed: ${response.status}`;
|
|
40703
40709
|
try {
|
|
40704
40710
|
const parsed = JSON.parse(body);
|
|
40705
40711
|
const violationsParsed = apiViolationsErrorSchema.safeParse(parsed);
|
|
@@ -40719,7 +40725,7 @@ function createMrrlinClient(config2) {
|
|
|
40719
40725
|
throw new MrrlinApiError({
|
|
40720
40726
|
code,
|
|
40721
40727
|
method,
|
|
40722
|
-
path:
|
|
40728
|
+
path: path33,
|
|
40723
40729
|
responseBody: body,
|
|
40724
40730
|
status: response.status,
|
|
40725
40731
|
violations,
|
|
@@ -40728,18 +40734,18 @@ function createMrrlinClient(config2) {
|
|
|
40728
40734
|
}
|
|
40729
40735
|
return response.json();
|
|
40730
40736
|
}
|
|
40731
|
-
async function requestText(
|
|
40737
|
+
async function requestText(path33, init) {
|
|
40732
40738
|
const method = init?.method ?? "GET";
|
|
40733
40739
|
const headers = new Headers(init?.headers ?? {});
|
|
40734
40740
|
if (token && !headers.has("authorization")) {
|
|
40735
40741
|
headers.set("authorization", `Bearer ${token}`);
|
|
40736
40742
|
}
|
|
40737
|
-
const response = await customFetch(`${baseUrl}${
|
|
40743
|
+
const response = await customFetch(`${baseUrl}${path33}`, { ...init, headers });
|
|
40738
40744
|
if (!response.ok) {
|
|
40739
40745
|
const body = await response.text();
|
|
40740
40746
|
let code = `HTTP_${response.status}`;
|
|
40741
40747
|
let violations = null;
|
|
40742
|
-
let message = `Mrrlin API ${method} ${
|
|
40748
|
+
let message = `Mrrlin API ${method} ${path33} failed: ${response.status}`;
|
|
40743
40749
|
try {
|
|
40744
40750
|
const parsed = JSON.parse(body);
|
|
40745
40751
|
const violationsParsed = apiViolationsErrorSchema.safeParse(parsed);
|
|
@@ -40759,7 +40765,7 @@ function createMrrlinClient(config2) {
|
|
|
40759
40765
|
throw new MrrlinApiError({
|
|
40760
40766
|
code,
|
|
40761
40767
|
method,
|
|
40762
|
-
path:
|
|
40768
|
+
path: path33,
|
|
40763
40769
|
responseBody: body,
|
|
40764
40770
|
status: response.status,
|
|
40765
40771
|
violations,
|
|
@@ -40927,16 +40933,16 @@ function createMrrlinClient(config2) {
|
|
|
40927
40933
|
// rejected against the first, MrrlinTask[]-only overload) -- the `any` here is contained to
|
|
40928
40934
|
// this one implementation signature; MrrlinClient's declared overloads keep callers precise.
|
|
40929
40935
|
async listTasks(projectSlug, filters = {}, options) {
|
|
40930
|
-
const
|
|
40931
|
-
const body = await request(
|
|
40936
|
+
const path33 = buildTaskListPath(projectSlug, filters, options?.view);
|
|
40937
|
+
const body = await request(path33, options?.signal ? { signal: options.signal } : void 0);
|
|
40932
40938
|
if (options?.view === "summary") {
|
|
40933
40939
|
return taskSummaryListResponseSchema.parse(body).data;
|
|
40934
40940
|
}
|
|
40935
40941
|
return taskListResponseSchema.parse(body).data;
|
|
40936
40942
|
},
|
|
40937
40943
|
async listTaskSummaries(projectSlug, filters = {}, options) {
|
|
40938
|
-
const
|
|
40939
|
-
const body = await request(
|
|
40944
|
+
const path33 = buildTaskListPath(projectSlug, filters, "summary");
|
|
40945
|
+
const body = await request(path33, options?.signal ? { signal: options.signal } : void 0);
|
|
40940
40946
|
return taskSummaryListResponseSchema.parse(body).data;
|
|
40941
40947
|
},
|
|
40942
40948
|
async listTaxonomy(projectSlug) {
|
|
@@ -40945,7 +40951,7 @@ function createMrrlinClient(config2) {
|
|
|
40945
40951
|
},
|
|
40946
40952
|
async listWikiPages(projectSlug, filters = {}, options) {
|
|
40947
40953
|
const view = options?.view ?? filters.view;
|
|
40948
|
-
const
|
|
40954
|
+
const path33 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
|
|
40949
40955
|
folder: filters.folder,
|
|
40950
40956
|
id: filters.id,
|
|
40951
40957
|
limit: filters.limit === void 0 ? void 0 : String(filters.limit),
|
|
@@ -40953,20 +40959,20 @@ function createMrrlinClient(config2) {
|
|
|
40953
40959
|
taskId: filters.taskId,
|
|
40954
40960
|
view
|
|
40955
40961
|
});
|
|
40956
|
-
const body = await request(
|
|
40962
|
+
const body = await request(path33, options?.signal ? { signal: options.signal } : void 0);
|
|
40957
40963
|
if (view === "summary") {
|
|
40958
40964
|
return wikiPageSummaryListResponseSchema.parse(body).data;
|
|
40959
40965
|
}
|
|
40960
40966
|
return wikiPageListResponseSchema.parse(body).data;
|
|
40961
40967
|
},
|
|
40962
40968
|
async searchWikiPages(projectSlug, query) {
|
|
40963
|
-
const
|
|
40969
|
+
const path33 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
|
|
40964
40970
|
folder: query.folder,
|
|
40965
40971
|
limit: query.limit === void 0 ? void 0 : String(query.limit),
|
|
40966
40972
|
pathPrefix: query.pathPrefix,
|
|
40967
40973
|
q: query.q
|
|
40968
40974
|
});
|
|
40969
|
-
const body = await request(
|
|
40975
|
+
const body = await request(path33);
|
|
40970
40976
|
return wikiPageSearchResponseSchema.parse(body).data;
|
|
40971
40977
|
},
|
|
40972
40978
|
async updatePlan(projectSlug, planId, patch) {
|
|
@@ -57354,8 +57360,8 @@ async function findSessionDays(stateDir, sessionId) {
|
|
|
57354
57360
|
function isRecord5(v) {
|
|
57355
57361
|
return v !== null && typeof v === "object";
|
|
57356
57362
|
}
|
|
57357
|
-
function resolvePath(root,
|
|
57358
|
-
const parts =
|
|
57363
|
+
function resolvePath(root, path33) {
|
|
57364
|
+
const parts = path33.split(".");
|
|
57359
57365
|
let cur = root;
|
|
57360
57366
|
for (let i = 0; i < parts.length - 1; i += 1) {
|
|
57361
57367
|
const part = parts[i];
|
|
@@ -57423,9 +57429,9 @@ async function gate(artifact, prose, ctx) {
|
|
|
57423
57429
|
return { ok: true, gated: true, artifact: withheldExcerptClone(artifact) };
|
|
57424
57430
|
}
|
|
57425
57431
|
const maskedClone = typeof structuredClone === "function" ? structuredClone(artifact) : JSON.parse(JSON.stringify(artifact));
|
|
57426
|
-
for (const { path:
|
|
57427
|
-
const target = resolvePath(maskedClone,
|
|
57428
|
-
if (!target) throw new Error(`pii-gate: path "${
|
|
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`);
|
|
57429
57435
|
target.parent[target.key] = masked;
|
|
57430
57436
|
}
|
|
57431
57437
|
return { ok: true, gated: false, artifact: maskedClone };
|
|
@@ -57635,9 +57641,9 @@ var CheckoutRegistry = class {
|
|
|
57635
57641
|
get(slug) {
|
|
57636
57642
|
return this.read()[slug] ?? null;
|
|
57637
57643
|
}
|
|
57638
|
-
confirm(slug,
|
|
57644
|
+
confirm(slug, path33, now) {
|
|
57639
57645
|
const all = this.read();
|
|
57640
|
-
all[slug] = { path:
|
|
57646
|
+
all[slug] = { path: path33, confirmedAt: now };
|
|
57641
57647
|
(0, import_node_fs7.writeFileSync)(this.file, JSON.stringify(all, null, 2));
|
|
57642
57648
|
}
|
|
57643
57649
|
/**
|
|
@@ -57775,20 +57781,113 @@ function checkoutStateData(projectSlug, entry, machineLabel) {
|
|
|
57775
57781
|
};
|
|
57776
57782
|
}
|
|
57777
57783
|
|
|
57778
|
-
// src/
|
|
57784
|
+
// src/local-checkout.ts
|
|
57785
|
+
var import_node_child_process14 = require("node:child_process");
|
|
57779
57786
|
var import_node_fs9 = require("node:fs");
|
|
57780
|
-
var import_node_os8 =
|
|
57787
|
+
var import_node_os8 = require("node:os");
|
|
57781
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);
|
|
57782
57881
|
function operatorDir() {
|
|
57783
|
-
const base = process.env.CODEX_HOME ?
|
|
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");
|
|
57784
57883
|
return base;
|
|
57785
57884
|
}
|
|
57786
57885
|
function operatorTokenPath() {
|
|
57787
|
-
return
|
|
57886
|
+
return import_node_path17.default.join(operatorDir(), "operator-token");
|
|
57788
57887
|
}
|
|
57789
57888
|
function readOperatorToken() {
|
|
57790
57889
|
try {
|
|
57791
|
-
const token = (0,
|
|
57890
|
+
const token = (0, import_node_fs10.readFileSync)(operatorTokenPath(), "utf8").trim();
|
|
57792
57891
|
return token.length > 0 ? token : null;
|
|
57793
57892
|
} catch {
|
|
57794
57893
|
return null;
|
|
@@ -57796,24 +57895,24 @@ function readOperatorToken() {
|
|
|
57796
57895
|
}
|
|
57797
57896
|
function persistOperatorToken(token) {
|
|
57798
57897
|
const dir = operatorDir();
|
|
57799
|
-
(0,
|
|
57800
|
-
(0,
|
|
57898
|
+
(0, import_node_fs10.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
57899
|
+
(0, import_node_fs10.writeFileSync)(operatorTokenPath(), `${token.trim()}
|
|
57801
57900
|
`, { encoding: "utf8", mode: 384 });
|
|
57802
57901
|
}
|
|
57803
57902
|
function agentCredentialPath() {
|
|
57804
|
-
return
|
|
57903
|
+
return import_node_path17.default.join(operatorDir(), "agent-credential");
|
|
57805
57904
|
}
|
|
57806
57905
|
function persistAgentSecret(secret) {
|
|
57807
57906
|
const dir = operatorDir();
|
|
57808
|
-
(0,
|
|
57809
|
-
(0,
|
|
57907
|
+
(0, import_node_fs10.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
57908
|
+
(0, import_node_fs10.writeFileSync)(agentCredentialPath(), `${secret.trim()}
|
|
57810
57909
|
`, { encoding: "utf8", mode: 384 });
|
|
57811
57910
|
}
|
|
57812
57911
|
function readAgentSecret() {
|
|
57813
57912
|
const fromEnv = process.env.MRRLIN_AGENT_SECRET?.trim();
|
|
57814
57913
|
if (fromEnv) return fromEnv;
|
|
57815
57914
|
try {
|
|
57816
|
-
const raw = (0,
|
|
57915
|
+
const raw = (0, import_node_fs10.readFileSync)(agentCredentialPath(), "utf8").trim();
|
|
57817
57916
|
return raw || void 0;
|
|
57818
57917
|
} catch {
|
|
57819
57918
|
return void 0;
|
|
@@ -57822,9 +57921,9 @@ function readAgentSecret() {
|
|
|
57822
57921
|
|
|
57823
57922
|
// src/worker-token.ts
|
|
57824
57923
|
var import_node_crypto10 = require("node:crypto");
|
|
57825
|
-
var
|
|
57826
|
-
var
|
|
57827
|
-
var
|
|
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);
|
|
57828
57927
|
var DEFAULT_WORKER_PORT = 8792;
|
|
57829
57928
|
function workerPort() {
|
|
57830
57929
|
const raw = process.env.MRRLIN_WORKER_PORT;
|
|
@@ -57833,15 +57932,15 @@ function workerPort() {
|
|
|
57833
57932
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_WORKER_PORT;
|
|
57834
57933
|
}
|
|
57835
57934
|
function workerDir() {
|
|
57836
|
-
const base = process.env.CODEX_HOME ?
|
|
57837
|
-
return
|
|
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");
|
|
57838
57937
|
}
|
|
57839
57938
|
function workerTokenPath() {
|
|
57840
|
-
return
|
|
57939
|
+
return import_node_path18.default.join(workerDir(), "token");
|
|
57841
57940
|
}
|
|
57842
57941
|
function readWorkerToken() {
|
|
57843
57942
|
try {
|
|
57844
|
-
const token = (0,
|
|
57943
|
+
const token = (0, import_node_fs11.readFileSync)(workerTokenPath(), "utf8").trim();
|
|
57845
57944
|
return token.length > 0 ? token : null;
|
|
57846
57945
|
} catch {
|
|
57847
57946
|
return null;
|
|
@@ -57851,9 +57950,9 @@ function readOrCreateWorkerToken() {
|
|
|
57851
57950
|
const existing = readWorkerToken();
|
|
57852
57951
|
if (existing) return existing;
|
|
57853
57952
|
const dir = workerDir();
|
|
57854
|
-
(0,
|
|
57953
|
+
(0, import_node_fs11.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
57855
57954
|
const token = (0, import_node_crypto10.randomBytes)(32).toString("hex");
|
|
57856
|
-
(0,
|
|
57955
|
+
(0, import_node_fs11.writeFileSync)(workerTokenPath(), `${token}
|
|
57857
57956
|
`, { encoding: "utf8", mode: 384 });
|
|
57858
57957
|
return token;
|
|
57859
57958
|
}
|
|
@@ -58625,8 +58724,10 @@ var createInboxItemInputSchema = projectScopedSchema.merge(mrrlinInboxItemCreate
|
|
|
58625
58724
|
var decideInboxItemInputSchema = projectScopedSchema.extend({ itemId: mrrlinInboxItemIdSchema }).merge(mrrlinInboxItemDecideSchema);
|
|
58626
58725
|
var resolveHandoffInputSchema = projectScopedSchema.extend({ runId: mrrlinExecutionRunIdSchema }).merge(mrrlinResolveHandoffSchema);
|
|
58627
58726
|
var registerLocalCheckoutInputSchema = projectScopedSchema.extend({
|
|
58628
|
-
path: external_exports.string().min(1).describe("Absolute path to the local git checkout (must be a git repo whose origin matches `repo`)."),
|
|
58629
|
-
repo: external_exports.string().min(1).describe(
|
|
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
|
+
)
|
|
58630
58731
|
});
|
|
58631
58732
|
var retrieveContextInputSchema = external_exports.object({
|
|
58632
58733
|
handle: external_exports.string().min(1).describe(
|
|
@@ -58821,7 +58922,7 @@ var mcpToolDescriptions = {
|
|
|
58821
58922
|
[mcpToolNames.restartExecutionRun]: "Restart a parked execution run (handoff_requested or handoff_queued) back to pending so the queue can resume it.",
|
|
58822
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.",
|
|
58823
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.",
|
|
58824
|
-
[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.",
|
|
58825
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."
|
|
58826
58927
|
};
|
|
58827
58928
|
var ARTIFACT_EXTENSION_TYPES = {
|
|
@@ -59793,7 +59894,7 @@ function createMrrlinTools(options) {
|
|
|
59793
59894
|
"Unable to upload artifact file.",
|
|
59794
59895
|
async (c, { projectSlug, path: filePath, class: artifactClass, taskId, runId, description }) => {
|
|
59795
59896
|
await checkTenantBoundary(projectSlug, "artifact upload");
|
|
59796
|
-
const extension2 =
|
|
59897
|
+
const extension2 = import_node_path19.default.extname(filePath).toLowerCase();
|
|
59797
59898
|
const contentType2 = ARTIFACT_EXTENSION_TYPES[extension2];
|
|
59798
59899
|
if (!contentType2) {
|
|
59799
59900
|
throw new McpToolCodedError(
|
|
@@ -59821,7 +59922,7 @@ function createMrrlinTools(options) {
|
|
|
59821
59922
|
"Artifact exceeds 5MB; split or summarize instead."
|
|
59822
59923
|
);
|
|
59823
59924
|
}
|
|
59824
|
-
const filename =
|
|
59925
|
+
const filename = import_node_path19.default.basename(filePath);
|
|
59825
59926
|
return deliverBuiltIn(
|
|
59826
59927
|
c,
|
|
59827
59928
|
projectSlug,
|
|
@@ -59844,7 +59945,7 @@ function createMrrlinTools(options) {
|
|
|
59844
59945
|
`Invalid filename '${filename}'; provide a bare filename with no path separators or '..'.`
|
|
59845
59946
|
);
|
|
59846
59947
|
}
|
|
59847
|
-
const extension2 =
|
|
59948
|
+
const extension2 = import_node_path19.default.extname(filename).toLowerCase();
|
|
59848
59949
|
const contentType2 = ARTIFACT_EXTENSION_TYPES[extension2];
|
|
59849
59950
|
if (!contentType2) {
|
|
59850
59951
|
throw new McpToolCodedError(
|
|
@@ -59929,10 +60030,37 @@ function createMrrlinTools(options) {
|
|
|
59929
60030
|
mcpToolNames.registerLocalCheckout,
|
|
59930
60031
|
"LOCAL_CHECKOUT_REGISTER_FAILED",
|
|
59931
60032
|
"Unable to register local checkout.",
|
|
59932
|
-
async (
|
|
60033
|
+
async (c, { projectSlug, path: checkoutPath, repo }) => {
|
|
59933
60034
|
await checkTenantBoundary(projectSlug, "local checkout");
|
|
59934
60035
|
const registry3 = new CheckoutRegistry(resolveStateDir());
|
|
59935
|
-
|
|
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());
|
|
59936
60064
|
if (!result.ok) {
|
|
59937
60065
|
const codeMap = {
|
|
59938
60066
|
not_absolute: "LOCAL_CHECKOUT_PATH_NOT_ABSOLUTE",
|
|
@@ -60033,20 +60161,20 @@ function allAgyGrantStrings() {
|
|
|
60033
60161
|
}
|
|
60034
60162
|
function resolveAgyConfigPath(options) {
|
|
60035
60163
|
if (options.agyConfigPath) return options.agyConfigPath;
|
|
60036
|
-
return
|
|
60164
|
+
return import_node_path20.default.join(options.homeDir ?? import_node_os12.default.homedir(), ".gemini", "config", "mcp_config.json");
|
|
60037
60165
|
}
|
|
60038
60166
|
function resolveConfigJsonPath(options) {
|
|
60039
60167
|
if (options.configJsonPath) return options.configJsonPath;
|
|
60040
|
-
return
|
|
60168
|
+
return import_node_path20.default.join(options.homeDir ?? import_node_os12.default.homedir(), ".gemini", "config", "config.json");
|
|
60041
60169
|
}
|
|
60042
60170
|
async function detectInstallDistribution3(options) {
|
|
60043
60171
|
if (options.distribution && options.distribution !== "auto") return options.distribution;
|
|
60044
|
-
let current2 =
|
|
60172
|
+
let current2 = import_node_path20.default.dirname(options.binPath);
|
|
60045
60173
|
while (true) {
|
|
60046
|
-
if (await pathExists4(
|
|
60174
|
+
if (await pathExists4(import_node_path20.default.join(current2, "pnpm-workspace.yaml"))) {
|
|
60047
60175
|
return "local";
|
|
60048
60176
|
}
|
|
60049
|
-
const parent =
|
|
60177
|
+
const parent = import_node_path20.default.dirname(current2);
|
|
60050
60178
|
if (parent === current2) break;
|
|
60051
60179
|
current2 = parent;
|
|
60052
60180
|
}
|
|
@@ -60068,7 +60196,7 @@ function browserTable3(binPath, distribution, homeDir) {
|
|
|
60068
60196
|
return { ...base, env: { PLAYWRIGHT_BROWSERS_PATH: browserPaths(homeDir).browsersPath } };
|
|
60069
60197
|
}
|
|
60070
60198
|
function managedEntries2(options, distribution) {
|
|
60071
|
-
const homeDir = options.homeDir ??
|
|
60199
|
+
const homeDir = options.homeDir ?? import_node_os12.default.homedir();
|
|
60072
60200
|
return [
|
|
60073
60201
|
{ id: "mrrlin", expected: mrrlinTable3(options.binPath, distribution, options.serveEnv) },
|
|
60074
60202
|
{ id: "mrrlin-browser", expected: browserTable3(options.binPath, distribution, homeDir) },
|
|
@@ -60088,8 +60216,8 @@ async function installAgy(options) {
|
|
|
60088
60216
|
const configJsonPath = resolveConfigJsonPath(options);
|
|
60089
60217
|
const distribution = await detectInstallDistribution3(options);
|
|
60090
60218
|
const entries = managedEntries2(options, distribution);
|
|
60091
|
-
await import_promises9.default.mkdir(
|
|
60092
|
-
await import_promises9.default.mkdir(
|
|
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 });
|
|
60093
60221
|
let action = "noop";
|
|
60094
60222
|
const preservedEnvBlocks = [];
|
|
60095
60223
|
if (!await pathExists4(configPath)) {
|
|
@@ -60205,14 +60333,14 @@ async function installAgy(options) {
|
|
|
60205
60333
|
|
|
60206
60334
|
// src/provider-readiness.ts
|
|
60207
60335
|
var import_promises10 = require("node:fs/promises");
|
|
60208
|
-
var
|
|
60209
|
-
var
|
|
60210
|
-
var
|
|
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);
|
|
60211
60339
|
var import_semver2 = __toESM(require_semver2(), 1);
|
|
60212
60340
|
var toml3 = __toESM(require_toml(), 1);
|
|
60213
60341
|
|
|
60214
60342
|
// src/agent-version.ts
|
|
60215
|
-
var
|
|
60343
|
+
var import_node_child_process15 = require("node:child_process");
|
|
60216
60344
|
var import_semver = __toESM(require_semver2(), 1);
|
|
60217
60345
|
var SEMVER_RE = /\b\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?\b/;
|
|
60218
60346
|
var CODEX_PACKAGE = process.env.MRRLIN_CODEX_PACKAGE?.trim() || "@openai/codex";
|
|
@@ -60222,7 +60350,7 @@ function parseCodexVersion(raw) {
|
|
|
60222
60350
|
return m ? m[0] : null;
|
|
60223
60351
|
}
|
|
60224
60352
|
var defaultRun = (args) => {
|
|
60225
|
-
const r = (0,
|
|
60353
|
+
const r = (0, import_node_child_process15.spawnSync)("codex", args, { encoding: "utf8", timeout: 8e3, shell: true });
|
|
60226
60354
|
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
60227
60355
|
};
|
|
60228
60356
|
function getInstalledAgentVersion(provider, run3) {
|
|
@@ -60298,13 +60426,13 @@ function startCodexProbe(deps = {}) {
|
|
|
60298
60426
|
// src/provider-readiness.ts
|
|
60299
60427
|
function resolveCodexHome2(opts) {
|
|
60300
60428
|
if (opts.codexHome) return opts.codexHome;
|
|
60301
|
-
if (opts.homeDir) return
|
|
60429
|
+
if (opts.homeDir) return import_node_path21.default.join(opts.homeDir, ".codex");
|
|
60302
60430
|
if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
|
|
60303
|
-
return
|
|
60431
|
+
return import_node_path21.default.join(import_node_os13.default.homedir(), ".codex");
|
|
60304
60432
|
}
|
|
60305
60433
|
function resolveClaudeConfigPath2(opts) {
|
|
60306
60434
|
if (opts.claudeConfigPath) return opts.claudeConfigPath;
|
|
60307
|
-
return
|
|
60435
|
+
return import_node_path21.default.join(opts.homeDir ?? import_node_os13.default.homedir(), ".claude.json");
|
|
60308
60436
|
}
|
|
60309
60437
|
function isExternalAgentsWrapper(table) {
|
|
60310
60438
|
if (!table) return false;
|
|
@@ -60373,9 +60501,9 @@ async function verifyProviderReadiness(provider, run3, opts = {}) {
|
|
|
60373
60501
|
if (!checks.version) details.push(`version: ${version2 ?? "unparseable"} is below the required 2.1.232`);
|
|
60374
60502
|
}
|
|
60375
60503
|
if (provider === "codex") {
|
|
60376
|
-
const authPath =
|
|
60504
|
+
const authPath = import_node_path21.default.join(resolveCodexHome2(opts), "auth.json");
|
|
60377
60505
|
try {
|
|
60378
|
-
await (0, import_promises10.access)(authPath,
|
|
60506
|
+
await (0, import_promises10.access)(authPath, import_node_fs12.constants.F_OK);
|
|
60379
60507
|
checks.auth = true;
|
|
60380
60508
|
} catch {
|
|
60381
60509
|
details.push(`auth: ${authPath} not found`);
|
|
@@ -60390,7 +60518,7 @@ async function verifyProviderReadiness(provider, run3, opts = {}) {
|
|
|
60390
60518
|
if (!checks.auth) details.push("auth: `claude auth status` failed");
|
|
60391
60519
|
}
|
|
60392
60520
|
if (provider === "codex") {
|
|
60393
|
-
const configPath =
|
|
60521
|
+
const configPath = import_node_path21.default.join(resolveCodexHome2(opts), "config.toml");
|
|
60394
60522
|
try {
|
|
60395
60523
|
const raw = await (0, import_promises10.readFile)(configPath, "utf8");
|
|
60396
60524
|
const parsed = toml3.parse(raw);
|
|
@@ -60441,9 +60569,9 @@ async function verifyProviderReadiness(provider, run3, opts = {}) {
|
|
|
60441
60569
|
}
|
|
60442
60570
|
|
|
60443
60571
|
// src/browser-interceptor.ts
|
|
60444
|
-
var
|
|
60572
|
+
var import_node_os14 = __toESM(require("node:os"), 1);
|
|
60445
60573
|
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
60446
|
-
var
|
|
60574
|
+
var import_node_child_process16 = require("node:child_process");
|
|
60447
60575
|
var INTERNAL_HOST_PATTERNS = [
|
|
60448
60576
|
/^(?:.*\.)?mrrlin\.(?:com|internal|local)$/i,
|
|
60449
60577
|
/^(?:localhost|127\.0\.0\.1)(?::\d+)?$/i
|
|
@@ -60615,7 +60743,7 @@ function wireBrowserServeProxy(streams) {
|
|
|
60615
60743
|
}
|
|
60616
60744
|
function signalToExitCode(signal) {
|
|
60617
60745
|
if (!signal) return 1;
|
|
60618
|
-
const sigNum =
|
|
60746
|
+
const sigNum = import_node_os14.default.constants.signals[signal];
|
|
60619
60747
|
if (typeof sigNum === "number") {
|
|
60620
60748
|
return 128 + sigNum;
|
|
60621
60749
|
}
|
|
@@ -60624,7 +60752,7 @@ function signalToExitCode(signal) {
|
|
|
60624
60752
|
async function runBrowserServeProxy(opts) {
|
|
60625
60753
|
const input = opts.input ?? process.stdin;
|
|
60626
60754
|
const output3 = opts.output ?? process.stdout;
|
|
60627
|
-
const child = (0,
|
|
60755
|
+
const child = (0, import_node_child_process16.spawn)(opts.command, opts.args, {
|
|
60628
60756
|
stdio: ["pipe", "pipe", "inherit"],
|
|
60629
60757
|
env: { ...process.env, ...opts.env }
|
|
60630
60758
|
});
|
|
@@ -60671,12 +60799,12 @@ async function runBrowserServeProxy(opts) {
|
|
|
60671
60799
|
}
|
|
60672
60800
|
|
|
60673
60801
|
// src/director-bridge.ts
|
|
60674
|
-
var
|
|
60802
|
+
var import_node_fs27 = __toESM(require("node:fs"), 1);
|
|
60675
60803
|
var import_node_http3 = __toESM(require("node:http"), 1);
|
|
60676
|
-
var
|
|
60677
|
-
var
|
|
60678
|
-
var
|
|
60679
|
-
var
|
|
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);
|
|
60680
60808
|
|
|
60681
60809
|
// src/turn-replay-buffer.ts
|
|
60682
60810
|
var DEFAULT_MAX_EVENTS = 2e3;
|
|
@@ -61220,17 +61348,17 @@ function createTurnLock() {
|
|
|
61220
61348
|
}
|
|
61221
61349
|
|
|
61222
61350
|
// src/self-update.ts
|
|
61223
|
-
var
|
|
61351
|
+
var import_node_child_process18 = require("node:child_process");
|
|
61224
61352
|
var import_node_crypto12 = require("node:crypto");
|
|
61225
|
-
var
|
|
61226
|
-
var
|
|
61353
|
+
var import_node_fs14 = require("node:fs");
|
|
61354
|
+
var import_node_path23 = __toESM(require("node:path"), 1);
|
|
61227
61355
|
var import_semver3 = __toESM(require_semver2(), 1);
|
|
61228
61356
|
|
|
61229
61357
|
// src/codex-auth-preflight.ts
|
|
61230
|
-
var
|
|
61231
|
-
var
|
|
61232
|
-
var
|
|
61233
|
-
var
|
|
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);
|
|
61234
61362
|
var DEFAULT_CODEX_AUTH_MIN_TTL_SECONDS = 15 * 60;
|
|
61235
61363
|
var DEFAULT_CODEX_AUTH_SMOKE_TIMEOUT_MS = 2e4;
|
|
61236
61364
|
var DEFAULT_CODEX_AUTH_SMOKE_MODEL = "gpt-5.4-mini";
|
|
@@ -61249,7 +61377,7 @@ function codexAuthSmokeTimeoutMs(env = process.env) {
|
|
|
61249
61377
|
function resolveCodexAuthPath(opts = {}) {
|
|
61250
61378
|
const env = opts.env ?? process.env;
|
|
61251
61379
|
const codexHome = env.CODEX_HOME?.trim();
|
|
61252
|
-
return
|
|
61380
|
+
return import_node_path22.default.join(codexHome || import_node_path22.default.join(opts.homeDir ?? import_node_os15.default.homedir(), ".codex"), "auth.json");
|
|
61253
61381
|
}
|
|
61254
61382
|
function decodeJwtExpMs(token) {
|
|
61255
61383
|
const parts = token.split(".");
|
|
@@ -61310,7 +61438,7 @@ function runCodexAuthRefreshSmokeForBridgeUpdate(opts = {}) {
|
|
|
61310
61438
|
const configuredExecutable = opts.codexExecutable ?? env.MRRLIN_DIRECTOR_BRIDGE_CODEX_BIN?.trim();
|
|
61311
61439
|
const executable = configuredExecutable || "codex";
|
|
61312
61440
|
const timeoutMs = opts.timeoutMs ?? codexAuthSmokeTimeoutMs(env);
|
|
61313
|
-
const cwd = opts.cwd ??
|
|
61441
|
+
const cwd = opts.cwd ?? import_node_os15.default.tmpdir();
|
|
61314
61442
|
const args = [
|
|
61315
61443
|
"exec",
|
|
61316
61444
|
"--sandbox",
|
|
@@ -61321,9 +61449,9 @@ function runCodexAuthRefreshSmokeForBridgeUpdate(opts = {}) {
|
|
|
61321
61449
|
CODEX_AUTH_SMOKE_PROMPT
|
|
61322
61450
|
];
|
|
61323
61451
|
const command = commandForSmoke(executable, model);
|
|
61324
|
-
const
|
|
61452
|
+
const execFileSync7 = opts.execFileSyncImpl ?? import_node_child_process17.execFileSync;
|
|
61325
61453
|
try {
|
|
61326
|
-
|
|
61454
|
+
execFileSync7(executable, args, {
|
|
61327
61455
|
cwd,
|
|
61328
61456
|
env,
|
|
61329
61457
|
encoding: "utf8",
|
|
@@ -61370,7 +61498,7 @@ function inspectCodexAuthForBridgeUpdate(opts = {}) {
|
|
|
61370
61498
|
const nowMs = opts.nowMs ?? Date.now();
|
|
61371
61499
|
const minTtlSeconds = opts.minTtlSeconds ?? codexAuthMinTtlSeconds(env);
|
|
61372
61500
|
const authPath = resolveCodexAuthPath({ env, homeDir: opts.homeDir });
|
|
61373
|
-
const readFile9 = opts.readFileSyncImpl ?? ((p, encoding) => (0,
|
|
61501
|
+
const readFile9 = opts.readFileSyncImpl ?? ((p, encoding) => (0, import_node_fs13.readFileSync)(p, encoding));
|
|
61374
61502
|
let raw;
|
|
61375
61503
|
try {
|
|
61376
61504
|
raw = readFile9(authPath, "utf8");
|
|
@@ -61484,26 +61612,26 @@ function inspectCodexAuthForBridgeUpdate(opts = {}) {
|
|
|
61484
61612
|
var BIN_NAME = "mrrlin-mcp";
|
|
61485
61613
|
var SELF_UPDATE_AUTH_PREFLIGHT_OFFER_PREFIX = "[bridge:update:auth-preflight]";
|
|
61486
61614
|
function resolveBinPath(opts) {
|
|
61487
|
-
if (opts.argv1 &&
|
|
61615
|
+
if (opts.argv1 && import_node_path23.default.basename(opts.argv1).includes("mrrlin")) {
|
|
61488
61616
|
return { path: opts.argv1, source: "argv" };
|
|
61489
61617
|
}
|
|
61490
61618
|
const whichSync = opts.whichSync ?? ((name) => {
|
|
61491
61619
|
try {
|
|
61492
|
-
return (0,
|
|
61620
|
+
return (0, import_node_child_process18.execFileSync)("which", [name], { encoding: "utf8", timeout: 3e3 }).trim() || null;
|
|
61493
61621
|
} catch {
|
|
61494
61622
|
return null;
|
|
61495
61623
|
}
|
|
61496
61624
|
});
|
|
61497
|
-
const
|
|
61625
|
+
const existsSync6 = opts.existsSync ?? import_node_fs14.existsSync;
|
|
61498
61626
|
const resolved = whichSync(BIN_NAME);
|
|
61499
|
-
if (resolved &&
|
|
61627
|
+
if (resolved && existsSync6(resolved)) {
|
|
61500
61628
|
return { path: resolved, source: "which" };
|
|
61501
61629
|
}
|
|
61502
61630
|
const envPath = (opts.env ?? process.env).PATH ?? "";
|
|
61503
|
-
for (const dir of envPath.split(
|
|
61631
|
+
for (const dir of envPath.split(import_node_path23.default.delimiter)) {
|
|
61504
61632
|
if (!dir) continue;
|
|
61505
|
-
const candidate =
|
|
61506
|
-
if (
|
|
61633
|
+
const candidate = import_node_path23.default.join(dir, BIN_NAME);
|
|
61634
|
+
if (existsSync6(candidate)) {
|
|
61507
61635
|
return { path: candidate, source: "path-walk" };
|
|
61508
61636
|
}
|
|
61509
61637
|
}
|
|
@@ -61533,7 +61661,7 @@ function sha256(buf) {
|
|
|
61533
61661
|
function startSelfUpdate(deps) {
|
|
61534
61662
|
const log = deps.log ?? (() => {
|
|
61535
61663
|
});
|
|
61536
|
-
const readFile9 = deps.readFileSyncImpl ?? ((p) => (0,
|
|
61664
|
+
const readFile9 = deps.readFileSyncImpl ?? ((p) => (0, import_node_fs14.readFileSync)(p));
|
|
61537
61665
|
const setIntervalFn = deps.setIntervalImpl ?? setInterval;
|
|
61538
61666
|
const clearIntervalFn = deps.clearIntervalImpl ?? clearInterval;
|
|
61539
61667
|
const intervalMs = deps.intervalMs ?? readIntervalEnv("MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE_INTERVAL_MS", DEFAULT_INTERVAL_MS);
|
|
@@ -61820,7 +61948,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
61820
61948
|
}
|
|
61821
61949
|
|
|
61822
61950
|
// src/_generated/version.ts
|
|
61823
|
-
var PKG_VERSION = "0.4.
|
|
61951
|
+
var PKG_VERSION = "0.4.117";
|
|
61824
61952
|
|
|
61825
61953
|
// src/receipt-signing.ts
|
|
61826
61954
|
var import_node_crypto13 = __toESM(require("node:crypto"), 1);
|
|
@@ -62704,14 +62832,14 @@ function parseLedger(value) {
|
|
|
62704
62832
|
}
|
|
62705
62833
|
|
|
62706
62834
|
// src/api-base-url-migrate.ts
|
|
62707
|
-
var
|
|
62708
|
-
var
|
|
62709
|
-
var
|
|
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);
|
|
62710
62838
|
|
|
62711
62839
|
// src/service-paths.ts
|
|
62712
|
-
var
|
|
62840
|
+
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
62713
62841
|
function isWorktreePath(p) {
|
|
62714
|
-
const norm =
|
|
62842
|
+
const norm = import_node_path24.default.normalize(p).split(import_node_path24.default.sep).join("/");
|
|
62715
62843
|
return norm.includes("/.claude/worktrees/");
|
|
62716
62844
|
}
|
|
62717
62845
|
function resolveServiceCwd(opts) {
|
|
@@ -62783,20 +62911,20 @@ ${envLines}
|
|
|
62783
62911
|
|
|
62784
62912
|
// src/api-base-url-migrate.ts
|
|
62785
62913
|
function defaultDeps(deps) {
|
|
62786
|
-
const home = deps.home ?? process.env.HOME ??
|
|
62914
|
+
const home = deps.home ?? process.env.HOME ?? import_node_os16.default.homedir();
|
|
62787
62915
|
return {
|
|
62788
62916
|
home,
|
|
62789
|
-
codexHome: deps.codexHome ?? process.env.CODEX_HOME?.trim() ??
|
|
62790
|
-
readFile: deps.readFile ?? ((p) =>
|
|
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")),
|
|
62791
62919
|
// Temp-file + atomic rename so a concurrent `serve` and `director-bridge` startup can never
|
|
62792
62920
|
// interleave partial writes into a config the next start has to parse. Note this normalizes the
|
|
62793
62921
|
// file to 0o600 — deliberate, since both files can carry a credential-bearing URL.
|
|
62794
62922
|
writeFile: deps.writeFile ?? ((p, c) => {
|
|
62795
62923
|
const tmp = `${p}.tmp-${process.pid}`;
|
|
62796
|
-
|
|
62797
|
-
|
|
62924
|
+
import_node_fs15.default.writeFileSync(tmp, c, { mode: 384 });
|
|
62925
|
+
import_node_fs15.default.renameSync(tmp, p);
|
|
62798
62926
|
}),
|
|
62799
|
-
exists: deps.exists ?? ((p) =>
|
|
62927
|
+
exists: deps.exists ?? ((p) => import_node_fs15.default.existsSync(p)),
|
|
62800
62928
|
log: deps.log ?? ((m) => process.stderr.write(`${m}
|
|
62801
62929
|
`))
|
|
62802
62930
|
};
|
|
@@ -62835,7 +62963,7 @@ function backupOnce(file2, text, deps) {
|
|
|
62835
62963
|
}
|
|
62836
62964
|
function migrateEcosystemConfig(deps = {}) {
|
|
62837
62965
|
const d = defaultDeps(deps);
|
|
62838
|
-
const file2 =
|
|
62966
|
+
const file2 = import_node_path25.default.join(d.home, ".mrrlin", "ecosystem.config.cjs");
|
|
62839
62967
|
if (!d.exists(file2)) return { file: file2, status: "absent" };
|
|
62840
62968
|
const text = d.readFile(file2);
|
|
62841
62969
|
if (!findRetiredHost(text) && !hasLiveLegacyStagingFlag(text, "js"))
|
|
@@ -62985,7 +63113,7 @@ ${envLines}
|
|
|
62985
63113
|
}
|
|
62986
63114
|
function migrateCodexConfig(deps = {}) {
|
|
62987
63115
|
const d = defaultDeps(deps);
|
|
62988
|
-
const file2 =
|
|
63116
|
+
const file2 = import_node_path25.default.join(d.codexHome, "config.toml");
|
|
62989
63117
|
if (!d.exists(file2)) return { file: file2, status: "absent" };
|
|
62990
63118
|
const text = d.readFile(file2);
|
|
62991
63119
|
const host = findRetiredHost(text);
|
|
@@ -63071,7 +63199,7 @@ $1`
|
|
|
63071
63199
|
}
|
|
63072
63200
|
function migrateClaudeConfig(deps = {}) {
|
|
63073
63201
|
const d = defaultDeps(deps);
|
|
63074
|
-
const file2 =
|
|
63202
|
+
const file2 = import_node_path25.default.join(d.home, ".claude.json");
|
|
63075
63203
|
if (!d.exists(file2)) return { file: file2, status: "absent" };
|
|
63076
63204
|
const text = d.readFile(file2);
|
|
63077
63205
|
let parsed;
|
|
@@ -63121,9 +63249,9 @@ function migrateRetiredApiBaseUrls(deps = {}) {
|
|
|
63121
63249
|
const d = defaultDeps(deps);
|
|
63122
63250
|
const results = [];
|
|
63123
63251
|
const steps = [
|
|
63124
|
-
{ run: migrateEcosystemConfig, file:
|
|
63125
|
-
{ run: migrateCodexConfig, file:
|
|
63126
|
-
{ run: migrateClaudeConfig, file:
|
|
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") }
|
|
63127
63255
|
];
|
|
63128
63256
|
for (const step of steps) {
|
|
63129
63257
|
try {
|
|
@@ -63149,8 +63277,8 @@ function migrateRetiredApiBaseUrls(deps = {}) {
|
|
|
63149
63277
|
}
|
|
63150
63278
|
|
|
63151
63279
|
// src/bridge-health.ts
|
|
63152
|
-
var
|
|
63153
|
-
var
|
|
63280
|
+
var import_node_fs16 = require("node:fs");
|
|
63281
|
+
var import_node_path26 = __toESM(require("node:path"), 1);
|
|
63154
63282
|
var SENTINEL_FILE_NAME = "bridge-health-circuit-breaker.json";
|
|
63155
63283
|
var CRASH_WINDOW_MS = 60 * 60 * 1e3;
|
|
63156
63284
|
var MAX_CRASHES_PER_WINDOW = 3;
|
|
@@ -63162,9 +63290,9 @@ function isCrashSentinel(value) {
|
|
|
63162
63290
|
return typeof candidate.crashCount === "number" && Number.isInteger(candidate.crashCount) && candidate.crashCount >= 0 && typeof candidate.windowStartedAt === "string";
|
|
63163
63291
|
}
|
|
63164
63292
|
async function readCrashSentinel(stateDir, now = Date.now) {
|
|
63165
|
-
const sentinelPath =
|
|
63293
|
+
const sentinelPath = import_node_path26.default.join(stateDir, SENTINEL_FILE_NAME);
|
|
63166
63294
|
try {
|
|
63167
|
-
const raw = await
|
|
63295
|
+
const raw = await import_node_fs16.promises.readFile(sentinelPath, "utf8");
|
|
63168
63296
|
const parsed = JSON.parse(raw);
|
|
63169
63297
|
if (isCrashSentinel(parsed)) return parsed;
|
|
63170
63298
|
} catch {
|
|
@@ -63172,11 +63300,11 @@ async function readCrashSentinel(stateDir, now = Date.now) {
|
|
|
63172
63300
|
return { crashCount: 0, windowStartedAt: new Date(now()).toISOString() };
|
|
63173
63301
|
}
|
|
63174
63302
|
async function writeCrashSentinel(stateDir, sentinel) {
|
|
63175
|
-
await
|
|
63176
|
-
const sentinelPath =
|
|
63303
|
+
await import_node_fs16.promises.mkdir(stateDir, { recursive: true });
|
|
63304
|
+
const sentinelPath = import_node_path26.default.join(stateDir, SENTINEL_FILE_NAME);
|
|
63177
63305
|
const tmpPath = `${sentinelPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
|
|
63178
|
-
await
|
|
63179
|
-
await
|
|
63306
|
+
await import_node_fs16.promises.writeFile(tmpPath, JSON.stringify(sentinel), "utf8");
|
|
63307
|
+
await import_node_fs16.promises.rename(tmpPath, sentinelPath);
|
|
63180
63308
|
}
|
|
63181
63309
|
function withTimeout(fn, ms = DEFAULT_OPERATION_TIMEOUT_MS) {
|
|
63182
63310
|
const controller = new AbortController();
|
|
@@ -63503,12 +63631,12 @@ function startSchedulerTickLoop(deps) {
|
|
|
63503
63631
|
|
|
63504
63632
|
// src/retention/pruner.ts
|
|
63505
63633
|
var import_promises11 = require("node:fs/promises");
|
|
63506
|
-
var
|
|
63634
|
+
var import_node_path27 = __toESM(require("node:path"), 1);
|
|
63507
63635
|
function protectedDayFloor(protectedSinceMs) {
|
|
63508
63636
|
return new Date(protectedSinceMs).toISOString().slice(0, 10);
|
|
63509
63637
|
}
|
|
63510
63638
|
async function prune(stateDir, bounds) {
|
|
63511
|
-
const logsDir =
|
|
63639
|
+
const logsDir = import_node_path27.default.join(stateDir, "logs");
|
|
63512
63640
|
let entries;
|
|
63513
63641
|
try {
|
|
63514
63642
|
entries = await (0, import_promises11.readdir)(logsDir);
|
|
@@ -63524,7 +63652,7 @@ async function prune(stateDir, bounds) {
|
|
|
63524
63652
|
for (const entry of entries) {
|
|
63525
63653
|
const m = bridgeRe.exec(entry);
|
|
63526
63654
|
if (!m?.[1]) continue;
|
|
63527
|
-
const fullPath =
|
|
63655
|
+
const fullPath = import_node_path27.default.join(logsDir, entry);
|
|
63528
63656
|
const s = await (0, import_promises11.stat)(fullPath);
|
|
63529
63657
|
files.push({ day: m[1], size: s.size, fullPath });
|
|
63530
63658
|
}
|
|
@@ -63533,7 +63661,7 @@ async function prune(stateDir, bounds) {
|
|
|
63533
63661
|
const reasonByDay = {};
|
|
63534
63662
|
let bytesRemoved = 0;
|
|
63535
63663
|
async function isDaySafeToDelete(day) {
|
|
63536
|
-
const telemetryDir =
|
|
63664
|
+
const telemetryDir = import_node_path27.default.join(stateDir, "telemetry");
|
|
63537
63665
|
let telemetryEntries;
|
|
63538
63666
|
try {
|
|
63539
63667
|
telemetryEntries = await (0, import_promises11.readdir)(telemetryDir);
|
|
@@ -63549,7 +63677,7 @@ async function prune(stateDir, bounds) {
|
|
|
63549
63677
|
}
|
|
63550
63678
|
if (projectSlugs.length === 0) return true;
|
|
63551
63679
|
for (const slug of projectSlugs) {
|
|
63552
|
-
const markerPath =
|
|
63680
|
+
const markerPath = import_node_path27.default.join(telemetryDir, `.processed-${slug}-${day}`);
|
|
63553
63681
|
try {
|
|
63554
63682
|
await (0, import_promises11.stat)(markerPath);
|
|
63555
63683
|
} catch (err) {
|
|
@@ -63599,7 +63727,7 @@ async function prune(stateDir, bounds) {
|
|
|
63599
63727
|
const budgetOvershootBytes = Math.max(0, totalSize2 - budgetBytes);
|
|
63600
63728
|
await emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining);
|
|
63601
63729
|
if (daysRemoved.length > 0) {
|
|
63602
|
-
const sessionsPath =
|
|
63730
|
+
const sessionsPath = import_node_path27.default.join(logsDir, ".sessions.json");
|
|
63603
63731
|
let sessionsObj = {};
|
|
63604
63732
|
let fileExists = true;
|
|
63605
63733
|
try {
|
|
@@ -63621,8 +63749,8 @@ async function prune(stateDir, bounds) {
|
|
|
63621
63749
|
return { daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining, budgetOvershootBytes };
|
|
63622
63750
|
}
|
|
63623
63751
|
async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining) {
|
|
63624
|
-
const logsDir =
|
|
63625
|
-
const logPath =
|
|
63752
|
+
const logsDir = import_node_path27.default.join(stateDir, "logs");
|
|
63753
|
+
const logPath = import_node_path27.default.join(logsDir, ".pruned.jsonl");
|
|
63626
63754
|
await (0, import_promises11.mkdir)(logsDir, { recursive: true });
|
|
63627
63755
|
const record2 = { ts: Date.now(), dir: "logs", daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining };
|
|
63628
63756
|
await (0, import_promises11.appendFile)(logPath, `${JSON.stringify(record2)}
|
|
@@ -63632,7 +63760,7 @@ async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, ol
|
|
|
63632
63760
|
// src/telemetry/turn-aggregator.ts
|
|
63633
63761
|
var import_node_crypto14 = require("node:crypto");
|
|
63634
63762
|
var import_promises12 = require("node:fs/promises");
|
|
63635
|
-
var
|
|
63763
|
+
var import_node_path28 = require("node:path");
|
|
63636
63764
|
var BRIDGE_FILE_RE = /^bridge-(\d{4}-\d{2}-\d{2})\.jsonl$/;
|
|
63637
63765
|
var PLUMBING_COUNTER_KEY = {
|
|
63638
63766
|
socket_close: "socketCloses",
|
|
@@ -63661,7 +63789,7 @@ function inheritSlug(seeds, index) {
|
|
|
63661
63789
|
return (preceding ?? following)?.slug;
|
|
63662
63790
|
}
|
|
63663
63791
|
async function foldClosedDays(stateDir, today) {
|
|
63664
|
-
const logsDir = (0,
|
|
63792
|
+
const logsDir = (0, import_node_path28.join)(stateDir, "logs");
|
|
63665
63793
|
let entries;
|
|
63666
63794
|
try {
|
|
63667
63795
|
entries = await (0, import_promises12.readdir)(logsDir);
|
|
@@ -63673,7 +63801,7 @@ async function foldClosedDays(stateDir, today) {
|
|
|
63673
63801
|
if (!m) continue;
|
|
63674
63802
|
const day = m[1];
|
|
63675
63803
|
if (day === today) continue;
|
|
63676
|
-
const raw = await (0, import_promises12.readFile)((0,
|
|
63804
|
+
const raw = await (0, import_promises12.readFile)((0, import_node_path28.join)(logsDir, entry), "utf8");
|
|
63677
63805
|
const groups = /* @__PURE__ */ new Map();
|
|
63678
63806
|
let groupCounter = 0;
|
|
63679
63807
|
for (const line of raw.split("\n")) {
|
|
@@ -63784,10 +63912,10 @@ async function foldClosedDays(stateDir, today) {
|
|
|
63784
63912
|
rowsByProject.set(slug, rows);
|
|
63785
63913
|
}
|
|
63786
63914
|
if (rowsByProject.size === 0) continue;
|
|
63787
|
-
const telemetryDir = (0,
|
|
63915
|
+
const telemetryDir = (0, import_node_path28.join)(stateDir, "telemetry");
|
|
63788
63916
|
await (0, import_promises12.mkdir)(telemetryDir, { recursive: true });
|
|
63789
63917
|
for (const [slug, rows] of rowsByProject) {
|
|
63790
|
-
const finalPath = (0,
|
|
63918
|
+
const finalPath = (0, import_node_path28.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
|
|
63791
63919
|
const tmpPath = `${finalPath}.tmp-${process.pid}-${(0, import_node_crypto14.randomBytes)(6).toString("hex")}`;
|
|
63792
63920
|
try {
|
|
63793
63921
|
await (0, import_promises12.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
|
|
@@ -63802,27 +63930,27 @@ async function foldClosedDays(stateDir, today) {
|
|
|
63802
63930
|
|
|
63803
63931
|
// src/telemetry/daily-uploader.ts
|
|
63804
63932
|
var import_promises13 = require("node:fs/promises");
|
|
63805
|
-
var
|
|
63933
|
+
var import_node_path30 = require("node:path");
|
|
63806
63934
|
|
|
63807
63935
|
// src/telemetry/installation-id.ts
|
|
63808
63936
|
var import_node_crypto15 = require("node:crypto");
|
|
63809
|
-
var
|
|
63810
|
-
var
|
|
63937
|
+
var import_node_fs17 = require("node:fs");
|
|
63938
|
+
var import_node_path29 = require("node:path");
|
|
63811
63939
|
var FILE_NAME = "installation-id";
|
|
63812
63940
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
63813
63941
|
var cache = /* @__PURE__ */ new Map();
|
|
63814
63942
|
function resolveInstallationId(stateDir) {
|
|
63815
63943
|
const cached2 = cache.get(stateDir);
|
|
63816
63944
|
if (cached2 !== void 0) return cached2;
|
|
63817
|
-
const
|
|
63945
|
+
const path33 = (0, import_node_path29.join)(stateDir, FILE_NAME);
|
|
63818
63946
|
let id;
|
|
63819
63947
|
try {
|
|
63820
|
-
id = (0,
|
|
63948
|
+
id = (0, import_node_fs17.readFileSync)(path33, "utf8").trim();
|
|
63821
63949
|
if (!UUID.test(id)) throw new Error("unusable");
|
|
63822
63950
|
} catch {
|
|
63823
63951
|
id = (0, import_node_crypto15.randomUUID)();
|
|
63824
|
-
(0,
|
|
63825
|
-
(0,
|
|
63952
|
+
(0, import_node_fs17.mkdirSync)((0, import_node_path29.dirname)(path33), { recursive: true });
|
|
63953
|
+
(0, import_node_fs17.writeFileSync)(path33, `${id}
|
|
63826
63954
|
`, "utf8");
|
|
63827
63955
|
}
|
|
63828
63956
|
cache.set(stateDir, id);
|
|
@@ -63839,7 +63967,7 @@ function truncateCause(err) {
|
|
|
63839
63967
|
return `${message.slice(0, MAX_CAUSE_CHARS - 3)}...`;
|
|
63840
63968
|
}
|
|
63841
63969
|
async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
|
|
63842
|
-
const telemetryDir = (0,
|
|
63970
|
+
const telemetryDir = (0, import_node_path30.join)(stateDir, "telemetry");
|
|
63843
63971
|
let files;
|
|
63844
63972
|
try {
|
|
63845
63973
|
files = await (0, import_promises13.readdir)(telemetryDir);
|
|
@@ -63855,14 +63983,14 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
|
|
|
63855
63983
|
const [, projectSlug, day] = match;
|
|
63856
63984
|
const key = `${projectSlug}\0${day}`;
|
|
63857
63985
|
const entry = discovered.get(key) ?? { projectSlug, day, rowsPath: null };
|
|
63858
|
-
if (rowsMatch) entry.rowsPath = (0,
|
|
63986
|
+
if (rowsMatch) entry.rowsPath = (0, import_node_path30.join)(telemetryDir, file2);
|
|
63859
63987
|
discovered.set(key, entry);
|
|
63860
63988
|
}
|
|
63861
63989
|
const today = telemetryDay();
|
|
63862
63990
|
const pending = [];
|
|
63863
63991
|
const deferred = [];
|
|
63864
63992
|
for (const { projectSlug, day, rowsPath } of discovered.values()) {
|
|
63865
|
-
const markerPath = (0,
|
|
63993
|
+
const markerPath = (0, import_node_path30.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
|
|
63866
63994
|
if (rowsPath === null && day >= today) {
|
|
63867
63995
|
try {
|
|
63868
63996
|
await (0, import_promises13.access)(markerPath);
|
|
@@ -63882,7 +64010,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
|
|
|
63882
64010
|
const fullUnprocessed = [...pending.map((p) => ({ projectSlug: p.projectSlug, day: p.day })), ...deferred];
|
|
63883
64011
|
pending.sort((a, b) => a.day.localeCompare(b.day));
|
|
63884
64012
|
for (const cur of pending) {
|
|
63885
|
-
const failurePath = (0,
|
|
64013
|
+
const failurePath = (0, import_node_path30.join)(telemetryDir, `.failed-${cur.projectSlug}-${cur.day}.json`);
|
|
63886
64014
|
let failureState = null;
|
|
63887
64015
|
try {
|
|
63888
64016
|
const data = await (0, import_promises13.readFile)(failurePath, "utf8");
|
|
@@ -63916,7 +64044,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
|
|
|
63916
64044
|
}
|
|
63917
64045
|
const gateCalls = [];
|
|
63918
64046
|
try {
|
|
63919
|
-
const rawGate = await (0, import_promises13.readFile)((0,
|
|
64047
|
+
const rawGate = await (0, import_promises13.readFile)((0, import_node_path30.join)(telemetryDir, gateFileName(cur.projectSlug, cur.day)), "utf8");
|
|
63920
64048
|
for (const line of rawGate.split("\n")) {
|
|
63921
64049
|
if (!line.trim()) continue;
|
|
63922
64050
|
try {
|
|
@@ -64118,7 +64246,7 @@ async function collectAgentPoolSnapshot(deps) {
|
|
|
64118
64246
|
}
|
|
64119
64247
|
|
|
64120
64248
|
// src/external-agents-spawn.ts
|
|
64121
|
-
var
|
|
64249
|
+
var import_node_child_process19 = require("node:child_process");
|
|
64122
64250
|
function runExternalAgentsCli(args, opts) {
|
|
64123
64251
|
let command;
|
|
64124
64252
|
let prefixArgs;
|
|
@@ -64149,7 +64277,7 @@ function runExternalAgentsCli(args, opts) {
|
|
|
64149
64277
|
};
|
|
64150
64278
|
let spawned;
|
|
64151
64279
|
try {
|
|
64152
|
-
spawned = (0,
|
|
64280
|
+
spawned = (0, import_node_child_process19.spawn)(command, [...prefixArgs, ...args], { stdio: stdioConfig });
|
|
64153
64281
|
} catch {
|
|
64154
64282
|
done(1);
|
|
64155
64283
|
return;
|
|
@@ -64261,14 +64389,14 @@ function startAgentPoolLoop(deps) {
|
|
|
64261
64389
|
}
|
|
64262
64390
|
|
|
64263
64391
|
// src/provider-readiness-loop.ts
|
|
64264
|
-
var
|
|
64392
|
+
var import_node_child_process20 = require("node:child_process");
|
|
64265
64393
|
var DEFAULT_INTERVAL_MS3 = 6e4;
|
|
64266
64394
|
function providerReadinessLoopDisabled(env = process.env) {
|
|
64267
64395
|
return env["MRRLIN_BRIDGE_PROVIDER_READINESS_DISABLE"] === "1";
|
|
64268
64396
|
}
|
|
64269
64397
|
function defaultRunnerFor(command) {
|
|
64270
64398
|
return (args) => {
|
|
64271
|
-
const r = (0,
|
|
64399
|
+
const r = (0, import_node_child_process20.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3 });
|
|
64272
64400
|
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
64273
64401
|
};
|
|
64274
64402
|
}
|
|
@@ -64311,9 +64439,9 @@ function startProviderReadinessLoop(deps) {
|
|
|
64311
64439
|
}
|
|
64312
64440
|
|
|
64313
64441
|
// src/execution-consumer.ts
|
|
64314
|
-
var
|
|
64315
|
-
var
|
|
64316
|
-
var
|
|
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);
|
|
64317
64445
|
var import_node_util2 = require("node:util");
|
|
64318
64446
|
|
|
64319
64447
|
// src/notify-templates.ts
|
|
@@ -65167,19 +65295,19 @@ async function awaitTurnWithDeadline(opts) {
|
|
|
65167
65295
|
}
|
|
65168
65296
|
|
|
65169
65297
|
// src/worktree.ts
|
|
65170
|
-
var
|
|
65298
|
+
var import_node_child_process21 = require("node:child_process");
|
|
65171
65299
|
var import_node_crypto16 = require("node:crypto");
|
|
65172
|
-
var
|
|
65173
|
-
var
|
|
65300
|
+
var import_node_fs19 = require("node:fs");
|
|
65301
|
+
var import_node_path32 = require("node:path");
|
|
65174
65302
|
|
|
65175
65303
|
// src/checkout-lock.ts
|
|
65176
|
-
var
|
|
65177
|
-
var
|
|
65304
|
+
var import_node_fs18 = require("node:fs");
|
|
65305
|
+
var import_node_path31 = require("node:path");
|
|
65178
65306
|
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
65179
65307
|
async function withCheckoutLock(locksDir, slug, fn) {
|
|
65180
|
-
(0,
|
|
65181
|
-
const target = (0,
|
|
65182
|
-
if (!(0,
|
|
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, "");
|
|
65183
65311
|
const release = await import_proper_lockfile.default.lock(target, {
|
|
65184
65312
|
retries: { retries: 600, factor: 1, minTimeout: 100, maxTimeout: 100 },
|
|
65185
65313
|
stale: 5 * 6e4
|
|
@@ -65195,28 +65323,28 @@ async function withCheckoutLock(locksDir, slug, fn) {
|
|
|
65195
65323
|
function worktreeBranch(runId) {
|
|
65196
65324
|
return `mrrlin/run-${runId}`;
|
|
65197
65325
|
}
|
|
65198
|
-
var defaultGitExec = (args, env) => (0,
|
|
65326
|
+
var defaultGitExec = (args, env) => (0, import_node_child_process21.execFileSync)("git", args, { encoding: "utf8", timeout: 3e4, env });
|
|
65199
65327
|
function disabledGitHooksPath(locksDir, scope) {
|
|
65200
65328
|
const scopeKey = (0, import_node_crypto16.createHash)("sha256").update(scope).digest("hex").slice(0, 32);
|
|
65201
|
-
return (0,
|
|
65329
|
+
return (0, import_node_path32.resolve)(locksDir, "..", "disabled-git-hooks", scopeKey);
|
|
65202
65330
|
}
|
|
65203
65331
|
function prepareDisabledGitHooksDir(locksDir, scope) {
|
|
65204
65332
|
const hooksDir = disabledGitHooksPath(locksDir, scope);
|
|
65205
|
-
const hooksRoot = (0,
|
|
65206
|
-
(0,
|
|
65207
|
-
(0,
|
|
65208
|
-
if ((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) {
|
|
65209
65337
|
throw new Error(`disabled_git_hooks_dir_not_empty: ${hooksDir}`);
|
|
65210
65338
|
}
|
|
65211
65339
|
try {
|
|
65212
|
-
(0,
|
|
65340
|
+
(0, import_node_fs19.chmodSync)(hooksDir, 320);
|
|
65213
65341
|
} catch {
|
|
65214
65342
|
}
|
|
65215
65343
|
return hooksDir;
|
|
65216
65344
|
}
|
|
65217
65345
|
function removeDisabledGitHooksDir(locksDir, scope) {
|
|
65218
65346
|
try {
|
|
65219
|
-
(0,
|
|
65347
|
+
(0, import_node_fs19.rmdirSync)(disabledGitHooksPath(locksDir, scope));
|
|
65220
65348
|
} catch {
|
|
65221
65349
|
}
|
|
65222
65350
|
}
|
|
@@ -65232,20 +65360,21 @@ function withDisabledGitHooksEnv(env, hooksDir) {
|
|
|
65232
65360
|
};
|
|
65233
65361
|
}
|
|
65234
65362
|
function git(checkout, args, hooksDir) {
|
|
65235
|
-
return (0,
|
|
65363
|
+
return (0, import_node_child_process21.execFileSync)("git", ["-C", checkout, "-c", `core.hooksPath=${hooksDir}`, ...args], {
|
|
65236
65364
|
encoding: "utf8",
|
|
65237
65365
|
timeout: 3e4,
|
|
65238
65366
|
env: { ...process.env, GIT_TERMINAL_PROMPT: "0" }
|
|
65239
65367
|
});
|
|
65240
65368
|
}
|
|
65241
65369
|
async function createRunWorktree(opts) {
|
|
65242
|
-
const worktreePath = (0,
|
|
65370
|
+
const worktreePath = (0, import_node_path32.join)(opts.worktreeRoot, opts.slug, opts.runId);
|
|
65243
65371
|
const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, opts.runId);
|
|
65244
65372
|
await withCheckoutLock(opts.locksDir, opts.slug, async () => {
|
|
65245
|
-
(0,
|
|
65373
|
+
(0, import_node_fs19.mkdirSync)(opts.worktreeRoot, { recursive: true });
|
|
65374
|
+
const base = opts.local ? `refs/heads/${opts.defaultBranch}` : `origin/${opts.defaultBranch}`;
|
|
65246
65375
|
try {
|
|
65247
|
-
git(opts.checkout, ["fetch", "origin", opts.defaultBranch], hooksDir);
|
|
65248
|
-
if (!(0,
|
|
65376
|
+
if (!opts.local) git(opts.checkout, ["fetch", "origin", opts.defaultBranch], hooksDir);
|
|
65377
|
+
if (!(0, import_node_fs19.existsSync)(worktreePath)) {
|
|
65249
65378
|
git(opts.checkout, [
|
|
65250
65379
|
"worktree",
|
|
65251
65380
|
"add",
|
|
@@ -65253,27 +65382,27 @@ async function createRunWorktree(opts) {
|
|
|
65253
65382
|
"-b",
|
|
65254
65383
|
worktreeBranch(opts.runId),
|
|
65255
65384
|
worktreePath,
|
|
65256
|
-
|
|
65385
|
+
base
|
|
65257
65386
|
], hooksDir);
|
|
65258
65387
|
}
|
|
65259
65388
|
} catch (error51) {
|
|
65260
65389
|
const detail = error51 instanceof Error ? error51.message : String(error51);
|
|
65261
65390
|
throw new Error(
|
|
65262
|
-
`default_branch_unresolved: could not provision worktree off
|
|
65391
|
+
`default_branch_unresolved: could not provision worktree off ${base} for ${opts.slug}/${opts.runId}: ${detail}`
|
|
65263
65392
|
);
|
|
65264
65393
|
}
|
|
65265
65394
|
});
|
|
65266
65395
|
return worktreePath;
|
|
65267
65396
|
}
|
|
65268
65397
|
async function removeRunWorktree(opts) {
|
|
65269
|
-
const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, (0,
|
|
65398
|
+
const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, (0, import_node_path32.basename)(opts.worktreePath));
|
|
65270
65399
|
await withCheckoutLock(opts.locksDir, opts.slug, async () => {
|
|
65271
65400
|
try {
|
|
65272
65401
|
git(opts.checkout, ["worktree", "remove", "--force", opts.worktreePath], hooksDir);
|
|
65273
65402
|
} catch {
|
|
65274
65403
|
}
|
|
65275
65404
|
git(opts.checkout, ["worktree", "prune"], hooksDir);
|
|
65276
|
-
removeDisabledGitHooksDir(opts.locksDir, (0,
|
|
65405
|
+
removeDisabledGitHooksDir(opts.locksDir, (0, import_node_path32.basename)(opts.worktreePath));
|
|
65277
65406
|
});
|
|
65278
65407
|
}
|
|
65279
65408
|
async function pushRunBranch(opts, execGit = defaultGitExec) {
|
|
@@ -65357,11 +65486,11 @@ async function sweepOrphanWorktrees(opts) {
|
|
|
65357
65486
|
const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, `sweep:${opts.slug}`);
|
|
65358
65487
|
const ownedPrefix = (() => {
|
|
65359
65488
|
try {
|
|
65360
|
-
return (
|
|
65489
|
+
return (import_node_fs19.realpathSync.native ?? import_node_fs19.realpathSync)(opts.worktreeRoot);
|
|
65361
65490
|
} catch {
|
|
65362
65491
|
return opts.worktreeRoot;
|
|
65363
65492
|
}
|
|
65364
|
-
})() +
|
|
65493
|
+
})() + import_node_path32.sep + opts.slug + import_node_path32.sep;
|
|
65365
65494
|
try {
|
|
65366
65495
|
await withCheckoutLock(opts.locksDir, opts.slug, async () => {
|
|
65367
65496
|
const listing = git(opts.checkout, ["worktree", "list", "--porcelain"], hooksDir);
|
|
@@ -65371,18 +65500,18 @@ async function sweepOrphanWorktrees(opts) {
|
|
|
65371
65500
|
if (!wt) continue;
|
|
65372
65501
|
const canonicalWt = (() => {
|
|
65373
65502
|
try {
|
|
65374
|
-
return (
|
|
65503
|
+
return (import_node_fs19.realpathSync.native ?? import_node_fs19.realpathSync)(wt);
|
|
65375
65504
|
} catch {
|
|
65376
65505
|
return wt;
|
|
65377
65506
|
}
|
|
65378
65507
|
})();
|
|
65379
|
-
const normWt = (0,
|
|
65380
|
-
const normPrefix = (0,
|
|
65508
|
+
const normWt = (0, import_node_path32.normalize)(canonicalWt);
|
|
65509
|
+
const normPrefix = (0, import_node_path32.normalize)(ownedPrefix);
|
|
65381
65510
|
const isMatch = process.platform === "win32" ? normWt.toLowerCase().startsWith(normPrefix.toLowerCase()) : normWt.startsWith(normPrefix);
|
|
65382
65511
|
if (isMatch && opts.isReapable(wt)) {
|
|
65383
65512
|
try {
|
|
65384
65513
|
git(opts.checkout, ["worktree", "remove", "--force", wt], hooksDir);
|
|
65385
|
-
removeDisabledGitHooksDir(opts.locksDir, (0,
|
|
65514
|
+
removeDisabledGitHooksDir(opts.locksDir, (0, import_node_path32.basename)(wt));
|
|
65386
65515
|
reaped.push(wt);
|
|
65387
65516
|
} catch {
|
|
65388
65517
|
}
|
|
@@ -65431,6 +65560,159 @@ function buildPullRequestBody(input) {
|
|
|
65431
65560
|
${lines2.join("\n")}`;
|
|
65432
65561
|
}
|
|
65433
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
|
+
|
|
65434
65716
|
// src/thread-retirement.ts
|
|
65435
65717
|
function decideThreadRetirement(input) {
|
|
65436
65718
|
if (input.disabled) return { retire: false };
|
|
@@ -65879,6 +66161,16 @@ var EXECUTOR_BASE_INSTRUCTIONS = [
|
|
|
65879
66161
|
"commit unverified delegated output. If dispatch fails or the pool is unavailable, do the",
|
|
65880
66162
|
"work yourself \u2014 never block the run on the pool."
|
|
65881
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}`;
|
|
65882
66174
|
function artifactKindForEvent(event) {
|
|
65883
66175
|
switch (event.type) {
|
|
65884
66176
|
case "assistant":
|
|
@@ -65914,13 +66206,20 @@ function isBridgeGeneratedArtifact(artifact) {
|
|
|
65914
66206
|
return typeof payload === "object" && payload !== null && "event" in payload;
|
|
65915
66207
|
}
|
|
65916
66208
|
function newArtifactId() {
|
|
65917
|
-
return `EA-${
|
|
66209
|
+
return `EA-${import_node_crypto18.default.randomUUID()}`;
|
|
65918
66210
|
}
|
|
65919
66211
|
var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
|
|
65920
|
-
function isBlastRadiusFloorPath(
|
|
65921
|
-
return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(
|
|
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();
|
|
65922
66222
|
}
|
|
65923
|
-
var execFileAsync2 = (0, import_node_util2.promisify)(import_node_child_process21.execFile);
|
|
65924
66223
|
async function defaultListRunDiffPaths(opts) {
|
|
65925
66224
|
const parse8 = (stdout) => stdout.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
65926
66225
|
try {
|
|
@@ -66165,7 +66464,7 @@ async function driveRun(deps, projectSlug, runId) {
|
|
|
66165
66464
|
if (!claimed) return;
|
|
66166
66465
|
if (!claimed.leaseId) {
|
|
66167
66466
|
await deps.client.createInboxItem(projectSlug, {
|
|
66168
|
-
id: `II-${
|
|
66467
|
+
id: `II-${import_node_crypto18.default.randomUUID()}`,
|
|
66169
66468
|
kind: "handoff",
|
|
66170
66469
|
taskId: claimed.taskId,
|
|
66171
66470
|
body: `Execution run ${runId} was claimed but returned no leaseId. This indicates DB/API corruption and requires operator attention.`
|
|
@@ -66182,6 +66481,7 @@ async function driveRun(deps, projectSlug, runId) {
|
|
|
66182
66481
|
return legacy != null ? Math.min(legacy, remaining) : remaining;
|
|
66183
66482
|
};
|
|
66184
66483
|
const task = await deps.client.getTask(projectSlug, claimed.taskId);
|
|
66484
|
+
let localGitMode = null;
|
|
66185
66485
|
if (task.declaredOutcome != null) {
|
|
66186
66486
|
for (const kind of task.declaredOutcome.requires) {
|
|
66187
66487
|
if (resolveKindCapability(kind) === null) {
|
|
@@ -66214,6 +66514,7 @@ async function driveRun(deps, projectSlug, runId) {
|
|
|
66214
66514
|
);
|
|
66215
66515
|
return;
|
|
66216
66516
|
}
|
|
66517
|
+
if (kind === "code_change") localGitMode = isLocalGitRoute(routeResolution.route);
|
|
66217
66518
|
}
|
|
66218
66519
|
}
|
|
66219
66520
|
const needsBrowser = claimed.prerequisites?.some((p) => p.mcp === "mrrlin-browser") || task.domains?.includes("browser");
|
|
@@ -66479,6 +66780,28 @@ ${renderTaskStateSection(taskState)}`;
|
|
|
66479
66780
|
let codex;
|
|
66480
66781
|
let disposeCodex = () => {
|
|
66481
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
|
+
}
|
|
66482
66805
|
if (claimed.codeExecution) {
|
|
66483
66806
|
if (!checkout) {
|
|
66484
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:
|
|
@@ -66494,22 +66817,46 @@ ${renderTaskStateSection(taskState)}`;
|
|
|
66494
66817
|
await failRun(deps, projectSlug, task, runId, leaseId, reason);
|
|
66495
66818
|
return;
|
|
66496
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
|
+
}
|
|
66497
66835
|
try {
|
|
66498
66836
|
const createWt = deps.createRunWorktree ?? createRunWorktree;
|
|
66499
|
-
|
|
66500
|
-
|
|
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
|
+
}
|
|
66501
66843
|
worktreePath = await createWt({
|
|
66502
|
-
checkout: checkout.path,
|
|
66844
|
+
checkout: localCheckoutRealPath ?? checkout.path,
|
|
66503
66845
|
worktreeRoot: deps.worktreeRoot ?? "/tmp/mrrlin-worktrees",
|
|
66504
66846
|
locksDir: deps.locksDir ?? "/tmp/mrrlin-locks",
|
|
66505
66847
|
slug: projectSlug,
|
|
66506
66848
|
runId,
|
|
66507
|
-
defaultBranch: resolvedDefaultBranch
|
|
66849
|
+
defaultBranch: resolvedDefaultBranch,
|
|
66850
|
+
...localGitMode ? { local: true } : {}
|
|
66508
66851
|
});
|
|
66852
|
+
if (localGitMode) {
|
|
66853
|
+
localBaseSha = await gitOutput(worktreePath, ["merge-base", "HEAD", `refs/heads/${resolvedDefaultBranch}`]);
|
|
66854
|
+
}
|
|
66509
66855
|
if (!await runHasLease(deps, projectSlug, runId, leaseId)) return;
|
|
66510
66856
|
await deps.client.updateExecutionRun(projectSlug, runId, {
|
|
66511
66857
|
worktreeId: worktreePath,
|
|
66512
|
-
branch: worktreeBranch(runId)
|
|
66858
|
+
branch: worktreeBranch(runId),
|
|
66859
|
+
...localBaseSha ? { baseSha: localBaseSha } : {}
|
|
66513
66860
|
});
|
|
66514
66861
|
sandbox = "danger-full-access";
|
|
66515
66862
|
turnCwd = worktreePath;
|
|
@@ -66578,7 +66925,7 @@ ${renderTaskStateSection(taskState)}`;
|
|
|
66578
66925
|
// write-authorized within its worktree, so it must NOT receive the
|
|
66579
66926
|
// read-only-sandbox claim (which makes a write-authorized model
|
|
66580
66927
|
// self-censor). The read-only path keeps the never-write restriction.
|
|
66581
|
-
baseInstructions: useExecutor ? EXECUTOR_BASE_INSTRUCTIONS : CONSUMER_BASE_INSTRUCTIONS,
|
|
66928
|
+
baseInstructions: useExecutor ? localGitMode ? EXECUTOR_LOCAL_GIT_BASE_INSTRUCTIONS : EXECUTOR_BASE_INSTRUCTIONS : CONSUMER_BASE_INSTRUCTIONS,
|
|
66582
66929
|
developerInstructions: null,
|
|
66583
66930
|
ephemeral: null,
|
|
66584
66931
|
mcpConfig: deps.mcpConfigPath
|
|
@@ -66790,7 +67137,7 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
|
|
|
66790
67137
|
if (!await runHasLease(deps, projectSlug, runId, leaseId)) return;
|
|
66791
67138
|
const hasCommitsFn = deps.hasCommitsToPush ?? hasCommitsToPush;
|
|
66792
67139
|
const defaultBranchForPush = resolvedDefaultBranch ?? "main";
|
|
66793
|
-
if (!await hasCommitsFn({ worktreePath, defaultBranch: defaultBranchForPush })) {
|
|
67140
|
+
if (!localGitMode && !await hasCommitsFn({ worktreePath, defaultBranch: defaultBranchForPush })) {
|
|
66794
67141
|
await failRun(
|
|
66795
67142
|
deps,
|
|
66796
67143
|
projectSlug,
|
|
@@ -66823,6 +67170,18 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
|
|
|
66823
67170
|
} else {
|
|
66824
67171
|
console.warn(JSON.stringify({ event: "self_review_gate_skipped", projectSlug, runId, reason: "no selfReviewTurn dep" }));
|
|
66825
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
|
+
}
|
|
66826
67185
|
const snapshot = await deps.client.getProjectSnapshot(projectSlug);
|
|
66827
67186
|
const expectedRepoFullName = snapshot.github?.repo ?? null;
|
|
66828
67187
|
if (!expectedRepoFullName) {
|
|
@@ -66955,7 +67314,7 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
|
|
|
66955
67314
|
taskId: task.id,
|
|
66956
67315
|
runId,
|
|
66957
67316
|
outcome: "completed",
|
|
66958
|
-
nonce:
|
|
67317
|
+
nonce: import_node_crypto18.default.randomUUID(),
|
|
66959
67318
|
artifacts: []
|
|
66960
67319
|
}
|
|
66961
67320
|
);
|
|
@@ -67443,7 +67802,7 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2,
|
|
|
67443
67802
|
taskId: task.id,
|
|
67444
67803
|
runId,
|
|
67445
67804
|
outcome: parsedResult.outcome,
|
|
67446
|
-
nonce:
|
|
67805
|
+
nonce: import_node_crypto18.default.randomUUID(),
|
|
67447
67806
|
artifacts: [
|
|
67448
67807
|
{
|
|
67449
67808
|
artifactId: pageId,
|
|
@@ -67512,6 +67871,141 @@ async function resetWedgedThread(deps, projectSlug, taskId, interruptFailed) {
|
|
|
67512
67871
|
await deps.client.resetDirectorThread(projectSlug, taskId).catch(() => {
|
|
67513
67872
|
});
|
|
67514
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
|
+
}
|
|
67515
68009
|
async function failRun(deps, projectSlug, task, runId, leaseId, reason, reasonCode) {
|
|
67516
68010
|
let currentRun;
|
|
67517
68011
|
try {
|
|
@@ -67673,7 +68167,7 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
|
|
|
67673
68167
|
}
|
|
67674
68168
|
try {
|
|
67675
68169
|
await deps.client.createInboxItem(projectSlug, {
|
|
67676
|
-
id: `II-${
|
|
68170
|
+
id: `II-${import_node_crypto18.default.randomUUID()}`,
|
|
67677
68171
|
kind: "handoff",
|
|
67678
68172
|
taskId: task.id,
|
|
67679
68173
|
body: `Task ${task.id} (${task.title}) still needs operator follow-up: ${reason}. Mrrlin could not move the task back to Handoff needed automatically.`
|
|
@@ -67708,7 +68202,7 @@ async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
|
|
|
67708
68202
|
}
|
|
67709
68203
|
try {
|
|
67710
68204
|
await deps.client.createInboxItem(projectSlug, {
|
|
67711
|
-
id: `II-${
|
|
68205
|
+
id: `II-${import_node_crypto18.default.randomUUID()}`,
|
|
67712
68206
|
kind: "handoff",
|
|
67713
68207
|
taskId: task.id,
|
|
67714
68208
|
body: `Execution run ${runId} for task ${task.id} (${task.title}) needs operator attention: ${reason}`
|
|
@@ -67850,8 +68344,8 @@ async function runBackstopSweep(deps, drive = (slug, id) => driveRun(deps, slug,
|
|
|
67850
68344
|
function isRunRecoverableByThisBridge(run3, worktreeRoot) {
|
|
67851
68345
|
if (!worktreeRoot) return true;
|
|
67852
68346
|
if (!run3.worktreeId) return true;
|
|
67853
|
-
const relative =
|
|
67854
|
-
return relative === "" || relative.length > 0 && !relative.startsWith("..") && !
|
|
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);
|
|
67855
68349
|
}
|
|
67856
68350
|
async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId) {
|
|
67857
68351
|
await deps.client.updateExecutionRun(projectSlug, runId, { status: "failed", finishedAt: (/* @__PURE__ */ new Date()).toISOString(), leaseId: leaseId ?? void 0 }).catch(() => {
|
|
@@ -67869,7 +68363,7 @@ async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId
|
|
|
67869
68363
|
}).catch(() => {
|
|
67870
68364
|
});
|
|
67871
68365
|
await deps.client.createInboxItem(projectSlug, {
|
|
67872
|
-
id: `II-${
|
|
68366
|
+
id: `II-${import_node_crypto18.default.randomUUID()}`,
|
|
67873
68367
|
kind: "handoff",
|
|
67874
68368
|
taskId: task.id,
|
|
67875
68369
|
body: `Deploy gate for run ${runId} (task ${task.id} \u2014 ${task.title}) needs operator attention: ${reason}`
|
|
@@ -67888,7 +68382,7 @@ function maxLeaseReclaims() {
|
|
|
67888
68382
|
}
|
|
67889
68383
|
|
|
67890
68384
|
// src/async-job-consumer.ts
|
|
67891
|
-
var
|
|
68385
|
+
var import_node_crypto19 = __toESM(require("node:crypto"), 1);
|
|
67892
68386
|
var ASYNC_JOB_MAX_ATTEMPTS = 2;
|
|
67893
68387
|
function ASYNC_UNOWNED_TTL_DAYS() {
|
|
67894
68388
|
const raw = Number(process.env.MRRLIN_ASYNC_UNOWNED_TTL_DAYS);
|
|
@@ -68013,7 +68507,7 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
|
|
|
68013
68507
|
const delivery = descriptor2.onComplete(outcome, input);
|
|
68014
68508
|
if (!delivery.suppressInbox) {
|
|
68015
68509
|
await deps.client.createInboxItem(projectSlug, {
|
|
68016
|
-
id: delivery.id ?? `II-${
|
|
68510
|
+
id: delivery.id ?? `II-${import_node_crypto19.default.randomUUID()}`,
|
|
68017
68511
|
kind: delivery.kind,
|
|
68018
68512
|
body: delivery.body,
|
|
68019
68513
|
...delivery.taskId ? { taskId: delivery.taskId } : {},
|
|
@@ -68031,13 +68525,13 @@ async function deriveRequestedHash(client, toolName2, input) {
|
|
|
68031
68525
|
if (input.requestedHash) return input.requestedHash;
|
|
68032
68526
|
if (toolName2 === "run_spec_consensus" && input.pageId) {
|
|
68033
68527
|
const page = await client.getWikiPage(input.projectSlug, input.pageId);
|
|
68034
|
-
return page.contentHash ??
|
|
68528
|
+
return page.contentHash ?? import_node_crypto19.default.createHash("sha256").update(page.markdownBody).digest("hex");
|
|
68035
68529
|
}
|
|
68036
68530
|
if (toolName2 === "draft_task_spec" && input.taskId) {
|
|
68037
68531
|
const task = await client.getTask(input.projectSlug, input.taskId);
|
|
68038
|
-
return task.updatedAt ??
|
|
68532
|
+
return task.updatedAt ?? import_node_crypto19.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
|
|
68039
68533
|
}
|
|
68040
|
-
return
|
|
68534
|
+
return import_node_crypto19.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
|
|
68041
68535
|
}
|
|
68042
68536
|
async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId)) {
|
|
68043
68537
|
const projects = await deps.client.listProjects();
|
|
@@ -68063,19 +68557,19 @@ async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJo
|
|
|
68063
68557
|
}
|
|
68064
68558
|
|
|
68065
68559
|
// src/bridge-artifacts.ts
|
|
68066
|
-
var
|
|
68560
|
+
var import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
68067
68561
|
var import_promises14 = __toESM(require("node:fs/promises"), 1);
|
|
68068
|
-
var
|
|
68562
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
68069
68563
|
var DEFAULT_MAX_ARTIFACTS_BYTES = 500 * 1024 * 1024;
|
|
68070
68564
|
var DEFAULT_MAX_ARTIFACT_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
68071
68565
|
function resolveArtifactsDir(baseStateDir) {
|
|
68072
68566
|
const stateDir = baseStateDir ?? resolveStateDir();
|
|
68073
|
-
return
|
|
68567
|
+
return import_node_path35.default.join(stateDir, "artifacts");
|
|
68074
68568
|
}
|
|
68075
68569
|
function ensureDir(dir) {
|
|
68076
|
-
|
|
68570
|
+
import_node_fs21.default.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
68077
68571
|
try {
|
|
68078
|
-
|
|
68572
|
+
import_node_fs21.default.chmodSync(dir, 448);
|
|
68079
68573
|
} catch {
|
|
68080
68574
|
}
|
|
68081
68575
|
}
|
|
@@ -68083,7 +68577,7 @@ function safeArtifactPath(artifactsDir, id) {
|
|
|
68083
68577
|
if (!id || typeof id !== "string" || !/^[a-zA-Z0-9_-]+$/.test(id)) {
|
|
68084
68578
|
throw new Error("Invalid artifact id");
|
|
68085
68579
|
}
|
|
68086
|
-
return
|
|
68580
|
+
return import_node_path35.default.join(artifactsDir, `${id}.json`);
|
|
68087
68581
|
}
|
|
68088
68582
|
async function writeLocalArtifact(id, payload, baseStateDir) {
|
|
68089
68583
|
const artifactsDir = resolveArtifactsDir(baseStateDir);
|
|
@@ -68126,7 +68620,7 @@ async function cleanArtifacts(baseStateDir, options) {
|
|
|
68126
68620
|
let deletedBytes = 0;
|
|
68127
68621
|
for (const name of entries) {
|
|
68128
68622
|
if (!name.endsWith(".json")) continue;
|
|
68129
|
-
const filePath =
|
|
68623
|
+
const filePath = import_node_path35.default.join(artifactsDir, name);
|
|
68130
68624
|
try {
|
|
68131
68625
|
const stat3 = await import_promises14.default.stat(filePath);
|
|
68132
68626
|
if (now - stat3.mtimeMs > maxAgeMs) {
|
|
@@ -68353,16 +68847,16 @@ function agentIdleMs(provider) {
|
|
|
68353
68847
|
}
|
|
68354
68848
|
|
|
68355
68849
|
// src/thread-index.ts
|
|
68356
|
-
var
|
|
68357
|
-
var
|
|
68850
|
+
var import_node_fs22 = require("node:fs");
|
|
68851
|
+
var import_node_path36 = __toESM(require("node:path"), 1);
|
|
68358
68852
|
function threadIndexPath(stateDir) {
|
|
68359
|
-
return
|
|
68853
|
+
return import_node_path36.default.join(stateDir, "threads.json");
|
|
68360
68854
|
}
|
|
68361
68855
|
function loadThreadIndex(stateDir, ttlMs, now) {
|
|
68362
68856
|
const result = /* @__PURE__ */ new Map();
|
|
68363
68857
|
let parsed;
|
|
68364
68858
|
try {
|
|
68365
|
-
parsed = JSON.parse((0,
|
|
68859
|
+
parsed = JSON.parse((0, import_node_fs22.readFileSync)(threadIndexPath(stateDir), "utf8"));
|
|
68366
68860
|
} catch {
|
|
68367
68861
|
return result;
|
|
68368
68862
|
}
|
|
@@ -68387,8 +68881,8 @@ function loadThreadIndex(stateDir, ttlMs, now) {
|
|
|
68387
68881
|
return result;
|
|
68388
68882
|
}
|
|
68389
68883
|
function saveThreadIndex(stateDir, entries) {
|
|
68390
|
-
(0,
|
|
68391
|
-
(0,
|
|
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)}
|
|
68392
68886
|
`, {
|
|
68393
68887
|
encoding: "utf8",
|
|
68394
68888
|
mode: 384
|
|
@@ -68524,9 +69018,9 @@ function createToolBusyClock(opts) {
|
|
|
68524
69018
|
|
|
68525
69019
|
// src/remote-phone-relay.ts
|
|
68526
69020
|
var import_node_events3 = require("node:events");
|
|
68527
|
-
var
|
|
68528
|
-
var
|
|
68529
|
-
var
|
|
69021
|
+
var import_node_fs23 = require("node:fs");
|
|
69022
|
+
var import_node_os17 = require("node:os");
|
|
69023
|
+
var import_node_path37 = require("node:path");
|
|
68530
69024
|
|
|
68531
69025
|
// ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/cryptoNode.js
|
|
68532
69026
|
var nc = __toESM(require("node:crypto"), 1);
|
|
@@ -68989,7 +69483,7 @@ var SHA256 = class extends SHA2 {
|
|
|
68989
69483
|
this.buffer.fill(0);
|
|
68990
69484
|
}
|
|
68991
69485
|
};
|
|
68992
|
-
var
|
|
69486
|
+
var sha2563 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
|
|
68993
69487
|
|
|
68994
69488
|
// ../../node_modules/.pnpm/@noble+curves@1.3.0/node_modules/@noble/curves/esm/abstract/utils.js
|
|
68995
69489
|
var _0n = BigInt(0);
|
|
@@ -69133,7 +69627,7 @@ function validateObject(object3, validators, optValidators = {}) {
|
|
|
69133
69627
|
// ../../packages/director-e2e/dist/verifier.js
|
|
69134
69628
|
var RELAY_AUTH_LABEL = utf8ToBytes("relay-auth");
|
|
69135
69629
|
function relayAuth(secret) {
|
|
69136
|
-
return hmac(
|
|
69630
|
+
return hmac(sha2563, secret, RELAY_AUTH_LABEL);
|
|
69137
69631
|
}
|
|
69138
69632
|
|
|
69139
69633
|
// ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/_u64.js
|
|
@@ -70467,16 +70961,16 @@ var hkdf = (hash3, ikm, salt, info, length) => expand(hash3, extract(hash3, ikm,
|
|
|
70467
70961
|
|
|
70468
70962
|
// ../../packages/director-e2e/dist/kdf.js
|
|
70469
70963
|
function deriveMasterKey(ikm, salt, info) {
|
|
70470
|
-
return hkdf(
|
|
70964
|
+
return hkdf(sha2563, ikm, salt, info, 32);
|
|
70471
70965
|
}
|
|
70472
70966
|
function deriveDirectionKeys(masterKey) {
|
|
70473
70967
|
return {
|
|
70474
|
-
p2a: hkdf(
|
|
70475
|
-
a2p: hkdf(
|
|
70968
|
+
p2a: hkdf(sha2563, masterKey, void 0, utf8ToBytes("dir:phone->agent"), 32),
|
|
70969
|
+
a2p: hkdf(sha2563, masterKey, void 0, utf8ToBytes("dir:agent->phone"), 32)
|
|
70476
70970
|
};
|
|
70477
70971
|
}
|
|
70478
70972
|
function confirmationMac(masterKey, role, transcript) {
|
|
70479
|
-
return hmac(
|
|
70973
|
+
return hmac(sha2563, masterKey, concatBytes(utf8ToBytes(`confirm:${role}`), transcript));
|
|
70480
70974
|
}
|
|
70481
70975
|
|
|
70482
70976
|
// ../../node_modules/.pnpm/@noble+ciphers@0.4.1/node_modules/@noble/ciphers/esm/utils.js
|
|
@@ -72097,9 +72591,9 @@ var DirectorRelay = class {
|
|
|
72097
72591
|
|
|
72098
72592
|
// src/remote-phone-relay.ts
|
|
72099
72593
|
function loadOrCreateAgentDeviceKey() {
|
|
72100
|
-
const
|
|
72594
|
+
const path33 = (0, import_node_path37.join)((0, import_node_os17.homedir)(), ".mrrlin", "agent-device-key");
|
|
72101
72595
|
try {
|
|
72102
|
-
const raw = JSON.parse((0,
|
|
72596
|
+
const raw = JSON.parse((0, import_node_fs23.readFileSync)(path33, "utf8"));
|
|
72103
72597
|
if (typeof raw.priv === "string" && typeof raw.pub === "string") {
|
|
72104
72598
|
return { privateKey: fromBase64Url(raw.priv), publicKey: fromBase64Url(raw.pub) };
|
|
72105
72599
|
}
|
|
@@ -72107,9 +72601,9 @@ function loadOrCreateAgentDeviceKey() {
|
|
|
72107
72601
|
}
|
|
72108
72602
|
const kp = generateIdentityKeyPair();
|
|
72109
72603
|
try {
|
|
72110
|
-
(0,
|
|
72111
|
-
(0,
|
|
72112
|
-
|
|
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,
|
|
72113
72607
|
JSON.stringify({ priv: toBase64Url(kp.privateKey), pub: toBase64Url(kp.publicKey) }),
|
|
72114
72608
|
{ mode: 384 }
|
|
72115
72609
|
);
|
|
@@ -72117,10 +72611,10 @@ function loadOrCreateAgentDeviceKey() {
|
|
|
72117
72611
|
}
|
|
72118
72612
|
return kp;
|
|
72119
72613
|
}
|
|
72120
|
-
var AGENT_PAIRING_PATH = (0,
|
|
72614
|
+
var AGENT_PAIRING_PATH = (0, import_node_path37.join)((0, import_node_os17.homedir)(), ".mrrlin", "agent-pairing.json");
|
|
72121
72615
|
function loadAgentPairing() {
|
|
72122
72616
|
try {
|
|
72123
|
-
const raw = JSON.parse((0,
|
|
72617
|
+
const raw = JSON.parse((0, import_node_fs23.readFileSync)(AGENT_PAIRING_PATH, "utf8"));
|
|
72124
72618
|
if (typeof raw.channelId === "string" && typeof raw.agentControlSecret === "string" && typeof raw.relayAuth === "string" && typeof raw.peerIdentityKey === "string") {
|
|
72125
72619
|
return {
|
|
72126
72620
|
channelId: raw.channelId,
|
|
@@ -72135,8 +72629,8 @@ function loadAgentPairing() {
|
|
|
72135
72629
|
}
|
|
72136
72630
|
function saveAgentPairing(record2) {
|
|
72137
72631
|
try {
|
|
72138
|
-
(0,
|
|
72139
|
-
(0,
|
|
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 });
|
|
72140
72634
|
} catch {
|
|
72141
72635
|
}
|
|
72142
72636
|
}
|
|
@@ -72314,14 +72808,14 @@ async function renderPairingQrSvg(payload) {
|
|
|
72314
72808
|
}
|
|
72315
72809
|
|
|
72316
72810
|
// src/executor-server.ts
|
|
72317
|
-
var
|
|
72811
|
+
var import_node_child_process24 = require("node:child_process");
|
|
72318
72812
|
function defaultReadinessRunner(provider) {
|
|
72319
72813
|
if (provider !== "codex" && provider !== "claude" && provider !== "agy") {
|
|
72320
72814
|
throw new Error(`unsupported executor provider: ${String(provider)}`);
|
|
72321
72815
|
}
|
|
72322
72816
|
const command = provider === "claude" ? "claude" : provider === "agy" ? "agy" : "codex";
|
|
72323
72817
|
return (args) => {
|
|
72324
|
-
const r = (0,
|
|
72818
|
+
const r = (0, import_node_child_process24.spawnSync)(command, args, { encoding: "utf8", timeout: 8e3, shell: true });
|
|
72325
72819
|
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
72326
72820
|
};
|
|
72327
72821
|
}
|
|
@@ -72375,7 +72869,7 @@ async function startExecutorServer(opts) {
|
|
|
72375
72869
|
const rawBaseEnv = opts.env ?? (isVerification ? buildVerificationEnv(process.env) : process.env);
|
|
72376
72870
|
const baseEnv = isVerification ? buildVerificationEnv(rawBaseEnv) : { ...rawBaseEnv };
|
|
72377
72871
|
const childEnv = withDisabledGitHooksEnv(baseEnv, opts.disabledGitHooksDir);
|
|
72378
|
-
const baseSpawn = opts.spawn ??
|
|
72872
|
+
const baseSpawn = opts.spawn ?? import_node_child_process24.spawn;
|
|
72379
72873
|
const hasExtraFd = opts.brokerSocket != null || opts.brokerSocketFd != null;
|
|
72380
72874
|
const spawnFn = (cmd, args = [], spawnOpts = {}) => {
|
|
72381
72875
|
const argList = [...args];
|
|
@@ -72519,10 +73013,10 @@ var import_node_http2 = __toESM(require("node:http"), 1);
|
|
|
72519
73013
|
var import_node_https2 = __toESM(require("node:https"), 1);
|
|
72520
73014
|
var import_node_net2 = __toESM(require("node:net"), 1);
|
|
72521
73015
|
var import_node_tls = __toESM(require("node:tls"), 1);
|
|
72522
|
-
var
|
|
72523
|
-
var
|
|
72524
|
-
var
|
|
72525
|
-
var
|
|
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);
|
|
72526
73020
|
var import_node_zlib = __toESM(require("node:zlib"), 1);
|
|
72527
73021
|
|
|
72528
73022
|
// src/verification-egress-policy.ts
|
|
@@ -72860,20 +73354,20 @@ function reauthorizeRedirect(params) {
|
|
|
72860
73354
|
// src/verification-broker.ts
|
|
72861
73355
|
var TEST_CONNECT_OVERRIDE_SYMBOL = Symbol.for("mrrlin.test.connectOverride");
|
|
72862
73356
|
async function createVerificationBrokerSession(options) {
|
|
72863
|
-
const nonce =
|
|
73357
|
+
const nonce = import_node_crypto20.default.randomBytes(16).toString("hex");
|
|
72864
73358
|
let createdDir = null;
|
|
72865
73359
|
let socketPath = options.socketPath;
|
|
72866
73360
|
if (!socketPath) {
|
|
72867
|
-
createdDir =
|
|
72868
|
-
|
|
72869
|
-
socketPath =
|
|
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(
|
|
72870
73364
|
createdDir,
|
|
72871
73365
|
`broker-${options.runId.replace(/[^a-zA-Z0-9_-]/g, "")}-${nonce}.sock`
|
|
72872
73366
|
);
|
|
72873
73367
|
}
|
|
72874
73368
|
try {
|
|
72875
|
-
if (
|
|
72876
|
-
|
|
73369
|
+
if (import_node_fs24.default.existsSync(socketPath)) {
|
|
73370
|
+
import_node_fs24.default.unlinkSync(socketPath);
|
|
72877
73371
|
}
|
|
72878
73372
|
} catch {
|
|
72879
73373
|
}
|
|
@@ -73161,12 +73655,12 @@ async function createVerificationBrokerSession(options) {
|
|
|
73161
73655
|
} catch (err) {
|
|
73162
73656
|
server.close();
|
|
73163
73657
|
try {
|
|
73164
|
-
if (
|
|
73658
|
+
if (import_node_fs24.default.existsSync(socketPath)) import_node_fs24.default.unlinkSync(socketPath);
|
|
73165
73659
|
} catch (error51) {
|
|
73166
73660
|
}
|
|
73167
73661
|
if (createdDir) {
|
|
73168
73662
|
try {
|
|
73169
|
-
|
|
73663
|
+
import_node_fs24.default.rmSync(createdDir, { recursive: true, force: true });
|
|
73170
73664
|
} catch (error51) {
|
|
73171
73665
|
}
|
|
73172
73666
|
}
|
|
@@ -73194,14 +73688,14 @@ async function createVerificationBrokerSession(options) {
|
|
|
73194
73688
|
server.close(() => resolve2());
|
|
73195
73689
|
});
|
|
73196
73690
|
try {
|
|
73197
|
-
if (
|
|
73198
|
-
|
|
73691
|
+
if (import_node_fs24.default.existsSync(socketPath)) {
|
|
73692
|
+
import_node_fs24.default.unlinkSync(socketPath);
|
|
73199
73693
|
}
|
|
73200
73694
|
} catch {
|
|
73201
73695
|
}
|
|
73202
73696
|
if (createdDir) {
|
|
73203
73697
|
try {
|
|
73204
|
-
|
|
73698
|
+
import_node_fs24.default.rmSync(createdDir, { recursive: true, force: true });
|
|
73205
73699
|
} catch {
|
|
73206
73700
|
}
|
|
73207
73701
|
}
|
|
@@ -73697,9 +74191,9 @@ function extractVerificationSection(markdown) {
|
|
|
73697
74191
|
}
|
|
73698
74192
|
|
|
73699
74193
|
// src/director-reseed.ts
|
|
73700
|
-
var
|
|
74194
|
+
var import_node_fs25 = require("node:fs");
|
|
73701
74195
|
var import_node_readline2 = require("node:readline");
|
|
73702
|
-
var
|
|
74196
|
+
var import_node_path39 = require("node:path");
|
|
73703
74197
|
function estimateTokens(s) {
|
|
73704
74198
|
return Buffer.byteLength(s, "utf8");
|
|
73705
74199
|
}
|
|
@@ -73848,9 +74342,9 @@ async function readSessionRows(logsDir, files, sessionIds) {
|
|
|
73848
74342
|
const lines2 = [];
|
|
73849
74343
|
let missingFiles = 0;
|
|
73850
74344
|
for (const f of files) {
|
|
73851
|
-
const filePath = (0,
|
|
74345
|
+
const filePath = (0, import_node_path39.join)(logsDir, f);
|
|
73852
74346
|
try {
|
|
73853
|
-
const stream = (0,
|
|
74347
|
+
const stream = (0, import_node_fs25.createReadStream)(filePath, { encoding: "utf8" });
|
|
73854
74348
|
const rl = (0, import_node_readline2.createInterface)({ input: stream, crlfDelay: Infinity });
|
|
73855
74349
|
try {
|
|
73856
74350
|
for await (const line of rl) {
|
|
@@ -73874,18 +74368,18 @@ async function readSessionRows(logsDir, files, sessionIds) {
|
|
|
73874
74368
|
}
|
|
73875
74369
|
|
|
73876
74370
|
// src/external-agents-scrub.ts
|
|
73877
|
-
var
|
|
73878
|
-
var
|
|
73879
|
-
var
|
|
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);
|
|
73880
74374
|
var REDACTION = "[REDACTED]";
|
|
73881
74375
|
var SHORT_VALUE_THRESHOLD = 8;
|
|
73882
|
-
var KEYS_ENV_PATH = () =>
|
|
74376
|
+
var KEYS_ENV_PATH = () => import_node_path40.default.join(import_node_os19.default.homedir(), ".local", "state", "external-agents", "keys.env");
|
|
73883
74377
|
var keysEnvCache = null;
|
|
73884
74378
|
function readKeysEnv() {
|
|
73885
74379
|
const filePath = KEYS_ENV_PATH();
|
|
73886
74380
|
let mtimeMs = 0;
|
|
73887
74381
|
try {
|
|
73888
|
-
mtimeMs =
|
|
74382
|
+
mtimeMs = import_node_fs26.default.statSync(filePath).mtimeMs;
|
|
73889
74383
|
} catch {
|
|
73890
74384
|
mtimeMs = 0;
|
|
73891
74385
|
}
|
|
@@ -73894,7 +74388,7 @@ function readKeysEnv() {
|
|
|
73894
74388
|
}
|
|
73895
74389
|
const map2 = /* @__PURE__ */ new Map();
|
|
73896
74390
|
try {
|
|
73897
|
-
const content =
|
|
74391
|
+
const content = import_node_fs26.default.readFileSync(filePath, "utf8");
|
|
73898
74392
|
for (const rawLine of content.split(/\r?\n/)) {
|
|
73899
74393
|
const line = rawLine.trim();
|
|
73900
74394
|
if (line === "" || line.startsWith("#")) continue;
|
|
@@ -74312,7 +74806,7 @@ function addBridgeModel(target, model) {
|
|
|
74312
74806
|
}
|
|
74313
74807
|
function readTextIfExists(filePath) {
|
|
74314
74808
|
try {
|
|
74315
|
-
return
|
|
74809
|
+
return import_node_fs27.default.readFileSync(filePath, "utf8");
|
|
74316
74810
|
} catch {
|
|
74317
74811
|
return null;
|
|
74318
74812
|
}
|
|
@@ -74323,9 +74817,9 @@ function readKnownGptSlugsFromTomlFile(filePath) {
|
|
|
74323
74817
|
return Array.from(raw.matchAll(/^\s*model\s*=\s*"([^"]+)"/gm)).map((match) => match[1]?.trim() ?? "").filter(isSelectableModelSlug);
|
|
74324
74818
|
}
|
|
74325
74819
|
function readCodexFallbackModels() {
|
|
74326
|
-
const codexHome = process.env.CODEX_HOME?.trim() ||
|
|
74820
|
+
const codexHome = process.env.CODEX_HOME?.trim() || import_node_path42.default.join(import_node_os21.default.homedir(), ".codex");
|
|
74327
74821
|
const models = /* @__PURE__ */ new Map();
|
|
74328
|
-
const cachePath =
|
|
74822
|
+
const cachePath = import_node_path42.default.join(codexHome, "models_cache.json");
|
|
74329
74823
|
const cacheRaw = readTextIfExists(cachePath);
|
|
74330
74824
|
if (cacheRaw) {
|
|
74331
74825
|
try {
|
|
@@ -74375,7 +74869,7 @@ function readCodexFallbackModels() {
|
|
|
74375
74869
|
);
|
|
74376
74870
|
}
|
|
74377
74871
|
}
|
|
74378
|
-
for (const slug of readKnownGptSlugsFromTomlFile(
|
|
74872
|
+
for (const slug of readKnownGptSlugsFromTomlFile(import_node_path42.default.join(codexHome, "config.toml"))) {
|
|
74379
74873
|
addBridgeModel(
|
|
74380
74874
|
models,
|
|
74381
74875
|
mapBridgeModel({
|
|
@@ -74389,11 +74883,11 @@ function readCodexFallbackModels() {
|
|
|
74389
74883
|
})
|
|
74390
74884
|
);
|
|
74391
74885
|
}
|
|
74392
|
-
const automationsDir =
|
|
74886
|
+
const automationsDir = import_node_path42.default.join(codexHome, "automations");
|
|
74393
74887
|
try {
|
|
74394
|
-
for (const entry of
|
|
74888
|
+
for (const entry of import_node_fs27.default.readdirSync(automationsDir, { withFileTypes: true })) {
|
|
74395
74889
|
if (!entry.isDirectory()) continue;
|
|
74396
|
-
for (const slug of readKnownGptSlugsFromTomlFile(
|
|
74890
|
+
for (const slug of readKnownGptSlugsFromTomlFile(import_node_path42.default.join(automationsDir, entry.name, "automation.toml"))) {
|
|
74397
74891
|
addBridgeModel(
|
|
74398
74892
|
models,
|
|
74399
74893
|
mapBridgeModel({
|
|
@@ -74413,18 +74907,18 @@ function readCodexFallbackModels() {
|
|
|
74413
74907
|
return [...models.values()];
|
|
74414
74908
|
}
|
|
74415
74909
|
function selfUpdateInboxItemId(offeredVersion) {
|
|
74416
|
-
if (!offeredVersion) return `II-MCPUPD-${(0,
|
|
74910
|
+
if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto21.randomUUID)()}`;
|
|
74417
74911
|
if (/^[A-Za-z0-9._-]+$/.test(offeredVersion)) return `II-MCPUPD-${offeredVersion}`;
|
|
74418
|
-
const hash3 =
|
|
74912
|
+
const hash3 = import_node_crypto21.default.createHash("sha256").update(offeredVersion).digest("hex").slice(0, 10);
|
|
74419
74913
|
return `II-MCPUPD-${offeredVersion.replace(/[^A-Za-z0-9._-]/g, "-")}-${hash3}`;
|
|
74420
74914
|
}
|
|
74421
74915
|
function neutralCheckoutCwd(stateDir) {
|
|
74422
|
-
const dir =
|
|
74916
|
+
const dir = import_node_path42.default.join(stateDir, "no-checkout");
|
|
74423
74917
|
try {
|
|
74424
|
-
|
|
74425
|
-
if (!
|
|
74918
|
+
import_node_fs27.default.mkdirSync(dir, { recursive: true });
|
|
74919
|
+
if (!import_node_fs27.default.existsSync(import_node_path42.default.join(dir, ".git"))) {
|
|
74426
74920
|
try {
|
|
74427
|
-
(0,
|
|
74921
|
+
(0, import_node_child_process25.spawnSync)("git", ["init", "-b", "main"], { cwd: dir, stdio: "ignore" });
|
|
74428
74922
|
} catch {
|
|
74429
74923
|
}
|
|
74430
74924
|
}
|
|
@@ -74947,7 +75441,7 @@ function resolveDefaultBranch(checkoutPath) {
|
|
|
74947
75441
|
if (!checkoutPath) return "main";
|
|
74948
75442
|
const runGit = (args) => {
|
|
74949
75443
|
try {
|
|
74950
|
-
return (0,
|
|
75444
|
+
return (0, import_node_child_process25.execFileSync)("git", ["-C", checkoutPath, ...args], {
|
|
74951
75445
|
encoding: "utf8",
|
|
74952
75446
|
stdio: ["ignore", "pipe", "ignore"],
|
|
74953
75447
|
timeout: 15e3,
|
|
@@ -74983,7 +75477,7 @@ async function runOrphanWorktreeSweep(client, opts) {
|
|
|
74983
75477
|
const cutoff = Date.now() - worktreeRetentionMs();
|
|
74984
75478
|
const isReapable = (worktreePath) => {
|
|
74985
75479
|
try {
|
|
74986
|
-
return
|
|
75480
|
+
return import_node_fs27.default.statSync(worktreePath).mtimeMs < cutoff;
|
|
74987
75481
|
} catch {
|
|
74988
75482
|
return false;
|
|
74989
75483
|
}
|
|
@@ -75135,7 +75629,7 @@ function createBridgeRequestListener(opts) {
|
|
|
75135
75629
|
res.end(JSON.stringify({ ok: false, error: "Origin not allowed." }));
|
|
75136
75630
|
return;
|
|
75137
75631
|
}
|
|
75138
|
-
const nonce =
|
|
75632
|
+
const nonce = import_node_crypto21.default.randomBytes(16).toString("base64url");
|
|
75139
75633
|
res.writeHead(200, { "content-type": "application/json" });
|
|
75140
75634
|
const publicHost = host === "0.0.0.0" ? "127.0.0.1" : host;
|
|
75141
75635
|
res.end(JSON.stringify({ ok: true, wsUrl: `ws://${publicHost}:${port}/ws`, token, nonce }));
|
|
@@ -75439,7 +75933,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
75439
75933
|
}
|
|
75440
75934
|
}
|
|
75441
75935
|
socket.on("message", async (data) => {
|
|
75442
|
-
const spanId =
|
|
75936
|
+
const spanId = import_node_crypto21.default.randomUUID();
|
|
75443
75937
|
if (logCtx) {
|
|
75444
75938
|
logCtx.span.id = spanId;
|
|
75445
75939
|
logCtx.span.at = Date.now();
|
|
@@ -75501,7 +75995,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
75501
75995
|
sendForSpan({ type: "checkout-state", ok: false, error: { code: "invalid_input", fields: { projectSlug: "required" } } });
|
|
75502
75996
|
return;
|
|
75503
75997
|
}
|
|
75504
|
-
const state = readCheckoutState(deps.checkoutRegistry, projectSlug,
|
|
75998
|
+
const state = readCheckoutState(deps.checkoutRegistry, projectSlug, import_node_os21.default.hostname());
|
|
75505
75999
|
if (!state) {
|
|
75506
76000
|
sendForSpan({ type: "checkout-state", ok: false, error: { code: "checkout_missing" } });
|
|
75507
76001
|
return;
|
|
@@ -75533,7 +76027,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
75533
76027
|
const result = registerCheckout(
|
|
75534
76028
|
deps.checkoutRegistry,
|
|
75535
76029
|
{ projectSlug, path: typeof msg.path === "string" ? msg.path : "", repo },
|
|
75536
|
-
|
|
76030
|
+
import_node_os21.default.hostname()
|
|
75537
76031
|
);
|
|
75538
76032
|
if (!result.ok) {
|
|
75539
76033
|
sendForSpan({ type: "checkout-register", ok: false, error: { code: result.code, detail: result.detail } });
|
|
@@ -76046,7 +76540,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
76046
76540
|
let desiredInstructionHash = null;
|
|
76047
76541
|
try {
|
|
76048
76542
|
const startParams = deps.buildStartParams(msg, desiredModel);
|
|
76049
|
-
desiredInstructionHash =
|
|
76543
|
+
desiredInstructionHash = import_node_crypto21.default.createHash("sha256").update(startParams.baseInstructions ?? "").digest("hex");
|
|
76050
76544
|
if (!thread) {
|
|
76051
76545
|
const newThread = {
|
|
76052
76546
|
threadId: "",
|
|
@@ -76123,7 +76617,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
76123
76617
|
thread.inFlight = true;
|
|
76124
76618
|
pendingTurnSessions.delete(directorSessionId);
|
|
76125
76619
|
thread.replay = createReplayBuffer({
|
|
76126
|
-
turnId: (0,
|
|
76620
|
+
turnId: (0, import_node_crypto21.randomUUID)(),
|
|
76127
76621
|
spanId,
|
|
76128
76622
|
...deps.retentionMs !== void 0 ? { retentionMs: deps.retentionMs } : {},
|
|
76129
76623
|
...deps.ackLingerMs !== void 0 ? { ackLingerMs: deps.ackLingerMs } : {}
|
|
@@ -76738,7 +77232,7 @@ function parseConfig() {
|
|
|
76738
77232
|
}
|
|
76739
77233
|
function scanForOtherBridges() {
|
|
76740
77234
|
try {
|
|
76741
|
-
const result = (0,
|
|
77235
|
+
const result = (0, import_node_child_process25.spawnSync)("pgrep", ["-f", "mrrlin-mcp director-bridge"], {
|
|
76742
77236
|
encoding: "utf8"
|
|
76743
77237
|
});
|
|
76744
77238
|
if (result.status !== 0) return [];
|
|
@@ -76934,8 +77428,10 @@ async function startDirectorBridge() {
|
|
|
76934
77428
|
codexCwd: config2.codexCwd,
|
|
76935
77429
|
codexExecutable: config2.codexExecutable,
|
|
76936
77430
|
checkoutRegistry,
|
|
76937
|
-
worktreeRoot:
|
|
76938
|
-
locksDir:
|
|
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"),
|
|
76939
77435
|
// Wire the executor server for code-execution runs. Each run gets its own provider process
|
|
76940
77436
|
// (app-server for codex, a resident CLI child for claude) at the run worktree, running
|
|
76941
77437
|
// UNRESTRICTED from the real operator config (owner no-sandbox decision — auth + mrrlin MCP
|
|
@@ -76952,7 +77448,7 @@ async function startDirectorBridge() {
|
|
|
76952
77448
|
// The run's provider process carries exactly its own project (or none), so its Mrrlin MCP
|
|
76953
77449
|
// server is bound to it and never to whatever the bridge's environment names.
|
|
76954
77450
|
env: threadProcessEnv(process.env, directorThreadEnv(projectSlug)),
|
|
76955
|
-
disabledGitHooksDir: prepareDisabledGitHooksDir(
|
|
77451
|
+
disabledGitHooksDir: prepareDisabledGitHooksDir(import_node_path42.default.join(config2.stateDir, "locks"), import_node_path42.default.basename(worktreePath)),
|
|
76956
77452
|
provider: providerId
|
|
76957
77453
|
});
|
|
76958
77454
|
return { handle: executor.handle, dispose: executor.dispose };
|
|
@@ -76983,10 +77479,10 @@ async function startDirectorBridge() {
|
|
|
76983
77479
|
runVerificationTurn: createRunVerificationTurn({
|
|
76984
77480
|
startSandbox: async (egressDomains, providerId, opts) => {
|
|
76985
77481
|
opts?.wrapCommand?.(["node"]);
|
|
76986
|
-
const scratchDir =
|
|
77482
|
+
const scratchDir = import_node_fs27.default.mkdtempSync(import_node_path42.default.join(import_node_os21.default.tmpdir(), "mrrlin-verify-"));
|
|
76987
77483
|
const executor = await startExecutorServer({
|
|
76988
77484
|
worktree: scratchDir,
|
|
76989
|
-
disabledGitHooksDir: prepareDisabledGitHooksDir(
|
|
77485
|
+
disabledGitHooksDir: prepareDisabledGitHooksDir(import_node_path42.default.join(config2.stateDir, "locks"), import_node_path42.default.basename(scratchDir)),
|
|
76990
77486
|
provider: providerId,
|
|
76991
77487
|
wrapCommand: opts?.wrapCommand,
|
|
76992
77488
|
brokerSocket: opts?.brokerSocket,
|
|
@@ -76999,7 +77495,7 @@ async function startDirectorBridge() {
|
|
|
76999
77495
|
dispose: () => {
|
|
77000
77496
|
executor.dispose();
|
|
77001
77497
|
try {
|
|
77002
|
-
|
|
77498
|
+
import_node_fs27.default.rmSync(scratchDir, { recursive: true, force: true });
|
|
77003
77499
|
} catch {
|
|
77004
77500
|
}
|
|
77005
77501
|
},
|
|
@@ -77032,7 +77528,7 @@ async function startDirectorBridge() {
|
|
|
77032
77528
|
};
|
|
77033
77529
|
const sessionSinks = createSessionSinkRegistry();
|
|
77034
77530
|
const tombstones = /* @__PURE__ */ new Map();
|
|
77035
|
-
const bridgeInstanceId = (0,
|
|
77531
|
+
const bridgeInstanceId = (0, import_node_crypto21.randomUUID)();
|
|
77036
77532
|
const asyncConsumerDeps = {
|
|
77037
77533
|
client,
|
|
77038
77534
|
run: wrappedTurnLock.run,
|
|
@@ -77210,7 +77706,7 @@ async function startDirectorBridge() {
|
|
|
77210
77706
|
const files = dayFilesInWindow(/* @__PURE__ */ new Date(), reseedWindowMs);
|
|
77211
77707
|
filesCount = files.length;
|
|
77212
77708
|
const sessionIds = [args.directorSessionId, ...args.priorSessionIds];
|
|
77213
|
-
const { lines: lines2, missingFiles } = await readSessionRows(
|
|
77709
|
+
const { lines: lines2, missingFiles } = await readSessionRows(import_node_path42.default.join(config2.stateDir, "logs"), files, sessionIds);
|
|
77214
77710
|
missingFilesCount = missingFiles;
|
|
77215
77711
|
const extracted = extractItems(lines2, sessionIds);
|
|
77216
77712
|
items = extracted.items;
|
|
@@ -77359,7 +77855,7 @@ async function startDirectorBridge() {
|
|
|
77359
77855
|
const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
|
|
77360
77856
|
let bridgeBinShaShort = "unknown00000";
|
|
77361
77857
|
try {
|
|
77362
|
-
bridgeBinShaShort =
|
|
77858
|
+
bridgeBinShaShort = import_node_crypto21.default.createHash("sha256").update(import_node_fs27.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
|
|
77363
77859
|
} catch {
|
|
77364
77860
|
}
|
|
77365
77861
|
attachBridgeWss(server, {
|
|
@@ -77495,8 +77991,8 @@ async function startDirectorBridge() {
|
|
|
77495
77991
|
);
|
|
77496
77992
|
void runOrphanWorktreeSweep(client, {
|
|
77497
77993
|
checkoutRegistry,
|
|
77498
|
-
worktreeRoot:
|
|
77499
|
-
locksDir:
|
|
77994
|
+
worktreeRoot: import_node_path42.default.join(config2.stateDir, "worktrees"),
|
|
77995
|
+
locksDir: import_node_path42.default.join(config2.stateDir, "locks")
|
|
77500
77996
|
});
|
|
77501
77997
|
{
|
|
77502
77998
|
const { retainedBuffers, retainedBytes, tombstonesRemoved } = sweepReplayBuffers(threads, tombstones, {
|
|
@@ -77800,7 +78296,7 @@ function timingSafeTokenEqual(provided, expected) {
|
|
|
77800
78296
|
const a = Buffer.from(provided);
|
|
77801
78297
|
const b = Buffer.from(expected);
|
|
77802
78298
|
if (a.length !== b.length) return false;
|
|
77803
|
-
return
|
|
78299
|
+
return import_node_crypto21.default.timingSafeEqual(a, b);
|
|
77804
78300
|
}
|
|
77805
78301
|
function readDispatchBody(req) {
|
|
77806
78302
|
return new Promise((resolve2, reject) => {
|
|
@@ -77822,15 +78318,15 @@ function readDispatchBody(req) {
|
|
|
77822
78318
|
function readOrCreateBridgeToken(stateDir) {
|
|
77823
78319
|
const explicit = (process.env.MRRLIN_DIRECTOR_BRIDGE_TOKEN ?? "").trim();
|
|
77824
78320
|
if (explicit) return explicit;
|
|
77825
|
-
const tokenPath =
|
|
78321
|
+
const tokenPath = import_node_path42.default.join(stateDir, "token.txt");
|
|
77826
78322
|
try {
|
|
77827
|
-
const existing =
|
|
78323
|
+
const existing = import_node_fs27.default.readFileSync(tokenPath, "utf8").trim();
|
|
77828
78324
|
if (existing) return existing;
|
|
77829
78325
|
} catch {
|
|
77830
78326
|
}
|
|
77831
|
-
|
|
77832
|
-
const token =
|
|
77833
|
-
|
|
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}
|
|
77834
78330
|
`, { mode: 384 });
|
|
77835
78331
|
return token;
|
|
77836
78332
|
}
|
|
@@ -78738,9 +79234,9 @@ function runSetCredential(args) {
|
|
|
78738
79234
|
}
|
|
78739
79235
|
|
|
78740
79236
|
// src/install-service.ts
|
|
78741
|
-
var
|
|
78742
|
-
var
|
|
78743
|
-
var
|
|
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);
|
|
78744
79240
|
function parseEnvLine(line, env) {
|
|
78745
79241
|
const trimmed = line.trim();
|
|
78746
79242
|
if (!trimmed || trimmed === "}" || trimmed === "},") return;
|
|
@@ -79129,7 +79625,7 @@ function performConfigBackup(deps, ecoPath, existingText) {
|
|
|
79129
79625
|
deps.log("Service config backup failed.");
|
|
79130
79626
|
return;
|
|
79131
79627
|
}
|
|
79132
|
-
const dir =
|
|
79628
|
+
const dir = import_node_path43.default.dirname(ecoPath);
|
|
79133
79629
|
let files;
|
|
79134
79630
|
try {
|
|
79135
79631
|
files = deps.listDir(dir);
|
|
@@ -79141,7 +79637,7 @@ function performConfigBackup(deps, ecoPath, existingText) {
|
|
|
79141
79637
|
deps.log("Service config backup failed.");
|
|
79142
79638
|
return;
|
|
79143
79639
|
}
|
|
79144
|
-
const base =
|
|
79640
|
+
const base = import_node_path43.default.basename(ecoPath);
|
|
79145
79641
|
const backupRegex = new RegExp(`^${escapeRegex2(base)}\\.bak-\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}-\\d{3}Z$`);
|
|
79146
79642
|
const existingBackups = files.filter((f) => backupRegex.test(f));
|
|
79147
79643
|
if (existingBackups.length >= 10) {
|
|
@@ -79176,7 +79672,7 @@ function performConfigBackup(deps, ecoPath, existingText) {
|
|
|
79176
79672
|
var SYSTEM_PATH_DIRS = ["/usr/bin", "/bin", "/usr/sbin", "/sbin"];
|
|
79177
79673
|
function defaultHomeOwnerUid(home) {
|
|
79178
79674
|
try {
|
|
79179
|
-
return (0,
|
|
79675
|
+
return (0, import_node_fs28.statSync)(home).uid;
|
|
79180
79676
|
} catch {
|
|
79181
79677
|
return null;
|
|
79182
79678
|
}
|
|
@@ -79217,11 +79713,11 @@ function installService(deps) {
|
|
|
79217
79713
|
deps.log(resolved.reason);
|
|
79218
79714
|
return { ok: false };
|
|
79219
79715
|
}
|
|
79220
|
-
const home = deps.env.HOME ??
|
|
79716
|
+
const home = deps.env.HOME ?? import_node_os22.default.homedir();
|
|
79221
79717
|
const user = resolveBridgeUser({
|
|
79222
79718
|
env: deps.env,
|
|
79223
79719
|
home,
|
|
79224
|
-
userInfo: deps.userInfo ?? (() =>
|
|
79720
|
+
userInfo: deps.userInfo ?? (() => import_node_os22.default.userInfo()),
|
|
79225
79721
|
homeOwnerUid: deps.homeOwnerUid ?? defaultHomeOwnerUid,
|
|
79226
79722
|
log: deps.log
|
|
79227
79723
|
});
|
|
@@ -79242,12 +79738,12 @@ function installService(deps) {
|
|
|
79242
79738
|
const claudeBin = deps.which("claude");
|
|
79243
79739
|
const agyBin = deps.which("agy");
|
|
79244
79740
|
const resolvedBins = [...bins, claudeBin, agyBin].filter((b) => b !== null);
|
|
79245
|
-
const isWin =
|
|
79246
|
-
const systemDirs = isWin ? (deps.env.PATH || "").split(
|
|
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;
|
|
79247
79743
|
const pathEnv = Array.from(
|
|
79248
|
-
/* @__PURE__ */ new Set([...resolvedBins.map((b) =>
|
|
79249
|
-
).join(
|
|
79250
|
-
const ecoPath =
|
|
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");
|
|
79251
79747
|
const existingText = deps.readFile ? deps.readFile(ecoPath) : null;
|
|
79252
79748
|
const parseResult = parseExistingEcosystemConfig(existingText);
|
|
79253
79749
|
if (parseResult.kind === "rejected") {
|
|
@@ -79325,14 +79821,14 @@ function uninstallService(deps) {
|
|
|
79325
79821
|
|
|
79326
79822
|
// src/uninstall-codex.ts
|
|
79327
79823
|
var import_promises17 = __toESM(require("node:fs/promises"), 1);
|
|
79328
|
-
var
|
|
79329
|
-
var
|
|
79824
|
+
var import_node_os23 = __toESM(require("node:os"), 1);
|
|
79825
|
+
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
79330
79826
|
var toml5 = __toESM(require_toml(), 1);
|
|
79331
79827
|
function resolveCodexHome3(options) {
|
|
79332
79828
|
if (options.codexHome) return options.codexHome;
|
|
79333
|
-
if (options.homeDir) return
|
|
79829
|
+
if (options.homeDir) return import_node_path44.default.join(options.homeDir, ".codex");
|
|
79334
79830
|
if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
|
|
79335
|
-
return
|
|
79831
|
+
return import_node_path44.default.join(import_node_os23.default.homedir(), ".codex");
|
|
79336
79832
|
}
|
|
79337
79833
|
async function pathExists6(target) {
|
|
79338
79834
|
try {
|
|
@@ -79345,7 +79841,7 @@ async function pathExists6(target) {
|
|
|
79345
79841
|
var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.(?:mrrlin(?:-browser)?|external-agents)(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
|
|
79346
79842
|
async function uninstallCodex(options = {}) {
|
|
79347
79843
|
const codexHome = resolveCodexHome3(options);
|
|
79348
|
-
const configPath =
|
|
79844
|
+
const configPath = import_node_path44.default.join(codexHome, "config.toml");
|
|
79349
79845
|
const removePrompts = async () => uninstallPrompts(codexHome, options.promptNames ?? []);
|
|
79350
79846
|
if (!await pathExists6(configPath)) {
|
|
79351
79847
|
return { action: "missing", configPath, prompts: await removePrompts() };
|
|
@@ -79373,10 +79869,10 @@ async function uninstallCodex(options = {}) {
|
|
|
79373
79869
|
}
|
|
79374
79870
|
async function uninstallPrompts(codexHome, names) {
|
|
79375
79871
|
if (names.length === 0) return [];
|
|
79376
|
-
const promptsDir =
|
|
79872
|
+
const promptsDir = import_node_path44.default.join(codexHome, "prompts");
|
|
79377
79873
|
const out = [];
|
|
79378
79874
|
for (const name of names) {
|
|
79379
|
-
const promptPath =
|
|
79875
|
+
const promptPath = import_node_path44.default.join(promptsDir, `${name}.md`);
|
|
79380
79876
|
try {
|
|
79381
79877
|
await import_promises17.default.unlink(promptPath);
|
|
79382
79878
|
out.push({ name, action: "removed", promptPath });
|
|
@@ -79394,7 +79890,7 @@ async function uninstallPrompts(codexHome, names) {
|
|
|
79394
79890
|
|
|
79395
79891
|
// src/extract/command.ts
|
|
79396
79892
|
var import_promises18 = require("node:fs/promises");
|
|
79397
|
-
var
|
|
79893
|
+
var import_node_path45 = require("node:path");
|
|
79398
79894
|
function parseArgs(args) {
|
|
79399
79895
|
const map2 = /* @__PURE__ */ new Map();
|
|
79400
79896
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -79431,7 +79927,7 @@ Missing required flag(s): ${missing.join(
|
|
|
79431
79927
|
const days = await findSessionDays(deps.stateDir, sessionId);
|
|
79432
79928
|
const matchingLines = [];
|
|
79433
79929
|
for (const day of days) {
|
|
79434
|
-
const logPath = (0,
|
|
79930
|
+
const logPath = (0, import_node_path45.join)(deps.stateDir, "logs", `bridge-${day}.jsonl`);
|
|
79435
79931
|
let raw;
|
|
79436
79932
|
try {
|
|
79437
79933
|
raw = await (0, import_promises18.readFile)(logPath, "utf8");
|
|
@@ -79519,29 +80015,29 @@ Missing required flag(s): ${missing.join(
|
|
|
79519
80015
|
function augmentProcessPathWithCommonDirs() {
|
|
79520
80016
|
const isWin = process.platform === "win32";
|
|
79521
80017
|
if (isWin) return;
|
|
79522
|
-
const home = process.env.HOME || (0,
|
|
80018
|
+
const home = process.env.HOME || (0, import_node_os24.homedir)();
|
|
79523
80019
|
const candidates = [
|
|
79524
|
-
|
|
79525
|
-
|
|
80020
|
+
import_node_path47.default.join(home, ".local", "bin"),
|
|
80021
|
+
import_node_path47.default.join(home, ".cargo", "bin"),
|
|
79526
80022
|
"/usr/local/bin",
|
|
79527
80023
|
"/opt/homebrew/bin"
|
|
79528
80024
|
];
|
|
79529
|
-
const existing = (process.env.PATH || "").split(
|
|
80025
|
+
const existing = (process.env.PATH || "").split(import_node_path47.default.delimiter).filter(Boolean);
|
|
79530
80026
|
const existingSet = new Set(existing);
|
|
79531
|
-
const toAdd = candidates.filter((d) => !existingSet.has(d) && (0,
|
|
80027
|
+
const toAdd = candidates.filter((d) => !existingSet.has(d) && (0, import_node_fs29.existsSync)(d));
|
|
79532
80028
|
if (toAdd.length > 0) {
|
|
79533
|
-
process.env.PATH = [...existing, ...toAdd].join(
|
|
80029
|
+
process.env.PATH = [...existing, ...toAdd].join(import_node_path47.default.delimiter);
|
|
79534
80030
|
}
|
|
79535
80031
|
}
|
|
79536
80032
|
augmentProcessPathWithCommonDirs();
|
|
79537
80033
|
function pm2Runner(args) {
|
|
79538
|
-
const r = (0,
|
|
80034
|
+
const r = (0, import_node_child_process26.spawnSync)("pm2", args, { encoding: "utf8" });
|
|
79539
80035
|
process.stderr.write(r.stdout ?? "");
|
|
79540
80036
|
process.stderr.write(r.stderr ?? "");
|
|
79541
80037
|
return { code: r.status ?? 1, stdout: r.stdout ?? "" };
|
|
79542
80038
|
}
|
|
79543
80039
|
function whichBin(bin) {
|
|
79544
|
-
const r = (0,
|
|
80040
|
+
const r = (0, import_node_child_process26.spawnSync)("which", [bin], { encoding: "utf8" });
|
|
79545
80041
|
const out = (r.stdout ?? "").trim();
|
|
79546
80042
|
return r.status === 0 && out ? out.split("\n")[0] ?? null : null;
|
|
79547
80043
|
}
|
|
@@ -79549,16 +80045,16 @@ function bootHookStatus() {
|
|
|
79549
80045
|
if (process.platform !== "darwin") return { status: "unknown" };
|
|
79550
80046
|
const uid = process.getuid?.();
|
|
79551
80047
|
if (uid === void 0 || uid === 0) return { status: "unknown" };
|
|
79552
|
-
const home = process.env.HOME ?? (0,
|
|
79553
|
-
const agents =
|
|
80048
|
+
const home = process.env.HOME ?? (0, import_node_os24.homedir)();
|
|
80049
|
+
const agents = import_node_path47.default.join(home, "Library", "LaunchAgents");
|
|
79554
80050
|
const candidates = [
|
|
79555
|
-
{ label: "com.mrrlin.director-bridge", plist:
|
|
79556
|
-
{ label: "com.PM2", 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`) }
|
|
79557
80053
|
];
|
|
79558
80054
|
for (const candidate of candidates) {
|
|
79559
|
-
const printed = (0,
|
|
80055
|
+
const printed = (0, import_node_child_process26.spawnSync)("launchctl", ["print", `gui/${uid}/${candidate.label}`], { encoding: "utf8" });
|
|
79560
80056
|
if (printed.status !== 0) continue;
|
|
79561
|
-
if (!(0,
|
|
80057
|
+
if (!(0, import_node_fs29.existsSync)(candidate.plist)) continue;
|
|
79562
80058
|
const out = printed.stdout ?? "";
|
|
79563
80059
|
const runs = /^\s*runs\s*=\s*(\d+)/m.exec(out);
|
|
79564
80060
|
const exitCode = /^\s*last exit code\s*=\s*(-?\d+)/m.exec(out);
|
|
@@ -79781,7 +80277,7 @@ async function main() {
|
|
|
79781
80277
|
}
|
|
79782
80278
|
case "external-agents-serve": {
|
|
79783
80279
|
const { command: command2, args } = externalAgentsServeArgs();
|
|
79784
|
-
const r = (0,
|
|
80280
|
+
const r = (0, import_node_child_process26.spawnSync)(command2, args, { stdio: "inherit", env: process.env });
|
|
79785
80281
|
process.exitCode = r.status ?? 1;
|
|
79786
80282
|
return;
|
|
79787
80283
|
}
|
|
@@ -79835,8 +80331,8 @@ async function main() {
|
|
|
79835
80331
|
}
|
|
79836
80332
|
}
|
|
79837
80333
|
try {
|
|
79838
|
-
const codexHome = process.env.CODEX_HOME ??
|
|
79839
|
-
(0,
|
|
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 });
|
|
79840
80336
|
} catch {
|
|
79841
80337
|
}
|
|
79842
80338
|
const claudeResult = await installClaude({ binPath, force, serveEnv });
|
|
@@ -79858,7 +80354,7 @@ async function main() {
|
|
|
79858
80354
|
);
|
|
79859
80355
|
}
|
|
79860
80356
|
const realProviderRunner = (command2) => (args) => {
|
|
79861
|
-
const r = (0,
|
|
80357
|
+
const r = (0, import_node_child_process26.spawnSync)(command2, args, { encoding: "utf8", timeout: 8e3 });
|
|
79862
80358
|
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
79863
80359
|
};
|
|
79864
80360
|
for (const provider of ["codex", "claude", "agy"]) {
|
|
@@ -79906,13 +80402,13 @@ async function main() {
|
|
|
79906
80402
|
env: process.env,
|
|
79907
80403
|
cwd: process.cwd(),
|
|
79908
80404
|
writeFile: (p, c) => {
|
|
79909
|
-
(0,
|
|
79910
|
-
(0,
|
|
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 });
|
|
79911
80407
|
},
|
|
79912
|
-
writeExclusiveFile: (p, c) => (0,
|
|
80408
|
+
writeExclusiveFile: (p, c) => (0, import_node_fs29.writeFileSync)(p, c, { flag: "wx", mode: 384 }),
|
|
79913
80409
|
listDir: (p) => {
|
|
79914
80410
|
try {
|
|
79915
|
-
return (0,
|
|
80411
|
+
return (0, import_node_fs29.readdirSync)(p);
|
|
79916
80412
|
} catch {
|
|
79917
80413
|
return null;
|
|
79918
80414
|
}
|
|
@@ -79923,7 +80419,7 @@ async function main() {
|
|
|
79923
80419
|
// value", never a failed install. See readExistingTelemetryDefaultProject.
|
|
79924
80420
|
readFile: (p) => {
|
|
79925
80421
|
try {
|
|
79926
|
-
return (0,
|
|
80422
|
+
return (0, import_node_fs29.readFileSync)(p, "utf8");
|
|
79927
80423
|
} catch {
|
|
79928
80424
|
return null;
|
|
79929
80425
|
}
|
|
@@ -79944,35 +80440,35 @@ async function main() {
|
|
|
79944
80440
|
runPm2: (a) => ({ code: pm2Runner(a).code }),
|
|
79945
80441
|
removeFile: (p) => {
|
|
79946
80442
|
try {
|
|
79947
|
-
(0,
|
|
80443
|
+
(0, import_node_fs29.rmSync)(p, { force: true });
|
|
79948
80444
|
} catch {
|
|
79949
80445
|
}
|
|
79950
80446
|
},
|
|
79951
80447
|
purgeSecret: purge,
|
|
79952
80448
|
secretPath: agentCredentialPath(),
|
|
79953
80449
|
tokenPath: operatorTokenPath(),
|
|
79954
|
-
ecoPath:
|
|
80450
|
+
ecoPath: import_node_path47.default.join(process.env.HOME ?? (0, import_node_os24.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
|
|
79955
80451
|
log: (m) => process.stderr.write(`[mrrlin-mcp uninstall-service] ${m}
|
|
79956
80452
|
`)
|
|
79957
80453
|
});
|
|
79958
80454
|
return;
|
|
79959
80455
|
}
|
|
79960
80456
|
case "uninstall": {
|
|
79961
|
-
const home = process.env.HOME ?? (0,
|
|
80457
|
+
const home = process.env.HOME ?? (0, import_node_os24.homedir)();
|
|
79962
80458
|
const log = (m) => process.stderr.write(`[mrrlin-mcp uninstall] ${m}
|
|
79963
80459
|
`);
|
|
79964
80460
|
uninstallService({
|
|
79965
80461
|
runPm2: (a) => ({ code: pm2Runner(a).code }),
|
|
79966
80462
|
removeFile: (p) => {
|
|
79967
80463
|
try {
|
|
79968
|
-
(0,
|
|
80464
|
+
(0, import_node_fs29.rmSync)(p, { force: true });
|
|
79969
80465
|
} catch {
|
|
79970
80466
|
}
|
|
79971
80467
|
},
|
|
79972
80468
|
purgeSecret: true,
|
|
79973
80469
|
secretPath: agentCredentialPath(),
|
|
79974
80470
|
tokenPath: operatorTokenPath(),
|
|
79975
|
-
ecoPath:
|
|
80471
|
+
ecoPath: import_node_path47.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
|
|
79976
80472
|
log
|
|
79977
80473
|
});
|
|
79978
80474
|
let codexOk = true;
|
|
@@ -79992,7 +80488,7 @@ async function main() {
|
|
|
79992
80488
|
log(`codex config NOT modified: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
79993
80489
|
}
|
|
79994
80490
|
try {
|
|
79995
|
-
(0,
|
|
80491
|
+
(0, import_node_fs29.rmSync)(import_node_path47.default.join(home, ".mrrlin"), { recursive: true, force: true });
|
|
79996
80492
|
} catch {
|
|
79997
80493
|
}
|
|
79998
80494
|
log("removed ~/.mrrlin");
|
|
@@ -80033,7 +80529,7 @@ ${HELP_TEXT}`);
|
|
|
80033
80529
|
}
|
|
80034
80530
|
}
|
|
80035
80531
|
function resolveSelfBinPath() {
|
|
80036
|
-
return
|
|
80532
|
+
return import_node_path46.default.resolve(process.argv[1] ?? process.execPath);
|
|
80037
80533
|
}
|
|
80038
80534
|
main().catch((error51) => {
|
|
80039
80535
|
process.stderr.write(`mrrlin-mcp fatal error: ${error51 instanceof Error ? error51.message : String(error51)}
|