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