@mrrlin-dev/mcp 0.4.175 → 0.4.177
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 +1646 -612
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -5258,8 +5258,8 @@ var require_utils = __commonJS({
|
|
|
5258
5258
|
}
|
|
5259
5259
|
return ind;
|
|
5260
5260
|
}
|
|
5261
|
-
function removeDotSegments(
|
|
5262
|
-
let input =
|
|
5261
|
+
function removeDotSegments(path39) {
|
|
5262
|
+
let input = path39;
|
|
5263
5263
|
const output3 = [];
|
|
5264
5264
|
let nextSlash = -1;
|
|
5265
5265
|
let len = 0;
|
|
@@ -5668,8 +5668,8 @@ var require_schemes = __commonJS({
|
|
|
5668
5668
|
}
|
|
5669
5669
|
if (wsComponent.resourceName) {
|
|
5670
5670
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
5671
|
-
const
|
|
5672
|
-
wsComponent.path =
|
|
5671
|
+
const path39 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
5672
|
+
wsComponent.path = path39 && path39 !== "/" ? path39 : void 0;
|
|
5673
5673
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
5674
5674
|
wsComponent.resourceName = void 0;
|
|
5675
5675
|
}
|
|
@@ -9305,7 +9305,7 @@ var require_windows = __commonJS({
|
|
|
9305
9305
|
module2.exports = isexe;
|
|
9306
9306
|
isexe.sync = sync;
|
|
9307
9307
|
var fs18 = require("fs");
|
|
9308
|
-
function checkPathExt(
|
|
9308
|
+
function checkPathExt(path39, options) {
|
|
9309
9309
|
var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
|
|
9310
9310
|
if (!pathext) {
|
|
9311
9311
|
return true;
|
|
@@ -9316,25 +9316,25 @@ var require_windows = __commonJS({
|
|
|
9316
9316
|
}
|
|
9317
9317
|
for (var i = 0; i < pathext.length; i++) {
|
|
9318
9318
|
var p = pathext[i].toLowerCase();
|
|
9319
|
-
if (p &&
|
|
9319
|
+
if (p && path39.substr(-p.length).toLowerCase() === p) {
|
|
9320
9320
|
return true;
|
|
9321
9321
|
}
|
|
9322
9322
|
}
|
|
9323
9323
|
return false;
|
|
9324
9324
|
}
|
|
9325
|
-
function checkStat(stat3,
|
|
9325
|
+
function checkStat(stat3, path39, options) {
|
|
9326
9326
|
if (!stat3.isSymbolicLink() && !stat3.isFile()) {
|
|
9327
9327
|
return false;
|
|
9328
9328
|
}
|
|
9329
|
-
return checkPathExt(
|
|
9329
|
+
return checkPathExt(path39, options);
|
|
9330
9330
|
}
|
|
9331
|
-
function isexe(
|
|
9332
|
-
fs18.stat(
|
|
9333
|
-
cb(er, er ? false : checkStat(stat3,
|
|
9331
|
+
function isexe(path39, options, cb) {
|
|
9332
|
+
fs18.stat(path39, function(er, stat3) {
|
|
9333
|
+
cb(er, er ? false : checkStat(stat3, path39, options));
|
|
9334
9334
|
});
|
|
9335
9335
|
}
|
|
9336
|
-
function sync(
|
|
9337
|
-
return checkStat(fs18.statSync(
|
|
9336
|
+
function sync(path39, options) {
|
|
9337
|
+
return checkStat(fs18.statSync(path39), path39, options);
|
|
9338
9338
|
}
|
|
9339
9339
|
}
|
|
9340
9340
|
});
|
|
@@ -9345,13 +9345,13 @@ var require_mode = __commonJS({
|
|
|
9345
9345
|
module2.exports = isexe;
|
|
9346
9346
|
isexe.sync = sync;
|
|
9347
9347
|
var fs18 = require("fs");
|
|
9348
|
-
function isexe(
|
|
9349
|
-
fs18.stat(
|
|
9348
|
+
function isexe(path39, options, cb) {
|
|
9349
|
+
fs18.stat(path39, function(er, stat3) {
|
|
9350
9350
|
cb(er, er ? false : checkStat(stat3, options));
|
|
9351
9351
|
});
|
|
9352
9352
|
}
|
|
9353
|
-
function sync(
|
|
9354
|
-
return checkStat(fs18.statSync(
|
|
9353
|
+
function sync(path39, options) {
|
|
9354
|
+
return checkStat(fs18.statSync(path39), options);
|
|
9355
9355
|
}
|
|
9356
9356
|
function checkStat(stat3, options) {
|
|
9357
9357
|
return stat3.isFile() && checkMode(stat3, options);
|
|
@@ -9384,7 +9384,7 @@ var require_isexe = __commonJS({
|
|
|
9384
9384
|
}
|
|
9385
9385
|
module2.exports = isexe;
|
|
9386
9386
|
isexe.sync = sync;
|
|
9387
|
-
function isexe(
|
|
9387
|
+
function isexe(path39, options, cb) {
|
|
9388
9388
|
if (typeof options === "function") {
|
|
9389
9389
|
cb = options;
|
|
9390
9390
|
options = {};
|
|
@@ -9394,7 +9394,7 @@ var require_isexe = __commonJS({
|
|
|
9394
9394
|
throw new TypeError("callback not provided");
|
|
9395
9395
|
}
|
|
9396
9396
|
return new Promise(function(resolve3, reject) {
|
|
9397
|
-
isexe(
|
|
9397
|
+
isexe(path39, options || {}, function(er, is) {
|
|
9398
9398
|
if (er) {
|
|
9399
9399
|
reject(er);
|
|
9400
9400
|
} else {
|
|
@@ -9403,7 +9403,7 @@ var require_isexe = __commonJS({
|
|
|
9403
9403
|
});
|
|
9404
9404
|
});
|
|
9405
9405
|
}
|
|
9406
|
-
core(
|
|
9406
|
+
core(path39, options || {}, function(er, is) {
|
|
9407
9407
|
if (er) {
|
|
9408
9408
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
9409
9409
|
er = null;
|
|
@@ -9413,9 +9413,9 @@ var require_isexe = __commonJS({
|
|
|
9413
9413
|
cb(er, is);
|
|
9414
9414
|
});
|
|
9415
9415
|
}
|
|
9416
|
-
function sync(
|
|
9416
|
+
function sync(path39, options) {
|
|
9417
9417
|
try {
|
|
9418
|
-
return core.sync(
|
|
9418
|
+
return core.sync(path39, options || {});
|
|
9419
9419
|
} catch (er) {
|
|
9420
9420
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
9421
9421
|
return false;
|
|
@@ -9431,7 +9431,7 @@ var require_isexe = __commonJS({
|
|
|
9431
9431
|
var require_which = __commonJS({
|
|
9432
9432
|
"../../node_modules/.pnpm/which@2.0.2/node_modules/which/which.js"(exports2, module2) {
|
|
9433
9433
|
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
9434
|
-
var
|
|
9434
|
+
var path39 = require("path");
|
|
9435
9435
|
var COLON = isWindows ? ";" : ":";
|
|
9436
9436
|
var isexe = require_isexe();
|
|
9437
9437
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
@@ -9469,7 +9469,7 @@ var require_which = __commonJS({
|
|
|
9469
9469
|
return opt.all && found.length ? resolve3(found) : reject(getNotFoundError(cmd));
|
|
9470
9470
|
const ppRaw = pathEnv[i];
|
|
9471
9471
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
9472
|
-
const pCmd =
|
|
9472
|
+
const pCmd = path39.join(pathPart, cmd);
|
|
9473
9473
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
9474
9474
|
resolve3(subStep(p, i, 0));
|
|
9475
9475
|
});
|
|
@@ -9496,7 +9496,7 @@ var require_which = __commonJS({
|
|
|
9496
9496
|
for (let i = 0; i < pathEnv.length; i++) {
|
|
9497
9497
|
const ppRaw = pathEnv[i];
|
|
9498
9498
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
9499
|
-
const pCmd =
|
|
9499
|
+
const pCmd = path39.join(pathPart, cmd);
|
|
9500
9500
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
9501
9501
|
for (let j = 0; j < pathExt.length; j++) {
|
|
9502
9502
|
const cur = p + pathExt[j];
|
|
@@ -9544,7 +9544,7 @@ var require_path_key = __commonJS({
|
|
|
9544
9544
|
var require_resolveCommand = __commonJS({
|
|
9545
9545
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/resolveCommand.js"(exports2, module2) {
|
|
9546
9546
|
"use strict";
|
|
9547
|
-
var
|
|
9547
|
+
var path39 = require("path");
|
|
9548
9548
|
var which = require_which();
|
|
9549
9549
|
var getPathKey = require_path_key();
|
|
9550
9550
|
function resolveCommandAttempt(parsed, withoutPathExt) {
|
|
@@ -9562,7 +9562,7 @@ var require_resolveCommand = __commonJS({
|
|
|
9562
9562
|
try {
|
|
9563
9563
|
resolved = which.sync(parsed.command, {
|
|
9564
9564
|
path: env[getPathKey({ env })],
|
|
9565
|
-
pathExt: withoutPathExt ?
|
|
9565
|
+
pathExt: withoutPathExt ? path39.delimiter : void 0
|
|
9566
9566
|
});
|
|
9567
9567
|
} catch (e) {
|
|
9568
9568
|
} finally {
|
|
@@ -9571,7 +9571,7 @@ var require_resolveCommand = __commonJS({
|
|
|
9571
9571
|
}
|
|
9572
9572
|
}
|
|
9573
9573
|
if (resolved) {
|
|
9574
|
-
resolved =
|
|
9574
|
+
resolved = path39.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
|
|
9575
9575
|
}
|
|
9576
9576
|
return resolved;
|
|
9577
9577
|
}
|
|
@@ -9625,8 +9625,8 @@ var require_shebang_command = __commonJS({
|
|
|
9625
9625
|
if (!match) {
|
|
9626
9626
|
return null;
|
|
9627
9627
|
}
|
|
9628
|
-
const [
|
|
9629
|
-
const binary =
|
|
9628
|
+
const [path39, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
9629
|
+
const binary = path39.split("/").pop();
|
|
9630
9630
|
if (binary === "env") {
|
|
9631
9631
|
return argument;
|
|
9632
9632
|
}
|
|
@@ -9661,7 +9661,7 @@ var require_readShebang = __commonJS({
|
|
|
9661
9661
|
var require_parse2 = __commonJS({
|
|
9662
9662
|
"../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/parse.js"(exports2, module2) {
|
|
9663
9663
|
"use strict";
|
|
9664
|
-
var
|
|
9664
|
+
var path39 = require("path");
|
|
9665
9665
|
var resolveCommand = require_resolveCommand();
|
|
9666
9666
|
var escape2 = require_escape();
|
|
9667
9667
|
var readShebang = require_readShebang();
|
|
@@ -9686,7 +9686,7 @@ var require_parse2 = __commonJS({
|
|
|
9686
9686
|
const needsShell = !isExecutableRegExp.test(commandFile);
|
|
9687
9687
|
if (parsed.options.forceShell || needsShell) {
|
|
9688
9688
|
const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
|
|
9689
|
-
parsed.command =
|
|
9689
|
+
parsed.command = path39.normalize(parsed.command);
|
|
9690
9690
|
parsed.command = escape2.command(parsed.command);
|
|
9691
9691
|
parsed.args = parsed.args.map((arg) => escape2.argument(arg, needsDoubleEscapeMetaChars));
|
|
9692
9692
|
const shellCommand = [parsed.command].concat(parsed.args).join(" ");
|
|
@@ -9848,14 +9848,14 @@ var require_polyfills = __commonJS({
|
|
|
9848
9848
|
fs18.fstatSync = statFixSync(fs18.fstatSync);
|
|
9849
9849
|
fs18.lstatSync = statFixSync(fs18.lstatSync);
|
|
9850
9850
|
if (fs18.chmod && !fs18.lchmod) {
|
|
9851
|
-
fs18.lchmod = function(
|
|
9851
|
+
fs18.lchmod = function(path39, mode, cb) {
|
|
9852
9852
|
if (cb) process.nextTick(cb);
|
|
9853
9853
|
};
|
|
9854
9854
|
fs18.lchmodSync = function() {
|
|
9855
9855
|
};
|
|
9856
9856
|
}
|
|
9857
9857
|
if (fs18.chown && !fs18.lchown) {
|
|
9858
|
-
fs18.lchown = function(
|
|
9858
|
+
fs18.lchown = function(path39, uid, gid, cb) {
|
|
9859
9859
|
if (cb) process.nextTick(cb);
|
|
9860
9860
|
};
|
|
9861
9861
|
fs18.lchownSync = function() {
|
|
@@ -9922,9 +9922,9 @@ var require_polyfills = __commonJS({
|
|
|
9922
9922
|
};
|
|
9923
9923
|
}(fs18.readSync);
|
|
9924
9924
|
function patchLchmod(fs19) {
|
|
9925
|
-
fs19.lchmod = function(
|
|
9925
|
+
fs19.lchmod = function(path39, mode, callback) {
|
|
9926
9926
|
fs19.open(
|
|
9927
|
-
|
|
9927
|
+
path39,
|
|
9928
9928
|
constants2.O_WRONLY | constants2.O_SYMLINK,
|
|
9929
9929
|
mode,
|
|
9930
9930
|
function(err, fd) {
|
|
@@ -9940,8 +9940,8 @@ var require_polyfills = __commonJS({
|
|
|
9940
9940
|
}
|
|
9941
9941
|
);
|
|
9942
9942
|
};
|
|
9943
|
-
fs19.lchmodSync = function(
|
|
9944
|
-
var fd = fs19.openSync(
|
|
9943
|
+
fs19.lchmodSync = function(path39, mode) {
|
|
9944
|
+
var fd = fs19.openSync(path39, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
|
|
9945
9945
|
var threw = true;
|
|
9946
9946
|
var ret;
|
|
9947
9947
|
try {
|
|
@@ -9962,8 +9962,8 @@ var require_polyfills = __commonJS({
|
|
|
9962
9962
|
}
|
|
9963
9963
|
function patchLutimes(fs19) {
|
|
9964
9964
|
if (constants2.hasOwnProperty("O_SYMLINK") && fs19.futimes) {
|
|
9965
|
-
fs19.lutimes = function(
|
|
9966
|
-
fs19.open(
|
|
9965
|
+
fs19.lutimes = function(path39, at, mt, cb) {
|
|
9966
|
+
fs19.open(path39, constants2.O_SYMLINK, function(er, fd) {
|
|
9967
9967
|
if (er) {
|
|
9968
9968
|
if (cb) cb(er);
|
|
9969
9969
|
return;
|
|
@@ -9975,8 +9975,8 @@ var require_polyfills = __commonJS({
|
|
|
9975
9975
|
});
|
|
9976
9976
|
});
|
|
9977
9977
|
};
|
|
9978
|
-
fs19.lutimesSync = function(
|
|
9979
|
-
var fd = fs19.openSync(
|
|
9978
|
+
fs19.lutimesSync = function(path39, at, mt) {
|
|
9979
|
+
var fd = fs19.openSync(path39, constants2.O_SYMLINK);
|
|
9980
9980
|
var ret;
|
|
9981
9981
|
var threw = true;
|
|
9982
9982
|
try {
|
|
@@ -10094,11 +10094,11 @@ var require_legacy_streams = __commonJS({
|
|
|
10094
10094
|
ReadStream,
|
|
10095
10095
|
WriteStream
|
|
10096
10096
|
};
|
|
10097
|
-
function ReadStream(
|
|
10098
|
-
if (!(this instanceof ReadStream)) return new ReadStream(
|
|
10097
|
+
function ReadStream(path39, options) {
|
|
10098
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path39, options);
|
|
10099
10099
|
Stream.call(this);
|
|
10100
10100
|
var self = this;
|
|
10101
|
-
this.path =
|
|
10101
|
+
this.path = path39;
|
|
10102
10102
|
this.fd = null;
|
|
10103
10103
|
this.readable = true;
|
|
10104
10104
|
this.paused = false;
|
|
@@ -10143,10 +10143,10 @@ var require_legacy_streams = __commonJS({
|
|
|
10143
10143
|
self._read();
|
|
10144
10144
|
});
|
|
10145
10145
|
}
|
|
10146
|
-
function WriteStream(
|
|
10147
|
-
if (!(this instanceof WriteStream)) return new WriteStream(
|
|
10146
|
+
function WriteStream(path39, options) {
|
|
10147
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path39, options);
|
|
10148
10148
|
Stream.call(this);
|
|
10149
|
-
this.path =
|
|
10149
|
+
this.path = path39;
|
|
10150
10150
|
this.fd = null;
|
|
10151
10151
|
this.writable = true;
|
|
10152
10152
|
this.flags = "w";
|
|
@@ -10257,14 +10257,14 @@ var require_graceful_fs = __commonJS({
|
|
|
10257
10257
|
return close;
|
|
10258
10258
|
}(fs18.close);
|
|
10259
10259
|
fs18.closeSync = function(fs$closeSync) {
|
|
10260
|
-
function
|
|
10260
|
+
function closeSync3(fd) {
|
|
10261
10261
|
fs$closeSync.apply(fs18, arguments);
|
|
10262
10262
|
resetQueue();
|
|
10263
10263
|
}
|
|
10264
|
-
Object.defineProperty(
|
|
10264
|
+
Object.defineProperty(closeSync3, previousSymbol, {
|
|
10265
10265
|
value: fs$closeSync
|
|
10266
10266
|
});
|
|
10267
|
-
return
|
|
10267
|
+
return closeSync3;
|
|
10268
10268
|
}(fs18.closeSync);
|
|
10269
10269
|
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
10270
10270
|
process.on("exit", function() {
|
|
@@ -10289,14 +10289,14 @@ var require_graceful_fs = __commonJS({
|
|
|
10289
10289
|
fs19.createWriteStream = createWriteStream;
|
|
10290
10290
|
var fs$readFile = fs19.readFile;
|
|
10291
10291
|
fs19.readFile = readFile10;
|
|
10292
|
-
function readFile10(
|
|
10292
|
+
function readFile10(path39, options, cb) {
|
|
10293
10293
|
if (typeof options === "function")
|
|
10294
10294
|
cb = options, options = null;
|
|
10295
|
-
return go$readFile(
|
|
10296
|
-
function go$readFile(
|
|
10297
|
-
return fs$readFile(
|
|
10295
|
+
return go$readFile(path39, options, cb);
|
|
10296
|
+
function go$readFile(path40, options2, cb2, startTime) {
|
|
10297
|
+
return fs$readFile(path40, options2, function(err) {
|
|
10298
10298
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
10299
|
-
enqueue([go$readFile, [
|
|
10299
|
+
enqueue([go$readFile, [path40, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
10300
10300
|
else {
|
|
10301
10301
|
if (typeof cb2 === "function")
|
|
10302
10302
|
cb2.apply(this, arguments);
|
|
@@ -10306,14 +10306,14 @@ var require_graceful_fs = __commonJS({
|
|
|
10306
10306
|
}
|
|
10307
10307
|
var fs$writeFile = fs19.writeFile;
|
|
10308
10308
|
fs19.writeFile = writeFile5;
|
|
10309
|
-
function writeFile5(
|
|
10309
|
+
function writeFile5(path39, data, options, cb) {
|
|
10310
10310
|
if (typeof options === "function")
|
|
10311
10311
|
cb = options, options = null;
|
|
10312
|
-
return go$writeFile(
|
|
10313
|
-
function go$writeFile(
|
|
10314
|
-
return fs$writeFile(
|
|
10312
|
+
return go$writeFile(path39, data, options, cb);
|
|
10313
|
+
function go$writeFile(path40, data2, options2, cb2, startTime) {
|
|
10314
|
+
return fs$writeFile(path40, data2, options2, function(err) {
|
|
10315
10315
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
10316
|
-
enqueue([go$writeFile, [
|
|
10316
|
+
enqueue([go$writeFile, [path40, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
10317
10317
|
else {
|
|
10318
10318
|
if (typeof cb2 === "function")
|
|
10319
10319
|
cb2.apply(this, arguments);
|
|
@@ -10324,14 +10324,14 @@ var require_graceful_fs = __commonJS({
|
|
|
10324
10324
|
var fs$appendFile = fs19.appendFile;
|
|
10325
10325
|
if (fs$appendFile)
|
|
10326
10326
|
fs19.appendFile = appendFile2;
|
|
10327
|
-
function appendFile2(
|
|
10327
|
+
function appendFile2(path39, data, options, cb) {
|
|
10328
10328
|
if (typeof options === "function")
|
|
10329
10329
|
cb = options, options = null;
|
|
10330
|
-
return go$appendFile(
|
|
10331
|
-
function go$appendFile(
|
|
10332
|
-
return fs$appendFile(
|
|
10330
|
+
return go$appendFile(path39, data, options, cb);
|
|
10331
|
+
function go$appendFile(path40, data2, options2, cb2, startTime) {
|
|
10332
|
+
return fs$appendFile(path40, data2, options2, function(err) {
|
|
10333
10333
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
10334
|
-
enqueue([go$appendFile, [
|
|
10334
|
+
enqueue([go$appendFile, [path40, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
10335
10335
|
else {
|
|
10336
10336
|
if (typeof cb2 === "function")
|
|
10337
10337
|
cb2.apply(this, arguments);
|
|
@@ -10362,31 +10362,31 @@ var require_graceful_fs = __commonJS({
|
|
|
10362
10362
|
var fs$readdir = fs19.readdir;
|
|
10363
10363
|
fs19.readdir = readdir5;
|
|
10364
10364
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
10365
|
-
function readdir5(
|
|
10365
|
+
function readdir5(path39, options, cb) {
|
|
10366
10366
|
if (typeof options === "function")
|
|
10367
10367
|
cb = options, options = null;
|
|
10368
|
-
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(
|
|
10369
|
-
return fs$readdir(
|
|
10370
|
-
|
|
10368
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path40, options2, cb2, startTime) {
|
|
10369
|
+
return fs$readdir(path40, fs$readdirCallback(
|
|
10370
|
+
path40,
|
|
10371
10371
|
options2,
|
|
10372
10372
|
cb2,
|
|
10373
10373
|
startTime
|
|
10374
10374
|
));
|
|
10375
|
-
} : function go$readdir2(
|
|
10376
|
-
return fs$readdir(
|
|
10377
|
-
|
|
10375
|
+
} : function go$readdir2(path40, options2, cb2, startTime) {
|
|
10376
|
+
return fs$readdir(path40, options2, fs$readdirCallback(
|
|
10377
|
+
path40,
|
|
10378
10378
|
options2,
|
|
10379
10379
|
cb2,
|
|
10380
10380
|
startTime
|
|
10381
10381
|
));
|
|
10382
10382
|
};
|
|
10383
|
-
return go$readdir(
|
|
10384
|
-
function fs$readdirCallback(
|
|
10383
|
+
return go$readdir(path39, options, cb);
|
|
10384
|
+
function fs$readdirCallback(path40, options2, cb2, startTime) {
|
|
10385
10385
|
return function(err, files) {
|
|
10386
10386
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
10387
10387
|
enqueue([
|
|
10388
10388
|
go$readdir,
|
|
10389
|
-
[
|
|
10389
|
+
[path40, options2, cb2],
|
|
10390
10390
|
err,
|
|
10391
10391
|
startTime || Date.now(),
|
|
10392
10392
|
Date.now()
|
|
@@ -10457,7 +10457,7 @@ var require_graceful_fs = __commonJS({
|
|
|
10457
10457
|
enumerable: true,
|
|
10458
10458
|
configurable: true
|
|
10459
10459
|
});
|
|
10460
|
-
function ReadStream(
|
|
10460
|
+
function ReadStream(path39, options) {
|
|
10461
10461
|
if (this instanceof ReadStream)
|
|
10462
10462
|
return fs$ReadStream.apply(this, arguments), this;
|
|
10463
10463
|
else
|
|
@@ -10477,7 +10477,7 @@ var require_graceful_fs = __commonJS({
|
|
|
10477
10477
|
}
|
|
10478
10478
|
});
|
|
10479
10479
|
}
|
|
10480
|
-
function WriteStream(
|
|
10480
|
+
function WriteStream(path39, options) {
|
|
10481
10481
|
if (this instanceof WriteStream)
|
|
10482
10482
|
return fs$WriteStream.apply(this, arguments), this;
|
|
10483
10483
|
else
|
|
@@ -10495,22 +10495,22 @@ var require_graceful_fs = __commonJS({
|
|
|
10495
10495
|
}
|
|
10496
10496
|
});
|
|
10497
10497
|
}
|
|
10498
|
-
function createReadStream2(
|
|
10499
|
-
return new fs19.ReadStream(
|
|
10498
|
+
function createReadStream2(path39, options) {
|
|
10499
|
+
return new fs19.ReadStream(path39, options);
|
|
10500
10500
|
}
|
|
10501
|
-
function createWriteStream(
|
|
10502
|
-
return new fs19.WriteStream(
|
|
10501
|
+
function createWriteStream(path39, options) {
|
|
10502
|
+
return new fs19.WriteStream(path39, options);
|
|
10503
10503
|
}
|
|
10504
10504
|
var fs$open = fs19.open;
|
|
10505
10505
|
fs19.open = open;
|
|
10506
|
-
function open(
|
|
10506
|
+
function open(path39, flags, mode, cb) {
|
|
10507
10507
|
if (typeof mode === "function")
|
|
10508
10508
|
cb = mode, mode = null;
|
|
10509
|
-
return go$open(
|
|
10510
|
-
function go$open(
|
|
10511
|
-
return fs$open(
|
|
10509
|
+
return go$open(path39, flags, mode, cb);
|
|
10510
|
+
function go$open(path40, flags2, mode2, cb2, startTime) {
|
|
10511
|
+
return fs$open(path40, flags2, mode2, function(err, fd) {
|
|
10512
10512
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
10513
|
-
enqueue([go$open, [
|
|
10513
|
+
enqueue([go$open, [path40, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
10514
10514
|
else {
|
|
10515
10515
|
if (typeof cb2 === "function")
|
|
10516
10516
|
cb2.apply(this, arguments);
|
|
@@ -11039,7 +11039,7 @@ var require_mtime_precision = __commonJS({
|
|
|
11039
11039
|
var require_lockfile = __commonJS({
|
|
11040
11040
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/lockfile.js"(exports2, module2) {
|
|
11041
11041
|
"use strict";
|
|
11042
|
-
var
|
|
11042
|
+
var path39 = require("path");
|
|
11043
11043
|
var fs18 = require_graceful_fs();
|
|
11044
11044
|
var retry = require_retry2();
|
|
11045
11045
|
var onExit = require_signal_exit();
|
|
@@ -11050,7 +11050,7 @@ var require_lockfile = __commonJS({
|
|
|
11050
11050
|
}
|
|
11051
11051
|
function resolveCanonicalPath(file2, options, callback) {
|
|
11052
11052
|
if (!options.realpath) {
|
|
11053
|
-
return callback(null,
|
|
11053
|
+
return callback(null, path39.resolve(file2));
|
|
11054
11054
|
}
|
|
11055
11055
|
options.fs.realpath(file2, callback);
|
|
11056
11056
|
}
|
|
@@ -17043,9 +17043,9 @@ async function pathExists5(target) {
|
|
|
17043
17043
|
}
|
|
17044
17044
|
}
|
|
17045
17045
|
async function writeAtomic(targetPath, content) {
|
|
17046
|
-
const dir =
|
|
17046
|
+
const dir = import_node_path41.default.dirname(targetPath);
|
|
17047
17047
|
await import_promises17.default.mkdir(dir, { recursive: true, mode: 448 });
|
|
17048
|
-
const tempPath =
|
|
17048
|
+
const tempPath = import_node_path41.default.join(dir, `.tmp.${import_node_path41.default.basename(targetPath)}.${Date.now()}`);
|
|
17049
17049
|
await import_promises17.default.writeFile(tempPath, content, { mode: 384 });
|
|
17050
17050
|
await import_promises17.default.rename(tempPath, targetPath);
|
|
17051
17051
|
}
|
|
@@ -17085,9 +17085,9 @@ ${newBlock}
|
|
|
17085
17085
|
function getDefaultNativePaths() {
|
|
17086
17086
|
const homeDir = import_node_os19.default.homedir();
|
|
17087
17087
|
return {
|
|
17088
|
-
claude:
|
|
17089
|
-
codex:
|
|
17090
|
-
gemini:
|
|
17088
|
+
claude: import_node_path41.default.join(homeDir, ".claude.json"),
|
|
17089
|
+
codex: import_node_path41.default.join(homeDir, ".codex", "config.toml"),
|
|
17090
|
+
gemini: import_node_path41.default.join(homeDir, ".gemini", "antigravity", "mcp_config.json")
|
|
17091
17091
|
};
|
|
17092
17092
|
}
|
|
17093
17093
|
async function writeServerToClaudeJson(filePath, serverId, expected, options = {}) {
|
|
@@ -17285,13 +17285,13 @@ async function installPublicMcpServerToConfigs(serverId, expected, options = {})
|
|
|
17285
17285
|
results
|
|
17286
17286
|
};
|
|
17287
17287
|
}
|
|
17288
|
-
var import_promises17, import_node_os19,
|
|
17288
|
+
var import_promises17, import_node_os19, import_node_path41, toml4;
|
|
17289
17289
|
var init_install_public_mcp = __esm({
|
|
17290
17290
|
"src/install-public-mcp.ts"() {
|
|
17291
17291
|
"use strict";
|
|
17292
17292
|
import_promises17 = __toESM(require("node:fs/promises"), 1);
|
|
17293
17293
|
import_node_os19 = __toESM(require("node:os"), 1);
|
|
17294
|
-
|
|
17294
|
+
import_node_path41 = __toESM(require("node:path"), 1);
|
|
17295
17295
|
toml4 = __toESM(require_toml(), 1);
|
|
17296
17296
|
}
|
|
17297
17297
|
});
|
|
@@ -18837,10 +18837,10 @@ var require_segments = __commonJS({
|
|
|
18837
18837
|
const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
|
|
18838
18838
|
const nodes = buildNodes(segs);
|
|
18839
18839
|
const graph = buildGraph(nodes, version2);
|
|
18840
|
-
const
|
|
18840
|
+
const path39 = dijkstra.find_path(graph.map, "start", "end");
|
|
18841
18841
|
const optimizedSegs = [];
|
|
18842
|
-
for (let i = 1; i <
|
|
18843
|
-
optimizedSegs.push(graph.table[
|
|
18842
|
+
for (let i = 1; i < path39.length - 1; i++) {
|
|
18843
|
+
optimizedSegs.push(graph.table[path39[i]].node);
|
|
18844
18844
|
}
|
|
18845
18845
|
return exports2.fromArray(mergeSegments(optimizedSegs));
|
|
18846
18846
|
};
|
|
@@ -21317,7 +21317,7 @@ var require_png2 = __commonJS({
|
|
|
21317
21317
|
});
|
|
21318
21318
|
png.pack();
|
|
21319
21319
|
};
|
|
21320
|
-
exports2.renderToFile = function renderToFile(
|
|
21320
|
+
exports2.renderToFile = function renderToFile(path39, qrData, options, cb) {
|
|
21321
21321
|
if (typeof cb === "undefined") {
|
|
21322
21322
|
cb = options;
|
|
21323
21323
|
options = void 0;
|
|
@@ -21328,7 +21328,7 @@ var require_png2 = __commonJS({
|
|
|
21328
21328
|
called = true;
|
|
21329
21329
|
cb.apply(null, args);
|
|
21330
21330
|
};
|
|
21331
|
-
const stream = fs18.createWriteStream(
|
|
21331
|
+
const stream = fs18.createWriteStream(path39);
|
|
21332
21332
|
stream.on("error", done);
|
|
21333
21333
|
stream.on("close", done);
|
|
21334
21334
|
exports2.renderToFileStream(stream, qrData, options);
|
|
@@ -21390,14 +21390,14 @@ var require_utf8 = __commonJS({
|
|
|
21390
21390
|
}
|
|
21391
21391
|
return output3;
|
|
21392
21392
|
};
|
|
21393
|
-
exports2.renderToFile = function renderToFile(
|
|
21393
|
+
exports2.renderToFile = function renderToFile(path39, qrData, options, cb) {
|
|
21394
21394
|
if (typeof cb === "undefined") {
|
|
21395
21395
|
cb = options;
|
|
21396
21396
|
options = void 0;
|
|
21397
21397
|
}
|
|
21398
21398
|
const fs18 = require("fs");
|
|
21399
21399
|
const utf8 = exports2.render(qrData, options);
|
|
21400
|
-
fs18.writeFile(
|
|
21400
|
+
fs18.writeFile(path39, utf8, cb);
|
|
21401
21401
|
};
|
|
21402
21402
|
}
|
|
21403
21403
|
});
|
|
@@ -21518,7 +21518,7 @@ var require_svg_tag = __commonJS({
|
|
|
21518
21518
|
return str;
|
|
21519
21519
|
}
|
|
21520
21520
|
function qrToPath(data, size, margin) {
|
|
21521
|
-
let
|
|
21521
|
+
let path39 = "";
|
|
21522
21522
|
let moveBy = 0;
|
|
21523
21523
|
let newRow = false;
|
|
21524
21524
|
let lineLength = 0;
|
|
@@ -21529,19 +21529,19 @@ var require_svg_tag = __commonJS({
|
|
|
21529
21529
|
if (data[i]) {
|
|
21530
21530
|
lineLength++;
|
|
21531
21531
|
if (!(i > 0 && col > 0 && data[i - 1])) {
|
|
21532
|
-
|
|
21532
|
+
path39 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
|
|
21533
21533
|
moveBy = 0;
|
|
21534
21534
|
newRow = false;
|
|
21535
21535
|
}
|
|
21536
21536
|
if (!(col + 1 < size && data[i + 1])) {
|
|
21537
|
-
|
|
21537
|
+
path39 += svgCmd("h", lineLength);
|
|
21538
21538
|
lineLength = 0;
|
|
21539
21539
|
}
|
|
21540
21540
|
} else {
|
|
21541
21541
|
moveBy++;
|
|
21542
21542
|
}
|
|
21543
21543
|
}
|
|
21544
|
-
return
|
|
21544
|
+
return path39;
|
|
21545
21545
|
}
|
|
21546
21546
|
exports2.render = function render(qrData, options, cb) {
|
|
21547
21547
|
const opts = Utils.getOptions(options);
|
|
@@ -21549,10 +21549,10 @@ var require_svg_tag = __commonJS({
|
|
|
21549
21549
|
const data = qrData.modules.data;
|
|
21550
21550
|
const qrcodesize = size + opts.margin * 2;
|
|
21551
21551
|
const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>';
|
|
21552
|
-
const
|
|
21552
|
+
const path39 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
|
|
21553
21553
|
const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"';
|
|
21554
21554
|
const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" ';
|
|
21555
|
-
const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg +
|
|
21555
|
+
const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path39 + "</svg>\n";
|
|
21556
21556
|
if (typeof cb === "function") {
|
|
21557
21557
|
cb(null, svgTag);
|
|
21558
21558
|
}
|
|
@@ -21566,7 +21566,7 @@ var require_svg = __commonJS({
|
|
|
21566
21566
|
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"(exports2) {
|
|
21567
21567
|
var svgTagRenderer = require_svg_tag();
|
|
21568
21568
|
exports2.render = svgTagRenderer.render;
|
|
21569
|
-
exports2.renderToFile = function renderToFile(
|
|
21569
|
+
exports2.renderToFile = function renderToFile(path39, qrData, options, cb) {
|
|
21570
21570
|
if (typeof cb === "undefined") {
|
|
21571
21571
|
cb = options;
|
|
21572
21572
|
options = void 0;
|
|
@@ -21574,7 +21574,7 @@ var require_svg = __commonJS({
|
|
|
21574
21574
|
const fs18 = require("fs");
|
|
21575
21575
|
const svgTag = exports2.render(qrData, options);
|
|
21576
21576
|
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;
|
|
21577
|
-
fs18.writeFile(
|
|
21577
|
+
fs18.writeFile(path39, xmlStr, cb);
|
|
21578
21578
|
};
|
|
21579
21579
|
}
|
|
21580
21580
|
});
|
|
@@ -21732,8 +21732,8 @@ var require_server = __commonJS({
|
|
|
21732
21732
|
cb
|
|
21733
21733
|
};
|
|
21734
21734
|
}
|
|
21735
|
-
function getTypeFromFilename(
|
|
21736
|
-
return
|
|
21735
|
+
function getTypeFromFilename(path39) {
|
|
21736
|
+
return path39.slice((path39.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
|
|
21737
21737
|
}
|
|
21738
21738
|
function getRendererFromType(type) {
|
|
21739
21739
|
switch (type) {
|
|
@@ -21797,17 +21797,17 @@ var require_server = __commonJS({
|
|
|
21797
21797
|
const renderer = getRendererFromType(params.opts.type);
|
|
21798
21798
|
return render(renderer.renderToBuffer, text, params);
|
|
21799
21799
|
};
|
|
21800
|
-
exports2.toFile = function toFile(
|
|
21801
|
-
if (typeof
|
|
21800
|
+
exports2.toFile = function toFile(path39, text, opts, cb) {
|
|
21801
|
+
if (typeof path39 !== "string" || !(typeof text === "string" || typeof text === "object")) {
|
|
21802
21802
|
throw new Error("Invalid argument");
|
|
21803
21803
|
}
|
|
21804
21804
|
if (arguments.length < 3 && !canPromise()) {
|
|
21805
21805
|
throw new Error("Too few arguments provided");
|
|
21806
21806
|
}
|
|
21807
21807
|
const params = checkParams(text, opts, cb);
|
|
21808
|
-
const type = params.opts.type || getTypeFromFilename(
|
|
21808
|
+
const type = params.opts.type || getTypeFromFilename(path39);
|
|
21809
21809
|
const renderer = getRendererFromType(type);
|
|
21810
|
-
const renderToFile = renderer.renderToFile.bind(null,
|
|
21810
|
+
const renderToFile = renderer.renderToFile.bind(null, path39);
|
|
21811
21811
|
return render(renderToFile, text, params);
|
|
21812
21812
|
};
|
|
21813
21813
|
exports2.toFileStream = function toFileStream(stream, text, opts) {
|
|
@@ -21835,11 +21835,11 @@ __export(bin_exports, {
|
|
|
21835
21835
|
augmentProcessPathWithCommonDirs: () => augmentProcessPathWithCommonDirs
|
|
21836
21836
|
});
|
|
21837
21837
|
module.exports = __toCommonJS(bin_exports);
|
|
21838
|
-
var
|
|
21838
|
+
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
21839
21839
|
var import_node_child_process27 = require("node:child_process");
|
|
21840
|
-
var
|
|
21840
|
+
var import_node_fs36 = require("node:fs");
|
|
21841
21841
|
var import_node_os26 = require("node:os");
|
|
21842
|
-
var
|
|
21842
|
+
var import_node_path54 = __toESM(require("node:path"), 1);
|
|
21843
21843
|
|
|
21844
21844
|
// src/install-codex.ts
|
|
21845
21845
|
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
@@ -22967,12 +22967,12 @@ async function installClaude(options) {
|
|
|
22967
22967
|
// src/install-agy.ts
|
|
22968
22968
|
var import_promises11 = __toESM(require("node:fs/promises"), 1);
|
|
22969
22969
|
var import_node_os14 = __toESM(require("node:os"), 1);
|
|
22970
|
-
var
|
|
22970
|
+
var import_node_path27 = __toESM(require("node:path"), 1);
|
|
22971
22971
|
|
|
22972
22972
|
// src/tools.ts
|
|
22973
|
-
var
|
|
22973
|
+
var import_node_crypto19 = require("node:crypto");
|
|
22974
22974
|
var import_promises10 = require("node:fs/promises");
|
|
22975
|
-
var
|
|
22975
|
+
var import_node_path26 = __toESM(require("node:path"), 1);
|
|
22976
22976
|
var import_node_os13 = __toESM(require("node:os"), 1);
|
|
22977
22977
|
|
|
22978
22978
|
// ../../packages/schemas/dist/canonical-json.js
|
|
@@ -23753,10 +23753,10 @@ function mergeDefs(...defs) {
|
|
|
23753
23753
|
function cloneDef(schema) {
|
|
23754
23754
|
return mergeDefs(schema._zod.def);
|
|
23755
23755
|
}
|
|
23756
|
-
function getElementAtPath(obj,
|
|
23757
|
-
if (!
|
|
23756
|
+
function getElementAtPath(obj, path39) {
|
|
23757
|
+
if (!path39)
|
|
23758
23758
|
return obj;
|
|
23759
|
-
return
|
|
23759
|
+
return path39.reduce((acc, key) => acc?.[key], obj);
|
|
23760
23760
|
}
|
|
23761
23761
|
function promiseAllObject(promisesObj) {
|
|
23762
23762
|
const keys = Object.keys(promisesObj);
|
|
@@ -24165,11 +24165,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
24165
24165
|
}
|
|
24166
24166
|
return false;
|
|
24167
24167
|
}
|
|
24168
|
-
function prefixIssues(
|
|
24168
|
+
function prefixIssues(path39, issues) {
|
|
24169
24169
|
return issues.map((iss) => {
|
|
24170
24170
|
var _a3;
|
|
24171
24171
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
24172
|
-
iss.path.unshift(
|
|
24172
|
+
iss.path.unshift(path39);
|
|
24173
24173
|
return iss;
|
|
24174
24174
|
});
|
|
24175
24175
|
}
|
|
@@ -24316,16 +24316,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
24316
24316
|
}
|
|
24317
24317
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
24318
24318
|
const fieldErrors = { _errors: [] };
|
|
24319
|
-
const processError = (error52,
|
|
24319
|
+
const processError = (error52, path39 = []) => {
|
|
24320
24320
|
for (const issue2 of error52.issues) {
|
|
24321
24321
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
24322
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
24322
|
+
issue2.errors.map((issues) => processError({ issues }, [...path39, ...issue2.path]));
|
|
24323
24323
|
} else if (issue2.code === "invalid_key") {
|
|
24324
|
-
processError({ issues: issue2.issues }, [...
|
|
24324
|
+
processError({ issues: issue2.issues }, [...path39, ...issue2.path]);
|
|
24325
24325
|
} else if (issue2.code === "invalid_element") {
|
|
24326
|
-
processError({ issues: issue2.issues }, [...
|
|
24326
|
+
processError({ issues: issue2.issues }, [...path39, ...issue2.path]);
|
|
24327
24327
|
} else {
|
|
24328
|
-
const fullpath = [...
|
|
24328
|
+
const fullpath = [...path39, ...issue2.path];
|
|
24329
24329
|
if (fullpath.length === 0) {
|
|
24330
24330
|
fieldErrors._errors.push(mapper(issue2));
|
|
24331
24331
|
} else {
|
|
@@ -24352,17 +24352,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
24352
24352
|
}
|
|
24353
24353
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
24354
24354
|
const result = { errors: [] };
|
|
24355
|
-
const processError = (error52,
|
|
24355
|
+
const processError = (error52, path39 = []) => {
|
|
24356
24356
|
var _a3, _b;
|
|
24357
24357
|
for (const issue2 of error52.issues) {
|
|
24358
24358
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
24359
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
24359
|
+
issue2.errors.map((issues) => processError({ issues }, [...path39, ...issue2.path]));
|
|
24360
24360
|
} else if (issue2.code === "invalid_key") {
|
|
24361
|
-
processError({ issues: issue2.issues }, [...
|
|
24361
|
+
processError({ issues: issue2.issues }, [...path39, ...issue2.path]);
|
|
24362
24362
|
} else if (issue2.code === "invalid_element") {
|
|
24363
|
-
processError({ issues: issue2.issues }, [...
|
|
24363
|
+
processError({ issues: issue2.issues }, [...path39, ...issue2.path]);
|
|
24364
24364
|
} else {
|
|
24365
|
-
const fullpath = [...
|
|
24365
|
+
const fullpath = [...path39, ...issue2.path];
|
|
24366
24366
|
if (fullpath.length === 0) {
|
|
24367
24367
|
result.errors.push(mapper(issue2));
|
|
24368
24368
|
continue;
|
|
@@ -24394,8 +24394,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
24394
24394
|
}
|
|
24395
24395
|
function toDotPath(_path) {
|
|
24396
24396
|
const segs = [];
|
|
24397
|
-
const
|
|
24398
|
-
for (const seg of
|
|
24397
|
+
const path39 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
24398
|
+
for (const seg of path39) {
|
|
24399
24399
|
if (typeof seg === "number")
|
|
24400
24400
|
segs.push(`[${seg}]`);
|
|
24401
24401
|
else if (typeof seg === "symbol")
|
|
@@ -37087,13 +37087,13 @@ function resolveRef(ref, ctx) {
|
|
|
37087
37087
|
if (!ref.startsWith("#")) {
|
|
37088
37088
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
37089
37089
|
}
|
|
37090
|
-
const
|
|
37091
|
-
if (
|
|
37090
|
+
const path39 = ref.slice(1).split("/").filter(Boolean);
|
|
37091
|
+
if (path39.length === 0) {
|
|
37092
37092
|
return ctx.rootSchema;
|
|
37093
37093
|
}
|
|
37094
37094
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
37095
|
-
if (
|
|
37096
|
-
const key =
|
|
37095
|
+
if (path39[0] === defsKey) {
|
|
37096
|
+
const key = path39[1];
|
|
37097
37097
|
if (!key || !ctx.defs[key]) {
|
|
37098
37098
|
throw new Error(`Reference not found: ${ref}`);
|
|
37099
37099
|
}
|
|
@@ -37792,6 +37792,10 @@ var openApiOperationIds = {
|
|
|
37792
37792
|
getCapabilityPermit: "getCapabilityPermit",
|
|
37793
37793
|
getCapabilityInvocation: "getCapabilityInvocation",
|
|
37794
37794
|
reconcilePendingCapabilityInvocations: "reconcilePendingCapabilityInvocations",
|
|
37795
|
+
issueLocalGitSettlement: "issueLocalGitSettlement",
|
|
37796
|
+
getLocalGitSettlement: "getLocalGitSettlement",
|
|
37797
|
+
acknowledgeLocalGitLanding: "acknowledgeLocalGitLanding",
|
|
37798
|
+
listPendingLocalGitLandings: "listPendingLocalGitLandings",
|
|
37795
37799
|
mintIntegrationSetupTicket: "mintIntegrationSetupTicket",
|
|
37796
37800
|
redeemIntegrationSetupTicket: "redeemIntegrationSetupTicket",
|
|
37797
37801
|
registerBridgeInstallation: "registerBridgeInstallation",
|
|
@@ -37843,6 +37847,7 @@ var operatorSessionSchema = external_exports.object({
|
|
|
37843
37847
|
// Default 'project' for backward-compat: tokens minted before this field existed parse
|
|
37844
37848
|
// cleanly into the project branch of the middleware (which mirrors today's behavior).
|
|
37845
37849
|
scope: external_exports.enum(["project", "operator"]).default("project"),
|
|
37850
|
+
agentCredentialId: external_exports.string().uuid().optional(),
|
|
37846
37851
|
accountId: external_exports.string().uuid().optional(),
|
|
37847
37852
|
identitySubject: external_exports.string().min(1).optional(),
|
|
37848
37853
|
githubId: external_exports.union([external_exports.number().int(), external_exports.string().min(1)]).optional(),
|
|
@@ -38863,6 +38868,188 @@ var manualTaskClosureRequestSchema = external_exports.object({
|
|
|
38863
38868
|
outcome: external_exports.enum(["completed", "negative_result", "wont_do"]),
|
|
38864
38869
|
reason: external_exports.string().optional()
|
|
38865
38870
|
});
|
|
38871
|
+
var gitOidSha1Schema = external_exports.string().regex(/^[0-9a-f]{40}$/, "Invalid SHA-1 Git OID (must be 40 lowercase hex characters)");
|
|
38872
|
+
var gitOidSha256Schema = external_exports.string().regex(/^[0-9a-f]{64}$/, "Invalid SHA-256 Git OID (must be 64 lowercase hex characters)");
|
|
38873
|
+
var gitOidSchema = external_exports.string().regex(/^[0-9a-f]{40}$|^[0-9a-f]{64}$/, "Invalid Git OID (must be 40 or 64 lowercase hex characters)");
|
|
38874
|
+
var gitRefSchema = external_exports.string().regex(/^refs\/[a-zA-Z0-9_./-]+$/, "Must be a fully-qualified git ref (refs/...)");
|
|
38875
|
+
var issueLocalGitSettlementRequestSchema = external_exports.object({
|
|
38876
|
+
leaseId: external_exports.string().min(1),
|
|
38877
|
+
evidence: external_exports.object({
|
|
38878
|
+
artifactId: external_exports.string().min(1)
|
|
38879
|
+
}).strict()
|
|
38880
|
+
}).strict();
|
|
38881
|
+
var localGitSettlementLandingStateSchema = external_exports.enum(["receipt_issued", "landing_applied"]);
|
|
38882
|
+
var localGitSettlementLandingReceiptIssuedSchema = external_exports.object({
|
|
38883
|
+
receiptId: external_exports.string().uuid(),
|
|
38884
|
+
state: external_exports.literal("receipt_issued"),
|
|
38885
|
+
appliedAt: external_exports.null(),
|
|
38886
|
+
evidenceSource: external_exports.literal("client_reported")
|
|
38887
|
+
}).passthrough();
|
|
38888
|
+
var localGitSettlementLandingAppliedSchema = external_exports.object({
|
|
38889
|
+
receiptId: external_exports.string().uuid(),
|
|
38890
|
+
state: external_exports.literal("landing_applied"),
|
|
38891
|
+
appliedAt: external_exports.string().min(1),
|
|
38892
|
+
evidenceSource: external_exports.literal("client_reported")
|
|
38893
|
+
}).passthrough();
|
|
38894
|
+
var localGitSettlementLandingSchema = external_exports.discriminatedUnion("state", [
|
|
38895
|
+
localGitSettlementLandingReceiptIssuedSchema,
|
|
38896
|
+
localGitSettlementLandingAppliedSchema
|
|
38897
|
+
]);
|
|
38898
|
+
var gitSha1BindingSchema = external_exports.object({
|
|
38899
|
+
object_format: external_exports.literal("sha1"),
|
|
38900
|
+
source_base_oid: gitOidSha1Schema,
|
|
38901
|
+
base_oid: gitOidSha1Schema,
|
|
38902
|
+
head_oid: gitOidSha1Schema,
|
|
38903
|
+
target_ref: gitRefSchema,
|
|
38904
|
+
run_ref: gitRefSchema,
|
|
38905
|
+
checkout_digest: external_exports.string().min(1)
|
|
38906
|
+
}).passthrough();
|
|
38907
|
+
var gitSha256BindingSchema = external_exports.object({
|
|
38908
|
+
object_format: external_exports.literal("sha256"),
|
|
38909
|
+
source_base_oid: gitOidSha256Schema,
|
|
38910
|
+
base_oid: gitOidSha256Schema,
|
|
38911
|
+
head_oid: gitOidSha256Schema,
|
|
38912
|
+
target_ref: gitRefSchema,
|
|
38913
|
+
run_ref: gitRefSchema,
|
|
38914
|
+
checkout_digest: external_exports.string().min(1)
|
|
38915
|
+
}).passthrough();
|
|
38916
|
+
var gitBindingSchema = external_exports.discriminatedUnion("object_format", [
|
|
38917
|
+
gitSha1BindingSchema,
|
|
38918
|
+
gitSha256BindingSchema
|
|
38919
|
+
]);
|
|
38920
|
+
var localGitSettlementPayloadV2Schema = external_exports.object({
|
|
38921
|
+
type: external_exports.literal("mrrlin.local_git_settlement"),
|
|
38922
|
+
version: external_exports.literal(2),
|
|
38923
|
+
candidate_id: external_exports.string().uuid(),
|
|
38924
|
+
project_slug: external_exports.string().min(1),
|
|
38925
|
+
task_id: external_exports.string().min(1),
|
|
38926
|
+
run_id: external_exports.string().min(1),
|
|
38927
|
+
closure_generation: external_exports.number().int().positive(),
|
|
38928
|
+
outcome: external_exports.literal("completed"),
|
|
38929
|
+
nonce: external_exports.string().min(1),
|
|
38930
|
+
signing_key_id: external_exports.string().min(1),
|
|
38931
|
+
server_attested: external_exports.object({
|
|
38932
|
+
owner_login: external_exports.string().min(1),
|
|
38933
|
+
owner_credential_id: external_exports.string().min(1),
|
|
38934
|
+
lease_id: external_exports.string().min(1),
|
|
38935
|
+
prepared_at: external_exports.string(),
|
|
38936
|
+
canonical_request_digest: external_exports.string(),
|
|
38937
|
+
artifact_set_digest: external_exports.string(),
|
|
38938
|
+
declared_outcome_digest: external_exports.string(),
|
|
38939
|
+
artifacts: external_exports.array(external_exports.object({
|
|
38940
|
+
artifact_id: external_exports.string(),
|
|
38941
|
+
storage_version: external_exports.string(),
|
|
38942
|
+
content_hash: external_exports.string(),
|
|
38943
|
+
kind: external_exports.literal("verification")
|
|
38944
|
+
}).passthrough())
|
|
38945
|
+
}).passthrough(),
|
|
38946
|
+
client_reported: external_exports.object({
|
|
38947
|
+
git: gitBindingSchema,
|
|
38948
|
+
local_build_receipt: external_exports.record(external_exports.string(), external_exports.unknown())
|
|
38949
|
+
}).passthrough()
|
|
38950
|
+
}).passthrough();
|
|
38951
|
+
var settlementReceiptV2Schema = external_exports.object({
|
|
38952
|
+
receiptId: external_exports.string().uuid(),
|
|
38953
|
+
candidateId: external_exports.string().uuid(),
|
|
38954
|
+
projectSlug: external_exports.string().min(1),
|
|
38955
|
+
taskId: external_exports.string().min(1),
|
|
38956
|
+
runId: external_exports.string().min(1),
|
|
38957
|
+
closureGeneration: external_exports.number().int().positive(),
|
|
38958
|
+
outcome: external_exports.literal("completed"),
|
|
38959
|
+
signingKeyId: external_exports.string().min(1),
|
|
38960
|
+
signingKeyStatus: signingKeyStatusSchema.optional(),
|
|
38961
|
+
signature: external_exports.string().min(1),
|
|
38962
|
+
canonicalPayload: localGitSettlementPayloadV2Schema,
|
|
38963
|
+
finalizedAt: external_exports.string(),
|
|
38964
|
+
isIdempotent: external_exports.boolean().optional()
|
|
38965
|
+
}).passthrough();
|
|
38966
|
+
var localGitSettlementResponseSchema = external_exports.object({
|
|
38967
|
+
data: external_exports.object({
|
|
38968
|
+
state: localGitSettlementLandingStateSchema,
|
|
38969
|
+
receipt: settlementReceiptV2Schema,
|
|
38970
|
+
signingKey: external_exports.object({
|
|
38971
|
+
keyId: external_exports.string().min(1),
|
|
38972
|
+
publicKey: external_exports.string().min(1),
|
|
38973
|
+
status: signingKeyStatusSchema
|
|
38974
|
+
}).passthrough(),
|
|
38975
|
+
landing: localGitSettlementLandingSchema,
|
|
38976
|
+
isIdempotent: external_exports.boolean()
|
|
38977
|
+
}).passthrough()
|
|
38978
|
+
}).passthrough();
|
|
38979
|
+
var acknowledgeLocalGitLandingRequestSchema = external_exports.object({
|
|
38980
|
+
receiptId: external_exports.string().uuid(),
|
|
38981
|
+
baseOid: gitOidSchema,
|
|
38982
|
+
headOid: gitOidSchema,
|
|
38983
|
+
targetRef: gitRefSchema,
|
|
38984
|
+
checkoutDigest: external_exports.string().min(1)
|
|
38985
|
+
}).strict();
|
|
38986
|
+
var localGitSettlementLookupSchema = external_exports.union([
|
|
38987
|
+
external_exports.object({
|
|
38988
|
+
data: external_exports.object({
|
|
38989
|
+
state: external_exports.enum(["prepared", "expired", "superseded"]),
|
|
38990
|
+
candidateId: external_exports.string().uuid(),
|
|
38991
|
+
expiresAt: external_exports.string()
|
|
38992
|
+
}).passthrough()
|
|
38993
|
+
}).passthrough(),
|
|
38994
|
+
localGitSettlementResponseSchema
|
|
38995
|
+
]);
|
|
38996
|
+
|
|
38997
|
+
// ../../packages/schemas/dist/receipt-canonical.js
|
|
38998
|
+
function isWellFormedString(str) {
|
|
38999
|
+
if (typeof str.isWellFormed === "function") {
|
|
39000
|
+
return str.isWellFormed();
|
|
39001
|
+
}
|
|
39002
|
+
return !/(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(str);
|
|
39003
|
+
}
|
|
39004
|
+
function canonicalizeJson(value) {
|
|
39005
|
+
if (value === null || typeof value === "boolean") {
|
|
39006
|
+
return JSON.stringify(value);
|
|
39007
|
+
}
|
|
39008
|
+
if (typeof value === "string") {
|
|
39009
|
+
if (!isWellFormedString(value)) {
|
|
39010
|
+
throw new TypeError("canonicalizeJson: string contains lone surrogates");
|
|
39011
|
+
}
|
|
39012
|
+
return JSON.stringify(value);
|
|
39013
|
+
}
|
|
39014
|
+
if (typeof value === "number") {
|
|
39015
|
+
if (!Number.isFinite(value)) {
|
|
39016
|
+
throw new TypeError("canonicalizeJson: non-finite numbers are not permitted");
|
|
39017
|
+
}
|
|
39018
|
+
return JSON.stringify(value);
|
|
39019
|
+
}
|
|
39020
|
+
if (value === void 0) {
|
|
39021
|
+
throw new TypeError("canonicalizeJson: undefined is not permitted at root");
|
|
39022
|
+
}
|
|
39023
|
+
if (Array.isArray(value)) {
|
|
39024
|
+
const items = [];
|
|
39025
|
+
for (let i = 0; i < value.length; i++) {
|
|
39026
|
+
const item = value[i];
|
|
39027
|
+
if (item === void 0 || typeof item === "symbol" || typeof item === "function") {
|
|
39028
|
+
items.push("null");
|
|
39029
|
+
} else {
|
|
39030
|
+
items.push(canonicalizeJson(item));
|
|
39031
|
+
}
|
|
39032
|
+
}
|
|
39033
|
+
return "[" + items.join(",") + "]";
|
|
39034
|
+
}
|
|
39035
|
+
if (typeof value === "object") {
|
|
39036
|
+
const obj = value;
|
|
39037
|
+
const keys = Object.keys(obj).sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
39038
|
+
const entries = [];
|
|
39039
|
+
for (const k of keys) {
|
|
39040
|
+
if (!isWellFormedString(k)) {
|
|
39041
|
+
throw new TypeError("canonicalizeJson: property name contains lone surrogates");
|
|
39042
|
+
}
|
|
39043
|
+
const v = obj[k];
|
|
39044
|
+
if (v === void 0 || typeof v === "symbol" || typeof v === "function") {
|
|
39045
|
+
continue;
|
|
39046
|
+
}
|
|
39047
|
+
entries.push(JSON.stringify(k) + ":" + canonicalizeJson(v));
|
|
39048
|
+
}
|
|
39049
|
+
return "{" + entries.join(",") + "}";
|
|
39050
|
+
}
|
|
39051
|
+
throw new TypeError(`canonicalizeJson: unsupported type ${typeof value}`);
|
|
39052
|
+
}
|
|
38866
39053
|
|
|
38867
39054
|
// ../../packages/schemas/dist/report-auth.js
|
|
38868
39055
|
var encoder2 = new TextEncoder();
|
|
@@ -40006,6 +40193,8 @@ var mrrlinTaskSchema = external_exports.object({
|
|
|
40006
40193
|
tags: mrrlinTaskTagsSchema,
|
|
40007
40194
|
title: external_exports.string().min(1),
|
|
40008
40195
|
type: mrrlinTaskTypeSchema,
|
|
40196
|
+
closureGeneration: external_exports.number().int().nonnegative().optional(),
|
|
40197
|
+
terminalReceiptId: external_exports.string().nullable().optional(),
|
|
40009
40198
|
// Maintained by a BEFORE UPDATE trigger (set_tasks_updated_at). Output-optional (not
|
|
40010
40199
|
// defaulted-required) so hardcoded task fixtures/mocks need no churn; DB rows always carry it.
|
|
40011
40200
|
// The scheduler's spec-draft re-arm signal compares this against the newest failed draft job.
|
|
@@ -40845,7 +41034,7 @@ var mrrlinExecutionRunCreateSchema = external_exports.object({
|
|
|
40845
41034
|
actor: external_exports.string().min(1),
|
|
40846
41035
|
branch: external_exports.string().min(1).optional(),
|
|
40847
41036
|
baseSha: external_exports.string().min(1).optional(),
|
|
40848
|
-
codeExecution: external_exports.boolean().optional().default
|
|
41037
|
+
codeExecution: external_exports.boolean().optional().describe("Omit to use the task-derived default; false requests a non-writable run."),
|
|
40849
41038
|
devWorkflowId: external_exports.number().int().positive().optional(),
|
|
40850
41039
|
id: mrrlinExecutionRunIdSchema,
|
|
40851
41040
|
prerequisites: external_exports.array(mrrlinRunPrerequisiteSchema).default([]),
|
|
@@ -41993,7 +42182,7 @@ function createMrrlinClient(config2) {
|
|
|
41993
42182
|
}
|
|
41994
42183
|
});
|
|
41995
42184
|
}
|
|
41996
|
-
async function executeFetch(
|
|
42185
|
+
async function executeFetch(path39, init) {
|
|
41997
42186
|
const method = (init?.method ?? "GET").toUpperCase();
|
|
41998
42187
|
const dynamicHeaders = typeof config2.headers === "function" ? await config2.headers() : config2.headers;
|
|
41999
42188
|
const headers = new Headers(dynamicHeaders ?? {});
|
|
@@ -42004,7 +42193,7 @@ function createMrrlinClient(config2) {
|
|
|
42004
42193
|
if (token && !headers.has("authorization")) {
|
|
42005
42194
|
headers.set("authorization", `Bearer ${token}`);
|
|
42006
42195
|
}
|
|
42007
|
-
const url2 = `${baseUrl}${
|
|
42196
|
+
const url2 = `${baseUrl}${path39}`;
|
|
42008
42197
|
const isIdempotent = method === "GET" || method === "HEAD";
|
|
42009
42198
|
const maxAttempts = isIdempotent ? 3 : 1;
|
|
42010
42199
|
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
@@ -42040,13 +42229,13 @@ function createMrrlinClient(config2) {
|
|
|
42040
42229
|
throw err;
|
|
42041
42230
|
}
|
|
42042
42231
|
}
|
|
42043
|
-
throw new Error(`Failed to execute ${method} ${
|
|
42232
|
+
throw new Error(`Failed to execute ${method} ${path39}`);
|
|
42044
42233
|
}
|
|
42045
|
-
async function handleResponseError(response, method,
|
|
42234
|
+
async function handleResponseError(response, method, path39) {
|
|
42046
42235
|
const body = await response.text();
|
|
42047
42236
|
let code = `HTTP_${response.status}`;
|
|
42048
42237
|
let violations = null;
|
|
42049
|
-
let message = `Mrrlin API ${method} ${
|
|
42238
|
+
let message = `Mrrlin API ${method} ${path39} failed: ${response.status}`;
|
|
42050
42239
|
try {
|
|
42051
42240
|
const parsed = JSON.parse(body);
|
|
42052
42241
|
const violationsParsed = apiViolationsErrorSchema.safeParse(parsed);
|
|
@@ -42066,26 +42255,26 @@ function createMrrlinClient(config2) {
|
|
|
42066
42255
|
throw new MrrlinApiError({
|
|
42067
42256
|
code,
|
|
42068
42257
|
method,
|
|
42069
|
-
path:
|
|
42258
|
+
path: path39,
|
|
42070
42259
|
responseBody: body,
|
|
42071
42260
|
status: response.status,
|
|
42072
42261
|
violations,
|
|
42073
42262
|
message
|
|
42074
42263
|
});
|
|
42075
42264
|
}
|
|
42076
|
-
async function request(
|
|
42265
|
+
async function request(path39, init) {
|
|
42077
42266
|
const method = init?.method ?? "GET";
|
|
42078
|
-
const response = await executeFetch(
|
|
42267
|
+
const response = await executeFetch(path39, init);
|
|
42079
42268
|
if (!response.ok) {
|
|
42080
|
-
await handleResponseError(response, method,
|
|
42269
|
+
await handleResponseError(response, method, path39);
|
|
42081
42270
|
}
|
|
42082
42271
|
return response.json();
|
|
42083
42272
|
}
|
|
42084
|
-
async function requestText(
|
|
42273
|
+
async function requestText(path39, init) {
|
|
42085
42274
|
const method = init?.method ?? "GET";
|
|
42086
|
-
const response = await executeFetch(
|
|
42275
|
+
const response = await executeFetch(path39, init);
|
|
42087
42276
|
if (!response.ok) {
|
|
42088
|
-
await handleResponseError(response, method,
|
|
42277
|
+
await handleResponseError(response, method, path39);
|
|
42089
42278
|
}
|
|
42090
42279
|
return response.text();
|
|
42091
42280
|
}
|
|
@@ -42256,16 +42445,16 @@ function createMrrlinClient(config2) {
|
|
|
42256
42445
|
// rejected against the first, MrrlinTask[]-only overload) -- the `any` here is contained to
|
|
42257
42446
|
// this one implementation signature; MrrlinClient's declared overloads keep callers precise.
|
|
42258
42447
|
async listTasks(projectSlug, filters = {}, options) {
|
|
42259
|
-
const
|
|
42260
|
-
const body = await request(
|
|
42448
|
+
const path39 = buildTaskListPath(projectSlug, filters, options?.view);
|
|
42449
|
+
const body = await request(path39, options?.signal ? { signal: options.signal } : void 0);
|
|
42261
42450
|
if (options?.view === "summary") {
|
|
42262
42451
|
return taskSummaryListResponseSchema.parse(body).data;
|
|
42263
42452
|
}
|
|
42264
42453
|
return taskListResponseSchema.parse(body).data;
|
|
42265
42454
|
},
|
|
42266
42455
|
async listTaskSummaries(projectSlug, filters = {}, options) {
|
|
42267
|
-
const
|
|
42268
|
-
const body = await request(
|
|
42456
|
+
const path39 = buildTaskListPath(projectSlug, filters, "summary");
|
|
42457
|
+
const body = await request(path39, options?.signal ? { signal: options.signal } : void 0);
|
|
42269
42458
|
return taskSummaryListResponseSchema.parse(body).data;
|
|
42270
42459
|
},
|
|
42271
42460
|
async listTaxonomy(projectSlug) {
|
|
@@ -42274,7 +42463,7 @@ function createMrrlinClient(config2) {
|
|
|
42274
42463
|
},
|
|
42275
42464
|
async listWikiPages(projectSlug, filters = {}, options) {
|
|
42276
42465
|
const view = options?.view ?? filters.view;
|
|
42277
|
-
const
|
|
42466
|
+
const path39 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
|
|
42278
42467
|
folder: filters.folder,
|
|
42279
42468
|
id: filters.id,
|
|
42280
42469
|
limit: filters.limit === void 0 ? void 0 : String(filters.limit),
|
|
@@ -42282,20 +42471,20 @@ function createMrrlinClient(config2) {
|
|
|
42282
42471
|
taskId: filters.taskId,
|
|
42283
42472
|
view
|
|
42284
42473
|
});
|
|
42285
|
-
const body = await request(
|
|
42474
|
+
const body = await request(path39, options?.signal ? { signal: options.signal } : void 0);
|
|
42286
42475
|
if (view === "summary") {
|
|
42287
42476
|
return wikiPageSummaryListResponseSchema.parse(body).data;
|
|
42288
42477
|
}
|
|
42289
42478
|
return wikiPageListResponseSchema.parse(body).data;
|
|
42290
42479
|
},
|
|
42291
42480
|
async searchWikiPages(projectSlug, query) {
|
|
42292
|
-
const
|
|
42481
|
+
const path39 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
|
|
42293
42482
|
folder: query.folder,
|
|
42294
42483
|
limit: query.limit === void 0 ? void 0 : String(query.limit),
|
|
42295
42484
|
pathPrefix: query.pathPrefix,
|
|
42296
42485
|
q: query.q
|
|
42297
42486
|
});
|
|
42298
|
-
const body = await request(
|
|
42487
|
+
const body = await request(path39);
|
|
42299
42488
|
return wikiPageSearchResponseSchema.parse(body).data;
|
|
42300
42489
|
},
|
|
42301
42490
|
async updatePlan(projectSlug, planId, patch) {
|
|
@@ -43240,6 +43429,34 @@ function createMrrlinClient(config2) {
|
|
|
43240
43429
|
const body = await request("/.well-known/jwks.json");
|
|
43241
43430
|
return jwksResponseSchema.parse(body);
|
|
43242
43431
|
},
|
|
43432
|
+
async issueLocalGitSettlement(projectSlug, runId, input, options) {
|
|
43433
|
+
const body = await request(`${projectPath(projectSlug)}/execution-runs/${encodeURIComponent(runId)}/settlement`, {
|
|
43434
|
+
method: "POST",
|
|
43435
|
+
headers: {
|
|
43436
|
+
"content-type": "application/json",
|
|
43437
|
+
"idempotency-key": options.idempotencyKey
|
|
43438
|
+
},
|
|
43439
|
+
body: JSON.stringify(input)
|
|
43440
|
+
});
|
|
43441
|
+
return localGitSettlementResponseSchema.parse(body).data;
|
|
43442
|
+
},
|
|
43443
|
+
async getLocalGitSettlement(projectSlug, runId, idempotencyKey) {
|
|
43444
|
+
const body = await request(`${projectPath(projectSlug)}/execution-runs/${encodeURIComponent(runId)}/settlement?idempotencyKey=${encodeURIComponent(idempotencyKey)}`);
|
|
43445
|
+
return localGitSettlementLookupSchema.parse(body);
|
|
43446
|
+
},
|
|
43447
|
+
async acknowledgeLocalGitLanding(projectSlug, runId, input) {
|
|
43448
|
+
const body = await request(`${projectPath(projectSlug)}/execution-runs/${encodeURIComponent(runId)}/settlement/landing`, {
|
|
43449
|
+
method: "POST",
|
|
43450
|
+
headers: { "content-type": "application/json" },
|
|
43451
|
+
body: JSON.stringify(input)
|
|
43452
|
+
});
|
|
43453
|
+
return localGitSettlementLandingSchema.parse(body.data ?? body);
|
|
43454
|
+
},
|
|
43455
|
+
async listPendingLocalGitLandings(projectSlug, options) {
|
|
43456
|
+
const q = options?.limit ? `?limit=${encodeURIComponent(options.limit)}` : "";
|
|
43457
|
+
const body = await request(`${projectPath(projectSlug)}/settlement/pending-landings${q}`);
|
|
43458
|
+
return body.data ?? body;
|
|
43459
|
+
},
|
|
43243
43460
|
async issueCapabilityPermit(projectSlug, input) {
|
|
43244
43461
|
const body = await request(`${projectPath(projectSlug)}/capability-permits`, {
|
|
43245
43462
|
method: "POST",
|
|
@@ -60320,8 +60537,8 @@ async function findSessionDays(stateDir, sessionId) {
|
|
|
60320
60537
|
function isRecord5(v) {
|
|
60321
60538
|
return v !== null && typeof v === "object";
|
|
60322
60539
|
}
|
|
60323
|
-
function resolvePath(root,
|
|
60324
|
-
const parts =
|
|
60540
|
+
function resolvePath(root, path39) {
|
|
60541
|
+
const parts = path39.split(".");
|
|
60325
60542
|
let cur = root;
|
|
60326
60543
|
for (let i = 0; i < parts.length - 1; i += 1) {
|
|
60327
60544
|
const part = parts[i];
|
|
@@ -60389,9 +60606,9 @@ async function gate(artifact, prose, ctx) {
|
|
|
60389
60606
|
return { ok: true, gated: true, artifact: withheldExcerptClone(artifact) };
|
|
60390
60607
|
}
|
|
60391
60608
|
const maskedClone = typeof structuredClone === "function" ? structuredClone(artifact) : JSON.parse(JSON.stringify(artifact));
|
|
60392
|
-
for (const { path:
|
|
60393
|
-
const target = resolvePath(maskedClone,
|
|
60394
|
-
if (!target) throw new Error(`pii-gate: path "${
|
|
60609
|
+
for (const { path: path39, masked } of fields) {
|
|
60610
|
+
const target = resolvePath(maskedClone, path39);
|
|
60611
|
+
if (!target) throw new Error(`pii-gate: path "${path39}" failed to resolve on the clone after validating on the original`);
|
|
60395
60612
|
target.parent[target.key] = masked;
|
|
60396
60613
|
}
|
|
60397
60614
|
return { ok: true, gated: false, artifact: maskedClone };
|
|
@@ -60601,9 +60818,9 @@ var CheckoutRegistry = class {
|
|
|
60601
60818
|
get(slug) {
|
|
60602
60819
|
return this.read()[slug] ?? null;
|
|
60603
60820
|
}
|
|
60604
|
-
confirm(slug,
|
|
60821
|
+
confirm(slug, path39, now) {
|
|
60605
60822
|
const all = this.read();
|
|
60606
|
-
all[slug] = { path:
|
|
60823
|
+
all[slug] = { path: path39, confirmedAt: now };
|
|
60607
60824
|
(0, import_node_fs10.writeFileSync)(this.file, JSON.stringify(all, null, 2));
|
|
60608
60825
|
}
|
|
60609
60826
|
/**
|
|
@@ -61020,9 +61237,9 @@ function provisionNewProjectFolder(registry3, projectSlug, machineLabel, options
|
|
|
61020
61237
|
|
|
61021
61238
|
// src/local-apply.ts
|
|
61022
61239
|
var import_node_child_process16 = require("node:child_process");
|
|
61023
|
-
var
|
|
61024
|
-
var
|
|
61025
|
-
var
|
|
61240
|
+
var import_node_crypto17 = __toESM(require("node:crypto"), 1);
|
|
61241
|
+
var import_node_fs17 = require("node:fs");
|
|
61242
|
+
var import_node_path23 = __toESM(require("node:path"), 1);
|
|
61026
61243
|
|
|
61027
61244
|
// src/checkout-lock.ts
|
|
61028
61245
|
var import_node_crypto13 = require("node:crypto");
|
|
@@ -61088,7 +61305,7 @@ function emptyHooksDir() {
|
|
|
61088
61305
|
return noHooksDir;
|
|
61089
61306
|
}
|
|
61090
61307
|
function gitArgs(repo, args) {
|
|
61091
|
-
return ["-C", repo, "-c", `core.hooksPath=${emptyHooksDir()}`, ...args];
|
|
61308
|
+
return ["-C", repo, "-c", `core.hooksPath=${emptyHooksDir()}`, "-c", "submodule.recurse=false", ...args];
|
|
61092
61309
|
}
|
|
61093
61310
|
var STEP_ENV_NAMES = /* @__PURE__ */ new Set([
|
|
61094
61311
|
// user, shell, temp dirs, locale
|
|
@@ -61484,7 +61701,7 @@ function restoreRunBranch(input) {
|
|
|
61484
61701
|
}
|
|
61485
61702
|
abortIntegration({ worktreePath: input.worktreePath });
|
|
61486
61703
|
git(input.worktreePath, ["checkout", "-q", "-f", `mrrlin/run-${input.runId}`]);
|
|
61487
|
-
git(input.worktreePath, ["reset", "-q", "--hard"]);
|
|
61704
|
+
git(input.worktreePath, ["reset", "-q", "--no-recurse-submodules", "--hard"]);
|
|
61488
61705
|
git(input.worktreePath, ["clean", "-q", "-f", "-d"]);
|
|
61489
61706
|
return { restored: true, branchTip: input.preMergeHead };
|
|
61490
61707
|
}
|
|
@@ -61565,9 +61782,76 @@ function verifyIntegrationResolved(input) {
|
|
|
61565
61782
|
function applyLocalRun(input) {
|
|
61566
61783
|
const repo = input.checkoutRealPath;
|
|
61567
61784
|
const ref = `refs/heads/${input.defaultBranch}`;
|
|
61568
|
-
|
|
61569
|
-
|
|
61570
|
-
|
|
61785
|
+
if (input.runBranchGuard) {
|
|
61786
|
+
const guardRes = gitTry(repo, ["rev-parse", "-q", "--verify", input.runBranchGuard.ref]);
|
|
61787
|
+
if (guardRes.status !== 0 || guardRes.stdout.trim() !== input.runBranchGuard.sha) {
|
|
61788
|
+
return {
|
|
61789
|
+
applied: false,
|
|
61790
|
+
reason: "run_branch_changed",
|
|
61791
|
+
detail: `run branch ${input.runBranchGuard.ref} moved or missing: expected ${input.runBranchGuard.sha.slice(0, 12)}, got ${guardRes.stdout.trim().slice(0, 12)}`
|
|
61792
|
+
};
|
|
61793
|
+
}
|
|
61794
|
+
}
|
|
61795
|
+
const oldRes = gitTry(repo, ["rev-parse", "-q", "--verify", ref]);
|
|
61796
|
+
if (oldRes.status !== 0) {
|
|
61797
|
+
return {
|
|
61798
|
+
applied: false,
|
|
61799
|
+
reason: "landing_partial",
|
|
61800
|
+
detail: `rev-parse ${ref} failed: ${oldRes.stderr || oldRes.stdout}`
|
|
61801
|
+
};
|
|
61802
|
+
}
|
|
61803
|
+
const old = oldRes.stdout.trim();
|
|
61804
|
+
const isTargetAtHead = old === input.headSha;
|
|
61805
|
+
const isTargetAncestorOfOld = !isTargetAtHead && isAncestor(repo, input.headSha, old);
|
|
61806
|
+
if (isTargetAtHead || isTargetAncestorOfOld) {
|
|
61807
|
+
const holders2 = worktreesWithBranch(repo, input.defaultBranch);
|
|
61808
|
+
const headTreeRes = gitTry(repo, ["rev-parse", `${input.headSha}^{tree}`]);
|
|
61809
|
+
if (headTreeRes.status !== 0) {
|
|
61810
|
+
return { applied: false, reason: "landing_partial", detail: `rev-parse head tree failed: ${headTreeRes.stderr || headTreeRes.stdout}` };
|
|
61811
|
+
}
|
|
61812
|
+
const headTree = headTreeRes.stdout.trim();
|
|
61813
|
+
const targetTreeRes = isTargetAncestorOfOld ? gitTry(repo, ["rev-parse", `${old}^{tree}`]) : null;
|
|
61814
|
+
if (targetTreeRes && targetTreeRes.status !== 0) {
|
|
61815
|
+
return { applied: false, reason: "landing_partial", detail: `rev-parse target tree failed: ${targetTreeRes.stderr || targetTreeRes.stdout}` };
|
|
61816
|
+
}
|
|
61817
|
+
const targetTree = targetTreeRes ? targetTreeRes.stdout.trim() : null;
|
|
61818
|
+
const holderStates = [];
|
|
61819
|
+
for (const h of holders2) {
|
|
61820
|
+
const updateIndexRes = gitTry(h, ["update-index", "-q", "--refresh"]);
|
|
61821
|
+
if (updateIndexRes.status !== 0 && updateIndexRes.status !== 1) {
|
|
61822
|
+
return { applied: false, reason: "landing_partial", detail: `update-index failed on ${h}: ${updateIndexRes.stderr || updateIndexRes.stdout}` };
|
|
61823
|
+
}
|
|
61824
|
+
const diffFilesRes = gitTry(h, ["diff-files", "--name-only"]);
|
|
61825
|
+
if (diffFilesRes.status !== 0) {
|
|
61826
|
+
return { applied: false, reason: "landing_partial", detail: `diff-files failed on ${h}: ${diffFilesRes.stderr || diffFilesRes.stdout}` };
|
|
61827
|
+
}
|
|
61828
|
+
const unstaged = diffFilesRes.stdout.trim();
|
|
61829
|
+
const hHeadRes = gitTry(h, ["rev-parse", "-q", "--verify", "HEAD"]);
|
|
61830
|
+
if (hHeadRes.status !== 0) {
|
|
61831
|
+
return { applied: false, reason: "landing_partial", detail: `rev-parse HEAD failed on ${h}: ${hHeadRes.stderr || hHeadRes.stdout}` };
|
|
61832
|
+
}
|
|
61833
|
+
const hHead = hHeadRes.stdout.trim();
|
|
61834
|
+
const hTreeRes = gitTry(h, ["write-tree"]);
|
|
61835
|
+
if (hTreeRes.status !== 0) {
|
|
61836
|
+
return { applied: false, reason: "landing_partial", detail: `write-tree failed on ${h}: ${hTreeRes.stderr || hTreeRes.stdout}` };
|
|
61837
|
+
}
|
|
61838
|
+
const hTree = hTreeRes.stdout.trim();
|
|
61839
|
+
const isSynced = isTargetAtHead ? hHead === input.headSha && hTree === headTree && unstaged.length === 0 : hHead === old && hTree === targetTree && unstaged.length === 0;
|
|
61840
|
+
holderStates.push({ holder: h, hHead, hTree, unstaged, isSynced });
|
|
61841
|
+
}
|
|
61842
|
+
const unsynced = holderStates.find((s) => !s.isSynced);
|
|
61843
|
+
if (!unsynced) {
|
|
61844
|
+
return {
|
|
61845
|
+
applied: false,
|
|
61846
|
+
reason: "already_applied",
|
|
61847
|
+
detail: `${input.defaultBranch} at ${old.slice(0, 12)} already contains ${input.headSha.slice(0, 12)}`
|
|
61848
|
+
};
|
|
61849
|
+
}
|
|
61850
|
+
return {
|
|
61851
|
+
applied: false,
|
|
61852
|
+
reason: "landing_partial",
|
|
61853
|
+
detail: `target branch ${input.defaultBranch} contains ${input.headSha.slice(0, 12)} at ${old.slice(0, 12)}, but holder ${unsynced.holder} is not cleanly synchronized (HEAD=${unsynced.hHead.slice(0, 8)}, unstaged=${unsynced.unstaged.length > 0}); refusing automatic repair to preserve operator changes`
|
|
61854
|
+
};
|
|
61571
61855
|
}
|
|
61572
61856
|
if (input.expectedOldSha && old !== input.expectedOldSha) {
|
|
61573
61857
|
return {
|
|
@@ -61585,12 +61869,38 @@ function applyLocalRun(input) {
|
|
|
61585
61869
|
}
|
|
61586
61870
|
const holders = worktreesWithBranch(repo, input.defaultBranch);
|
|
61587
61871
|
for (const holder of holders) {
|
|
61588
|
-
gitTry(holder, ["update-index", "-q", "--refresh"]);
|
|
61589
|
-
|
|
61872
|
+
const uRes = gitTry(holder, ["update-index", "-q", "--refresh"]);
|
|
61873
|
+
if (uRes.status !== 0 && uRes.status !== 1) {
|
|
61874
|
+
return { applied: false, reason: "landing_partial", detail: `update-index failed on ${holder}: ${uRes.stderr || uRes.stdout}` };
|
|
61875
|
+
}
|
|
61876
|
+
const statusRes = gitTry(holder, ["status", "--porcelain", "--untracked-files=no"]);
|
|
61877
|
+
if (statusRes.status !== 0) {
|
|
61878
|
+
return { applied: false, reason: "landing_partial", detail: `status failed on ${holder}: ${statusRes.stderr || statusRes.stdout}` };
|
|
61879
|
+
}
|
|
61880
|
+
const dirty = statusRes.stdout.trim();
|
|
61590
61881
|
if (dirty.length > 0) {
|
|
61591
61882
|
return { applied: false, reason: "uncommitted_changes", detail: dirty };
|
|
61592
61883
|
}
|
|
61593
61884
|
}
|
|
61885
|
+
const holdersInfo = [];
|
|
61886
|
+
for (const holder of holders) {
|
|
61887
|
+
const wtRes = gitTry(holder, ["write-tree"]);
|
|
61888
|
+
if (wtRes.status !== 0) {
|
|
61889
|
+
return { applied: false, reason: "landing_partial", detail: `write-tree failed on ${holder}: ${wtRes.stderr || wtRes.stdout}` };
|
|
61890
|
+
}
|
|
61891
|
+
holdersInfo.push({
|
|
61892
|
+
path: holder,
|
|
61893
|
+
beforeIndexTree: wtRes.stdout.trim(),
|
|
61894
|
+
synced: false
|
|
61895
|
+
});
|
|
61896
|
+
}
|
|
61897
|
+
input.onLandingPrepared?.({
|
|
61898
|
+
baseOid: old,
|
|
61899
|
+
headOid: input.headSha,
|
|
61900
|
+
targetRef: ref,
|
|
61901
|
+
runRef: input.runBranchGuard?.ref ?? "",
|
|
61902
|
+
holders: holdersInfo
|
|
61903
|
+
});
|
|
61594
61904
|
input.beforeRefUpdate?.();
|
|
61595
61905
|
input.beforeRefTransaction?.();
|
|
61596
61906
|
const transaction = [
|
|
@@ -61623,6 +61933,7 @@ function applyLocalRun(input) {
|
|
|
61623
61933
|
return { applied: false, reason: "default_branch_moved", detail };
|
|
61624
61934
|
}
|
|
61625
61935
|
input.afterRefUpdate?.();
|
|
61936
|
+
input.onRefUpdated?.();
|
|
61626
61937
|
const updated = [];
|
|
61627
61938
|
for (const holder of holders) {
|
|
61628
61939
|
const moved = gitTry(holder, ["read-tree", "-m", "-u", old, input.headSha]);
|
|
@@ -61647,14 +61958,34 @@ function applyLocalRun(input) {
|
|
|
61647
61958
|
if (/overwritten/.test(detail)) return { applied: false, reason: "would_overwrite_files", detail };
|
|
61648
61959
|
return { applied: false, reason: "ff_failed", detail };
|
|
61649
61960
|
}
|
|
61961
|
+
const nowRefRes = gitTry(repo, ["rev-parse", "--verify", "-q", ref]);
|
|
61962
|
+
if (nowRefRes.status !== 0) {
|
|
61963
|
+
return {
|
|
61964
|
+
applied: false,
|
|
61965
|
+
reason: "landing_partial",
|
|
61966
|
+
detail: `rev-parse ${ref} failed after landing: ${nowRefRes.stderr || nowRefRes.stdout}`
|
|
61967
|
+
};
|
|
61968
|
+
}
|
|
61969
|
+
const nowRef = nowRefRes.stdout.trim();
|
|
61970
|
+
const headTreeExpectedRes = gitTry(repo, ["rev-parse", `${input.headSha}^{tree}`]);
|
|
61971
|
+
if (headTreeExpectedRes.status !== 0) {
|
|
61972
|
+
return {
|
|
61973
|
+
applied: false,
|
|
61974
|
+
reason: "landing_partial",
|
|
61975
|
+
detail: `rev-parse ${input.headSha}^{tree} failed after landing: ${headTreeExpectedRes.stderr || headTreeExpectedRes.stdout}`
|
|
61976
|
+
};
|
|
61977
|
+
}
|
|
61978
|
+
const expectedHeadTree = headTreeExpectedRes.stdout.trim();
|
|
61979
|
+
const off = [];
|
|
61980
|
+
for (const holder of holders) {
|
|
61981
|
+
const headRes = gitTry(holder, ["rev-parse", "HEAD"]);
|
|
61982
|
+
const writeTreeRes = gitTry(holder, ["write-tree"]);
|
|
61983
|
+
if (headRes.status !== 0 || writeTreeRes.status !== 0 || headRes.stdout.trim() !== input.headSha || writeTreeRes.stdout.trim() !== expectedHeadTree) {
|
|
61984
|
+
off.push(holder);
|
|
61985
|
+
}
|
|
61986
|
+
}
|
|
61650
61987
|
const known = new Set(holders.map((holder) => realpathOr(holder)));
|
|
61651
61988
|
const appeared = worktreesWithBranch(repo, input.defaultBranch).filter((holder) => !known.has(realpathOr(holder)));
|
|
61652
|
-
const nowRef = gitTry(repo, ["rev-parse", "--verify", "-q", ref]).stdout || "missing";
|
|
61653
|
-
const off = holders.filter((holder) => {
|
|
61654
|
-
const head = gitTry(holder, ["rev-parse", "HEAD"]).stdout;
|
|
61655
|
-
const indexTree = gitTry(holder, ["write-tree"]).stdout;
|
|
61656
|
-
return head !== input.headSha || indexTree !== gitTry(holder, ["rev-parse", `${input.headSha}^{tree}`]).stdout;
|
|
61657
|
-
});
|
|
61658
61989
|
if (nowRef !== input.headSha || off.length > 0 || appeared.length > 0) {
|
|
61659
61990
|
return {
|
|
61660
61991
|
applied: false,
|
|
@@ -61662,6 +61993,7 @@ function applyLocalRun(input) {
|
|
|
61662
61993
|
detail: `${ref} is at ${nowRef.slice(0, 12)} (was ${old.slice(0, 12)}, landing ${input.headSha.slice(0, 12)}); worktrees whose HEAD or index is not the landed commit: ${off.length > 0 ? off.join(", ") : "none"}; worktrees that started holding ${input.defaultBranch} during the landing: ${appeared.length > 0 ? appeared.join(", ") : "none"}`
|
|
61663
61994
|
};
|
|
61664
61995
|
}
|
|
61996
|
+
input.onFilesSynced?.();
|
|
61665
61997
|
return { applied: true, previousSha: old };
|
|
61666
61998
|
}
|
|
61667
61999
|
function realpathOr(target) {
|
|
@@ -61682,11 +62014,133 @@ function worktreesWithBranch(repo, branch) {
|
|
|
61682
62014
|
return holders;
|
|
61683
62015
|
}
|
|
61684
62016
|
|
|
62017
|
+
// src/delivery/settlement-journal.ts
|
|
62018
|
+
var import_node_fs15 = require("node:fs");
|
|
62019
|
+
var import_node_path21 = __toESM(require("node:path"), 1);
|
|
62020
|
+
var import_node_crypto15 = __toESM(require("node:crypto"), 1);
|
|
62021
|
+
function settlementJournalDir(stateDir, projectSlug, runId) {
|
|
62022
|
+
return import_node_path21.default.join(stateDir, "settlements", projectSlug, runId);
|
|
62023
|
+
}
|
|
62024
|
+
function settlementJournalPath(stateDir, projectSlug, runId, idempotencyKey) {
|
|
62025
|
+
return import_node_path21.default.join(settlementJournalDir(stateDir, projectSlug, runId), `${idempotencyKey}.json`);
|
|
62026
|
+
}
|
|
62027
|
+
function writeSettlementJournalSync(stateDir, journal) {
|
|
62028
|
+
const dir = settlementJournalDir(stateDir, journal.projectSlug, journal.runId);
|
|
62029
|
+
(0, import_node_fs15.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
62030
|
+
const finalPath = import_node_path21.default.join(dir, `${journal.idempotencyKey}.json`);
|
|
62031
|
+
const tempPath = import_node_path21.default.join(dir, `${journal.idempotencyKey}.tmp.${process.pid}.${Date.now()}.${import_node_crypto15.default.randomBytes(4).toString("hex")}`);
|
|
62032
|
+
const content = JSON.stringify(journal, null, 2);
|
|
62033
|
+
const fd = (0, import_node_fs15.openSync)(tempPath, "w", 384);
|
|
62034
|
+
try {
|
|
62035
|
+
(0, import_node_fs15.writeFileSync)(fd, content, "utf8");
|
|
62036
|
+
(0, import_node_fs15.fsyncSync)(fd);
|
|
62037
|
+
} finally {
|
|
62038
|
+
(0, import_node_fs15.closeSync)(fd);
|
|
62039
|
+
}
|
|
62040
|
+
(0, import_node_fs15.renameSync)(tempPath, finalPath);
|
|
62041
|
+
try {
|
|
62042
|
+
const dirFd = (0, import_node_fs15.openSync)(dir, "r");
|
|
62043
|
+
try {
|
|
62044
|
+
(0, import_node_fs15.fsyncSync)(dirFd);
|
|
62045
|
+
} finally {
|
|
62046
|
+
(0, import_node_fs15.closeSync)(dirFd);
|
|
62047
|
+
}
|
|
62048
|
+
} catch {
|
|
62049
|
+
}
|
|
62050
|
+
}
|
|
62051
|
+
function readSettlementJournalSync(stateDir, projectSlug, runId, idempotencyKey) {
|
|
62052
|
+
const filePath = settlementJournalPath(stateDir, projectSlug, runId, idempotencyKey);
|
|
62053
|
+
try {
|
|
62054
|
+
if (!(0, import_node_fs15.existsSync)(filePath)) return null;
|
|
62055
|
+
const raw = (0, import_node_fs15.readFileSync)(filePath, "utf8");
|
|
62056
|
+
const parsed = JSON.parse(raw);
|
|
62057
|
+
if (parsed.version !== 1 || parsed.projectSlug !== projectSlug || parsed.runId !== runId) {
|
|
62058
|
+
return null;
|
|
62059
|
+
}
|
|
62060
|
+
return parsed;
|
|
62061
|
+
} catch {
|
|
62062
|
+
return null;
|
|
62063
|
+
}
|
|
62064
|
+
}
|
|
62065
|
+
function findSettlementJournalsSync(stateDir, projectSlug, runId) {
|
|
62066
|
+
const dir = settlementJournalDir(stateDir, projectSlug, runId);
|
|
62067
|
+
try {
|
|
62068
|
+
if (!(0, import_node_fs15.existsSync)(dir)) return [];
|
|
62069
|
+
const entries = (0, import_node_fs15.readdirSync)(dir);
|
|
62070
|
+
const journals = [];
|
|
62071
|
+
for (const entry of entries) {
|
|
62072
|
+
if (!entry.endsWith(".json") || entry.includes(".tmp.")) continue;
|
|
62073
|
+
const key = entry.slice(0, -".json".length);
|
|
62074
|
+
const journal = readSettlementJournalSync(stateDir, projectSlug, runId, key);
|
|
62075
|
+
if (journal) journals.push(journal);
|
|
62076
|
+
}
|
|
62077
|
+
return journals;
|
|
62078
|
+
} catch {
|
|
62079
|
+
return [];
|
|
62080
|
+
}
|
|
62081
|
+
}
|
|
62082
|
+
function createSettlementJournal(params) {
|
|
62083
|
+
const stateDir = params.stateDir ?? resolveStateDir();
|
|
62084
|
+
const idempotencyKey = params.idempotencyKey ?? import_node_crypto15.default.randomUUID();
|
|
62085
|
+
const journal = {
|
|
62086
|
+
version: 1,
|
|
62087
|
+
projectSlug: params.projectSlug,
|
|
62088
|
+
taskId: params.taskId,
|
|
62089
|
+
runId: params.runId,
|
|
62090
|
+
idempotencyKey,
|
|
62091
|
+
artifactId: params.artifactId,
|
|
62092
|
+
leaseId: params.leaseId,
|
|
62093
|
+
phase: "request_pending",
|
|
62094
|
+
receipt: null,
|
|
62095
|
+
landing: null
|
|
62096
|
+
};
|
|
62097
|
+
writeSettlementJournalSync(stateDir, journal);
|
|
62098
|
+
return journal;
|
|
62099
|
+
}
|
|
62100
|
+
function updateSettlementJournalSync(stateDir, journal, updates) {
|
|
62101
|
+
const updated = {
|
|
62102
|
+
...journal,
|
|
62103
|
+
...updates,
|
|
62104
|
+
version: 1,
|
|
62105
|
+
projectSlug: journal.projectSlug,
|
|
62106
|
+
runId: journal.runId,
|
|
62107
|
+
idempotencyKey: journal.idempotencyKey
|
|
62108
|
+
};
|
|
62109
|
+
writeSettlementJournalSync(stateDir, updated);
|
|
62110
|
+
return updated;
|
|
62111
|
+
}
|
|
62112
|
+
function listPendingSettlementJournalsSync(stateDir, projectSlug) {
|
|
62113
|
+
const settlementsRoot = import_node_path21.default.join(stateDir, "settlements");
|
|
62114
|
+
if (!(0, import_node_fs15.existsSync)(settlementsRoot)) return [];
|
|
62115
|
+
const results = [];
|
|
62116
|
+
try {
|
|
62117
|
+
const projects = projectSlug ? [projectSlug] : (0, import_node_fs15.readdirSync)(settlementsRoot);
|
|
62118
|
+
for (const proj of projects) {
|
|
62119
|
+
const projDir = import_node_path21.default.join(settlementsRoot, proj);
|
|
62120
|
+
try {
|
|
62121
|
+
if (!(0, import_node_fs15.existsSync)(projDir)) continue;
|
|
62122
|
+
const runs = (0, import_node_fs15.readdirSync)(projDir);
|
|
62123
|
+
for (const r of runs) {
|
|
62124
|
+
const journals = findSettlementJournalsSync(stateDir, proj, r);
|
|
62125
|
+
for (const j of journals) {
|
|
62126
|
+
if (j.phase !== "complete") {
|
|
62127
|
+
results.push(j);
|
|
62128
|
+
}
|
|
62129
|
+
}
|
|
62130
|
+
}
|
|
62131
|
+
} catch {
|
|
62132
|
+
}
|
|
62133
|
+
}
|
|
62134
|
+
} catch {
|
|
62135
|
+
}
|
|
62136
|
+
return results;
|
|
62137
|
+
}
|
|
62138
|
+
|
|
61685
62139
|
// src/worktree.ts
|
|
61686
62140
|
var import_node_child_process14 = require("node:child_process");
|
|
61687
|
-
var
|
|
61688
|
-
var
|
|
61689
|
-
var
|
|
62141
|
+
var import_node_crypto16 = require("node:crypto");
|
|
62142
|
+
var import_node_fs16 = require("node:fs");
|
|
62143
|
+
var import_node_path22 = require("node:path");
|
|
61690
62144
|
var import_node_util3 = require("node:util");
|
|
61691
62145
|
function worktreeBranch(runId) {
|
|
61692
62146
|
return `mrrlin/run-${runId}`;
|
|
@@ -61694,26 +62148,26 @@ function worktreeBranch(runId) {
|
|
|
61694
62148
|
var defaultGitExec = (args, env) => (0, import_node_child_process14.execFileSync)("git", args, { encoding: "utf8", timeout: 3e4, env });
|
|
61695
62149
|
var execGitPush = (0, import_node_util3.promisify)(import_node_child_process14.execFile);
|
|
61696
62150
|
function disabledGitHooksPath(locksDir, scope) {
|
|
61697
|
-
const scopeKey = (0,
|
|
61698
|
-
return (0,
|
|
62151
|
+
const scopeKey = (0, import_node_crypto16.createHash)("sha256").update(scope).digest("hex").slice(0, 32);
|
|
62152
|
+
return (0, import_node_path22.resolve)(locksDir, "..", "disabled-git-hooks", scopeKey);
|
|
61699
62153
|
}
|
|
61700
62154
|
function prepareDisabledGitHooksDir(locksDir, scope) {
|
|
61701
62155
|
const hooksDir = disabledGitHooksPath(locksDir, scope);
|
|
61702
|
-
const hooksRoot = (0,
|
|
61703
|
-
(0,
|
|
61704
|
-
(0,
|
|
61705
|
-
if ((0,
|
|
62156
|
+
const hooksRoot = (0, import_node_path22.resolve)(hooksDir, "..");
|
|
62157
|
+
(0, import_node_fs16.mkdirSync)(hooksRoot, { recursive: true, mode: 448 });
|
|
62158
|
+
(0, import_node_fs16.mkdirSync)(hooksDir, { recursive: true, mode: 320 });
|
|
62159
|
+
if ((0, import_node_fs16.readdirSync)(hooksDir).length > 0) {
|
|
61706
62160
|
throw new Error(`disabled_git_hooks_dir_not_empty: ${hooksDir}`);
|
|
61707
62161
|
}
|
|
61708
62162
|
try {
|
|
61709
|
-
(0,
|
|
62163
|
+
(0, import_node_fs16.chmodSync)(hooksDir, 320);
|
|
61710
62164
|
} catch {
|
|
61711
62165
|
}
|
|
61712
62166
|
return hooksDir;
|
|
61713
62167
|
}
|
|
61714
62168
|
function removeDisabledGitHooksDir(locksDir, scope) {
|
|
61715
62169
|
try {
|
|
61716
|
-
(0,
|
|
62170
|
+
(0, import_node_fs16.rmdirSync)(disabledGitHooksPath(locksDir, scope));
|
|
61717
62171
|
} catch {
|
|
61718
62172
|
}
|
|
61719
62173
|
}
|
|
@@ -61736,14 +62190,14 @@ function git2(checkout, args, hooksDir, baseEnv = process.env) {
|
|
|
61736
62190
|
});
|
|
61737
62191
|
}
|
|
61738
62192
|
async function createRunWorktree(opts) {
|
|
61739
|
-
const worktreePath = (0,
|
|
62193
|
+
const worktreePath = (0, import_node_path22.join)(opts.worktreeRoot, opts.slug, opts.runId);
|
|
61740
62194
|
const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, opts.runId);
|
|
61741
62195
|
await withCheckoutLock(opts.locksDir, opts.slug, async () => {
|
|
61742
|
-
(0,
|
|
62196
|
+
(0, import_node_fs16.mkdirSync)(opts.worktreeRoot, { recursive: true });
|
|
61743
62197
|
const base = opts.local ? `refs/heads/${opts.defaultBranch}` : `origin/${opts.defaultBranch}`;
|
|
61744
62198
|
try {
|
|
61745
62199
|
if (!opts.local) git2(opts.checkout, ["fetch", "origin", opts.defaultBranch], hooksDir);
|
|
61746
|
-
if (!(0,
|
|
62200
|
+
if (!(0, import_node_fs16.existsSync)(worktreePath)) {
|
|
61747
62201
|
git2(opts.checkout, [
|
|
61748
62202
|
"worktree",
|
|
61749
62203
|
"add",
|
|
@@ -61764,16 +62218,16 @@ async function createRunWorktree(opts) {
|
|
|
61764
62218
|
return worktreePath;
|
|
61765
62219
|
}
|
|
61766
62220
|
async function openRunWorktree(opts) {
|
|
61767
|
-
const worktreePath = (0,
|
|
62221
|
+
const worktreePath = (0, import_node_path22.join)(opts.worktreeRoot, opts.slug, opts.runId);
|
|
61768
62222
|
const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, opts.runId);
|
|
61769
62223
|
const branch = worktreeBranch(opts.runId);
|
|
61770
62224
|
const env = buildLocalStepEnv();
|
|
61771
62225
|
await withCheckoutLock(opts.locksDir, opts.slug, async () => {
|
|
61772
|
-
if ((0,
|
|
61773
|
-
const real = (0,
|
|
62226
|
+
if ((0, import_node_fs16.existsSync)(worktreePath)) {
|
|
62227
|
+
const real = (0, import_node_fs16.realpathSync)(worktreePath);
|
|
61774
62228
|
const listed = git2(opts.checkout, ["worktree", "list", "--porcelain"], hooksDir, env).split(/\n\s*\n/).map((block) => block.split("\n")).find((lines2) => {
|
|
61775
62229
|
const listedPath = lines2.find((line) => line.startsWith("worktree "))?.slice("worktree ".length);
|
|
61776
|
-
return listedPath !== void 0 && (0,
|
|
62230
|
+
return listedPath !== void 0 && (0, import_node_fs16.existsSync)(listedPath) && (0, import_node_fs16.realpathSync)(listedPath) === real;
|
|
61777
62231
|
});
|
|
61778
62232
|
if (!listed) {
|
|
61779
62233
|
throw new Error(`run_worktree_invalid: ${worktreePath} exists but is not a worktree of ${opts.checkout}`);
|
|
@@ -61788,21 +62242,21 @@ async function openRunWorktree(opts) {
|
|
|
61788
62242
|
} catch {
|
|
61789
62243
|
throw new Error(`run_branch_missing: ${opts.checkout} has no branch ${branch}`);
|
|
61790
62244
|
}
|
|
61791
|
-
(0,
|
|
62245
|
+
(0, import_node_fs16.mkdirSync)(opts.worktreeRoot, { recursive: true });
|
|
61792
62246
|
git2(opts.checkout, ["worktree", "prune"], hooksDir, env);
|
|
61793
62247
|
git2(opts.checkout, ["worktree", "add", worktreePath, branch], hooksDir, env);
|
|
61794
62248
|
});
|
|
61795
62249
|
return worktreePath;
|
|
61796
62250
|
}
|
|
61797
62251
|
async function removeRunWorktree(opts) {
|
|
61798
|
-
const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, (0,
|
|
62252
|
+
const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, (0, import_node_path22.basename)(opts.worktreePath));
|
|
61799
62253
|
await withCheckoutLock(opts.locksDir, opts.slug, async () => {
|
|
61800
62254
|
try {
|
|
61801
62255
|
git2(opts.checkout, ["worktree", "remove", "--force", opts.worktreePath], hooksDir);
|
|
61802
62256
|
} catch {
|
|
61803
62257
|
}
|
|
61804
62258
|
git2(opts.checkout, ["worktree", "prune"], hooksDir);
|
|
61805
|
-
removeDisabledGitHooksDir(opts.locksDir, (0,
|
|
62259
|
+
removeDisabledGitHooksDir(opts.locksDir, (0, import_node_path22.basename)(opts.worktreePath));
|
|
61806
62260
|
});
|
|
61807
62261
|
}
|
|
61808
62262
|
async function pushRunBranch(opts, execGit = defaultGitExec) {
|
|
@@ -61924,11 +62378,11 @@ async function sweepOrphanWorktrees(opts) {
|
|
|
61924
62378
|
const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, `sweep:${opts.slug}`);
|
|
61925
62379
|
const ownedPrefix = (() => {
|
|
61926
62380
|
try {
|
|
61927
|
-
return (
|
|
62381
|
+
return (import_node_fs16.realpathSync.native ?? import_node_fs16.realpathSync)(opts.worktreeRoot);
|
|
61928
62382
|
} catch {
|
|
61929
62383
|
return opts.worktreeRoot;
|
|
61930
62384
|
}
|
|
61931
|
-
})() +
|
|
62385
|
+
})() + import_node_path22.sep + opts.slug + import_node_path22.sep;
|
|
61932
62386
|
try {
|
|
61933
62387
|
await withCheckoutLock(opts.locksDir, opts.slug, async () => {
|
|
61934
62388
|
const listing = git2(opts.checkout, ["worktree", "list", "--porcelain"], hooksDir);
|
|
@@ -61938,18 +62392,18 @@ async function sweepOrphanWorktrees(opts) {
|
|
|
61938
62392
|
if (!wt) continue;
|
|
61939
62393
|
const canonicalWt = (() => {
|
|
61940
62394
|
try {
|
|
61941
|
-
return (
|
|
62395
|
+
return (import_node_fs16.realpathSync.native ?? import_node_fs16.realpathSync)(wt);
|
|
61942
62396
|
} catch {
|
|
61943
62397
|
return wt;
|
|
61944
62398
|
}
|
|
61945
62399
|
})();
|
|
61946
|
-
const normWt = (0,
|
|
61947
|
-
const normPrefix = (0,
|
|
62400
|
+
const normWt = (0, import_node_path22.normalize)(canonicalWt);
|
|
62401
|
+
const normPrefix = (0, import_node_path22.normalize)(ownedPrefix);
|
|
61948
62402
|
const isMatch = process.platform === "win32" ? normWt.toLowerCase().startsWith(normPrefix.toLowerCase()) : normWt.startsWith(normPrefix);
|
|
61949
62403
|
if (isMatch && opts.isReapable(wt)) {
|
|
61950
62404
|
try {
|
|
61951
62405
|
git2(opts.checkout, ["worktree", "remove", "--force", wt], hooksDir);
|
|
61952
|
-
removeDisabledGitHooksDir(opts.locksDir, (0,
|
|
62406
|
+
removeDisabledGitHooksDir(opts.locksDir, (0, import_node_path22.basename)(wt));
|
|
61953
62407
|
reaped.push(wt);
|
|
61954
62408
|
} catch {
|
|
61955
62409
|
}
|
|
@@ -62086,9 +62540,24 @@ function renderUnlandedWork(branches, base) {
|
|
|
62086
62540
|
}
|
|
62087
62541
|
|
|
62088
62542
|
// src/local-apply.ts
|
|
62543
|
+
function verifyReceiptSignature(payload, signatureBase64, publicKeyBase64) {
|
|
62544
|
+
try {
|
|
62545
|
+
const bytes3 = Buffer.from(canonicalizeJson(payload), "utf8");
|
|
62546
|
+
const sigBuffer = Buffer.from(signatureBase64, "base64");
|
|
62547
|
+
const isUrl = publicKeyBase64.includes("-") || publicKeyBase64.includes("_");
|
|
62548
|
+
let keyBuffer = Buffer.from(publicKeyBase64, isUrl ? "base64url" : "base64");
|
|
62549
|
+
if (keyBuffer.length === 32) {
|
|
62550
|
+
keyBuffer = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), keyBuffer]);
|
|
62551
|
+
}
|
|
62552
|
+
const pubKey = import_node_crypto17.default.createPublicKey({ key: keyBuffer, format: "der", type: "spki" });
|
|
62553
|
+
return import_node_crypto17.default.verify(null, bytes3, pubKey, sigBuffer);
|
|
62554
|
+
} catch {
|
|
62555
|
+
return false;
|
|
62556
|
+
}
|
|
62557
|
+
}
|
|
62089
62558
|
function readIntegratedTip(localEvidenceDir, runId) {
|
|
62090
62559
|
try {
|
|
62091
|
-
const evidence = JSON.parse((0,
|
|
62560
|
+
const evidence = JSON.parse((0, import_node_fs17.readFileSync)(import_node_path23.default.join(localEvidenceDir, `${runId}.json`), "utf8"));
|
|
62092
62561
|
return typeof evidence.integration?.defaultTipSha === "string" ? evidence.integration.defaultTipSha : null;
|
|
62093
62562
|
} catch {
|
|
62094
62563
|
return null;
|
|
@@ -62111,12 +62580,12 @@ function gitRead(cwd, args) {
|
|
|
62111
62580
|
}
|
|
62112
62581
|
function isBridgeRunWorktree(worktreePath, checkout, worktreeRoot) {
|
|
62113
62582
|
const real = (target) => {
|
|
62114
|
-
const resolved = (
|
|
62583
|
+
const resolved = (import_node_fs17.realpathSync.native ?? import_node_fs17.realpathSync)(target);
|
|
62115
62584
|
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
62116
62585
|
};
|
|
62117
62586
|
try {
|
|
62118
62587
|
const own = real(worktreePath);
|
|
62119
|
-
return own !== real(checkout) && own.startsWith(`${real(worktreeRoot)}${
|
|
62588
|
+
return own !== real(checkout) && own.startsWith(`${real(worktreeRoot)}${import_node_path23.default.sep}`);
|
|
62120
62589
|
} catch {
|
|
62121
62590
|
return false;
|
|
62122
62591
|
}
|
|
@@ -62159,7 +62628,7 @@ async function fileLocalLandingNote(client, projectSlug, outcome, ctx) {
|
|
|
62159
62628
|
);
|
|
62160
62629
|
await client.createInboxItem(projectSlug, { id: note.id, kind: "info", taskId: ctx.taskId, body: note.body }).catch(logFailure("inbox_note"));
|
|
62161
62630
|
await client.appendExecutionArtifact(projectSlug, ctx.runId, {
|
|
62162
|
-
id: `EA-${
|
|
62631
|
+
id: `EA-${import_node_crypto17.default.randomUUID()}`,
|
|
62163
62632
|
kind: "checkpoint",
|
|
62164
62633
|
payload: {
|
|
62165
62634
|
event: "local_apply",
|
|
@@ -62351,9 +62820,9 @@ async function applyLocalRunForTool(deps, input) {
|
|
|
62351
62820
|
})
|
|
62352
62821
|
);
|
|
62353
62822
|
const record2 = (extra) => {
|
|
62354
|
-
(0,
|
|
62355
|
-
(0,
|
|
62356
|
-
|
|
62823
|
+
(0, import_node_fs17.mkdirSync)(deps.localEvidenceDir, { recursive: true, mode: 448 });
|
|
62824
|
+
(0, import_node_fs17.writeFileSync)(
|
|
62825
|
+
import_node_path23.default.join(deps.localEvidenceDir, `${runId}.apply.json`),
|
|
62357
62826
|
JSON.stringify({ checkout, defaultBranch, ...extra }, null, 2),
|
|
62358
62827
|
{ mode: 384 }
|
|
62359
62828
|
);
|
|
@@ -62395,7 +62864,7 @@ async function applyLocalRunForTool(deps, input) {
|
|
|
62395
62864
|
"Gemfile.lock",
|
|
62396
62865
|
"poetry.lock"
|
|
62397
62866
|
]);
|
|
62398
|
-
const isLockfile = (file2) => LOCKFILE_NAMES.has(
|
|
62867
|
+
const isLockfile = (file2) => LOCKFILE_NAMES.has(import_node_path23.default.basename(file2));
|
|
62399
62868
|
const nonLockfiles = changedByBuild.filter((f) => !isLockfile(f));
|
|
62400
62869
|
const lockfilesChanged = changedByBuild.filter((f) => isLockfile(f));
|
|
62401
62870
|
if (lockfilesChanged.length > 0) {
|
|
@@ -62437,11 +62906,174 @@ async function applyLocalRunForTool(deps, input) {
|
|
|
62437
62906
|
deliveryLockKey(checkout),
|
|
62438
62907
|
async () => {
|
|
62439
62908
|
if (!runBranchStillSigned()) return branchChanged();
|
|
62909
|
+
const serverDeclaredV2 = Boolean(
|
|
62910
|
+
task.terminalReceiptId || task.closureGeneration !== null && task.closureGeneration !== void 0 && task.closureGeneration >= 1
|
|
62911
|
+
);
|
|
62912
|
+
const stateDir = resolveStateDir();
|
|
62913
|
+
const journals = findSettlementJournalsSync(stateDir, projectSlug, runId);
|
|
62914
|
+
const v2Journal = journals.find((j) => j.receipt !== null);
|
|
62915
|
+
const idempotencyKey = v2Journal?.idempotencyKey ?? journals[0]?.idempotencyKey;
|
|
62916
|
+
let serverSettlement = null;
|
|
62917
|
+
if (deps.client.getLocalGitSettlement && idempotencyKey) {
|
|
62918
|
+
try {
|
|
62919
|
+
serverSettlement = await deps.client.getLocalGitSettlement(projectSlug, runId, idempotencyKey);
|
|
62920
|
+
} catch (error51) {
|
|
62921
|
+
const lookupErr = error51;
|
|
62922
|
+
if (serverDeclaredV2 || v2Journal) {
|
|
62923
|
+
return {
|
|
62924
|
+
outcome: "build_failed",
|
|
62925
|
+
previousSha: null,
|
|
62926
|
+
headSha: delivered.headSha,
|
|
62927
|
+
detail: `Failed to fetch authoritative server settlement: ${lookupErr?.message ?? String(lookupErr)}`
|
|
62928
|
+
};
|
|
62929
|
+
}
|
|
62930
|
+
}
|
|
62931
|
+
}
|
|
62932
|
+
const v2Response = serverSettlement && "data" in serverSettlement && "receipt" in serverSettlement.data ? serverSettlement.data : null;
|
|
62933
|
+
const isV2 = Boolean(serverDeclaredV2 || v2Journal || v2Response);
|
|
62934
|
+
let verifiedReceipt = null;
|
|
62935
|
+
if (isV2) {
|
|
62936
|
+
let receipt = v2Response?.receipt ?? v2Journal?.receipt;
|
|
62937
|
+
if (!receipt && task.terminalReceiptId && deps.client.getSettlementReceipt) {
|
|
62938
|
+
try {
|
|
62939
|
+
receipt = await deps.client.getSettlementReceipt(projectSlug, task.terminalReceiptId);
|
|
62940
|
+
} catch (error51) {
|
|
62941
|
+
const fetchErr = error51;
|
|
62942
|
+
return {
|
|
62943
|
+
outcome: "build_failed",
|
|
62944
|
+
previousSha: null,
|
|
62945
|
+
headSha: delivered.headSha,
|
|
62946
|
+
detail: `Failed to fetch terminal settlement receipt ${task.terminalReceiptId}: ${fetchErr?.message ?? String(fetchErr)}`
|
|
62947
|
+
};
|
|
62948
|
+
}
|
|
62949
|
+
}
|
|
62950
|
+
if (!receipt) {
|
|
62951
|
+
return {
|
|
62952
|
+
outcome: "build_failed",
|
|
62953
|
+
previousSha: null,
|
|
62954
|
+
headSha: delivered.headSha,
|
|
62955
|
+
detail: "Missing authoritative V2 settlement receipt for verified landing"
|
|
62956
|
+
};
|
|
62957
|
+
}
|
|
62958
|
+
const targetKeyId = receipt.signingKeyId ?? receipt.signing_key_id;
|
|
62959
|
+
let publicKey = null;
|
|
62960
|
+
if (deps.client.getJwks) {
|
|
62961
|
+
let jwks;
|
|
62962
|
+
try {
|
|
62963
|
+
jwks = await deps.client.getJwks();
|
|
62964
|
+
} catch (error51) {
|
|
62965
|
+
const err = error51;
|
|
62966
|
+
return {
|
|
62967
|
+
outcome: "build_failed",
|
|
62968
|
+
previousSha: null,
|
|
62969
|
+
headSha: delivered.headSha,
|
|
62970
|
+
detail: `Failed to fetch authoritative JWKS public key registry: ${err?.message ?? String(err)}`
|
|
62971
|
+
};
|
|
62972
|
+
}
|
|
62973
|
+
const found = jwks?.keys?.find((k) => k.kid === targetKeyId);
|
|
62974
|
+
if (!found?.x) {
|
|
62975
|
+
return {
|
|
62976
|
+
outcome: "build_failed",
|
|
62977
|
+
previousSha: null,
|
|
62978
|
+
headSha: delivered.headSha,
|
|
62979
|
+
detail: `Signing key ${targetKeyId ?? "unknown"} is not published in JWKS (omitted, expired, or compromised)`
|
|
62980
|
+
};
|
|
62981
|
+
}
|
|
62982
|
+
publicKey = found.x;
|
|
62983
|
+
} else if (v2Response?.signingKey) {
|
|
62984
|
+
const respKey = v2Response.signingKey;
|
|
62985
|
+
if (respKey.keyId === targetKeyId) {
|
|
62986
|
+
if (respKey.status === "compromised") {
|
|
62987
|
+
return {
|
|
62988
|
+
outcome: "build_failed",
|
|
62989
|
+
previousSha: null,
|
|
62990
|
+
headSha: delivered.headSha,
|
|
62991
|
+
detail: `Signing key ${respKey.keyId} is compromised`
|
|
62992
|
+
};
|
|
62993
|
+
}
|
|
62994
|
+
if (respKey.status === "active" || respKey.status === "retired") {
|
|
62995
|
+
publicKey = respKey.publicKey;
|
|
62996
|
+
}
|
|
62997
|
+
}
|
|
62998
|
+
}
|
|
62999
|
+
if (!publicKey) {
|
|
63000
|
+
return {
|
|
63001
|
+
outcome: "build_failed",
|
|
63002
|
+
previousSha: null,
|
|
63003
|
+
headSha: delivered.headSha,
|
|
63004
|
+
detail: `Signing key ${targetKeyId ?? "unknown"} is not recognized, expired, or compromised (must be active or retired)`
|
|
63005
|
+
};
|
|
63006
|
+
}
|
|
63007
|
+
const canonicalPayload = receipt.canonicalPayload ?? receipt.payload;
|
|
63008
|
+
if (!canonicalPayload || !receipt.signature || !verifyReceiptSignature(canonicalPayload, receipt.signature, publicKey)) {
|
|
63009
|
+
return { outcome: "build_failed", previousSha: null, headSha: delivered.headSha, detail: "Invalid V2 receipt signature" };
|
|
63010
|
+
}
|
|
63011
|
+
const git3 = canonicalPayload?.client_reported?.git;
|
|
63012
|
+
if (!git3) {
|
|
63013
|
+
return { outcome: "build_failed", previousSha: null, headSha: delivered.headSha, detail: "Missing signed git binding in receipt" };
|
|
63014
|
+
}
|
|
63015
|
+
if (git3.head_oid !== delivered.headSha) {
|
|
63016
|
+
return { outcome: "build_failed", previousSha: null, headSha: delivered.headSha, detail: `Delivered head ${delivered.headSha} does not match receipt head_oid ${git3.head_oid}` };
|
|
63017
|
+
}
|
|
63018
|
+
if (git3.target_ref !== `refs/heads/${defaultBranch}`) {
|
|
63019
|
+
return { outcome: "build_failed", previousSha: null, headSha: delivered.headSha, detail: `Target ref refs/heads/${defaultBranch} does not match receipt target_ref ${git3.target_ref}` };
|
|
63020
|
+
}
|
|
63021
|
+
if (git3.base_oid !== expectedTip) {
|
|
63022
|
+
return { outcome: "default_branch_moved", previousSha: null, headSha: delivered.headSha, detail: `Expected tip ${expectedTip} does not match receipt base_oid ${git3.base_oid}` };
|
|
63023
|
+
}
|
|
63024
|
+
const expectedRunRef = `refs/heads/${worktreeBranch(runId)}`;
|
|
63025
|
+
if (git3.run_ref !== expectedRunRef) {
|
|
63026
|
+
return { outcome: "build_failed", previousSha: null, headSha: delivered.headSha, detail: `Run ref ${expectedRunRef} does not match receipt run_ref ${git3.run_ref}` };
|
|
63027
|
+
}
|
|
63028
|
+
const currentCheckoutDigest = import_node_crypto17.default.createHash("sha256").update(checkout).digest("hex");
|
|
63029
|
+
if (git3.checkout_digest && git3.checkout_digest !== currentCheckoutDigest) {
|
|
63030
|
+
return { outcome: "build_failed", previousSha: null, headSha: delivered.headSha, detail: `Checkout digest ${currentCheckoutDigest} does not match receipt checkout_digest ${git3.checkout_digest}` };
|
|
63031
|
+
}
|
|
63032
|
+
verifiedReceipt = receipt;
|
|
63033
|
+
}
|
|
62440
63034
|
const first = await land(delivered.headSha, expectedTip);
|
|
62441
|
-
if (first.applied
|
|
63035
|
+
if (first.applied || isV2 && first.reason === "already_applied") {
|
|
63036
|
+
if (isV2) {
|
|
63037
|
+
const receiptToAck = verifiedReceipt ?? v2Response?.receipt ?? v2Journal?.receipt;
|
|
63038
|
+
const canonicalPayload = receiptToAck?.canonicalPayload ?? receiptToAck?.payload;
|
|
63039
|
+
const git3 = canonicalPayload?.client_reported?.git;
|
|
63040
|
+
if (git3 && receiptToAck && deps.client.acknowledgeLocalGitLanding) {
|
|
63041
|
+
try {
|
|
63042
|
+
await deps.client.acknowledgeLocalGitLanding(projectSlug, runId, {
|
|
63043
|
+
receiptId: receiptToAck.receiptId,
|
|
63044
|
+
headOid: git3.head_oid,
|
|
63045
|
+
baseOid: git3.base_oid,
|
|
63046
|
+
targetRef: git3.target_ref,
|
|
63047
|
+
checkoutDigest: git3.checkout_digest
|
|
63048
|
+
});
|
|
63049
|
+
if (v2Journal) {
|
|
63050
|
+
updateSettlementJournalSync(stateDir, v2Journal, { phase: "complete" });
|
|
63051
|
+
}
|
|
63052
|
+
} catch (ackError) {
|
|
63053
|
+
if (v2Journal) {
|
|
63054
|
+
updateSettlementJournalSync(stateDir, v2Journal, { phase: "ack_pending" });
|
|
63055
|
+
}
|
|
63056
|
+
process.stderr.write(
|
|
63057
|
+
`[mrrlin-mcp local-apply] failed to acknowledge local git landing for ${projectSlug}/${runId}: ${ackError instanceof Error ? ackError.message : String(ackError)}
|
|
63058
|
+
`
|
|
63059
|
+
);
|
|
63060
|
+
}
|
|
63061
|
+
} else if (v2Journal) {
|
|
63062
|
+
updateSettlementJournalSync(stateDir, v2Journal, { phase: "complete" });
|
|
63063
|
+
}
|
|
63064
|
+
}
|
|
63065
|
+
if (first.applied) {
|
|
63066
|
+
return { outcome: "applied", previousSha: first.previousSha, headSha: delivered.headSha, detail: "" };
|
|
63067
|
+
} else {
|
|
63068
|
+
return { outcome: "already_applied", previousSha: null, headSha: delivered.headSha, detail: first.detail };
|
|
63069
|
+
}
|
|
63070
|
+
}
|
|
62442
63071
|
if (first.reason !== "default_branch_moved") {
|
|
62443
63072
|
return { outcome: first.reason, previousSha: null, headSha: delivered.headSha, detail: first.detail };
|
|
62444
63073
|
}
|
|
63074
|
+
if (isV2) {
|
|
63075
|
+
return { outcome: "default_branch_moved", previousSha: null, headSha: delivered.headSha, detail: first.detail };
|
|
63076
|
+
}
|
|
62445
63077
|
const worktreePath = await openRunWorktree({
|
|
62446
63078
|
checkout,
|
|
62447
63079
|
worktreeRoot: deps.worktreeRoot,
|
|
@@ -62493,8 +63125,8 @@ async function applyLocalRunForTool(deps, input) {
|
|
|
62493
63125
|
{ name: DELIVERY_LOCK_NAME, maxWaitMs: DELIVERY_LOCK_MAX_WAIT_MS }
|
|
62494
63126
|
);
|
|
62495
63127
|
if (landing.outcome === "applied" || landing.outcome === "already_applied") {
|
|
62496
|
-
const worktreePath =
|
|
62497
|
-
if ((0,
|
|
63128
|
+
const worktreePath = import_node_path23.default.join(deps.worktreeRoot, projectSlug, runId);
|
|
63129
|
+
if ((0, import_node_fs17.existsSync)(worktreePath)) {
|
|
62498
63130
|
await removeRunWorktree({ checkout, worktreePath, locksDir: deps.locksDir, slug: projectSlug }).catch(() => {
|
|
62499
63131
|
});
|
|
62500
63132
|
}
|
|
@@ -62535,19 +63167,19 @@ async function applyLocalRunForTool(deps, input) {
|
|
|
62535
63167
|
}
|
|
62536
63168
|
|
|
62537
63169
|
// src/operator-token.ts
|
|
62538
|
-
var
|
|
63170
|
+
var import_node_fs18 = require("node:fs");
|
|
62539
63171
|
var import_node_os11 = __toESM(require("node:os"), 1);
|
|
62540
|
-
var
|
|
63172
|
+
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
62541
63173
|
function operatorDir() {
|
|
62542
|
-
const base = process.env.CODEX_HOME ?
|
|
63174
|
+
const base = process.env.CODEX_HOME ? import_node_path24.default.join(process.env.CODEX_HOME, "mrrlin") : import_node_path24.default.join(import_node_os11.default.homedir(), ".mrrlin");
|
|
62543
63175
|
return base;
|
|
62544
63176
|
}
|
|
62545
63177
|
function operatorTokenPath() {
|
|
62546
|
-
return
|
|
63178
|
+
return import_node_path24.default.join(operatorDir(), "operator-token");
|
|
62547
63179
|
}
|
|
62548
63180
|
function readOperatorToken() {
|
|
62549
63181
|
try {
|
|
62550
|
-
const token = (0,
|
|
63182
|
+
const token = (0, import_node_fs18.readFileSync)(operatorTokenPath(), "utf8").trim();
|
|
62551
63183
|
return token.length > 0 ? token : null;
|
|
62552
63184
|
} catch {
|
|
62553
63185
|
return null;
|
|
@@ -62555,24 +63187,24 @@ function readOperatorToken() {
|
|
|
62555
63187
|
}
|
|
62556
63188
|
function persistOperatorToken(token) {
|
|
62557
63189
|
const dir = operatorDir();
|
|
62558
|
-
(0,
|
|
62559
|
-
(0,
|
|
63190
|
+
(0, import_node_fs18.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
63191
|
+
(0, import_node_fs18.writeFileSync)(operatorTokenPath(), `${token.trim()}
|
|
62560
63192
|
`, { encoding: "utf8", mode: 384 });
|
|
62561
63193
|
}
|
|
62562
63194
|
function agentCredentialPath() {
|
|
62563
|
-
return
|
|
63195
|
+
return import_node_path24.default.join(operatorDir(), "agent-credential");
|
|
62564
63196
|
}
|
|
62565
63197
|
function persistAgentSecret(secret) {
|
|
62566
63198
|
const dir = operatorDir();
|
|
62567
|
-
(0,
|
|
62568
|
-
(0,
|
|
63199
|
+
(0, import_node_fs18.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
63200
|
+
(0, import_node_fs18.writeFileSync)(agentCredentialPath(), `${secret.trim()}
|
|
62569
63201
|
`, { encoding: "utf8", mode: 384 });
|
|
62570
63202
|
}
|
|
62571
63203
|
function readAgentSecret() {
|
|
62572
63204
|
const fromEnv = process.env.MRRLIN_AGENT_SECRET?.trim();
|
|
62573
63205
|
if (fromEnv) return fromEnv;
|
|
62574
63206
|
try {
|
|
62575
|
-
const raw = (0,
|
|
63207
|
+
const raw = (0, import_node_fs18.readFileSync)(agentCredentialPath(), "utf8").trim();
|
|
62576
63208
|
return raw || void 0;
|
|
62577
63209
|
} catch {
|
|
62578
63210
|
return void 0;
|
|
@@ -62580,10 +63212,10 @@ function readAgentSecret() {
|
|
|
62580
63212
|
}
|
|
62581
63213
|
|
|
62582
63214
|
// src/worker-token.ts
|
|
62583
|
-
var
|
|
62584
|
-
var
|
|
63215
|
+
var import_node_crypto18 = require("node:crypto");
|
|
63216
|
+
var import_node_fs19 = require("node:fs");
|
|
62585
63217
|
var import_node_os12 = __toESM(require("node:os"), 1);
|
|
62586
|
-
var
|
|
63218
|
+
var import_node_path25 = __toESM(require("node:path"), 1);
|
|
62587
63219
|
var DEFAULT_WORKER_PORT = 8792;
|
|
62588
63220
|
function workerPort() {
|
|
62589
63221
|
const raw = process.env.MRRLIN_WORKER_PORT;
|
|
@@ -62592,15 +63224,15 @@ function workerPort() {
|
|
|
62592
63224
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_WORKER_PORT;
|
|
62593
63225
|
}
|
|
62594
63226
|
function workerDir() {
|
|
62595
|
-
const base = process.env.CODEX_HOME ?
|
|
62596
|
-
return
|
|
63227
|
+
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");
|
|
63228
|
+
return import_node_path25.default.join(base, "worker");
|
|
62597
63229
|
}
|
|
62598
63230
|
function workerTokenPath() {
|
|
62599
|
-
return
|
|
63231
|
+
return import_node_path25.default.join(workerDir(), "token");
|
|
62600
63232
|
}
|
|
62601
63233
|
function readWorkerToken() {
|
|
62602
63234
|
try {
|
|
62603
|
-
const token = (0,
|
|
63235
|
+
const token = (0, import_node_fs19.readFileSync)(workerTokenPath(), "utf8").trim();
|
|
62604
63236
|
return token.length > 0 ? token : null;
|
|
62605
63237
|
} catch {
|
|
62606
63238
|
return null;
|
|
@@ -62610,9 +63242,9 @@ function readOrCreateWorkerToken() {
|
|
|
62610
63242
|
const existing = readWorkerToken();
|
|
62611
63243
|
if (existing) return existing;
|
|
62612
63244
|
const dir = workerDir();
|
|
62613
|
-
(0,
|
|
62614
|
-
const token = (0,
|
|
62615
|
-
(0,
|
|
63245
|
+
(0, import_node_fs19.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
63246
|
+
const token = (0, import_node_crypto18.randomBytes)(32).toString("hex");
|
|
63247
|
+
(0, import_node_fs19.writeFileSync)(workerTokenPath(), `${token}
|
|
62616
63248
|
`, { encoding: "utf8", mode: 384 });
|
|
62617
63249
|
return token;
|
|
62618
63250
|
}
|
|
@@ -64476,7 +65108,7 @@ function createMrrlinTools(options) {
|
|
|
64476
65108
|
async (c, { projectSlug, ...input }) => {
|
|
64477
65109
|
await checkTenantBoundary(projectSlug, "execution run");
|
|
64478
65110
|
const run3 = await c.createExecutionRun(projectSlug, input);
|
|
64479
|
-
pingWorkerDispatch(projectSlug, run3.id);
|
|
65111
|
+
(options.dispatchExecutionRun ?? pingWorkerDispatch)(projectSlug, run3.id);
|
|
64480
65112
|
return run3;
|
|
64481
65113
|
}
|
|
64482
65114
|
),
|
|
@@ -64545,7 +65177,7 @@ function createMrrlinTools(options) {
|
|
|
64545
65177
|
"Unable to record produced URL.",
|
|
64546
65178
|
async (c, { projectSlug, runId, url: url2, label }) => {
|
|
64547
65179
|
await checkTenantBoundary(projectSlug, "produced url");
|
|
64548
|
-
const id = `EA-pu-${(0,
|
|
65180
|
+
const id = `EA-pu-${(0, import_node_crypto19.randomBytes)(4).toString("hex")}`;
|
|
64549
65181
|
const payload = label ? { url: url2, label } : { url: url2 };
|
|
64550
65182
|
return await c.appendExecutionArtifact(projectSlug, runId, {
|
|
64551
65183
|
id,
|
|
@@ -64632,7 +65264,7 @@ function createMrrlinTools(options) {
|
|
|
64632
65264
|
"Unable to upload artifact file.",
|
|
64633
65265
|
async (c, { projectSlug, path: filePath, class: artifactClass, taskId, runId, description }) => {
|
|
64634
65266
|
await checkTenantBoundary(projectSlug, "artifact upload");
|
|
64635
|
-
const extension2 =
|
|
65267
|
+
const extension2 = import_node_path26.default.extname(filePath).toLowerCase();
|
|
64636
65268
|
const contentType2 = ARTIFACT_EXTENSION_TYPES[extension2];
|
|
64637
65269
|
if (!contentType2) {
|
|
64638
65270
|
throw new McpToolCodedError(
|
|
@@ -64660,7 +65292,7 @@ function createMrrlinTools(options) {
|
|
|
64660
65292
|
"Artifact exceeds 5MB; split or summarize instead."
|
|
64661
65293
|
);
|
|
64662
65294
|
}
|
|
64663
|
-
const filename =
|
|
65295
|
+
const filename = import_node_path26.default.basename(filePath);
|
|
64664
65296
|
return deliverBuiltIn(
|
|
64665
65297
|
c,
|
|
64666
65298
|
projectSlug,
|
|
@@ -64683,7 +65315,7 @@ function createMrrlinTools(options) {
|
|
|
64683
65315
|
`Invalid filename '${filename}'; provide a bare filename with no path separators or '..'.`
|
|
64684
65316
|
);
|
|
64685
65317
|
}
|
|
64686
|
-
const extension2 =
|
|
65318
|
+
const extension2 = import_node_path26.default.extname(filename).toLowerCase();
|
|
64687
65319
|
const contentType2 = ARTIFACT_EXTENSION_TYPES[extension2];
|
|
64688
65320
|
if (!contentType2) {
|
|
64689
65321
|
throw new McpToolCodedError(
|
|
@@ -64826,9 +65458,9 @@ function createMrrlinTools(options) {
|
|
|
64826
65458
|
{
|
|
64827
65459
|
client: c,
|
|
64828
65460
|
registry: new CheckoutRegistry(stateDir),
|
|
64829
|
-
locksDir:
|
|
64830
|
-
worktreeRoot:
|
|
64831
|
-
localEvidenceDir:
|
|
65461
|
+
locksDir: import_node_path26.default.join(stateDir, "locks"),
|
|
65462
|
+
worktreeRoot: import_node_path26.default.join(stateDir, "worktrees"),
|
|
65463
|
+
localEvidenceDir: import_node_path26.default.join(stateDir, "local-evidence")
|
|
64832
65464
|
},
|
|
64833
65465
|
{ projectSlug, runId }
|
|
64834
65466
|
);
|
|
@@ -64971,20 +65603,20 @@ function allAgyGrantStrings() {
|
|
|
64971
65603
|
}
|
|
64972
65604
|
function resolveAgyConfigPath(options) {
|
|
64973
65605
|
if (options.agyConfigPath) return options.agyConfigPath;
|
|
64974
|
-
return
|
|
65606
|
+
return import_node_path27.default.join(options.homeDir ?? import_node_os14.default.homedir(), ".gemini", "config", "mcp_config.json");
|
|
64975
65607
|
}
|
|
64976
65608
|
function resolveConfigJsonPath(options) {
|
|
64977
65609
|
if (options.configJsonPath) return options.configJsonPath;
|
|
64978
|
-
return
|
|
65610
|
+
return import_node_path27.default.join(options.homeDir ?? import_node_os14.default.homedir(), ".gemini", "config", "config.json");
|
|
64979
65611
|
}
|
|
64980
65612
|
async function detectInstallDistribution3(options) {
|
|
64981
65613
|
if (options.distribution && options.distribution !== "auto") return options.distribution;
|
|
64982
|
-
let current2 =
|
|
65614
|
+
let current2 = import_node_path27.default.dirname(options.binPath);
|
|
64983
65615
|
while (true) {
|
|
64984
|
-
if (await pathExists4(
|
|
65616
|
+
if (await pathExists4(import_node_path27.default.join(current2, "pnpm-workspace.yaml"))) {
|
|
64985
65617
|
return "local";
|
|
64986
65618
|
}
|
|
64987
|
-
const parent =
|
|
65619
|
+
const parent = import_node_path27.default.dirname(current2);
|
|
64988
65620
|
if (parent === current2) break;
|
|
64989
65621
|
current2 = parent;
|
|
64990
65622
|
}
|
|
@@ -65021,8 +65653,8 @@ async function installAgy(options) {
|
|
|
65021
65653
|
const configJsonPath = resolveConfigJsonPath(options);
|
|
65022
65654
|
const distribution = await detectInstallDistribution3(options);
|
|
65023
65655
|
const entries = managedEntries2(options, distribution);
|
|
65024
|
-
await import_promises11.default.mkdir(
|
|
65025
|
-
await import_promises11.default.mkdir(
|
|
65656
|
+
await import_promises11.default.mkdir(import_node_path27.default.dirname(configPath), { recursive: true });
|
|
65657
|
+
await import_promises11.default.mkdir(import_node_path27.default.dirname(configJsonPath), { recursive: true });
|
|
65026
65658
|
let action = "noop";
|
|
65027
65659
|
const preservedEnvBlocks = [];
|
|
65028
65660
|
if (!await pathExists4(configPath)) {
|
|
@@ -65138,9 +65770,9 @@ async function installAgy(options) {
|
|
|
65138
65770
|
|
|
65139
65771
|
// src/provider-readiness.ts
|
|
65140
65772
|
var import_promises12 = require("node:fs/promises");
|
|
65141
|
-
var
|
|
65773
|
+
var import_node_fs20 = require("node:fs");
|
|
65142
65774
|
var import_node_os15 = __toESM(require("node:os"), 1);
|
|
65143
|
-
var
|
|
65775
|
+
var import_node_path28 = __toESM(require("node:path"), 1);
|
|
65144
65776
|
var import_semver2 = __toESM(require_semver2(), 1);
|
|
65145
65777
|
var toml3 = __toESM(require_toml(), 1);
|
|
65146
65778
|
|
|
@@ -65231,13 +65863,13 @@ function startCodexProbe(deps = {}) {
|
|
|
65231
65863
|
// src/provider-readiness.ts
|
|
65232
65864
|
function resolveCodexHome2(opts) {
|
|
65233
65865
|
if (opts.codexHome) return opts.codexHome;
|
|
65234
|
-
if (opts.homeDir) return
|
|
65866
|
+
if (opts.homeDir) return import_node_path28.default.join(opts.homeDir, ".codex");
|
|
65235
65867
|
if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
|
|
65236
|
-
return
|
|
65868
|
+
return import_node_path28.default.join(import_node_os15.default.homedir(), ".codex");
|
|
65237
65869
|
}
|
|
65238
65870
|
function resolveClaudeConfigPath2(opts) {
|
|
65239
65871
|
if (opts.claudeConfigPath) return opts.claudeConfigPath;
|
|
65240
|
-
return
|
|
65872
|
+
return import_node_path28.default.join(opts.homeDir ?? import_node_os15.default.homedir(), ".claude.json");
|
|
65241
65873
|
}
|
|
65242
65874
|
async function verifyProviderReadiness(provider, run3, opts = {}) {
|
|
65243
65875
|
if (provider === "agy") {
|
|
@@ -65298,9 +65930,9 @@ async function verifyProviderReadiness(provider, run3, opts = {}) {
|
|
|
65298
65930
|
if (!checks.version) details.push(`version: ${version2 ?? "unparseable"} is below the required 2.1.232`);
|
|
65299
65931
|
}
|
|
65300
65932
|
if (provider === "codex") {
|
|
65301
|
-
const authPath =
|
|
65933
|
+
const authPath = import_node_path28.default.join(resolveCodexHome2(opts), "auth.json");
|
|
65302
65934
|
try {
|
|
65303
|
-
await (0, import_promises12.access)(authPath,
|
|
65935
|
+
await (0, import_promises12.access)(authPath, import_node_fs20.constants.F_OK);
|
|
65304
65936
|
checks.auth = true;
|
|
65305
65937
|
} catch {
|
|
65306
65938
|
details.push(`auth: ${authPath} not found`);
|
|
@@ -65315,7 +65947,7 @@ async function verifyProviderReadiness(provider, run3, opts = {}) {
|
|
|
65315
65947
|
if (!checks.auth) details.push("auth: `claude auth status` failed");
|
|
65316
65948
|
}
|
|
65317
65949
|
if (provider === "codex") {
|
|
65318
|
-
const configPath =
|
|
65950
|
+
const configPath = import_node_path28.default.join(resolveCodexHome2(opts), "config.toml");
|
|
65319
65951
|
try {
|
|
65320
65952
|
const raw = await (0, import_promises12.readFile)(configPath, "utf8");
|
|
65321
65953
|
const parsed = toml3.parse(raw);
|
|
@@ -65596,21 +66228,21 @@ async function runBrowserServeProxy(opts) {
|
|
|
65596
66228
|
}
|
|
65597
66229
|
|
|
65598
66230
|
// src/director-bridge.ts
|
|
65599
|
-
var
|
|
66231
|
+
var import_node_fs33 = __toESM(require("node:fs"), 1);
|
|
65600
66232
|
|
|
65601
66233
|
// src/executor-thread-instructions.ts
|
|
65602
|
-
var
|
|
65603
|
-
var
|
|
65604
|
-
var
|
|
66234
|
+
var import_node_crypto20 = require("node:crypto");
|
|
66235
|
+
var import_node_fs21 = require("node:fs");
|
|
66236
|
+
var import_node_path29 = require("node:path");
|
|
65605
66237
|
function instructionHash(instructions) {
|
|
65606
|
-
return (0,
|
|
66238
|
+
return (0, import_node_crypto20.createHash)("sha256").update(instructions ?? "").digest("hex").slice(0, 16);
|
|
65607
66239
|
}
|
|
65608
66240
|
var MAX_ENTRIES = 1e4;
|
|
65609
|
-
function createExecutorThreadInstructionStore(
|
|
66241
|
+
function createExecutorThreadInstructionStore(path39, warn = (message) => process.stderr.write(`${message}
|
|
65610
66242
|
`)) {
|
|
65611
66243
|
const load = () => {
|
|
65612
66244
|
try {
|
|
65613
|
-
const parsed = JSON.parse((0,
|
|
66245
|
+
const parsed = JSON.parse((0, import_node_fs21.readFileSync)(path39, "utf8"));
|
|
65614
66246
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
65615
66247
|
const out = {};
|
|
65616
66248
|
for (const [key, value] of Object.entries(parsed)) {
|
|
@@ -65640,15 +66272,15 @@ function createExecutorThreadInstructionStore(path38, warn = (message) => proces
|
|
|
65640
66272
|
ordered.delete(threadId);
|
|
65641
66273
|
ordered.set(threadId, hash3);
|
|
65642
66274
|
const kept = [...ordered].slice(Math.max(0, ordered.size - MAX_ENTRIES));
|
|
65643
|
-
(0,
|
|
65644
|
-
const tmp = `${
|
|
65645
|
-
(0,
|
|
65646
|
-
(0,
|
|
66275
|
+
(0, import_node_fs21.mkdirSync)((0, import_node_path29.dirname)(path39), { recursive: true });
|
|
66276
|
+
const tmp = `${path39}.${process.pid}.tmp`;
|
|
66277
|
+
(0, import_node_fs21.writeFileSync)(tmp, JSON.stringify(Object.fromEntries(kept)), { mode: 384 });
|
|
66278
|
+
(0, import_node_fs21.renameSync)(tmp, path39);
|
|
65647
66279
|
} catch (error51) {
|
|
65648
66280
|
if (!warned) {
|
|
65649
66281
|
warned = true;
|
|
65650
66282
|
warn(
|
|
65651
|
-
`[mrrlin-mcp director-bridge] executor_thread_instructions_write_failed ${
|
|
66283
|
+
`[mrrlin-mcp director-bridge] executor_thread_instructions_write_failed ${path39}: ${error51 instanceof Error ? error51.message : String(error51)} (kept in memory for this session)`
|
|
65652
66284
|
);
|
|
65653
66285
|
}
|
|
65654
66286
|
}
|
|
@@ -65659,9 +66291,9 @@ function createExecutorThreadInstructionStore(path38, warn = (message) => proces
|
|
|
65659
66291
|
// src/director-bridge.ts
|
|
65660
66292
|
var import_node_http4 = __toESM(require("node:http"), 1);
|
|
65661
66293
|
var import_node_os23 = __toESM(require("node:os"), 1);
|
|
65662
|
-
var
|
|
66294
|
+
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
65663
66295
|
var import_node_child_process25 = require("node:child_process");
|
|
65664
|
-
var
|
|
66296
|
+
var import_node_crypto28 = __toESM(require("node:crypto"), 1);
|
|
65665
66297
|
|
|
65666
66298
|
// src/turn-replay-buffer.ts
|
|
65667
66299
|
var DEFAULT_MAX_EVENTS = 2e3;
|
|
@@ -66206,16 +66838,16 @@ function createTurnLock() {
|
|
|
66206
66838
|
|
|
66207
66839
|
// src/self-update.ts
|
|
66208
66840
|
var import_node_child_process20 = require("node:child_process");
|
|
66209
|
-
var
|
|
66210
|
-
var
|
|
66211
|
-
var
|
|
66841
|
+
var import_node_crypto21 = require("node:crypto");
|
|
66842
|
+
var import_node_fs23 = require("node:fs");
|
|
66843
|
+
var import_node_path31 = __toESM(require("node:path"), 1);
|
|
66212
66844
|
var import_semver3 = __toESM(require_semver2(), 1);
|
|
66213
66845
|
|
|
66214
66846
|
// src/codex-auth-preflight.ts
|
|
66215
66847
|
var import_node_child_process19 = require("node:child_process");
|
|
66216
|
-
var
|
|
66848
|
+
var import_node_fs22 = require("node:fs");
|
|
66217
66849
|
var import_node_os17 = __toESM(require("node:os"), 1);
|
|
66218
|
-
var
|
|
66850
|
+
var import_node_path30 = __toESM(require("node:path"), 1);
|
|
66219
66851
|
var DEFAULT_CODEX_AUTH_MIN_TTL_SECONDS = 15 * 60;
|
|
66220
66852
|
var DEFAULT_CODEX_AUTH_SMOKE_TIMEOUT_MS = 2e4;
|
|
66221
66853
|
var DEFAULT_CODEX_AUTH_SMOKE_MODEL = "gpt-5.4-mini";
|
|
@@ -66234,7 +66866,7 @@ function codexAuthSmokeTimeoutMs(env = process.env) {
|
|
|
66234
66866
|
function resolveCodexAuthPath(opts = {}) {
|
|
66235
66867
|
const env = opts.env ?? process.env;
|
|
66236
66868
|
const codexHome = env.CODEX_HOME?.trim();
|
|
66237
|
-
return
|
|
66869
|
+
return import_node_path30.default.join(codexHome || import_node_path30.default.join(opts.homeDir ?? import_node_os17.default.homedir(), ".codex"), "auth.json");
|
|
66238
66870
|
}
|
|
66239
66871
|
function decodeJwtExpMs(token) {
|
|
66240
66872
|
const parts = token.split(".");
|
|
@@ -66355,7 +66987,7 @@ function inspectCodexAuthForBridgeUpdate(opts = {}) {
|
|
|
66355
66987
|
const nowMs = opts.nowMs ?? Date.now();
|
|
66356
66988
|
const minTtlSeconds = opts.minTtlSeconds ?? codexAuthMinTtlSeconds(env);
|
|
66357
66989
|
const authPath = resolveCodexAuthPath({ env, homeDir: opts.homeDir });
|
|
66358
|
-
const readFile10 = opts.readFileSyncImpl ?? ((p, encoding) => (0,
|
|
66990
|
+
const readFile10 = opts.readFileSyncImpl ?? ((p, encoding) => (0, import_node_fs22.readFileSync)(p, encoding));
|
|
66359
66991
|
let raw;
|
|
66360
66992
|
try {
|
|
66361
66993
|
raw = readFile10(authPath, "utf8");
|
|
@@ -66469,7 +67101,7 @@ function inspectCodexAuthForBridgeUpdate(opts = {}) {
|
|
|
66469
67101
|
var BIN_NAME = "mrrlin-mcp";
|
|
66470
67102
|
var SELF_UPDATE_AUTH_PREFLIGHT_OFFER_PREFIX = "[bridge:update:auth-preflight]";
|
|
66471
67103
|
function resolveBinPath(opts) {
|
|
66472
|
-
if (opts.argv1 &&
|
|
67104
|
+
if (opts.argv1 && import_node_path31.default.basename(opts.argv1).includes("mrrlin")) {
|
|
66473
67105
|
return { path: opts.argv1, source: "argv" };
|
|
66474
67106
|
}
|
|
66475
67107
|
const whichSync = opts.whichSync ?? ((name) => {
|
|
@@ -66479,16 +67111,16 @@ function resolveBinPath(opts) {
|
|
|
66479
67111
|
return null;
|
|
66480
67112
|
}
|
|
66481
67113
|
});
|
|
66482
|
-
const
|
|
67114
|
+
const existsSync8 = opts.existsSync ?? import_node_fs23.existsSync;
|
|
66483
67115
|
const resolved = whichSync(BIN_NAME);
|
|
66484
|
-
if (resolved &&
|
|
67116
|
+
if (resolved && existsSync8(resolved)) {
|
|
66485
67117
|
return { path: resolved, source: "which" };
|
|
66486
67118
|
}
|
|
66487
67119
|
const envPath = (opts.env ?? process.env).PATH ?? "";
|
|
66488
|
-
for (const dir of envPath.split(
|
|
67120
|
+
for (const dir of envPath.split(import_node_path31.default.delimiter)) {
|
|
66489
67121
|
if (!dir) continue;
|
|
66490
|
-
const candidate =
|
|
66491
|
-
if (
|
|
67122
|
+
const candidate = import_node_path31.default.join(dir, BIN_NAME);
|
|
67123
|
+
if (existsSync8(candidate)) {
|
|
66492
67124
|
return { path: candidate, source: "path-walk" };
|
|
66493
67125
|
}
|
|
66494
67126
|
}
|
|
@@ -66514,12 +67146,12 @@ function readIntervalEnv(name, fallback) {
|
|
|
66514
67146
|
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
66515
67147
|
}
|
|
66516
67148
|
function sha2562(buf) {
|
|
66517
|
-
return (0,
|
|
67149
|
+
return (0, import_node_crypto21.createHash)("sha256").update(buf).digest("hex");
|
|
66518
67150
|
}
|
|
66519
67151
|
function startSelfUpdate(deps) {
|
|
66520
67152
|
const log2 = deps.log ?? (() => {
|
|
66521
67153
|
});
|
|
66522
|
-
const readFile10 = deps.readFileSyncImpl ?? ((p) => (0,
|
|
67154
|
+
const readFile10 = deps.readFileSyncImpl ?? ((p) => (0, import_node_fs23.readFileSync)(p));
|
|
66523
67155
|
const setIntervalFn = deps.setIntervalImpl ?? setInterval;
|
|
66524
67156
|
const clearIntervalFn = deps.clearIntervalImpl ?? clearInterval;
|
|
66525
67157
|
const intervalMs = deps.intervalMs ?? readIntervalEnv("MRRLIN_DIRECTOR_BRIDGE_SELF_UPDATE_INTERVAL_MS", DEFAULT_INTERVAL_MS);
|
|
@@ -66810,7 +67442,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
66810
67442
|
}
|
|
66811
67443
|
|
|
66812
67444
|
// src/_generated/version.ts
|
|
66813
|
-
var PKG_VERSION = "0.4.
|
|
67445
|
+
var PKG_VERSION = "0.4.177";
|
|
66814
67446
|
|
|
66815
67447
|
// src/bridge-allowed-origins.ts
|
|
66816
67448
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -66839,28 +67471,28 @@ function readDirectorBridgeAllowedOrigins(env = process.env) {
|
|
|
66839
67471
|
}
|
|
66840
67472
|
|
|
66841
67473
|
// src/receipt-signing.ts
|
|
66842
|
-
var
|
|
67474
|
+
var import_node_crypto22 = __toESM(require("node:crypto"), 1);
|
|
66843
67475
|
var FIXTURE_SIGNING_KEY_ID = "ed25519:fixture:default";
|
|
66844
67476
|
var FIXTURE_PRIVATE_KEY_BASE64 = "MC4CAQAwBQYDK2VwBCIEIFnZBWdVAlsGODDrzXF2wQxO4mBVB/AEos6tYJzg/C/+";
|
|
66845
|
-
function
|
|
67477
|
+
function canonicalizeJson2(obj) {
|
|
66846
67478
|
if (obj === null || typeof obj !== "object") {
|
|
66847
67479
|
return JSON.stringify(obj);
|
|
66848
67480
|
}
|
|
66849
67481
|
if (Array.isArray(obj)) {
|
|
66850
|
-
return "[" + obj.map((item) =>
|
|
67482
|
+
return "[" + obj.map((item) => canonicalizeJson2(item)).join(",") + "]";
|
|
66851
67483
|
}
|
|
66852
67484
|
const keys = Object.keys(obj).sort();
|
|
66853
67485
|
const entries = keys.map((key) => {
|
|
66854
67486
|
const val = obj[key];
|
|
66855
|
-
return JSON.stringify(key) + ":" +
|
|
67487
|
+
return JSON.stringify(key) + ":" + canonicalizeJson2(val);
|
|
66856
67488
|
});
|
|
66857
67489
|
return "{" + entries.join(",") + "}";
|
|
66858
67490
|
}
|
|
66859
67491
|
function canonicalBytes(obj) {
|
|
66860
|
-
return Buffer.from(
|
|
67492
|
+
return Buffer.from(canonicalizeJson2(obj), "utf8");
|
|
66861
67493
|
}
|
|
66862
67494
|
function sha256Hex(data) {
|
|
66863
|
-
return
|
|
67495
|
+
return import_node_crypto22.default.createHash("sha256").update(data).digest("hex");
|
|
66864
67496
|
}
|
|
66865
67497
|
var LocalEd25519SigningProvider = class {
|
|
66866
67498
|
keyId;
|
|
@@ -66873,9 +67505,9 @@ var LocalEd25519SigningProvider = class {
|
|
|
66873
67505
|
if (options.privateKey) {
|
|
66874
67506
|
if (typeof options.privateKey === "string") {
|
|
66875
67507
|
if (options.privateKey.includes("-----BEGIN")) {
|
|
66876
|
-
this.privateKey =
|
|
67508
|
+
this.privateKey = import_node_crypto22.default.createPrivateKey(options.privateKey);
|
|
66877
67509
|
} else {
|
|
66878
|
-
this.privateKey =
|
|
67510
|
+
this.privateKey = import_node_crypto22.default.createPrivateKey({
|
|
66879
67511
|
key: Buffer.from(options.privateKey, "base64"),
|
|
66880
67512
|
format: "der",
|
|
66881
67513
|
type: "pkcs8"
|
|
@@ -66884,10 +67516,10 @@ var LocalEd25519SigningProvider = class {
|
|
|
66884
67516
|
} else {
|
|
66885
67517
|
this.privateKey = options.privateKey;
|
|
66886
67518
|
}
|
|
66887
|
-
const pub =
|
|
67519
|
+
const pub = import_node_crypto22.default.createPublicKey(this.privateKey);
|
|
66888
67520
|
this.publicKeyBase64 = pub.export({ type: "spki", format: "der" }).toString("base64");
|
|
66889
67521
|
} else {
|
|
66890
|
-
const pair =
|
|
67522
|
+
const pair = import_node_crypto22.default.generateKeyPairSync("ed25519");
|
|
66891
67523
|
this.privateKey = pair.privateKey;
|
|
66892
67524
|
this.publicKeyBase64 = pair.publicKey.export({ type: "spki", format: "der" }).toString("base64");
|
|
66893
67525
|
}
|
|
@@ -66910,24 +67542,38 @@ var LocalEd25519SigningProvider = class {
|
|
|
66910
67542
|
throw new Error(`KEY_COMPROMISED: signing key ${this.keyId} is compromised: ${this.compromiseReason}`);
|
|
66911
67543
|
}
|
|
66912
67544
|
const bytes3 = canonicalBytes(payload);
|
|
66913
|
-
const signature =
|
|
67545
|
+
const signature = import_node_crypto22.default.sign(null, bytes3, this.privateKey).toString("base64");
|
|
66914
67546
|
return {
|
|
66915
67547
|
keyId: this.keyId,
|
|
66916
67548
|
signature,
|
|
66917
|
-
canonicalPayload: JSON.parse(
|
|
67549
|
+
canonicalPayload: JSON.parse(canonicalizeJson2(payload))
|
|
66918
67550
|
};
|
|
66919
67551
|
}
|
|
66920
67552
|
verify(payload, signature, publicKeySpkiBase64) {
|
|
66921
67553
|
try {
|
|
66922
67554
|
const bytes3 = canonicalBytes(payload);
|
|
66923
67555
|
const sigBuffer = Buffer.from(signature, "base64");
|
|
66924
|
-
const pubKey = publicKeySpkiBase64 ?
|
|
66925
|
-
return
|
|
67556
|
+
const pubKey = publicKeySpkiBase64 ? import_node_crypto22.default.createPublicKey({ key: Buffer.from(publicKeySpkiBase64, "base64"), format: "der", type: "spki" }) : import_node_crypto22.default.createPublicKey(this.privateKey);
|
|
67557
|
+
return import_node_crypto22.default.verify(null, bytes3, pubKey, sigBuffer);
|
|
66926
67558
|
} catch {
|
|
66927
67559
|
return false;
|
|
66928
67560
|
}
|
|
66929
67561
|
}
|
|
66930
67562
|
};
|
|
67563
|
+
function verifySettlementReceiptV2(receipt, publicKeyBase64) {
|
|
67564
|
+
try {
|
|
67565
|
+
const bytes3 = canonicalBytes(receipt.canonicalPayload);
|
|
67566
|
+
const sigBuffer = Buffer.from(receipt.signature, "base64");
|
|
67567
|
+
let keyBuffer = Buffer.from(publicKeyBase64, "base64");
|
|
67568
|
+
if (keyBuffer.length === 32) {
|
|
67569
|
+
keyBuffer = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), keyBuffer]);
|
|
67570
|
+
}
|
|
67571
|
+
const pubKey = import_node_crypto22.default.createPublicKey({ key: keyBuffer, format: "der", type: "spki" });
|
|
67572
|
+
return import_node_crypto22.default.verify(null, bytes3, pubKey, sigBuffer);
|
|
67573
|
+
} catch {
|
|
67574
|
+
return false;
|
|
67575
|
+
}
|
|
67576
|
+
}
|
|
66931
67577
|
|
|
66932
67578
|
// src/director-closure.ts
|
|
66933
67579
|
var CLOSURE_SNAPSHOT_TIMEOUT_MS = 2e3;
|
|
@@ -67189,7 +67835,7 @@ async function orchestrateSettlementClosure(deps, params) {
|
|
|
67189
67835
|
outcome: params.outcome,
|
|
67190
67836
|
nonce: params.nonce
|
|
67191
67837
|
};
|
|
67192
|
-
const canonicalRequestDigest = sha256Hex(
|
|
67838
|
+
const canonicalRequestDigest = sha256Hex(canonicalizeJson2(canonicalRequest));
|
|
67193
67839
|
const candidate = await deps.prepareSettlementCandidate(params.projectSlug, {
|
|
67194
67840
|
taskId: params.taskId,
|
|
67195
67841
|
runId: params.runId,
|
|
@@ -67216,7 +67862,7 @@ async function orchestrateSettlementClosure(deps, params) {
|
|
|
67216
67862
|
const signed = deps.signingProvider.sign(signingPayload);
|
|
67217
67863
|
if (deps.resolveCurrentArtifacts) {
|
|
67218
67864
|
const currentArtifacts = await deps.resolveCurrentArtifacts(params.projectSlug, params.runId);
|
|
67219
|
-
if (
|
|
67865
|
+
if (canonicalizeJson2(currentArtifacts) !== canonicalizeJson2(params.artifacts)) {
|
|
67220
67866
|
throw new Error("ARTIFACT_SET_DRIFT: authorized artifacts have changed after candidate preparation");
|
|
67221
67867
|
}
|
|
67222
67868
|
}
|
|
@@ -67231,6 +67877,142 @@ async function orchestrateSettlementClosure(deps, params) {
|
|
|
67231
67877
|
isIdempotent: finalized.isIdempotent
|
|
67232
67878
|
};
|
|
67233
67879
|
}
|
|
67880
|
+
var RETRYABLE_STATUSES = /* @__PURE__ */ new Set([408, 429, 500, 502, 503, 504]);
|
|
67881
|
+
function isRetryableTransportError(error51) {
|
|
67882
|
+
if (error51 instanceof MrrlinApiError) {
|
|
67883
|
+
return RETRYABLE_STATUSES.has(error51.status);
|
|
67884
|
+
}
|
|
67885
|
+
return true;
|
|
67886
|
+
}
|
|
67887
|
+
async function orchestrateLocalGitSettlementClosure(deps, params) {
|
|
67888
|
+
const { journal } = deps;
|
|
67889
|
+
const sleep = deps.retrySleep ?? ((ms) => new Promise((resolve3) => setTimeout(resolve3, ms)));
|
|
67890
|
+
let receipt = journal.receipt;
|
|
67891
|
+
let signingKey = null;
|
|
67892
|
+
if (!receipt) {
|
|
67893
|
+
const delays = [500, 1e3, 2e3];
|
|
67894
|
+
let lastError = null;
|
|
67895
|
+
for (let attempt = 0; attempt <= delays.length; attempt++) {
|
|
67896
|
+
try {
|
|
67897
|
+
const issued = await deps.issueLocalGitSettlement(
|
|
67898
|
+
params.projectSlug,
|
|
67899
|
+
params.runId,
|
|
67900
|
+
{ leaseId: params.leaseId, evidence: params.evidence },
|
|
67901
|
+
{ idempotencyKey: journal.idempotencyKey }
|
|
67902
|
+
);
|
|
67903
|
+
receipt = issued.receipt;
|
|
67904
|
+
signingKey = issued.signingKey;
|
|
67905
|
+
break;
|
|
67906
|
+
} catch (err) {
|
|
67907
|
+
lastError = err;
|
|
67908
|
+
if (!isRetryableTransportError(err)) {
|
|
67909
|
+
throw err;
|
|
67910
|
+
}
|
|
67911
|
+
try {
|
|
67912
|
+
const lookup = await deps.getLocalGitSettlement(params.projectSlug, params.runId, journal.idempotencyKey);
|
|
67913
|
+
const data = lookup && "data" in lookup ? lookup.data : null;
|
|
67914
|
+
if (data && "receipt" in data && "signingKey" in data) {
|
|
67915
|
+
const settlement = data;
|
|
67916
|
+
receipt = settlement.receipt;
|
|
67917
|
+
signingKey = settlement.signingKey;
|
|
67918
|
+
break;
|
|
67919
|
+
}
|
|
67920
|
+
} catch {
|
|
67921
|
+
}
|
|
67922
|
+
const delay3 = delays[attempt];
|
|
67923
|
+
if (delay3 !== void 0) {
|
|
67924
|
+
await sleep(delay3);
|
|
67925
|
+
}
|
|
67926
|
+
}
|
|
67927
|
+
}
|
|
67928
|
+
if (!receipt || !signingKey) {
|
|
67929
|
+
throw lastError ?? new Error("LOCAL_GIT_SETTLEMENT_FAILED: failed to obtain server settlement receipt");
|
|
67930
|
+
}
|
|
67931
|
+
} else {
|
|
67932
|
+
const lookup = await deps.getLocalGitSettlement(params.projectSlug, params.runId, journal.idempotencyKey);
|
|
67933
|
+
const data = lookup && "data" in lookup ? lookup.data : null;
|
|
67934
|
+
if (!data || !("signingKey" in data)) {
|
|
67935
|
+
throw new Error(`SIGNING_KEY_LOOKUP_FAILED: cannot find signing key for receipt ${receipt.receiptId}`);
|
|
67936
|
+
}
|
|
67937
|
+
signingKey = data.signingKey;
|
|
67938
|
+
}
|
|
67939
|
+
if (!signingKey) {
|
|
67940
|
+
throw new Error("SIGNING_KEY_MISSING: signing key details are not available");
|
|
67941
|
+
}
|
|
67942
|
+
const targetKeyId = receipt.signingKeyId ?? receipt.signing_key_id;
|
|
67943
|
+
let resolvedPublicKey = null;
|
|
67944
|
+
if (deps.getJwks) {
|
|
67945
|
+
let jwks = null;
|
|
67946
|
+
let lastJwksError = null;
|
|
67947
|
+
const jwksDelays = [200, 500, 1e3];
|
|
67948
|
+
for (let attempt = 0; attempt <= jwksDelays.length; attempt++) {
|
|
67949
|
+
try {
|
|
67950
|
+
jwks = await deps.getJwks();
|
|
67951
|
+
break;
|
|
67952
|
+
} catch (err) {
|
|
67953
|
+
lastJwksError = err;
|
|
67954
|
+
const delay3 = jwksDelays[attempt];
|
|
67955
|
+
if (delay3 !== void 0) {
|
|
67956
|
+
await sleep(delay3);
|
|
67957
|
+
}
|
|
67958
|
+
}
|
|
67959
|
+
}
|
|
67960
|
+
if (!jwks) {
|
|
67961
|
+
throw new Error(`JWKS_FETCH_FAILED: failed to fetch authoritative JWKS public key registry: ${lastJwksError instanceof Error ? lastJwksError.message : String(lastJwksError)}`);
|
|
67962
|
+
}
|
|
67963
|
+
const found = jwks.keys?.find((k) => k.kid === targetKeyId);
|
|
67964
|
+
if (!found?.x) {
|
|
67965
|
+
throw new Error(`SIGNING_KEY_NOT_PUBLISHED: signing key ${targetKeyId ?? "unknown"} is not published in JWKS (omitted, expired, or compromised)`);
|
|
67966
|
+
}
|
|
67967
|
+
resolvedPublicKey = found.x;
|
|
67968
|
+
} else {
|
|
67969
|
+
if (signingKey.status === "compromised" || signingKey.status === "revoked") {
|
|
67970
|
+
throw new Error(`REVOKED_SIGNING_KEY: signing key ${signingKey.keyId} has been revoked or compromised`);
|
|
67971
|
+
}
|
|
67972
|
+
resolvedPublicKey = signingKey.publicKey;
|
|
67973
|
+
}
|
|
67974
|
+
const verify = deps.verifyReceipt ?? verifySettlementReceiptV2;
|
|
67975
|
+
const verified = verify(receipt, resolvedPublicKey);
|
|
67976
|
+
if (!verified) {
|
|
67977
|
+
throw new Error("RECEIPT_SIGNATURE_INVALID: server receipt failed cryptographic signature verification");
|
|
67978
|
+
}
|
|
67979
|
+
const payload = receipt.canonicalPayload ?? receipt.payload;
|
|
67980
|
+
if (!payload || !payload.client_reported || !payload.client_reported.git) {
|
|
67981
|
+
throw new Error("MALFORMED_RECEIPT: receipt missing canonicalPayload or client_reported.git");
|
|
67982
|
+
}
|
|
67983
|
+
const git3 = payload.client_reported.git;
|
|
67984
|
+
if (git3.head_oid !== params.expectedGit.headOid) {
|
|
67985
|
+
throw new Error(`BINDING_MISMATCH: head_oid mismatch (expected ${params.expectedGit.headOid}, got ${git3.head_oid})`);
|
|
67986
|
+
}
|
|
67987
|
+
if (git3.base_oid !== params.expectedGit.baseOid) {
|
|
67988
|
+
throw new Error(`BINDING_MISMATCH: base_oid mismatch (expected ${params.expectedGit.baseOid}, got ${git3.base_oid})`);
|
|
67989
|
+
}
|
|
67990
|
+
if (git3.target_ref !== params.expectedGit.targetRef) {
|
|
67991
|
+
throw new Error(`BINDING_MISMATCH: target_ref mismatch (expected ${params.expectedGit.targetRef}, got ${git3.target_ref})`);
|
|
67992
|
+
}
|
|
67993
|
+
if (git3.run_ref !== params.expectedGit.runRef) {
|
|
67994
|
+
throw new Error(`BINDING_MISMATCH: run_ref mismatch (expected ${params.expectedGit.runRef}, got ${git3.run_ref})`);
|
|
67995
|
+
}
|
|
67996
|
+
if (params.expectedGit.checkoutDigest && git3.checkout_digest !== params.expectedGit.checkoutDigest) {
|
|
67997
|
+
throw new Error(`BINDING_MISMATCH: checkout_digest mismatch (expected ${params.expectedGit.checkoutDigest}, got ${git3.checkout_digest})`);
|
|
67998
|
+
}
|
|
67999
|
+
journal.receipt = receipt;
|
|
68000
|
+
if (journal.phase === "request_pending") {
|
|
68001
|
+
journal.phase = "receipt_saved";
|
|
68002
|
+
}
|
|
68003
|
+
if (deps.stateDir) {
|
|
68004
|
+
updateSettlementJournalSync(deps.stateDir, journal, {
|
|
68005
|
+
phase: journal.phase,
|
|
68006
|
+
receipt
|
|
68007
|
+
});
|
|
68008
|
+
}
|
|
68009
|
+
const state = journal.phase === "files_synced" || journal.phase === "complete" ? "landing_applied" : "receipt_issued";
|
|
68010
|
+
return {
|
|
68011
|
+
receipt,
|
|
68012
|
+
git: git3,
|
|
68013
|
+
state
|
|
68014
|
+
};
|
|
68015
|
+
}
|
|
67234
68016
|
|
|
67235
68017
|
// src/clarification-ledger.ts
|
|
67236
68018
|
var LEDGER_MAX_ITEMS = 20;
|
|
@@ -67720,14 +68502,14 @@ function parseLedger(value) {
|
|
|
67720
68502
|
}
|
|
67721
68503
|
|
|
67722
68504
|
// src/api-base-url-migrate.ts
|
|
67723
|
-
var
|
|
68505
|
+
var import_node_fs24 = __toESM(require("node:fs"), 1);
|
|
67724
68506
|
var import_node_os18 = __toESM(require("node:os"), 1);
|
|
67725
|
-
var
|
|
68507
|
+
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
67726
68508
|
|
|
67727
68509
|
// src/service-paths.ts
|
|
67728
|
-
var
|
|
68510
|
+
var import_node_path32 = __toESM(require("node:path"), 1);
|
|
67729
68511
|
function isWorktreePath(p) {
|
|
67730
|
-
const norm =
|
|
68512
|
+
const norm = import_node_path32.default.normalize(p).split(import_node_path32.default.sep).join("/");
|
|
67731
68513
|
return norm.includes("/.claude/worktrees/");
|
|
67732
68514
|
}
|
|
67733
68515
|
function resolveServiceCwd(opts) {
|
|
@@ -67802,17 +68584,17 @@ function defaultDeps(deps) {
|
|
|
67802
68584
|
const home = deps.home ?? process.env.HOME ?? import_node_os18.default.homedir();
|
|
67803
68585
|
return {
|
|
67804
68586
|
home,
|
|
67805
|
-
codexHome: deps.codexHome ?? process.env.CODEX_HOME?.trim() ??
|
|
67806
|
-
readFile: deps.readFile ?? ((p) =>
|
|
68587
|
+
codexHome: deps.codexHome ?? process.env.CODEX_HOME?.trim() ?? import_node_path33.default.join(home, ".codex"),
|
|
68588
|
+
readFile: deps.readFile ?? ((p) => import_node_fs24.default.readFileSync(p, "utf8")),
|
|
67807
68589
|
// Temp-file + atomic rename so a concurrent `serve` and `director-bridge` startup can never
|
|
67808
68590
|
// interleave partial writes into a config the next start has to parse. Note this normalizes the
|
|
67809
68591
|
// file to 0o600 — deliberate, since both files can carry a credential-bearing URL.
|
|
67810
68592
|
writeFile: deps.writeFile ?? ((p, c) => {
|
|
67811
68593
|
const tmp = `${p}.tmp-${process.pid}`;
|
|
67812
|
-
|
|
67813
|
-
|
|
68594
|
+
import_node_fs24.default.writeFileSync(tmp, c, { mode: 384 });
|
|
68595
|
+
import_node_fs24.default.renameSync(tmp, p);
|
|
67814
68596
|
}),
|
|
67815
|
-
exists: deps.exists ?? ((p) =>
|
|
68597
|
+
exists: deps.exists ?? ((p) => import_node_fs24.default.existsSync(p)),
|
|
67816
68598
|
log: deps.log ?? ((m) => process.stderr.write(`${m}
|
|
67817
68599
|
`))
|
|
67818
68600
|
};
|
|
@@ -67851,7 +68633,7 @@ function backupOnce(file2, text, deps) {
|
|
|
67851
68633
|
}
|
|
67852
68634
|
function migrateEcosystemConfig(deps = {}) {
|
|
67853
68635
|
const d = defaultDeps(deps);
|
|
67854
|
-
const file2 =
|
|
68636
|
+
const file2 = import_node_path33.default.join(d.home, ".mrrlin", "ecosystem.config.cjs");
|
|
67855
68637
|
if (!d.exists(file2)) return { file: file2, status: "absent" };
|
|
67856
68638
|
const text = d.readFile(file2);
|
|
67857
68639
|
if (!findRetiredHost(text) && !hasLiveLegacyStagingFlag(text, "js"))
|
|
@@ -68001,7 +68783,7 @@ ${envLines}
|
|
|
68001
68783
|
}
|
|
68002
68784
|
function migrateCodexConfig(deps = {}) {
|
|
68003
68785
|
const d = defaultDeps(deps);
|
|
68004
|
-
const file2 =
|
|
68786
|
+
const file2 = import_node_path33.default.join(d.codexHome, "config.toml");
|
|
68005
68787
|
if (!d.exists(file2)) return { file: file2, status: "absent" };
|
|
68006
68788
|
const text = d.readFile(file2);
|
|
68007
68789
|
const host = findRetiredHost(text);
|
|
@@ -68087,7 +68869,7 @@ $1`
|
|
|
68087
68869
|
}
|
|
68088
68870
|
function migrateClaudeConfig(deps = {}) {
|
|
68089
68871
|
const d = defaultDeps(deps);
|
|
68090
|
-
const file2 =
|
|
68872
|
+
const file2 = import_node_path33.default.join(d.home, ".claude.json");
|
|
68091
68873
|
if (!d.exists(file2)) return { file: file2, status: "absent" };
|
|
68092
68874
|
const text = d.readFile(file2);
|
|
68093
68875
|
let parsed;
|
|
@@ -68137,9 +68919,9 @@ function migrateRetiredApiBaseUrls(deps = {}) {
|
|
|
68137
68919
|
const d = defaultDeps(deps);
|
|
68138
68920
|
const results = [];
|
|
68139
68921
|
const steps = [
|
|
68140
|
-
{ run: migrateEcosystemConfig, file:
|
|
68141
|
-
{ run: migrateCodexConfig, file:
|
|
68142
|
-
{ run: migrateClaudeConfig, file:
|
|
68922
|
+
{ run: migrateEcosystemConfig, file: import_node_path33.default.join(d.home, ".mrrlin", "ecosystem.config.cjs") },
|
|
68923
|
+
{ run: migrateCodexConfig, file: import_node_path33.default.join(d.codexHome, "config.toml") },
|
|
68924
|
+
{ run: migrateClaudeConfig, file: import_node_path33.default.join(d.home, ".claude.json") }
|
|
68143
68925
|
];
|
|
68144
68926
|
for (const step of steps) {
|
|
68145
68927
|
try {
|
|
@@ -68165,8 +68947,8 @@ function migrateRetiredApiBaseUrls(deps = {}) {
|
|
|
68165
68947
|
}
|
|
68166
68948
|
|
|
68167
68949
|
// src/bridge-health.ts
|
|
68168
|
-
var
|
|
68169
|
-
var
|
|
68950
|
+
var import_node_fs25 = require("node:fs");
|
|
68951
|
+
var import_node_path34 = __toESM(require("node:path"), 1);
|
|
68170
68952
|
var SENTINEL_FILE_NAME = "bridge-health-circuit-breaker.json";
|
|
68171
68953
|
var CRASH_WINDOW_MS = 60 * 60 * 1e3;
|
|
68172
68954
|
var MAX_CRASHES_PER_WINDOW = 3;
|
|
@@ -68178,9 +68960,9 @@ function isCrashSentinel(value) {
|
|
|
68178
68960
|
return typeof candidate.crashCount === "number" && Number.isInteger(candidate.crashCount) && candidate.crashCount >= 0 && typeof candidate.windowStartedAt === "string";
|
|
68179
68961
|
}
|
|
68180
68962
|
async function readCrashSentinel(stateDir, now = Date.now) {
|
|
68181
|
-
const sentinelPath =
|
|
68963
|
+
const sentinelPath = import_node_path34.default.join(stateDir, SENTINEL_FILE_NAME);
|
|
68182
68964
|
try {
|
|
68183
|
-
const raw = await
|
|
68965
|
+
const raw = await import_node_fs25.promises.readFile(sentinelPath, "utf8");
|
|
68184
68966
|
const parsed = JSON.parse(raw);
|
|
68185
68967
|
if (isCrashSentinel(parsed)) return parsed;
|
|
68186
68968
|
} catch {
|
|
@@ -68188,11 +68970,11 @@ async function readCrashSentinel(stateDir, now = Date.now) {
|
|
|
68188
68970
|
return { crashCount: 0, windowStartedAt: new Date(now()).toISOString() };
|
|
68189
68971
|
}
|
|
68190
68972
|
async function writeCrashSentinel(stateDir, sentinel) {
|
|
68191
|
-
await
|
|
68192
|
-
const sentinelPath =
|
|
68973
|
+
await import_node_fs25.promises.mkdir(stateDir, { recursive: true });
|
|
68974
|
+
const sentinelPath = import_node_path34.default.join(stateDir, SENTINEL_FILE_NAME);
|
|
68193
68975
|
const tmpPath = `${sentinelPath}.tmp-${process.pid}-${Math.random().toString(36).slice(2)}`;
|
|
68194
|
-
await
|
|
68195
|
-
await
|
|
68976
|
+
await import_node_fs25.promises.writeFile(tmpPath, JSON.stringify(sentinel), "utf8");
|
|
68977
|
+
await import_node_fs25.promises.rename(tmpPath, sentinelPath);
|
|
68196
68978
|
}
|
|
68197
68979
|
function withTimeout(fn, ms = DEFAULT_OPERATION_TIMEOUT_MS) {
|
|
68198
68980
|
const controller = new AbortController();
|
|
@@ -68519,14 +69301,14 @@ function startSchedulerTickLoop(deps) {
|
|
|
68519
69301
|
|
|
68520
69302
|
// src/retention/pruner.ts
|
|
68521
69303
|
var import_promises13 = require("node:fs/promises");
|
|
68522
|
-
var
|
|
69304
|
+
var import_node_path35 = __toESM(require("node:path"), 1);
|
|
68523
69305
|
var LOG_DIR_MODE2 = 448;
|
|
68524
69306
|
var LOG_FILE_MODE2 = 384;
|
|
68525
69307
|
function protectedDayFloor(protectedSinceMs) {
|
|
68526
69308
|
return new Date(protectedSinceMs).toISOString().slice(0, 10);
|
|
68527
69309
|
}
|
|
68528
69310
|
async function prune(stateDir, bounds) {
|
|
68529
|
-
const logsDir =
|
|
69311
|
+
const logsDir = import_node_path35.default.join(stateDir, "logs");
|
|
68530
69312
|
let entries;
|
|
68531
69313
|
try {
|
|
68532
69314
|
entries = await (0, import_promises13.readdir)(logsDir);
|
|
@@ -68542,7 +69324,7 @@ async function prune(stateDir, bounds) {
|
|
|
68542
69324
|
for (const entry of entries) {
|
|
68543
69325
|
const m = bridgeRe.exec(entry);
|
|
68544
69326
|
if (!m?.[1]) continue;
|
|
68545
|
-
const fullPath =
|
|
69327
|
+
const fullPath = import_node_path35.default.join(logsDir, entry);
|
|
68546
69328
|
const s = await (0, import_promises13.stat)(fullPath);
|
|
68547
69329
|
files.push({ day: m[1], size: s.size, fullPath });
|
|
68548
69330
|
}
|
|
@@ -68551,7 +69333,7 @@ async function prune(stateDir, bounds) {
|
|
|
68551
69333
|
const reasonByDay = {};
|
|
68552
69334
|
let bytesRemoved = 0;
|
|
68553
69335
|
async function isDaySafeToDelete(day) {
|
|
68554
|
-
const telemetryDir =
|
|
69336
|
+
const telemetryDir = import_node_path35.default.join(stateDir, "telemetry");
|
|
68555
69337
|
let telemetryEntries;
|
|
68556
69338
|
try {
|
|
68557
69339
|
telemetryEntries = await (0, import_promises13.readdir)(telemetryDir);
|
|
@@ -68567,7 +69349,7 @@ async function prune(stateDir, bounds) {
|
|
|
68567
69349
|
}
|
|
68568
69350
|
if (projectSlugs.length === 0) return true;
|
|
68569
69351
|
for (const slug of projectSlugs) {
|
|
68570
|
-
const markerPath =
|
|
69352
|
+
const markerPath = import_node_path35.default.join(telemetryDir, `.processed-${slug}-${day}`);
|
|
68571
69353
|
try {
|
|
68572
69354
|
await (0, import_promises13.stat)(markerPath);
|
|
68573
69355
|
} catch (err) {
|
|
@@ -68617,7 +69399,7 @@ async function prune(stateDir, bounds) {
|
|
|
68617
69399
|
const budgetOvershootBytes = Math.max(0, totalSize2 - budgetBytes);
|
|
68618
69400
|
await emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining);
|
|
68619
69401
|
if (daysRemoved.length > 0) {
|
|
68620
|
-
const sessionsPath =
|
|
69402
|
+
const sessionsPath = import_node_path35.default.join(logsDir, ".sessions.json");
|
|
68621
69403
|
let sessionsObj = {};
|
|
68622
69404
|
let fileExists = true;
|
|
68623
69405
|
try {
|
|
@@ -68639,8 +69421,8 @@ async function prune(stateDir, bounds) {
|
|
|
68639
69421
|
return { daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining, budgetOvershootBytes };
|
|
68640
69422
|
}
|
|
68641
69423
|
async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining) {
|
|
68642
|
-
const logsDir =
|
|
68643
|
-
const logPath =
|
|
69424
|
+
const logsDir = import_node_path35.default.join(stateDir, "logs");
|
|
69425
|
+
const logPath = import_node_path35.default.join(logsDir, ".pruned.jsonl");
|
|
68644
69426
|
await (0, import_promises13.mkdir)(logsDir, { recursive: true, mode: LOG_DIR_MODE2 });
|
|
68645
69427
|
const record2 = { ts: Date.now(), dir: "logs", daysRemoved, reasonByDay, bytesRemoved, oldestDayRemaining };
|
|
68646
69428
|
await (0, import_promises13.appendFile)(logPath, `${JSON.stringify(record2)}
|
|
@@ -68648,9 +69430,9 @@ async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, ol
|
|
|
68648
69430
|
}
|
|
68649
69431
|
|
|
68650
69432
|
// src/telemetry/turn-aggregator.ts
|
|
68651
|
-
var
|
|
69433
|
+
var import_node_crypto23 = require("node:crypto");
|
|
68652
69434
|
var import_promises14 = require("node:fs/promises");
|
|
68653
|
-
var
|
|
69435
|
+
var import_node_path36 = require("node:path");
|
|
68654
69436
|
var BRIDGE_FILE_RE = /^bridge-(\d{4}-\d{2}-\d{2})\.jsonl$/;
|
|
68655
69437
|
var PLUMBING_COUNTER_KEY = {
|
|
68656
69438
|
socket_close: "socketCloses",
|
|
@@ -68679,7 +69461,7 @@ function inheritSlug(seeds, index) {
|
|
|
68679
69461
|
return (preceding ?? following)?.slug;
|
|
68680
69462
|
}
|
|
68681
69463
|
async function foldClosedDays(stateDir, today) {
|
|
68682
|
-
const logsDir = (0,
|
|
69464
|
+
const logsDir = (0, import_node_path36.join)(stateDir, "logs");
|
|
68683
69465
|
let entries;
|
|
68684
69466
|
try {
|
|
68685
69467
|
entries = await (0, import_promises14.readdir)(logsDir);
|
|
@@ -68691,7 +69473,7 @@ async function foldClosedDays(stateDir, today) {
|
|
|
68691
69473
|
if (!m) continue;
|
|
68692
69474
|
const day = m[1];
|
|
68693
69475
|
if (day === today) continue;
|
|
68694
|
-
const raw = await (0, import_promises14.readFile)((0,
|
|
69476
|
+
const raw = await (0, import_promises14.readFile)((0, import_node_path36.join)(logsDir, entry), "utf8");
|
|
68695
69477
|
const groups = /* @__PURE__ */ new Map();
|
|
68696
69478
|
let groupCounter = 0;
|
|
68697
69479
|
for (const line of raw.split("\n")) {
|
|
@@ -68802,11 +69584,11 @@ async function foldClosedDays(stateDir, today) {
|
|
|
68802
69584
|
rowsByProject.set(slug, rows);
|
|
68803
69585
|
}
|
|
68804
69586
|
if (rowsByProject.size === 0) continue;
|
|
68805
|
-
const telemetryDir = (0,
|
|
69587
|
+
const telemetryDir = (0, import_node_path36.join)(stateDir, "telemetry");
|
|
68806
69588
|
await (0, import_promises14.mkdir)(telemetryDir, { recursive: true });
|
|
68807
69589
|
for (const [slug, rows] of rowsByProject) {
|
|
68808
|
-
const finalPath = (0,
|
|
68809
|
-
const tmpPath = `${finalPath}.tmp-${process.pid}-${(0,
|
|
69590
|
+
const finalPath = (0, import_node_path36.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
|
|
69591
|
+
const tmpPath = `${finalPath}.tmp-${process.pid}-${(0, import_node_crypto23.randomBytes)(6).toString("hex")}`;
|
|
68810
69592
|
try {
|
|
68811
69593
|
await (0, import_promises14.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
|
|
68812
69594
|
await (0, import_promises14.rename)(tmpPath, finalPath);
|
|
@@ -68820,27 +69602,27 @@ async function foldClosedDays(stateDir, today) {
|
|
|
68820
69602
|
|
|
68821
69603
|
// src/telemetry/daily-uploader.ts
|
|
68822
69604
|
var import_promises15 = require("node:fs/promises");
|
|
68823
|
-
var
|
|
69605
|
+
var import_node_path38 = require("node:path");
|
|
68824
69606
|
|
|
68825
69607
|
// src/telemetry/installation-id.ts
|
|
68826
|
-
var
|
|
68827
|
-
var
|
|
68828
|
-
var
|
|
69608
|
+
var import_node_crypto24 = require("node:crypto");
|
|
69609
|
+
var import_node_fs26 = require("node:fs");
|
|
69610
|
+
var import_node_path37 = require("node:path");
|
|
68829
69611
|
var FILE_NAME = "installation-id";
|
|
68830
69612
|
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
68831
69613
|
var cache = /* @__PURE__ */ new Map();
|
|
68832
69614
|
function resolveInstallationId(stateDir) {
|
|
68833
69615
|
const cached2 = cache.get(stateDir);
|
|
68834
69616
|
if (cached2 !== void 0) return cached2;
|
|
68835
|
-
const
|
|
69617
|
+
const path39 = (0, import_node_path37.join)(stateDir, FILE_NAME);
|
|
68836
69618
|
let id;
|
|
68837
69619
|
try {
|
|
68838
|
-
id = (0,
|
|
69620
|
+
id = (0, import_node_fs26.readFileSync)(path39, "utf8").trim();
|
|
68839
69621
|
if (!UUID.test(id)) throw new Error("unusable");
|
|
68840
69622
|
} catch {
|
|
68841
|
-
id = (0,
|
|
68842
|
-
(0,
|
|
68843
|
-
(0,
|
|
69623
|
+
id = (0, import_node_crypto24.randomUUID)();
|
|
69624
|
+
(0, import_node_fs26.mkdirSync)((0, import_node_path37.dirname)(path39), { recursive: true });
|
|
69625
|
+
(0, import_node_fs26.writeFileSync)(path39, `${id}
|
|
68844
69626
|
`, "utf8");
|
|
68845
69627
|
}
|
|
68846
69628
|
cache.set(stateDir, id);
|
|
@@ -68857,7 +69639,7 @@ function truncateCause(err) {
|
|
|
68857
69639
|
return `${message.slice(0, MAX_CAUSE_CHARS - 3)}...`;
|
|
68858
69640
|
}
|
|
68859
69641
|
async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
|
|
68860
|
-
const telemetryDir = (0,
|
|
69642
|
+
const telemetryDir = (0, import_node_path38.join)(stateDir, "telemetry");
|
|
68861
69643
|
let files;
|
|
68862
69644
|
try {
|
|
68863
69645
|
files = await (0, import_promises15.readdir)(telemetryDir);
|
|
@@ -68873,14 +69655,14 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
|
|
|
68873
69655
|
const [, projectSlug, day] = match;
|
|
68874
69656
|
const key = `${projectSlug}\0${day}`;
|
|
68875
69657
|
const entry = discovered.get(key) ?? { projectSlug, day, rowsPath: null };
|
|
68876
|
-
if (rowsMatch) entry.rowsPath = (0,
|
|
69658
|
+
if (rowsMatch) entry.rowsPath = (0, import_node_path38.join)(telemetryDir, file2);
|
|
68877
69659
|
discovered.set(key, entry);
|
|
68878
69660
|
}
|
|
68879
69661
|
const today = telemetryDay();
|
|
68880
69662
|
const pending = [];
|
|
68881
69663
|
const deferred = [];
|
|
68882
69664
|
for (const { projectSlug, day, rowsPath } of discovered.values()) {
|
|
68883
|
-
const markerPath = (0,
|
|
69665
|
+
const markerPath = (0, import_node_path38.join)(telemetryDir, `.processed-${projectSlug}-${day}`);
|
|
68884
69666
|
if (rowsPath === null && day >= today) {
|
|
68885
69667
|
try {
|
|
68886
69668
|
await (0, import_promises15.access)(markerPath);
|
|
@@ -68900,7 +69682,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
|
|
|
68900
69682
|
const fullUnprocessed = [...pending.map((p) => ({ projectSlug: p.projectSlug, day: p.day })), ...deferred];
|
|
68901
69683
|
pending.sort((a, b) => a.day.localeCompare(b.day));
|
|
68902
69684
|
for (const cur of pending) {
|
|
68903
|
-
const failurePath = (0,
|
|
69685
|
+
const failurePath = (0, import_node_path38.join)(telemetryDir, `.failed-${cur.projectSlug}-${cur.day}.json`);
|
|
68904
69686
|
let failureState = null;
|
|
68905
69687
|
try {
|
|
68906
69688
|
const data = await (0, import_promises15.readFile)(failurePath, "utf8");
|
|
@@ -68934,7 +69716,7 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
|
|
|
68934
69716
|
}
|
|
68935
69717
|
const gateCalls = [];
|
|
68936
69718
|
try {
|
|
68937
|
-
const rawGate = await (0, import_promises15.readFile)((0,
|
|
69719
|
+
const rawGate = await (0, import_promises15.readFile)((0, import_node_path38.join)(telemetryDir, gateFileName(cur.projectSlug, cur.day)), "utf8");
|
|
68938
69720
|
for (const line of rawGate.split("\n")) {
|
|
68939
69721
|
if (!line.trim()) continue;
|
|
68940
69722
|
try {
|
|
@@ -69084,8 +69866,8 @@ function setSelectedProvider(value) {
|
|
|
69084
69866
|
|
|
69085
69867
|
// src/execution-consumer.ts
|
|
69086
69868
|
var import_node_child_process22 = require("node:child_process");
|
|
69087
|
-
var
|
|
69088
|
-
var
|
|
69869
|
+
var import_node_crypto25 = __toESM(require("node:crypto"), 1);
|
|
69870
|
+
var import_node_path39 = __toESM(require("node:path"), 1);
|
|
69089
69871
|
var import_node_util5 = require("node:util");
|
|
69090
69872
|
|
|
69091
69873
|
// src/notify-templates.ts
|
|
@@ -70876,11 +71658,11 @@ function isBridgeGeneratedArtifact(artifact) {
|
|
|
70876
71658
|
return typeof payload === "object" && payload !== null && "event" in payload;
|
|
70877
71659
|
}
|
|
70878
71660
|
function newArtifactId() {
|
|
70879
|
-
return `EA-${
|
|
71661
|
+
return `EA-${import_node_crypto25.default.randomUUID()}`;
|
|
70880
71662
|
}
|
|
70881
71663
|
var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
|
|
70882
|
-
function isBlastRadiusFloorPath(
|
|
70883
|
-
return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(
|
|
71664
|
+
function isBlastRadiusFloorPath(path39) {
|
|
71665
|
+
return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path39));
|
|
70884
71666
|
}
|
|
70885
71667
|
var execFileAsync3 = (0, import_node_util5.promisify)(import_node_child_process22.execFile);
|
|
70886
71668
|
async function gitOutput(cwd, args) {
|
|
@@ -71149,7 +71931,7 @@ async function readApprovedMixedCodeSpec(client, projectSlug, runId, runApproval
|
|
|
71149
71931
|
if (!matches(task)) throw changed();
|
|
71150
71932
|
const read = async () => {
|
|
71151
71933
|
const page = await client.getWikiPage(projectSlug, runApproval.specPageId);
|
|
71152
|
-
if (page.id !== runApproval.specPageId || page.folder !== "Specs" || page.taskId !== task.id || page.specReady !== true ||
|
|
71934
|
+
if (page.id !== runApproval.specPageId || page.folder !== "Specs" || page.taskId !== task.id || page.specReady !== true || import_node_crypto25.default.createHash("sha256").update(page.markdownBody, "utf8").digest("hex") !== runApproval.specContentHash) {
|
|
71153
71935
|
throw changed();
|
|
71154
71936
|
}
|
|
71155
71937
|
const current2 = await client.getTask(projectSlug, task.id);
|
|
@@ -71285,7 +72067,7 @@ async function driveRun(deps, projectSlug, runId) {
|
|
|
71285
72067
|
if (!claimed) return;
|
|
71286
72068
|
if (!claimed.leaseId) {
|
|
71287
72069
|
await deps.client.createInboxItem(projectSlug, {
|
|
71288
|
-
id: `II-${
|
|
72070
|
+
id: `II-${import_node_crypto25.default.randomUUID()}`,
|
|
71289
72071
|
kind: "handoff",
|
|
71290
72072
|
taskId: claimed.taskId,
|
|
71291
72073
|
body: `Execution run ${runId} was claimed but returned no leaseId. This indicates DB/API corruption and requires operator attention.`
|
|
@@ -72461,7 +73243,7 @@ ${workInstruction}` : workInstruction;
|
|
|
72461
73243
|
taskId: task.id,
|
|
72462
73244
|
runId,
|
|
72463
73245
|
outcome: "completed",
|
|
72464
|
-
nonce:
|
|
73246
|
+
nonce: import_node_crypto25.default.randomUUID(),
|
|
72465
73247
|
artifacts: []
|
|
72466
73248
|
}
|
|
72467
73249
|
);
|
|
@@ -72958,7 +73740,7 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2,
|
|
|
72958
73740
|
taskId: task.id,
|
|
72959
73741
|
runId,
|
|
72960
73742
|
outcome: parsedResult.outcome,
|
|
72961
|
-
nonce:
|
|
73743
|
+
nonce: import_node_crypto25.default.randomUUID(),
|
|
72962
73744
|
artifacts: [
|
|
72963
73745
|
{
|
|
72964
73746
|
artifactId: pageId,
|
|
@@ -73315,12 +74097,26 @@ async function deliverLocalRun(deps, input) {
|
|
|
73315
74097
|
localBuild: outcome.evidence
|
|
73316
74098
|
};
|
|
73317
74099
|
const artifactId = `EA-LG-${runId}-${outcome.evidence.headSha.slice(0, 12)}`;
|
|
74100
|
+
const outcomeHeadSha = outcome.evidence.headSha;
|
|
74101
|
+
const gitSettlementBinding = {
|
|
74102
|
+
object_format: outcomeHeadSha.length === 64 ? "sha256" : "sha1",
|
|
74103
|
+
source_base_oid: input.baseSha,
|
|
74104
|
+
base_oid: input.integration?.defaultTipSha ?? input.baseSha,
|
|
74105
|
+
head_oid: outcomeHeadSha,
|
|
74106
|
+
target_ref: `refs/heads/${input.defaultBranch}`,
|
|
74107
|
+
run_ref: `refs/heads/${worktreeBranch(runId)}`,
|
|
74108
|
+
checkout_digest: outcome.evidence.checkoutDigest
|
|
74109
|
+
};
|
|
73318
74110
|
let artifact;
|
|
73319
74111
|
try {
|
|
73320
74112
|
artifact = await deps.client.appendExecutionArtifact(projectSlug, runId, {
|
|
73321
74113
|
id: artifactId,
|
|
73322
74114
|
kind: "verification",
|
|
73323
|
-
payload: {
|
|
74115
|
+
payload: {
|
|
74116
|
+
[LOCAL_BUILD_RECEIPT_PAYLOAD_KEY]: receipt,
|
|
74117
|
+
deliveryRef: outcome.deliveryRef,
|
|
74118
|
+
gitSettlement: gitSettlementBinding
|
|
74119
|
+
}
|
|
73324
74120
|
});
|
|
73325
74121
|
} catch (error51) {
|
|
73326
74122
|
const existing = await deps.client.listExecutionArtifacts(projectSlug, runId).catch(() => []);
|
|
@@ -73329,74 +74125,127 @@ async function deliverLocalRun(deps, input) {
|
|
|
73329
74125
|
await handOff(`local_delivery_failed: could not record the build receipt: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
73330
74126
|
return;
|
|
73331
74127
|
}
|
|
74128
|
+
const foundPayload = found.payload;
|
|
74129
|
+
const foundBuildReceipt = foundPayload?.[LOCAL_BUILD_RECEIPT_PAYLOAD_KEY];
|
|
74130
|
+
const foundGitSettlement = foundPayload?.gitSettlement ?? foundPayload?.gitBinding ?? foundPayload?.git;
|
|
74131
|
+
if (foundPayload?.deliveryRef !== outcome.deliveryRef || foundBuildReceipt?.evidenceValue !== outcome.evidence.headSha || foundBuildReceipt?.localBuild?.headSha !== outcome.evidence.headSha || foundBuildReceipt?.localBuild?.baseSha !== outcome.evidence.baseSha || foundGitSettlement && (foundGitSettlement.head_oid !== outcome.evidence.headSha || foundGitSettlement.base_oid !== (input.integration?.defaultTipSha ?? input.baseSha))) {
|
|
74132
|
+
await handOff(`local_delivery_failed: artifact ${artifactId} already exists with different payload bindings`);
|
|
74133
|
+
return;
|
|
74134
|
+
}
|
|
73332
74135
|
artifact = found;
|
|
73333
74136
|
}
|
|
73334
|
-
if (!deps.signingProvider) {
|
|
73335
|
-
await handOff(`closure_signing_unavailable: run ${runId} delivered ${outcome.deliveryRef} with a green bridge-run build, but this bridge has no receipt signing key (MRRLIN_SIGNING_KEY_ID / MRRLIN_SIGNING_PRIVATE_KEY), so the task cannot be closed. Configure signing and restart the run.`);
|
|
73336
|
-
return;
|
|
73337
|
-
}
|
|
73338
|
-
const stored = artifact?.payload ?? {};
|
|
73339
|
-
const contentHash = String(stored.contentHash ?? stored.content_hash ?? stored.hash ?? "");
|
|
73340
74137
|
if (!await runHasLease(deps, projectSlug, runId, leaseId)) {
|
|
73341
74138
|
await restoreForLostLease();
|
|
73342
74139
|
return;
|
|
73343
74140
|
}
|
|
73344
|
-
const
|
|
73345
|
-
|
|
73346
|
-
|
|
73347
|
-
|
|
73348
|
-
|
|
73349
|
-
|
|
73350
|
-
|
|
73351
|
-
|
|
73352
|
-
|
|
73353
|
-
|
|
73354
|
-
|
|
74141
|
+
const stateDir = deps.stateDir ?? resolveStateDir();
|
|
74142
|
+
const existingJournals = findSettlementJournalsSync(stateDir, projectSlug, runId);
|
|
74143
|
+
let journal = existingJournals.find((j) => j.artifactId === (artifact?.id ?? artifactId)) ?? null;
|
|
74144
|
+
if (!journal) {
|
|
74145
|
+
journal = createSettlementJournal({
|
|
74146
|
+
stateDir,
|
|
74147
|
+
projectSlug,
|
|
74148
|
+
taskId: task.id,
|
|
74149
|
+
runId,
|
|
74150
|
+
idempotencyKey: import_node_crypto25.default.randomUUID(),
|
|
74151
|
+
artifactId: artifact?.id ?? artifactId,
|
|
74152
|
+
leaseId
|
|
74153
|
+
});
|
|
74154
|
+
}
|
|
74155
|
+
let verifiedSettlement = null;
|
|
74156
|
+
if (!deps.signingProvider) {
|
|
74157
|
+
try {
|
|
74158
|
+
await input.guard?.check();
|
|
74159
|
+
verifiedSettlement = await orchestrateLocalGitSettlementClosure(
|
|
74160
|
+
{
|
|
74161
|
+
issueLocalGitSettlement: async (slug, rId, params, options) => {
|
|
73355
74162
|
await input.guard?.check();
|
|
73356
|
-
return deps.client.
|
|
73357
|
-
}
|
|
73358
|
-
|
|
73359
|
-
|
|
73360
|
-
|
|
73361
|
-
|
|
73362
|
-
|
|
73363
|
-
|
|
73364
|
-
|
|
73365
|
-
nonce: import_node_crypto24.default.randomUUID(),
|
|
73366
|
-
artifacts: [{ artifactId: artifact?.id ?? artifactId, storageVersion: "1", contentHash, kind: "verification" }]
|
|
73367
|
-
}
|
|
73368
|
-
);
|
|
73369
|
-
} catch (error51) {
|
|
73370
|
-
if (error51 instanceof MixedCodeApprovalError) throw error51;
|
|
73371
|
-
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
73372
|
-
const settlement = await readSettlementState(deps, projectSlug, task.id, runId, SETTLEMENT_READBACK_ATTEMPTS);
|
|
73373
|
-
if (!settlement || settlement.taskStatus !== "closed_done" || !settlement.runDone) {
|
|
73374
|
-
if (!settlement && finalizeUnanswered.seen) {
|
|
73375
|
-
console.warn(JSON.stringify({
|
|
73376
|
-
event: "settlement_outcome_unknown",
|
|
74163
|
+
return deps.client.issueLocalGitSettlement(slug, rId, params, options);
|
|
74164
|
+
},
|
|
74165
|
+
getLocalGitSettlement: (slug, rId, key) => deps.client.getLocalGitSettlement(slug, rId, key),
|
|
74166
|
+
getJwks: deps.client.getJwks ? () => deps.client.getJwks() : void 0,
|
|
74167
|
+
journal,
|
|
74168
|
+
stateDir,
|
|
74169
|
+
retrySleep: deps.settlementRetrySleep
|
|
74170
|
+
},
|
|
74171
|
+
{
|
|
73377
74172
|
projectSlug,
|
|
73378
74173
|
runId,
|
|
73379
|
-
|
|
73380
|
-
|
|
73381
|
-
|
|
73382
|
-
|
|
73383
|
-
|
|
73384
|
-
|
|
73385
|
-
|
|
74174
|
+
leaseId,
|
|
74175
|
+
evidence: { artifactId: artifact?.id ?? artifactId },
|
|
74176
|
+
expectedGit: {
|
|
74177
|
+
headOid: outcome.evidence.headSha,
|
|
74178
|
+
baseOid: input.integration?.defaultTipSha ?? input.baseSha,
|
|
74179
|
+
targetRef: `refs/heads/${input.defaultBranch}`,
|
|
74180
|
+
runRef: `refs/heads/${worktreeBranch(runId)}`,
|
|
74181
|
+
checkoutDigest: outcome.evidence.checkoutDigest
|
|
74182
|
+
}
|
|
74183
|
+
}
|
|
74184
|
+
);
|
|
74185
|
+
} catch (error51) {
|
|
74186
|
+
if (error51 instanceof MixedCodeApprovalError) throw error51;
|
|
74187
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
73386
74188
|
await handOff(`local_delivery_settlement_failed: ${message}`);
|
|
73387
74189
|
return;
|
|
73388
74190
|
}
|
|
73389
|
-
|
|
73390
|
-
|
|
73391
|
-
|
|
73392
|
-
|
|
73393
|
-
|
|
73394
|
-
|
|
73395
|
-
|
|
74191
|
+
} else {
|
|
74192
|
+
const stored = artifact?.payload ?? {};
|
|
74193
|
+
const contentHash = String(stored.contentHash ?? stored.content_hash ?? stored.hash ?? "");
|
|
74194
|
+
const finalizeUnanswered = { seen: false };
|
|
74195
|
+
await input.guard?.check();
|
|
74196
|
+
try {
|
|
74197
|
+
await orchestrateSettlementClosure(
|
|
74198
|
+
{
|
|
74199
|
+
prepareSettlementCandidate: (slug, params) => deps.client.prepareSettlementCandidate(slug, params),
|
|
74200
|
+
signingProvider: deps.signingProvider,
|
|
74201
|
+
finalizeSettlementReceipt: (slug, params) => finalizeWithReplay(deps, { projectSlug, runId, taskId: task.id, unanswered: finalizeUnanswered }, async () => {
|
|
74202
|
+
await input.guard?.check();
|
|
74203
|
+
return deps.client.finalizeSettlementReceipt(slug, params);
|
|
74204
|
+
})
|
|
74205
|
+
},
|
|
74206
|
+
{
|
|
74207
|
+
projectSlug,
|
|
74208
|
+
taskId: task.id,
|
|
74209
|
+
runId,
|
|
74210
|
+
outcome: "completed",
|
|
74211
|
+
nonce: import_node_crypto25.default.randomUUID(),
|
|
74212
|
+
artifacts: [{ artifactId: artifact?.id ?? artifactId, storageVersion: "1", contentHash, kind: "verification" }]
|
|
74213
|
+
}
|
|
74214
|
+
);
|
|
74215
|
+
} catch (error51) {
|
|
74216
|
+
if (error51 instanceof MixedCodeApprovalError) throw error51;
|
|
74217
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
74218
|
+
const settlement = await readSettlementState(deps, projectSlug, task.id, runId, SETTLEMENT_READBACK_ATTEMPTS);
|
|
74219
|
+
if (!settlement || settlement.taskStatus !== "closed_done" || !settlement.runDone) {
|
|
74220
|
+
if (!settlement && finalizeUnanswered.seen) {
|
|
74221
|
+
console.warn(JSON.stringify({
|
|
74222
|
+
event: "settlement_outcome_unknown",
|
|
74223
|
+
projectSlug,
|
|
74224
|
+
runId,
|
|
74225
|
+
taskId: task.id,
|
|
74226
|
+
headSha: outcome.evidence.headSha,
|
|
74227
|
+
deliveryRef: outcome.deliveryRef,
|
|
74228
|
+
error: message,
|
|
74229
|
+
next: `Once the API answers: if ${task.id} is closed_done, ask the Director to apply run ${runId} (apply_local_run); otherwise the run is handed off or requeued as usual.`
|
|
74230
|
+
}));
|
|
74231
|
+
}
|
|
74232
|
+
await handOff(`local_delivery_settlement_failed: ${message}`);
|
|
74233
|
+
return;
|
|
74234
|
+
}
|
|
74235
|
+
console.warn(JSON.stringify({
|
|
74236
|
+
event: "settlement_outcome_recovered",
|
|
74237
|
+
projectSlug,
|
|
74238
|
+
runId,
|
|
74239
|
+
taskId: task.id,
|
|
74240
|
+
error: message
|
|
74241
|
+
}));
|
|
74242
|
+
}
|
|
73396
74243
|
}
|
|
73397
74244
|
if (input.delivery) input.delivery.settled = true;
|
|
73398
74245
|
const locksDir = deps.locksDir ?? "/tmp/mrrlin-locks";
|
|
73399
|
-
const headSha = outcome.evidence.headSha;
|
|
74246
|
+
const headSha = verifiedSettlement ? verifiedSettlement.git.head_oid : outcome.evidence.headSha;
|
|
74247
|
+
const expectedOldSha = verifiedSettlement ? verifiedSettlement.git.base_oid : input.integration ? input.integration.defaultTipSha : void 0;
|
|
74248
|
+
const runBranchGuardRef = verifiedSettlement ? verifiedSettlement.git.run_ref : `refs/heads/${worktreeBranch(runId)}`;
|
|
73400
74249
|
const logLanding = (event, extra) => console.warn(JSON.stringify({ event, projectSlug, runId, taskId: task.id, headSha, ...extra }));
|
|
73401
74250
|
logLanding("landing_started", { defaultBranch: input.defaultBranch });
|
|
73402
74251
|
let settledLease;
|
|
@@ -73434,16 +74283,73 @@ async function deliverLocalRun(deps, input) {
|
|
|
73434
74283
|
defaultBranch: input.defaultBranch,
|
|
73435
74284
|
headSha,
|
|
73436
74285
|
hooksDir,
|
|
73437
|
-
|
|
73438
|
-
|
|
73439
|
-
|
|
73440
|
-
|
|
73441
|
-
|
|
74286
|
+
expectedOldSha,
|
|
74287
|
+
runBranchGuard: { ref: runBranchGuardRef, sha: headSha },
|
|
74288
|
+
onLandingPrepared: (info) => {
|
|
74289
|
+
if (journal) {
|
|
74290
|
+
journal = updateSettlementJournalSync(stateDir, journal, {
|
|
74291
|
+
phase: "landing_prepared",
|
|
74292
|
+
landing: {
|
|
74293
|
+
baseOid: info.baseOid,
|
|
74294
|
+
headOid: info.headOid,
|
|
74295
|
+
targetRef: info.targetRef,
|
|
74296
|
+
runRef: info.runRef,
|
|
74297
|
+
checkoutDigest: verifiedSettlement?.git.checkout_digest ?? outcome.evidence.checkoutDigest,
|
|
74298
|
+
holders: info.holders
|
|
74299
|
+
}
|
|
74300
|
+
});
|
|
74301
|
+
}
|
|
74302
|
+
},
|
|
74303
|
+
onRefUpdated: () => {
|
|
74304
|
+
if (journal) {
|
|
74305
|
+
journal = updateSettlementJournalSync(stateDir, journal, {
|
|
74306
|
+
phase: "ref_updated"
|
|
74307
|
+
});
|
|
74308
|
+
}
|
|
74309
|
+
},
|
|
74310
|
+
onFilesSynced: () => {
|
|
74311
|
+
if (journal) {
|
|
74312
|
+
if (journal.landing) {
|
|
74313
|
+
journal.landing.holders.forEach((h) => {
|
|
74314
|
+
h.synced = true;
|
|
74315
|
+
});
|
|
74316
|
+
}
|
|
74317
|
+
journal = updateSettlementJournalSync(stateDir, journal, {
|
|
74318
|
+
phase: "files_synced",
|
|
74319
|
+
landing: journal.landing
|
|
74320
|
+
});
|
|
74321
|
+
}
|
|
74322
|
+
}
|
|
73442
74323
|
})
|
|
73443
74324
|
);
|
|
73444
74325
|
} catch (error51) {
|
|
73445
74326
|
landing = { applied: false, reason: "ff_failed", detail: error51 instanceof Error ? error51.message : String(error51) };
|
|
73446
74327
|
}
|
|
74328
|
+
if ((landing.applied || landing.reason === "already_applied") && verifiedSettlement && typeof deps.client.acknowledgeLocalGitLanding === "function") {
|
|
74329
|
+
if (journal) {
|
|
74330
|
+
journal = updateSettlementJournalSync(stateDir, journal, { phase: "ack_pending" });
|
|
74331
|
+
}
|
|
74332
|
+
try {
|
|
74333
|
+
await deps.client.acknowledgeLocalGitLanding(projectSlug, runId, {
|
|
74334
|
+
receiptId: verifiedSettlement.receipt.receiptId,
|
|
74335
|
+
headOid: verifiedSettlement.git.head_oid,
|
|
74336
|
+
baseOid: verifiedSettlement.git.base_oid,
|
|
74337
|
+
targetRef: verifiedSettlement.git.target_ref,
|
|
74338
|
+
checkoutDigest: verifiedSettlement.git.checkout_digest
|
|
74339
|
+
});
|
|
74340
|
+
if (journal) {
|
|
74341
|
+
journal = updateSettlementJournalSync(stateDir, journal, { phase: "complete" });
|
|
74342
|
+
}
|
|
74343
|
+
} catch (ackError) {
|
|
74344
|
+
console.warn(JSON.stringify({
|
|
74345
|
+
event: "landing_ack_failed",
|
|
74346
|
+
projectSlug,
|
|
74347
|
+
runId,
|
|
74348
|
+
receiptId: verifiedSettlement.receipt.receiptId,
|
|
74349
|
+
error: ackError instanceof Error ? ackError.message : String(ackError)
|
|
74350
|
+
}));
|
|
74351
|
+
}
|
|
74352
|
+
}
|
|
73447
74353
|
logLanding("landing_result", {
|
|
73448
74354
|
outcome: landing.applied ? "applied" : landing.reason,
|
|
73449
74355
|
...landing.applied ? { previousSha: landing.previousSha } : { detail: landing.detail }
|
|
@@ -73689,7 +74595,7 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
|
|
|
73689
74595
|
}
|
|
73690
74596
|
try {
|
|
73691
74597
|
await deps.client.createInboxItem(projectSlug, {
|
|
73692
|
-
id: `II-${
|
|
74598
|
+
id: `II-${import_node_crypto25.default.randomUUID()}`,
|
|
73693
74599
|
kind: "handoff",
|
|
73694
74600
|
taskId: task.id,
|
|
73695
74601
|
body: `Task ${task.id} (${task.title}) still needs operator follow-up: ${reason}. Mrrlin could not move the task back to Handoff needed automatically.`
|
|
@@ -73724,7 +74630,7 @@ async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
|
|
|
73724
74630
|
}
|
|
73725
74631
|
try {
|
|
73726
74632
|
await deps.client.createInboxItem(projectSlug, {
|
|
73727
|
-
id: `II-${
|
|
74633
|
+
id: `II-${import_node_crypto25.default.randomUUID()}`,
|
|
73728
74634
|
kind: "handoff",
|
|
73729
74635
|
taskId: task.id,
|
|
73730
74636
|
body: `Execution run ${runId} for task ${task.id} (${task.title}) needs operator attention: ${reason}`
|
|
@@ -73881,8 +74787,8 @@ async function runBackstopSweep(deps, drive = (slug, id) => driveRun(deps, slug,
|
|
|
73881
74787
|
function isRunRecoverableByThisBridge(run3, worktreeRoot) {
|
|
73882
74788
|
if (!worktreeRoot) return true;
|
|
73883
74789
|
if (!run3.worktreeId) return true;
|
|
73884
|
-
const relative =
|
|
73885
|
-
return relative === "" || relative.length > 0 && !relative.startsWith("..") && !
|
|
74790
|
+
const relative = import_node_path39.default.relative(import_node_path39.default.resolve(worktreeRoot), import_node_path39.default.resolve(run3.worktreeId));
|
|
74791
|
+
return relative === "" || relative.length > 0 && !relative.startsWith("..") && !import_node_path39.default.isAbsolute(relative);
|
|
73886
74792
|
}
|
|
73887
74793
|
async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId, reasonCode) {
|
|
73888
74794
|
const isRollbackReconciliation = reason.startsWith(`${ROLLBACK_INVOCATION_UNCONFIRMED}:`);
|
|
@@ -73909,7 +74815,7 @@ async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId
|
|
|
73909
74815
|
});
|
|
73910
74816
|
if (isRollbackReconciliation) return;
|
|
73911
74817
|
await deps.client.createInboxItem(projectSlug, {
|
|
73912
|
-
id: `II-${
|
|
74818
|
+
id: `II-${import_node_crypto25.default.randomUUID()}`,
|
|
73913
74819
|
kind: "handoff",
|
|
73914
74820
|
taskId: task.id,
|
|
73915
74821
|
body: `Deploy gate for run ${runId} (task ${task.id} \u2014 ${task.title}) needs operator attention: ${reason}`
|
|
@@ -73928,7 +74834,7 @@ function maxLeaseReclaims() {
|
|
|
73928
74834
|
}
|
|
73929
74835
|
|
|
73930
74836
|
// src/async-job-consumer.ts
|
|
73931
|
-
var
|
|
74837
|
+
var import_node_crypto26 = __toESM(require("node:crypto"), 1);
|
|
73932
74838
|
var ASYNC_JOB_MAX_ATTEMPTS = 2;
|
|
73933
74839
|
function ASYNC_UNOWNED_TTL_DAYS() {
|
|
73934
74840
|
const raw = Number(process.env.MRRLIN_ASYNC_UNOWNED_TTL_DAYS);
|
|
@@ -74053,7 +74959,7 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
|
|
|
74053
74959
|
const delivery = descriptor2.onComplete(outcome, input);
|
|
74054
74960
|
if (!delivery.suppressInbox) {
|
|
74055
74961
|
await deps.client.createInboxItem(projectSlug, {
|
|
74056
|
-
id: delivery.id ?? `II-${
|
|
74962
|
+
id: delivery.id ?? `II-${import_node_crypto26.default.randomUUID()}`,
|
|
74057
74963
|
kind: delivery.kind,
|
|
74058
74964
|
body: delivery.body,
|
|
74059
74965
|
...delivery.taskId ? { taskId: delivery.taskId } : {},
|
|
@@ -74071,13 +74977,13 @@ async function deriveRequestedHash(client, toolName2, input) {
|
|
|
74071
74977
|
if (input.requestedHash) return input.requestedHash;
|
|
74072
74978
|
if (toolName2 === "run_spec_consensus" && input.pageId) {
|
|
74073
74979
|
const page = await client.getWikiPage(input.projectSlug, input.pageId);
|
|
74074
|
-
return page.contentHash ??
|
|
74980
|
+
return page.contentHash ?? import_node_crypto26.default.createHash("sha256").update(page.markdownBody).digest("hex");
|
|
74075
74981
|
}
|
|
74076
74982
|
if (toolName2 === "draft_task_spec" && input.taskId) {
|
|
74077
74983
|
const task = await client.getTask(input.projectSlug, input.taskId);
|
|
74078
|
-
return task.updatedAt ??
|
|
74984
|
+
return task.updatedAt ?? import_node_crypto26.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
|
|
74079
74985
|
}
|
|
74080
|
-
return
|
|
74986
|
+
return import_node_crypto26.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
|
|
74081
74987
|
}
|
|
74082
74988
|
async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId)) {
|
|
74083
74989
|
const projects = await deps.client.listProjects();
|
|
@@ -74103,19 +75009,19 @@ async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJo
|
|
|
74103
75009
|
}
|
|
74104
75010
|
|
|
74105
75011
|
// src/bridge-artifacts.ts
|
|
74106
|
-
var
|
|
75012
|
+
var import_node_fs27 = __toESM(require("node:fs"), 1);
|
|
74107
75013
|
var import_promises16 = __toESM(require("node:fs/promises"), 1);
|
|
74108
|
-
var
|
|
75014
|
+
var import_node_path40 = __toESM(require("node:path"), 1);
|
|
74109
75015
|
var DEFAULT_MAX_ARTIFACTS_BYTES = 500 * 1024 * 1024;
|
|
74110
75016
|
var DEFAULT_MAX_ARTIFACT_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
74111
75017
|
function resolveArtifactsDir(baseStateDir) {
|
|
74112
75018
|
const stateDir = baseStateDir ?? resolveStateDir();
|
|
74113
|
-
return
|
|
75019
|
+
return import_node_path40.default.join(stateDir, "artifacts");
|
|
74114
75020
|
}
|
|
74115
75021
|
function ensureDir(dir) {
|
|
74116
|
-
|
|
75022
|
+
import_node_fs27.default.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
74117
75023
|
try {
|
|
74118
|
-
|
|
75024
|
+
import_node_fs27.default.chmodSync(dir, 448);
|
|
74119
75025
|
} catch {
|
|
74120
75026
|
}
|
|
74121
75027
|
}
|
|
@@ -74123,7 +75029,7 @@ function safeArtifactPath(artifactsDir, id) {
|
|
|
74123
75029
|
if (!id || typeof id !== "string" || !/^[a-zA-Z0-9_-]+$/.test(id)) {
|
|
74124
75030
|
throw new Error("Invalid artifact id");
|
|
74125
75031
|
}
|
|
74126
|
-
return
|
|
75032
|
+
return import_node_path40.default.join(artifactsDir, `${id}.json`);
|
|
74127
75033
|
}
|
|
74128
75034
|
async function writeLocalArtifact(id, payload, baseStateDir) {
|
|
74129
75035
|
const artifactsDir = resolveArtifactsDir(baseStateDir);
|
|
@@ -74166,7 +75072,7 @@ async function cleanArtifacts(baseStateDir, options) {
|
|
|
74166
75072
|
let deletedBytes = 0;
|
|
74167
75073
|
for (const name of entries) {
|
|
74168
75074
|
if (!name.endsWith(".json")) continue;
|
|
74169
|
-
const filePath =
|
|
75075
|
+
const filePath = import_node_path40.default.join(artifactsDir, name);
|
|
74170
75076
|
try {
|
|
74171
75077
|
const stat3 = await import_promises16.default.stat(filePath);
|
|
74172
75078
|
if (now - stat3.mtimeMs > maxAgeMs) {
|
|
@@ -75711,16 +76617,16 @@ async function handleIntegrationRpc(deps, msg) {
|
|
|
75711
76617
|
}
|
|
75712
76618
|
|
|
75713
76619
|
// src/thread-index.ts
|
|
75714
|
-
var
|
|
75715
|
-
var
|
|
76620
|
+
var import_node_fs28 = require("node:fs");
|
|
76621
|
+
var import_node_path42 = __toESM(require("node:path"), 1);
|
|
75716
76622
|
function threadIndexPath(stateDir) {
|
|
75717
|
-
return
|
|
76623
|
+
return import_node_path42.default.join(stateDir, "threads.json");
|
|
75718
76624
|
}
|
|
75719
76625
|
function loadThreadIndex(stateDir, ttlMs, now) {
|
|
75720
76626
|
const result = /* @__PURE__ */ new Map();
|
|
75721
76627
|
let parsed;
|
|
75722
76628
|
try {
|
|
75723
|
-
parsed = JSON.parse((0,
|
|
76629
|
+
parsed = JSON.parse((0, import_node_fs28.readFileSync)(threadIndexPath(stateDir), "utf8"));
|
|
75724
76630
|
} catch {
|
|
75725
76631
|
return result;
|
|
75726
76632
|
}
|
|
@@ -75746,8 +76652,8 @@ function loadThreadIndex(stateDir, ttlMs, now) {
|
|
|
75746
76652
|
return result;
|
|
75747
76653
|
}
|
|
75748
76654
|
function saveThreadIndex(stateDir, entries) {
|
|
75749
|
-
(0,
|
|
75750
|
-
(0,
|
|
76655
|
+
(0, import_node_fs28.mkdirSync)(stateDir, { recursive: true, mode: 448 });
|
|
76656
|
+
(0, import_node_fs28.writeFileSync)(threadIndexPath(stateDir), `${JSON.stringify(Object.fromEntries(entries), null, 2)}
|
|
75751
76657
|
`, {
|
|
75752
76658
|
encoding: "utf8",
|
|
75753
76659
|
mode: 384
|
|
@@ -75883,13 +76789,13 @@ function createToolBusyClock(opts) {
|
|
|
75883
76789
|
|
|
75884
76790
|
// src/remote-phone-relay.ts
|
|
75885
76791
|
var import_node_events3 = require("node:events");
|
|
75886
|
-
var
|
|
76792
|
+
var import_node_fs29 = require("node:fs");
|
|
75887
76793
|
var import_node_os20 = require("node:os");
|
|
75888
|
-
var
|
|
76794
|
+
var import_node_path43 = require("node:path");
|
|
75889
76795
|
|
|
75890
76796
|
// ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/cryptoNode.js
|
|
75891
76797
|
var nc = __toESM(require("node:crypto"), 1);
|
|
75892
|
-
var
|
|
76798
|
+
var crypto13 = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : void 0;
|
|
75893
76799
|
|
|
75894
76800
|
// ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/utils.js
|
|
75895
76801
|
function isBytes(a) {
|
|
@@ -75944,8 +76850,8 @@ function wrapConstructor(hashCons) {
|
|
|
75944
76850
|
return hashC;
|
|
75945
76851
|
}
|
|
75946
76852
|
function randomBytes5(bytesLength = 32) {
|
|
75947
|
-
if (
|
|
75948
|
-
return
|
|
76853
|
+
if (crypto13 && typeof crypto13.getRandomValues === "function") {
|
|
76854
|
+
return crypto13.getRandomValues(new Uint8Array(bytesLength));
|
|
75949
76855
|
}
|
|
75950
76856
|
throw new Error("crypto.getRandomValues must be defined");
|
|
75951
76857
|
}
|
|
@@ -79456,9 +80362,9 @@ var DirectorRelay = class {
|
|
|
79456
80362
|
|
|
79457
80363
|
// src/remote-phone-relay.ts
|
|
79458
80364
|
function loadOrCreateAgentDeviceKey() {
|
|
79459
|
-
const
|
|
80365
|
+
const path39 = (0, import_node_path43.join)((0, import_node_os20.homedir)(), ".mrrlin", "agent-device-key");
|
|
79460
80366
|
try {
|
|
79461
|
-
const raw = JSON.parse((0,
|
|
80367
|
+
const raw = JSON.parse((0, import_node_fs29.readFileSync)(path39, "utf8"));
|
|
79462
80368
|
if (typeof raw.priv === "string" && typeof raw.pub === "string") {
|
|
79463
80369
|
return { privateKey: fromBase64Url(raw.priv), publicKey: fromBase64Url(raw.pub) };
|
|
79464
80370
|
}
|
|
@@ -79466,9 +80372,9 @@ function loadOrCreateAgentDeviceKey() {
|
|
|
79466
80372
|
}
|
|
79467
80373
|
const kp = generateIdentityKeyPair();
|
|
79468
80374
|
try {
|
|
79469
|
-
(0,
|
|
79470
|
-
(0,
|
|
79471
|
-
|
|
80375
|
+
(0, import_node_fs29.mkdirSync)((0, import_node_path43.join)((0, import_node_os20.homedir)(), ".mrrlin"), { recursive: true });
|
|
80376
|
+
(0, import_node_fs29.writeFileSync)(
|
|
80377
|
+
path39,
|
|
79472
80378
|
JSON.stringify({ priv: toBase64Url(kp.privateKey), pub: toBase64Url(kp.publicKey) }),
|
|
79473
80379
|
{ mode: 384 }
|
|
79474
80380
|
);
|
|
@@ -79476,10 +80382,10 @@ function loadOrCreateAgentDeviceKey() {
|
|
|
79476
80382
|
}
|
|
79477
80383
|
return kp;
|
|
79478
80384
|
}
|
|
79479
|
-
var AGENT_PAIRING_PATH = (0,
|
|
80385
|
+
var AGENT_PAIRING_PATH = (0, import_node_path43.join)((0, import_node_os20.homedir)(), ".mrrlin", "agent-pairing.json");
|
|
79480
80386
|
function loadAgentPairing() {
|
|
79481
80387
|
try {
|
|
79482
|
-
const raw = JSON.parse((0,
|
|
80388
|
+
const raw = JSON.parse((0, import_node_fs29.readFileSync)(AGENT_PAIRING_PATH, "utf8"));
|
|
79483
80389
|
if (typeof raw.channelId === "string" && typeof raw.agentControlSecret === "string" && typeof raw.relayAuth === "string" && typeof raw.peerIdentityKey === "string") {
|
|
79484
80390
|
return {
|
|
79485
80391
|
channelId: raw.channelId,
|
|
@@ -79494,8 +80400,8 @@ function loadAgentPairing() {
|
|
|
79494
80400
|
}
|
|
79495
80401
|
function saveAgentPairing(record2) {
|
|
79496
80402
|
try {
|
|
79497
|
-
(0,
|
|
79498
|
-
(0,
|
|
80403
|
+
(0, import_node_fs29.mkdirSync)((0, import_node_path43.join)((0, import_node_os20.homedir)(), ".mrrlin"), { recursive: true });
|
|
80404
|
+
(0, import_node_fs29.writeFileSync)(AGENT_PAIRING_PATH, JSON.stringify(record2), { mode: 384 });
|
|
79499
80405
|
} catch {
|
|
79500
80406
|
}
|
|
79501
80407
|
}
|
|
@@ -79844,10 +80750,10 @@ var import_node_http3 = __toESM(require("node:http"), 1);
|
|
|
79844
80750
|
var import_node_https3 = __toESM(require("node:https"), 1);
|
|
79845
80751
|
var import_node_net3 = __toESM(require("node:net"), 1);
|
|
79846
80752
|
var import_node_tls = __toESM(require("node:tls"), 1);
|
|
79847
|
-
var
|
|
80753
|
+
var import_node_fs30 = __toESM(require("node:fs"), 1);
|
|
79848
80754
|
var import_node_os21 = __toESM(require("node:os"), 1);
|
|
79849
|
-
var
|
|
79850
|
-
var
|
|
80755
|
+
var import_node_path44 = __toESM(require("node:path"), 1);
|
|
80756
|
+
var import_node_crypto27 = __toESM(require("node:crypto"), 1);
|
|
79851
80757
|
var import_node_zlib = __toESM(require("node:zlib"), 1);
|
|
79852
80758
|
|
|
79853
80759
|
// src/verification-egress-policy.ts
|
|
@@ -80190,29 +81096,29 @@ function createBrokerSocketPath(runId, nonce, baseDirs = process.platform === "w
|
|
|
80190
81096
|
for (const base of baseDirs) {
|
|
80191
81097
|
let dir;
|
|
80192
81098
|
try {
|
|
80193
|
-
dir =
|
|
81099
|
+
dir = import_node_fs30.default.mkdtempSync(import_node_path44.default.join(base, "mrrlin-b-"));
|
|
80194
81100
|
} catch {
|
|
80195
81101
|
continue;
|
|
80196
81102
|
}
|
|
80197
|
-
const socketPath =
|
|
81103
|
+
const socketPath = import_node_path44.default.join(dir, fileName);
|
|
80198
81104
|
if (process.platform === "win32" || Buffer.byteLength(socketPath) <= MAX_UNIX_SOCKET_PATH_BYTES) {
|
|
80199
|
-
|
|
81105
|
+
import_node_fs30.default.chmodSync(dir, 448);
|
|
80200
81106
|
return { dir, socketPath };
|
|
80201
81107
|
}
|
|
80202
|
-
|
|
81108
|
+
import_node_fs30.default.rmSync(dir, { recursive: true, force: true });
|
|
80203
81109
|
}
|
|
80204
81110
|
throw new Error(`BROKER_SOCKET_ERROR: no temp directory gives a socket path within ${MAX_UNIX_SOCKET_PATH_BYTES} bytes`);
|
|
80205
81111
|
}
|
|
80206
81112
|
async function createVerificationBrokerSession(options) {
|
|
80207
|
-
const nonce =
|
|
81113
|
+
const nonce = import_node_crypto27.default.randomBytes(16).toString("hex");
|
|
80208
81114
|
let createdDir = null;
|
|
80209
81115
|
let socketPath = options.socketPath;
|
|
80210
81116
|
if (!socketPath) {
|
|
80211
81117
|
({ dir: createdDir, socketPath } = createBrokerSocketPath(options.runId, nonce));
|
|
80212
81118
|
}
|
|
80213
81119
|
try {
|
|
80214
|
-
if (
|
|
80215
|
-
|
|
81120
|
+
if (import_node_fs30.default.existsSync(socketPath)) {
|
|
81121
|
+
import_node_fs30.default.unlinkSync(socketPath);
|
|
80216
81122
|
}
|
|
80217
81123
|
} catch {
|
|
80218
81124
|
}
|
|
@@ -80500,12 +81406,12 @@ async function createVerificationBrokerSession(options) {
|
|
|
80500
81406
|
} catch (err) {
|
|
80501
81407
|
server.close();
|
|
80502
81408
|
try {
|
|
80503
|
-
if (
|
|
81409
|
+
if (import_node_fs30.default.existsSync(socketPath)) import_node_fs30.default.unlinkSync(socketPath);
|
|
80504
81410
|
} catch (error51) {
|
|
80505
81411
|
}
|
|
80506
81412
|
if (createdDir) {
|
|
80507
81413
|
try {
|
|
80508
|
-
|
|
81414
|
+
import_node_fs30.default.rmSync(createdDir, { recursive: true, force: true });
|
|
80509
81415
|
} catch (error51) {
|
|
80510
81416
|
}
|
|
80511
81417
|
}
|
|
@@ -80533,14 +81439,14 @@ async function createVerificationBrokerSession(options) {
|
|
|
80533
81439
|
server.close(() => resolve3());
|
|
80534
81440
|
});
|
|
80535
81441
|
try {
|
|
80536
|
-
if (
|
|
80537
|
-
|
|
81442
|
+
if (import_node_fs30.default.existsSync(socketPath)) {
|
|
81443
|
+
import_node_fs30.default.unlinkSync(socketPath);
|
|
80538
81444
|
}
|
|
80539
81445
|
} catch {
|
|
80540
81446
|
}
|
|
80541
81447
|
if (createdDir) {
|
|
80542
81448
|
try {
|
|
80543
|
-
|
|
81449
|
+
import_node_fs30.default.rmSync(createdDir, { recursive: true, force: true });
|
|
80544
81450
|
} catch {
|
|
80545
81451
|
}
|
|
80546
81452
|
}
|
|
@@ -81009,9 +81915,9 @@ function createRunVerificationTurn(deps) {
|
|
|
81009
81915
|
}
|
|
81010
81916
|
|
|
81011
81917
|
// src/director-reseed.ts
|
|
81012
|
-
var
|
|
81918
|
+
var import_node_fs31 = require("node:fs");
|
|
81013
81919
|
var import_node_readline3 = require("node:readline");
|
|
81014
|
-
var
|
|
81920
|
+
var import_node_path45 = require("node:path");
|
|
81015
81921
|
function estimateTokens(s) {
|
|
81016
81922
|
return Buffer.byteLength(s, "utf8");
|
|
81017
81923
|
}
|
|
@@ -81160,9 +82066,9 @@ async function readSessionRows(logsDir, files, sessionIds) {
|
|
|
81160
82066
|
const lines2 = [];
|
|
81161
82067
|
let missingFiles = 0;
|
|
81162
82068
|
for (const f of files) {
|
|
81163
|
-
const filePath = (0,
|
|
82069
|
+
const filePath = (0, import_node_path45.join)(logsDir, f);
|
|
81164
82070
|
try {
|
|
81165
|
-
const stream = (0,
|
|
82071
|
+
const stream = (0, import_node_fs31.createReadStream)(filePath, { encoding: "utf8" });
|
|
81166
82072
|
const rl = (0, import_node_readline3.createInterface)({ input: stream, crlfDelay: Infinity });
|
|
81167
82073
|
try {
|
|
81168
82074
|
for await (const line of rl) {
|
|
@@ -81186,10 +82092,10 @@ async function readSessionRows(logsDir, files, sessionIds) {
|
|
|
81186
82092
|
}
|
|
81187
82093
|
|
|
81188
82094
|
// src/external-agents-prune.ts
|
|
81189
|
-
var
|
|
82095
|
+
var import_node_fs32 = require("node:fs");
|
|
81190
82096
|
var import_promises19 = __toESM(require("node:fs/promises"), 1);
|
|
81191
82097
|
var import_node_os22 = __toESM(require("node:os"), 1);
|
|
81192
|
-
var
|
|
82098
|
+
var import_node_path46 = __toESM(require("node:path"), 1);
|
|
81193
82099
|
var toml5 = __toESM(require_toml(), 1);
|
|
81194
82100
|
var LEGACY_EXTERNAL_AGENTS_TOOL_NAMES = [
|
|
81195
82101
|
"dispatch",
|
|
@@ -81242,8 +82148,8 @@ async function realPathOr(file2) {
|
|
|
81242
82148
|
}
|
|
81243
82149
|
}
|
|
81244
82150
|
function resolveCodexConfigPath(options) {
|
|
81245
|
-
const codexHome = options.codexHome ?? (options.homeDir ?
|
|
81246
|
-
return
|
|
82151
|
+
const codexHome = options.codexHome ?? (options.homeDir ? import_node_path46.default.join(options.homeDir, ".codex") : process.env.CODEX_HOME ?? import_node_path46.default.join(import_node_os22.default.homedir(), ".codex"));
|
|
82152
|
+
return import_node_path46.default.join(codexHome, "config.toml");
|
|
81247
82153
|
}
|
|
81248
82154
|
async function pruneCodexExternalAgents(options) {
|
|
81249
82155
|
const configPath = await realPathOr(resolveCodexConfigPath(options));
|
|
@@ -81277,13 +82183,13 @@ async function pruneJsonMcpEntry(client, file2, binPath) {
|
|
|
81277
82183
|
return { ...absent, status: "pruned" };
|
|
81278
82184
|
}
|
|
81279
82185
|
async function pruneClaudeExternalAgents(options) {
|
|
81280
|
-
const file2 = options.claudeConfigPath ??
|
|
82186
|
+
const file2 = options.claudeConfigPath ?? import_node_path46.default.join(options.homeDir ?? import_node_os22.default.homedir(), ".claude.json");
|
|
81281
82187
|
return pruneJsonMcpEntry("claude", file2, options.binPath);
|
|
81282
82188
|
}
|
|
81283
82189
|
async function pruneAgyExternalAgents(options) {
|
|
81284
82190
|
const home = options.homeDir ?? import_node_os22.default.homedir();
|
|
81285
|
-
const mcpFile = options.agyConfigPath ??
|
|
81286
|
-
const configJsonPath = options.configJsonPath ??
|
|
82191
|
+
const mcpFile = options.agyConfigPath ?? import_node_path46.default.join(home, ".gemini", "config", "mcp_config.json");
|
|
82192
|
+
const configJsonPath = options.configJsonPath ?? import_node_path46.default.join(home, ".gemini", "config", "config.json");
|
|
81287
82193
|
const result = await pruneJsonMcpEntry("agy", mcpFile, options.binPath);
|
|
81288
82194
|
if (result.status !== "pruned") return result;
|
|
81289
82195
|
const raw = await readIfExists(configJsonPath);
|
|
@@ -81323,10 +82229,10 @@ function runningBinPaths(argv1, resolveOpts) {
|
|
|
81323
82229
|
const out = /* @__PURE__ */ new Set();
|
|
81324
82230
|
const add2 = (p) => {
|
|
81325
82231
|
if (!p) return;
|
|
81326
|
-
const resolved =
|
|
82232
|
+
const resolved = import_node_path46.default.resolve(p);
|
|
81327
82233
|
out.add(resolved);
|
|
81328
82234
|
try {
|
|
81329
|
-
out.add((0,
|
|
82235
|
+
out.add((0, import_node_fs32.realpathSync)(resolved));
|
|
81330
82236
|
} catch {
|
|
81331
82237
|
}
|
|
81332
82238
|
};
|
|
@@ -81405,7 +82311,7 @@ function addBridgeModel(target, model) {
|
|
|
81405
82311
|
}
|
|
81406
82312
|
function readTextIfExists(filePath) {
|
|
81407
82313
|
try {
|
|
81408
|
-
return
|
|
82314
|
+
return import_node_fs33.default.readFileSync(filePath, "utf8");
|
|
81409
82315
|
} catch {
|
|
81410
82316
|
return null;
|
|
81411
82317
|
}
|
|
@@ -81416,9 +82322,9 @@ function readKnownGptSlugsFromTomlFile(filePath) {
|
|
|
81416
82322
|
return Array.from(raw.matchAll(/^\s*model\s*=\s*"([^"]+)"/gm)).map((match) => match[1]?.trim() ?? "").filter(isSelectableModelSlug);
|
|
81417
82323
|
}
|
|
81418
82324
|
function readCodexFallbackModels() {
|
|
81419
|
-
const codexHome = process.env.CODEX_HOME?.trim() ||
|
|
82325
|
+
const codexHome = process.env.CODEX_HOME?.trim() || import_node_path47.default.join(import_node_os23.default.homedir(), ".codex");
|
|
81420
82326
|
const models = /* @__PURE__ */ new Map();
|
|
81421
|
-
const cachePath =
|
|
82327
|
+
const cachePath = import_node_path47.default.join(codexHome, "models_cache.json");
|
|
81422
82328
|
const cacheRaw = readTextIfExists(cachePath);
|
|
81423
82329
|
if (cacheRaw) {
|
|
81424
82330
|
try {
|
|
@@ -81468,7 +82374,7 @@ function readCodexFallbackModels() {
|
|
|
81468
82374
|
);
|
|
81469
82375
|
}
|
|
81470
82376
|
}
|
|
81471
|
-
for (const slug of readKnownGptSlugsFromTomlFile(
|
|
82377
|
+
for (const slug of readKnownGptSlugsFromTomlFile(import_node_path47.default.join(codexHome, "config.toml"))) {
|
|
81472
82378
|
addBridgeModel(
|
|
81473
82379
|
models,
|
|
81474
82380
|
mapBridgeModel({
|
|
@@ -81482,11 +82388,11 @@ function readCodexFallbackModels() {
|
|
|
81482
82388
|
})
|
|
81483
82389
|
);
|
|
81484
82390
|
}
|
|
81485
|
-
const automationsDir =
|
|
82391
|
+
const automationsDir = import_node_path47.default.join(codexHome, "automations");
|
|
81486
82392
|
try {
|
|
81487
|
-
for (const entry of
|
|
82393
|
+
for (const entry of import_node_fs33.default.readdirSync(automationsDir, { withFileTypes: true })) {
|
|
81488
82394
|
if (!entry.isDirectory()) continue;
|
|
81489
|
-
for (const slug of readKnownGptSlugsFromTomlFile(
|
|
82395
|
+
for (const slug of readKnownGptSlugsFromTomlFile(import_node_path47.default.join(automationsDir, entry.name, "automation.toml"))) {
|
|
81490
82396
|
addBridgeModel(
|
|
81491
82397
|
models,
|
|
81492
82398
|
mapBridgeModel({
|
|
@@ -81506,16 +82412,16 @@ function readCodexFallbackModels() {
|
|
|
81506
82412
|
return [...models.values()];
|
|
81507
82413
|
}
|
|
81508
82414
|
function selfUpdateInboxItemId(offeredVersion) {
|
|
81509
|
-
if (!offeredVersion) return `II-MCPUPD-${(0,
|
|
82415
|
+
if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto28.randomUUID)()}`;
|
|
81510
82416
|
if (/^[A-Za-z0-9._-]+$/.test(offeredVersion)) return `II-MCPUPD-${offeredVersion}`;
|
|
81511
|
-
const hash3 =
|
|
82417
|
+
const hash3 = import_node_crypto28.default.createHash("sha256").update(offeredVersion).digest("hex").slice(0, 10);
|
|
81512
82418
|
return `II-MCPUPD-${offeredVersion.replace(/[^A-Za-z0-9._-]/g, "-")}-${hash3}`;
|
|
81513
82419
|
}
|
|
81514
82420
|
function neutralCheckoutCwd(stateDir) {
|
|
81515
|
-
const dir =
|
|
82421
|
+
const dir = import_node_path47.default.join(stateDir, "no-checkout");
|
|
81516
82422
|
try {
|
|
81517
|
-
|
|
81518
|
-
if (!
|
|
82423
|
+
import_node_fs33.default.mkdirSync(dir, { recursive: true });
|
|
82424
|
+
if (!import_node_fs33.default.existsSync(import_node_path47.default.join(dir, ".git"))) {
|
|
81519
82425
|
try {
|
|
81520
82426
|
(0, import_node_child_process25.spawnSync)("git", ["init", "-b", "main"], { cwd: dir, stdio: "ignore" });
|
|
81521
82427
|
} catch {
|
|
@@ -82102,7 +83008,7 @@ async function runOrphanWorktreeSweep(client, opts) {
|
|
|
82102
83008
|
const cutoff = Date.now() - worktreeRetentionMs();
|
|
82103
83009
|
const isReapable = (worktreePath) => {
|
|
82104
83010
|
try {
|
|
82105
|
-
return
|
|
83011
|
+
return import_node_fs33.default.statSync(worktreePath).mtimeMs < cutoff;
|
|
82106
83012
|
} catch {
|
|
82107
83013
|
return false;
|
|
82108
83014
|
}
|
|
@@ -82138,6 +83044,136 @@ async function runOrphanWorktreeSweep(client, opts) {
|
|
|
82138
83044
|
);
|
|
82139
83045
|
}
|
|
82140
83046
|
}
|
|
83047
|
+
await recoverPendingSettlementJournals(client, opts);
|
|
83048
|
+
}
|
|
83049
|
+
async function recoverSingleLanding(client, checkoutPath, projectSlug, runId, receipt, locksDir, journal, stateDir) {
|
|
83050
|
+
if (!receipt || !client.getJwks) return false;
|
|
83051
|
+
const targetKeyId = receipt.signingKeyId ?? receipt.signing_key_id;
|
|
83052
|
+
const jwks = await client.getJwks().catch(() => null);
|
|
83053
|
+
const activeKey = jwks?.keys?.find((k) => k.kid === targetKeyId);
|
|
83054
|
+
if (!activeKey?.x) {
|
|
83055
|
+
return false;
|
|
83056
|
+
}
|
|
83057
|
+
const canonicalPayload = receipt.canonicalPayload ?? receipt.payload;
|
|
83058
|
+
if (!canonicalPayload || !receipt.signature) {
|
|
83059
|
+
return false;
|
|
83060
|
+
}
|
|
83061
|
+
if (!verifyReceiptSignature(canonicalPayload, receipt.signature, activeKey.x)) {
|
|
83062
|
+
return false;
|
|
83063
|
+
}
|
|
83064
|
+
const git3 = canonicalPayload?.client_reported?.git;
|
|
83065
|
+
if (!git3 || !git3.head_oid || !git3.base_oid || !git3.target_ref || !git3.checkout_digest) {
|
|
83066
|
+
return false;
|
|
83067
|
+
}
|
|
83068
|
+
const checkoutRealPath = import_node_fs33.default.realpathSync(checkoutPath);
|
|
83069
|
+
const currentCheckoutDigest = import_node_crypto28.default.createHash("sha256").update(checkoutRealPath).digest("hex");
|
|
83070
|
+
if (git3.checkout_digest !== currentCheckoutDigest) {
|
|
83071
|
+
return false;
|
|
83072
|
+
}
|
|
83073
|
+
const expectedRunRef = `refs/heads/mrrlin/run-${runId}`;
|
|
83074
|
+
if (git3.run_ref !== expectedRunRef) {
|
|
83075
|
+
return false;
|
|
83076
|
+
}
|
|
83077
|
+
const defaultBranch = resolveLocalDefaultBranch(checkoutRealPath);
|
|
83078
|
+
if (git3.target_ref !== `refs/heads/${defaultBranch}`) {
|
|
83079
|
+
return false;
|
|
83080
|
+
}
|
|
83081
|
+
let success2 = false;
|
|
83082
|
+
await withCheckoutLock(locksDir, deliveryLockKey(checkoutRealPath), async () => {
|
|
83083
|
+
const hooksDir = prepareDisabledGitHooksDir(locksDir, runId);
|
|
83084
|
+
const applyRes = applyLocalRun({
|
|
83085
|
+
checkoutRealPath,
|
|
83086
|
+
defaultBranch,
|
|
83087
|
+
headSha: git3.head_oid,
|
|
83088
|
+
expectedOldSha: git3.base_oid,
|
|
83089
|
+
hooksDir,
|
|
83090
|
+
runBranchGuard: { ref: expectedRunRef, sha: git3.head_oid },
|
|
83091
|
+
recoveryContext: journal ? {
|
|
83092
|
+
phase: journal.phase,
|
|
83093
|
+
holders: journal.landing?.holders
|
|
83094
|
+
} : void 0
|
|
83095
|
+
});
|
|
83096
|
+
if (applyRes.applied || applyRes.reason === "already_applied") {
|
|
83097
|
+
if (client.acknowledgeLocalGitLanding) {
|
|
83098
|
+
await client.acknowledgeLocalGitLanding(projectSlug, runId, {
|
|
83099
|
+
receiptId: receipt.receiptId,
|
|
83100
|
+
headOid: git3.head_oid,
|
|
83101
|
+
baseOid: git3.base_oid,
|
|
83102
|
+
targetRef: git3.target_ref,
|
|
83103
|
+
checkoutDigest: git3.checkout_digest
|
|
83104
|
+
});
|
|
83105
|
+
}
|
|
83106
|
+
if (journal && stateDir) {
|
|
83107
|
+
updateSettlementJournalSync(stateDir, journal, { phase: "complete" });
|
|
83108
|
+
}
|
|
83109
|
+
success2 = true;
|
|
83110
|
+
}
|
|
83111
|
+
});
|
|
83112
|
+
return success2;
|
|
83113
|
+
}
|
|
83114
|
+
async function recoverPendingSettlementJournals(client, opts) {
|
|
83115
|
+
const stateDir = resolveStateDir(process.env);
|
|
83116
|
+
const pendingJournals = listPendingSettlementJournalsSync(stateDir);
|
|
83117
|
+
const locksDir = import_node_path47.default.join(stateDir, "locks");
|
|
83118
|
+
for (const journal of pendingJournals) {
|
|
83119
|
+
const checkout = opts.checkoutRegistry.get(journal.projectSlug);
|
|
83120
|
+
if (!checkout) continue;
|
|
83121
|
+
if (!journal.receipt && client.getLocalGitSettlement && journal.idempotencyKey) {
|
|
83122
|
+
const lookup = await client.getLocalGitSettlement(journal.projectSlug, journal.runId, journal.idempotencyKey).catch(() => null);
|
|
83123
|
+
if (lookup && "data" in lookup && "receipt" in lookup.data) {
|
|
83124
|
+
journal.receipt = lookup.data.receipt;
|
|
83125
|
+
updateSettlementJournalSync(stateDir, journal, { receipt: journal.receipt, phase: "receipt_saved" });
|
|
83126
|
+
}
|
|
83127
|
+
}
|
|
83128
|
+
if (!journal.receipt) continue;
|
|
83129
|
+
try {
|
|
83130
|
+
await recoverSingleLanding(
|
|
83131
|
+
client,
|
|
83132
|
+
checkout.path,
|
|
83133
|
+
journal.projectSlug,
|
|
83134
|
+
journal.runId,
|
|
83135
|
+
journal.receipt,
|
|
83136
|
+
locksDir,
|
|
83137
|
+
journal,
|
|
83138
|
+
stateDir
|
|
83139
|
+
);
|
|
83140
|
+
} catch {
|
|
83141
|
+
}
|
|
83142
|
+
}
|
|
83143
|
+
try {
|
|
83144
|
+
const projects = await client.listProjects();
|
|
83145
|
+
for (const project of projects) {
|
|
83146
|
+
const checkout = opts.checkoutRegistry.get(project.slug);
|
|
83147
|
+
if (!checkout) continue;
|
|
83148
|
+
if (!client.listPendingLocalGitLandings) continue;
|
|
83149
|
+
const pendingResponse = await client.listPendingLocalGitLandings(project.slug).catch(() => null);
|
|
83150
|
+
if (!Array.isArray(pendingResponse)) continue;
|
|
83151
|
+
for (const landing of pendingResponse) {
|
|
83152
|
+
if (landing.state !== "receipt_issued") continue;
|
|
83153
|
+
const journals = findSettlementJournalsSync(stateDir, project.slug, landing.runId);
|
|
83154
|
+
const idempotencyKey = journals.find((j) => j.idempotencyKey)?.idempotencyKey;
|
|
83155
|
+
if (!idempotencyKey) continue;
|
|
83156
|
+
const lookup = await client.getLocalGitSettlement(project.slug, landing.runId, idempotencyKey).catch(() => null);
|
|
83157
|
+
if (!lookup || !("data" in lookup) || !("receipt" in lookup.data)) continue;
|
|
83158
|
+
const settlement = lookup.data;
|
|
83159
|
+
const journal = journals.find((j) => j.receipt?.receiptId === settlement.receipt.receiptId);
|
|
83160
|
+
try {
|
|
83161
|
+
await recoverSingleLanding(
|
|
83162
|
+
client,
|
|
83163
|
+
checkout.path,
|
|
83164
|
+
project.slug,
|
|
83165
|
+
landing.runId,
|
|
83166
|
+
settlement.receipt,
|
|
83167
|
+
locksDir,
|
|
83168
|
+
journal,
|
|
83169
|
+
stateDir
|
|
83170
|
+
);
|
|
83171
|
+
} catch {
|
|
83172
|
+
}
|
|
83173
|
+
}
|
|
83174
|
+
}
|
|
83175
|
+
} catch {
|
|
83176
|
+
}
|
|
82141
83177
|
}
|
|
82142
83178
|
function readStateDir() {
|
|
82143
83179
|
return resolveStateDir(process.env);
|
|
@@ -82251,7 +83287,7 @@ function createBridgeRequestListener(opts) {
|
|
|
82251
83287
|
res.end(JSON.stringify({ ok: false, error: "Origin not allowed." }));
|
|
82252
83288
|
return;
|
|
82253
83289
|
}
|
|
82254
|
-
const nonce =
|
|
83290
|
+
const nonce = import_node_crypto28.default.randomBytes(16).toString("base64url");
|
|
82255
83291
|
res.writeHead(200, { "content-type": "application/json" });
|
|
82256
83292
|
const publicHost = host === "0.0.0.0" ? "127.0.0.1" : host;
|
|
82257
83293
|
res.end(JSON.stringify({ ok: true, wsUrl: `ws://${publicHost}:${port}/ws`, token, nonce }));
|
|
@@ -82536,7 +83572,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
82536
83572
|
}
|
|
82537
83573
|
}
|
|
82538
83574
|
socket.on("message", async (data) => {
|
|
82539
|
-
const spanId =
|
|
83575
|
+
const spanId = import_node_crypto28.default.randomUUID();
|
|
82540
83576
|
if (logCtx) {
|
|
82541
83577
|
logCtx.span.id = spanId;
|
|
82542
83578
|
logCtx.span.at = Date.now();
|
|
@@ -82733,7 +83769,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
82733
83769
|
return;
|
|
82734
83770
|
}
|
|
82735
83771
|
if (typeof msg.type === "string" && isIntegrationRpcType(msg.type)) {
|
|
82736
|
-
const store = deps.connectionStore ?? new LocalConnectionStore(deps.stateDir ??
|
|
83772
|
+
const store = deps.connectionStore ?? new LocalConnectionStore(deps.stateDir ?? import_node_path47.default.join(import_node_os23.default.homedir(), ".mrrlin"));
|
|
82737
83773
|
const allowLocal = process.env.NODE_ENV !== "production" && (process.env.NODE_ENV === "test" || process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1");
|
|
82738
83774
|
const rawMsg = msg;
|
|
82739
83775
|
const msgProjectSlug = typeof rawMsg.projectSlug === "string" ? rawMsg.projectSlug : typeof rawMsg.context?.projectSlug === "string" ? rawMsg.context.projectSlug : void 0;
|
|
@@ -83015,7 +84051,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
83015
84051
|
let desiredInstructionHash = null;
|
|
83016
84052
|
try {
|
|
83017
84053
|
const startParams = deps.buildStartParams(msg, desiredModel);
|
|
83018
|
-
desiredInstructionHash =
|
|
84054
|
+
desiredInstructionHash = import_node_crypto28.default.createHash("sha256").update(startParams.baseInstructions ?? "").digest("hex");
|
|
83019
84055
|
if (!thread) {
|
|
83020
84056
|
const newThread = {
|
|
83021
84057
|
threadId: "",
|
|
@@ -83096,7 +84132,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
83096
84132
|
thread.inFlight = true;
|
|
83097
84133
|
pendingTurnSessions.delete(directorSessionId);
|
|
83098
84134
|
thread.replay = createReplayBuffer({
|
|
83099
|
-
turnId: (0,
|
|
84135
|
+
turnId: (0, import_node_crypto28.randomUUID)(),
|
|
83100
84136
|
spanId,
|
|
83101
84137
|
...deps.retentionMs !== void 0 ? { retentionMs: deps.retentionMs } : {},
|
|
83102
84138
|
...deps.ackLingerMs !== void 0 ? { ackLingerMs: deps.ackLingerMs } : {}
|
|
@@ -83731,23 +84767,10 @@ function createSelectedProviderRefresher(deps) {
|
|
|
83731
84767
|
}
|
|
83732
84768
|
});
|
|
83733
84769
|
}
|
|
83734
|
-
var envSigningProvider;
|
|
83735
84770
|
function buildBridgeSigningProvider() {
|
|
83736
|
-
const signingKeyId = process.env.MRRLIN_SIGNING_KEY_ID;
|
|
83737
|
-
const signingPrivateKey = process.env.MRRLIN_SIGNING_PRIVATE_KEY;
|
|
83738
84771
|
delete process.env.MRRLIN_SIGNING_PRIVATE_KEY;
|
|
83739
|
-
|
|
83740
|
-
|
|
83741
|
-
keyId: signingKeyId,
|
|
83742
|
-
privateKey: signingPrivateKey
|
|
83743
|
-
});
|
|
83744
|
-
return envSigningProvider;
|
|
83745
|
-
}
|
|
83746
|
-
if (signingKeyId && envSigningProvider?.getKeyId() === signingKeyId) {
|
|
83747
|
-
return envSigningProvider;
|
|
83748
|
-
}
|
|
83749
|
-
const isTestOrSmoke = process.env.NODE_ENV === "test" || process.env.MRRLIN_TEST === "1" || process.env.MRRLIN_SMOKE_TEST === "1";
|
|
83750
|
-
if (isTestOrSmoke) {
|
|
84772
|
+
const isExplicitTest = process.env.NODE_ENV === "test" || process.env.MRRLIN_TEST === "1" || process.env.MRRLIN_SMOKE_TEST === "1";
|
|
84773
|
+
if (isExplicitTest) {
|
|
83751
84774
|
return new LocalEd25519SigningProvider({
|
|
83752
84775
|
keyId: FIXTURE_SIGNING_KEY_ID,
|
|
83753
84776
|
privateKey: FIXTURE_PRIVATE_KEY_BASE64
|
|
@@ -83938,10 +84961,10 @@ async function startDirectorBridge(startupDeps = {}) {
|
|
|
83938
84961
|
codexCwd: config2.codexCwd,
|
|
83939
84962
|
codexExecutable: config2.codexExecutable,
|
|
83940
84963
|
checkoutRegistry,
|
|
83941
|
-
worktreeRoot:
|
|
83942
|
-
locksDir:
|
|
84964
|
+
worktreeRoot: import_node_path47.default.join(config2.stateDir, "worktrees"),
|
|
84965
|
+
locksDir: import_node_path47.default.join(config2.stateDir, "locks"),
|
|
83943
84966
|
// local-git-delivery: bridge-local evidence (checkout realpath, build logs) that never leaves this machine.
|
|
83944
|
-
localEvidenceDir:
|
|
84967
|
+
localEvidenceDir: import_node_path47.default.join(config2.stateDir, "local-evidence"),
|
|
83945
84968
|
// Wire the executor server for code-execution runs. Each run gets its own provider process
|
|
83946
84969
|
// (app-server for codex, a resident CLI child for claude) at the run worktree, running
|
|
83947
84970
|
// UNRESTRICTED from the real operator config (owner no-sandbox decision — auth + mrrlin MCP
|
|
@@ -83958,7 +84981,7 @@ async function startDirectorBridge(startupDeps = {}) {
|
|
|
83958
84981
|
// The run's provider process carries exactly its own project (or none), so its Mrrlin MCP
|
|
83959
84982
|
// server is bound to it and never to whatever the bridge's environment names.
|
|
83960
84983
|
env: threadProcessEnv(process.env, directorThreadEnv(projectSlug)),
|
|
83961
|
-
disabledGitHooksDir: prepareDisabledGitHooksDir(
|
|
84984
|
+
disabledGitHooksDir: prepareDisabledGitHooksDir(import_node_path47.default.join(config2.stateDir, "locks"), import_node_path47.default.basename(worktreePath)),
|
|
83962
84985
|
provider: providerId
|
|
83963
84986
|
});
|
|
83964
84987
|
return { handle: executor.handle, dispose: executor.dispose };
|
|
@@ -83976,7 +84999,7 @@ async function startDirectorBridge(startupDeps = {}) {
|
|
|
83976
84999
|
provisionProjectFolder: (projectSlug) => provisionNewProjectFolder(checkoutRegistry, projectSlug, import_node_os23.default.hostname()),
|
|
83977
85000
|
// Dogfood v2 F-36: an executor thread started under older instructions is not resumed.
|
|
83978
85001
|
executorThreadInstructions: createExecutorThreadInstructionStore(
|
|
83979
|
-
|
|
85002
|
+
import_node_path47.default.join(config2.stateDir, "executor-thread-instructions.json")
|
|
83980
85003
|
),
|
|
83981
85004
|
// ADR 0007 self-review: critique the committed diff on the executor's own agent handle before
|
|
83982
85005
|
// push/PR. Reuses the collected-turn runner (startThread + collect assistant text).
|
|
@@ -84001,10 +85024,10 @@ async function startDirectorBridge(startupDeps = {}) {
|
|
|
84001
85024
|
runVerificationTurn: createRunVerificationTurn({
|
|
84002
85025
|
startSandbox: async (egressDomains, providerId, opts) => {
|
|
84003
85026
|
opts?.wrapCommand?.(["node"]);
|
|
84004
|
-
const scratchDir =
|
|
85027
|
+
const scratchDir = import_node_fs33.default.mkdtempSync(import_node_path47.default.join(import_node_os23.default.tmpdir(), "mrrlin-verify-"));
|
|
84005
85028
|
const executor = await startExecutorServer({
|
|
84006
85029
|
worktree: scratchDir,
|
|
84007
|
-
disabledGitHooksDir: prepareDisabledGitHooksDir(
|
|
85030
|
+
disabledGitHooksDir: prepareDisabledGitHooksDir(import_node_path47.default.join(config2.stateDir, "locks"), import_node_path47.default.basename(scratchDir)),
|
|
84008
85031
|
provider: providerId,
|
|
84009
85032
|
wrapCommand: opts?.wrapCommand,
|
|
84010
85033
|
brokerSocket: opts?.brokerSocket,
|
|
@@ -84017,7 +85040,7 @@ async function startDirectorBridge(startupDeps = {}) {
|
|
|
84017
85040
|
dispose: () => {
|
|
84018
85041
|
executor.dispose();
|
|
84019
85042
|
try {
|
|
84020
|
-
|
|
85043
|
+
import_node_fs33.default.rmSync(scratchDir, { recursive: true, force: true });
|
|
84021
85044
|
} catch {
|
|
84022
85045
|
}
|
|
84023
85046
|
},
|
|
@@ -84051,7 +85074,7 @@ async function startDirectorBridge(startupDeps = {}) {
|
|
|
84051
85074
|
};
|
|
84052
85075
|
const sessionSinks = createSessionSinkRegistry();
|
|
84053
85076
|
const tombstones = /* @__PURE__ */ new Map();
|
|
84054
|
-
const bridgeInstanceId = (0,
|
|
85077
|
+
const bridgeInstanceId = (0, import_node_crypto28.randomUUID)();
|
|
84055
85078
|
const asyncConsumerDeps = {
|
|
84056
85079
|
client,
|
|
84057
85080
|
run: wrappedTurnLock.run,
|
|
@@ -84230,7 +85253,7 @@ async function startDirectorBridge(startupDeps = {}) {
|
|
|
84230
85253
|
const files = dayFilesInWindow(/* @__PURE__ */ new Date(), reseedWindowMs);
|
|
84231
85254
|
filesCount = files.length;
|
|
84232
85255
|
const sessionIds = [args.directorSessionId, ...args.priorSessionIds];
|
|
84233
|
-
const { lines: lines2, missingFiles } = await readSessionRows(
|
|
85256
|
+
const { lines: lines2, missingFiles } = await readSessionRows(import_node_path47.default.join(config2.stateDir, "logs"), files, sessionIds);
|
|
84234
85257
|
missingFilesCount = missingFiles;
|
|
84235
85258
|
const extracted = extractItems(lines2, sessionIds);
|
|
84236
85259
|
items = extracted.items;
|
|
@@ -84379,7 +85402,7 @@ async function startDirectorBridge(startupDeps = {}) {
|
|
|
84379
85402
|
const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
|
|
84380
85403
|
let bridgeBinShaShort = "unknown00000";
|
|
84381
85404
|
try {
|
|
84382
|
-
bridgeBinShaShort =
|
|
85405
|
+
bridgeBinShaShort = import_node_crypto28.default.createHash("sha256").update(import_node_fs33.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
|
|
84383
85406
|
} catch {
|
|
84384
85407
|
}
|
|
84385
85408
|
attachBridgeWss(server, {
|
|
@@ -84520,8 +85543,8 @@ async function startDirectorBridge(startupDeps = {}) {
|
|
|
84520
85543
|
);
|
|
84521
85544
|
void runOrphanWorktreeSweep(client, {
|
|
84522
85545
|
checkoutRegistry,
|
|
84523
|
-
worktreeRoot:
|
|
84524
|
-
locksDir:
|
|
85546
|
+
worktreeRoot: import_node_path47.default.join(config2.stateDir, "worktrees"),
|
|
85547
|
+
locksDir: import_node_path47.default.join(config2.stateDir, "locks")
|
|
84525
85548
|
});
|
|
84526
85549
|
{
|
|
84527
85550
|
const { retainedBuffers, retainedBytes, tombstonesRemoved } = sweepReplayBuffers(threads, tombstones, {
|
|
@@ -84614,6 +85637,12 @@ async function startDirectorBridge(startupDeps = {}) {
|
|
|
84614
85637
|
}, claimIntervalMs());
|
|
84615
85638
|
claimTimer.unref?.();
|
|
84616
85639
|
};
|
|
85640
|
+
void recoverPendingSettlementJournals(client, { checkoutRegistry }).catch((err) => {
|
|
85641
|
+
process.stderr.write(
|
|
85642
|
+
`[mrrlin-mcp director-bridge] startup settlement recovery failed: ${err instanceof Error ? err.message : String(err)}
|
|
85643
|
+
`
|
|
85644
|
+
);
|
|
85645
|
+
});
|
|
84617
85646
|
if (shouldRunClaimLoop({ hasStaticToken, hasTokenProvider: Boolean(tokenProvider) })) {
|
|
84618
85647
|
scheduleClaimLoop();
|
|
84619
85648
|
} else {
|
|
@@ -84820,7 +85849,7 @@ function timingSafeTokenEqual(provided, expected) {
|
|
|
84820
85849
|
const a = Buffer.from(provided);
|
|
84821
85850
|
const b = Buffer.from(expected);
|
|
84822
85851
|
if (a.length !== b.length) return false;
|
|
84823
|
-
return
|
|
85852
|
+
return import_node_crypto28.default.timingSafeEqual(a, b);
|
|
84824
85853
|
}
|
|
84825
85854
|
function readDispatchBody(req) {
|
|
84826
85855
|
return new Promise((resolve3, reject) => {
|
|
@@ -84842,15 +85871,15 @@ function readDispatchBody(req) {
|
|
|
84842
85871
|
function readOrCreateBridgeToken(stateDir) {
|
|
84843
85872
|
const explicit = (process.env.MRRLIN_DIRECTOR_BRIDGE_TOKEN ?? "").trim();
|
|
84844
85873
|
if (explicit) return explicit;
|
|
84845
|
-
const tokenPath =
|
|
85874
|
+
const tokenPath = import_node_path47.default.join(stateDir, "token.txt");
|
|
84846
85875
|
try {
|
|
84847
|
-
const existing =
|
|
85876
|
+
const existing = import_node_fs33.default.readFileSync(tokenPath, "utf8").trim();
|
|
84848
85877
|
if (existing) return existing;
|
|
84849
85878
|
} catch {
|
|
84850
85879
|
}
|
|
84851
|
-
|
|
84852
|
-
const token =
|
|
84853
|
-
|
|
85880
|
+
import_node_fs33.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
|
|
85881
|
+
const token = import_node_crypto28.default.randomBytes(32).toString("base64url");
|
|
85882
|
+
import_node_fs33.default.writeFileSync(tokenPath, `${token}
|
|
84854
85883
|
`, { mode: 384 });
|
|
84855
85884
|
return token;
|
|
84856
85885
|
}
|
|
@@ -86111,6 +87140,7 @@ function resolveServerOptions(input = {}) {
|
|
|
86111
87140
|
return {
|
|
86112
87141
|
apiBaseUrl,
|
|
86113
87142
|
fetch: input.fetch,
|
|
87143
|
+
dispatchExecutionRun: input.dispatchExecutionRun,
|
|
86114
87144
|
remoteAllowed: true,
|
|
86115
87145
|
// Deliberately do NOT bake process.env.MRRLIN_TOKEN in here: withAuth (tools.ts) resolves
|
|
86116
87146
|
// env + the bridge-persisted operator-token file lazily per request, so long-lived MCP
|
|
@@ -86235,8 +87265,12 @@ function createMrrlinMcpServer(options = {}) {
|
|
|
86235
87265
|
message: `Unknown MCP tool: ${name}`
|
|
86236
87266
|
});
|
|
86237
87267
|
}
|
|
87268
|
+
const args = request.params.arguments ?? {};
|
|
87269
|
+
if (name === mcpToolNames.createExecutionRun && Object.hasOwn(args, "code_execution")) {
|
|
87270
|
+
return buildToolError({ code: "INVALID_CODE_EXECUTION_FIELD", message: "Use codeExecution, not code_execution." });
|
|
87271
|
+
}
|
|
86238
87272
|
const schema = mcpToolInputSchemas[name];
|
|
86239
|
-
const parsed = schema.safeParse(
|
|
87273
|
+
const parsed = schema.safeParse(args);
|
|
86240
87274
|
if (!parsed.success) {
|
|
86241
87275
|
return buildToolError({
|
|
86242
87276
|
code: "VALIDATION_FAILED",
|
|
@@ -86298,8 +87332,8 @@ function runSetCredential(args) {
|
|
|
86298
87332
|
|
|
86299
87333
|
// src/install-service.ts
|
|
86300
87334
|
var import_node_os24 = __toESM(require("node:os"), 1);
|
|
86301
|
-
var
|
|
86302
|
-
var
|
|
87335
|
+
var import_node_fs34 = require("node:fs");
|
|
87336
|
+
var import_node_path48 = __toESM(require("node:path"), 1);
|
|
86303
87337
|
function parseEnvLine(line, env) {
|
|
86304
87338
|
const trimmed = line.trim();
|
|
86305
87339
|
if (!trimmed || trimmed === "}" || trimmed === "},") return;
|
|
@@ -86688,7 +87722,7 @@ function performConfigBackup(deps, ecoPath, existingText) {
|
|
|
86688
87722
|
deps.log("Service config backup failed.");
|
|
86689
87723
|
return;
|
|
86690
87724
|
}
|
|
86691
|
-
const dir =
|
|
87725
|
+
const dir = import_node_path48.default.dirname(ecoPath);
|
|
86692
87726
|
let files;
|
|
86693
87727
|
try {
|
|
86694
87728
|
files = deps.listDir(dir);
|
|
@@ -86700,7 +87734,7 @@ function performConfigBackup(deps, ecoPath, existingText) {
|
|
|
86700
87734
|
deps.log("Service config backup failed.");
|
|
86701
87735
|
return;
|
|
86702
87736
|
}
|
|
86703
|
-
const base =
|
|
87737
|
+
const base = import_node_path48.default.basename(ecoPath);
|
|
86704
87738
|
const backupRegex = new RegExp(`^${escapeRegex2(base)}\\.bak-\\d{4}-\\d{2}-\\d{2}T\\d{2}-\\d{2}-\\d{2}-\\d{3}Z$`);
|
|
86705
87739
|
const existingBackups = files.filter((f) => backupRegex.test(f));
|
|
86706
87740
|
if (existingBackups.length >= 10) {
|
|
@@ -86735,7 +87769,7 @@ function performConfigBackup(deps, ecoPath, existingText) {
|
|
|
86735
87769
|
var SYSTEM_PATH_DIRS = ["/usr/bin", "/bin", "/usr/sbin", "/sbin"];
|
|
86736
87770
|
function defaultHomeOwnerUid(home) {
|
|
86737
87771
|
try {
|
|
86738
|
-
return (0,
|
|
87772
|
+
return (0, import_node_fs34.statSync)(home).uid;
|
|
86739
87773
|
} catch {
|
|
86740
87774
|
return null;
|
|
86741
87775
|
}
|
|
@@ -86802,11 +87836,11 @@ function installService(deps) {
|
|
|
86802
87836
|
const agyBin = deps.which("agy");
|
|
86803
87837
|
const resolvedBins = [...bins, claudeBin, agyBin].filter((b) => b !== null);
|
|
86804
87838
|
const isWin = import_node_os24.default.platform() === "win32";
|
|
86805
|
-
const systemDirs = isWin ? (deps.env.PATH || "").split(
|
|
87839
|
+
const systemDirs = isWin ? (deps.env.PATH || "").split(import_node_path48.default.delimiter).filter(Boolean) : SYSTEM_PATH_DIRS;
|
|
86806
87840
|
const pathEnv = Array.from(
|
|
86807
|
-
/* @__PURE__ */ new Set([...resolvedBins.map((b) =>
|
|
86808
|
-
).join(
|
|
86809
|
-
const ecoPath =
|
|
87841
|
+
/* @__PURE__ */ new Set([...resolvedBins.map((b) => import_node_path48.default.dirname(b)), ...systemDirs])
|
|
87842
|
+
).join(import_node_path48.default.delimiter);
|
|
87843
|
+
const ecoPath = import_node_path48.default.join(home, ".mrrlin", "ecosystem.config.cjs");
|
|
86810
87844
|
const existingText = deps.readFile ? deps.readFile(ecoPath) : null;
|
|
86811
87845
|
const parseResult = parseExistingEcosystemConfig(existingText);
|
|
86812
87846
|
if (parseResult.kind === "rejected") {
|
|
@@ -86885,13 +87919,13 @@ function uninstallService(deps) {
|
|
|
86885
87919
|
// src/uninstall-codex.ts
|
|
86886
87920
|
var import_promises20 = __toESM(require("node:fs/promises"), 1);
|
|
86887
87921
|
var import_node_os25 = __toESM(require("node:os"), 1);
|
|
86888
|
-
var
|
|
87922
|
+
var import_node_path49 = __toESM(require("node:path"), 1);
|
|
86889
87923
|
var toml6 = __toESM(require_toml(), 1);
|
|
86890
87924
|
function resolveCodexHome3(options) {
|
|
86891
87925
|
if (options.codexHome) return options.codexHome;
|
|
86892
|
-
if (options.homeDir) return
|
|
87926
|
+
if (options.homeDir) return import_node_path49.default.join(options.homeDir, ".codex");
|
|
86893
87927
|
if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
|
|
86894
|
-
return
|
|
87928
|
+
return import_node_path49.default.join(import_node_os25.default.homedir(), ".codex");
|
|
86895
87929
|
}
|
|
86896
87930
|
async function pathExists6(target) {
|
|
86897
87931
|
try {
|
|
@@ -86904,7 +87938,7 @@ async function pathExists6(target) {
|
|
|
86904
87938
|
var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.(?:mrrlin(?:-browser)?|external-agents)(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
|
|
86905
87939
|
async function uninstallCodex(options = {}) {
|
|
86906
87940
|
const codexHome = resolveCodexHome3(options);
|
|
86907
|
-
const configPath =
|
|
87941
|
+
const configPath = import_node_path49.default.join(codexHome, "config.toml");
|
|
86908
87942
|
const removePrompts = async () => uninstallPrompts(codexHome, options.promptNames ?? []);
|
|
86909
87943
|
if (!await pathExists6(configPath)) {
|
|
86910
87944
|
return { action: "missing", configPath, prompts: await removePrompts() };
|
|
@@ -86932,10 +87966,10 @@ async function uninstallCodex(options = {}) {
|
|
|
86932
87966
|
}
|
|
86933
87967
|
async function uninstallPrompts(codexHome, names) {
|
|
86934
87968
|
if (names.length === 0) return [];
|
|
86935
|
-
const promptsDir =
|
|
87969
|
+
const promptsDir = import_node_path49.default.join(codexHome, "prompts");
|
|
86936
87970
|
const out = [];
|
|
86937
87971
|
for (const name of names) {
|
|
86938
|
-
const promptPath =
|
|
87972
|
+
const promptPath = import_node_path49.default.join(promptsDir, `${name}.md`);
|
|
86939
87973
|
try {
|
|
86940
87974
|
await import_promises20.default.unlink(promptPath);
|
|
86941
87975
|
out.push({ name, action: "removed", promptPath });
|
|
@@ -87115,32 +88149,32 @@ async function runConnect(argv, deps) {
|
|
|
87115
88149
|
}
|
|
87116
88150
|
|
|
87117
88151
|
// src/doctor.ts
|
|
87118
|
-
var
|
|
87119
|
-
var
|
|
88152
|
+
var import_node_fs35 = require("node:fs");
|
|
88153
|
+
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
87120
88154
|
var import_semver4 = __toESM(require_semver2(), 1);
|
|
87121
88155
|
var ISO_TS = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
|
|
87122
88156
|
var defaultLogFs = {
|
|
87123
88157
|
listDir: (dir) => {
|
|
87124
88158
|
try {
|
|
87125
|
-
return (0,
|
|
88159
|
+
return (0, import_node_fs35.readdirSync)(dir);
|
|
87126
88160
|
} catch {
|
|
87127
88161
|
return null;
|
|
87128
88162
|
}
|
|
87129
88163
|
},
|
|
87130
88164
|
readFile: (p) => {
|
|
87131
88165
|
try {
|
|
87132
|
-
return (0,
|
|
88166
|
+
return (0, import_node_fs35.readFileSync)(p, "utf8");
|
|
87133
88167
|
} catch {
|
|
87134
88168
|
return null;
|
|
87135
88169
|
}
|
|
87136
88170
|
}
|
|
87137
88171
|
};
|
|
87138
88172
|
function readRecentErrorEntries(stateDir, n, fs18 = defaultLogFs) {
|
|
87139
|
-
const logsDir =
|
|
88173
|
+
const logsDir = import_node_path50.default.join(stateDir, "logs");
|
|
87140
88174
|
const names = (fs18.listDir(logsDir) ?? []).filter((name) => name.endsWith(".jsonl")).sort();
|
|
87141
88175
|
const entries = [];
|
|
87142
88176
|
for (const name of names) {
|
|
87143
|
-
const raw = fs18.readFile(
|
|
88177
|
+
const raw = fs18.readFile(import_node_path50.default.join(logsDir, name));
|
|
87144
88178
|
if (!raw) continue;
|
|
87145
88179
|
for (const line of raw.split("\n")) {
|
|
87146
88180
|
if (!line.trim()) continue;
|
|
@@ -87162,7 +88196,7 @@ function readRecentErrorEntries(stateDir, n, fs18 = defaultLogFs) {
|
|
|
87162
88196
|
function configChecks(deps) {
|
|
87163
88197
|
const fix = "mrrlin-mcp configure bridge";
|
|
87164
88198
|
let claudeOk = false;
|
|
87165
|
-
const claudeRaw = deps.readFile(
|
|
88199
|
+
const claudeRaw = deps.readFile(import_node_path50.default.join(deps.homedir, ".claude.json"));
|
|
87166
88200
|
if (claudeRaw) {
|
|
87167
88201
|
try {
|
|
87168
88202
|
const parsed = JSON.parse(claudeRaw);
|
|
@@ -87171,7 +88205,7 @@ function configChecks(deps) {
|
|
|
87171
88205
|
claudeOk = false;
|
|
87172
88206
|
}
|
|
87173
88207
|
}
|
|
87174
|
-
const codexPath =
|
|
88208
|
+
const codexPath = import_node_path50.default.join(deps.codexHome ?? import_node_path50.default.join(deps.homedir, ".codex"), "config.toml");
|
|
87175
88209
|
const codexOk = /^\[mcp_servers\.mrrlin\]/m.test(deps.readFile(codexPath) ?? "");
|
|
87176
88210
|
return [
|
|
87177
88211
|
{
|
|
@@ -87337,17 +88371,17 @@ async function runDoctor(flags, deps) {
|
|
|
87337
88371
|
}
|
|
87338
88372
|
|
|
87339
88373
|
// src/launch-agent.ts
|
|
87340
|
-
var
|
|
88374
|
+
var import_node_path51 = __toESM(require("node:path"), 1);
|
|
87341
88375
|
var BRIDGE_LAUNCH_AGENT_LABEL = "com.mrrlin.director-bridge";
|
|
87342
88376
|
function escapeXml(value) {
|
|
87343
88377
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
87344
88378
|
}
|
|
87345
88379
|
function bridgeLaunchAgentPath(home) {
|
|
87346
|
-
return
|
|
88380
|
+
return import_node_path51.default.join(home, "Library", "LaunchAgents", `${BRIDGE_LAUNCH_AGENT_LABEL}.plist`);
|
|
87347
88381
|
}
|
|
87348
88382
|
function renderBridgeLaunchAgent(input) {
|
|
87349
88383
|
const { home, pm2Path, nodeDir } = input;
|
|
87350
|
-
const launchPath = `${nodeDir}:${
|
|
88384
|
+
const launchPath = `${nodeDir}:${import_node_path51.default.dirname(pm2Path)}:/usr/bin:/bin`;
|
|
87351
88385
|
const logDir = `${home}/.mrrlin/director-bridge`;
|
|
87352
88386
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
87353
88387
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
@@ -87388,7 +88422,7 @@ function installBridgeLaunchAgent(deps) {
|
|
|
87388
88422
|
const plistPath = bridgeLaunchAgentPath(deps.home);
|
|
87389
88423
|
const domain2 = `gui/${deps.uid}`;
|
|
87390
88424
|
try {
|
|
87391
|
-
deps.mkdirp(
|
|
88425
|
+
deps.mkdirp(import_node_path51.default.dirname(plistPath));
|
|
87392
88426
|
deps.writeFile(
|
|
87393
88427
|
plistPath,
|
|
87394
88428
|
renderBridgeLaunchAgent({ home: deps.home, pm2Path: deps.pm2Path, nodeDir: deps.nodeDir }),
|
|
@@ -87418,7 +88452,7 @@ function removeBridgeLaunchAgent(deps) {
|
|
|
87418
88452
|
|
|
87419
88453
|
// src/extract/command.ts
|
|
87420
88454
|
var import_promises21 = require("node:fs/promises");
|
|
87421
|
-
var
|
|
88455
|
+
var import_node_path52 = require("node:path");
|
|
87422
88456
|
function parseArgs(args) {
|
|
87423
88457
|
const map2 = /* @__PURE__ */ new Map();
|
|
87424
88458
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -87455,7 +88489,7 @@ Missing required flag(s): ${missing.join(
|
|
|
87455
88489
|
const days = await findSessionDays(deps.stateDir, sessionId);
|
|
87456
88490
|
const matchingLines = [];
|
|
87457
88491
|
for (const day of days) {
|
|
87458
|
-
const logPath = (0,
|
|
88492
|
+
const logPath = (0, import_node_path52.join)(deps.stateDir, "logs", `bridge-${day}.jsonl`);
|
|
87459
88493
|
let raw;
|
|
87460
88494
|
try {
|
|
87461
88495
|
raw = await (0, import_promises21.readFile)(logPath, "utf8");
|
|
@@ -87545,16 +88579,16 @@ function augmentProcessPathWithCommonDirs() {
|
|
|
87545
88579
|
if (isWin) return;
|
|
87546
88580
|
const home = process.env.HOME || (0, import_node_os26.homedir)();
|
|
87547
88581
|
const candidates = [
|
|
87548
|
-
|
|
87549
|
-
|
|
88582
|
+
import_node_path54.default.join(home, ".local", "bin"),
|
|
88583
|
+
import_node_path54.default.join(home, ".cargo", "bin"),
|
|
87550
88584
|
"/usr/local/bin",
|
|
87551
88585
|
"/opt/homebrew/bin"
|
|
87552
88586
|
];
|
|
87553
|
-
const existing = (process.env.PATH || "").split(
|
|
88587
|
+
const existing = (process.env.PATH || "").split(import_node_path54.default.delimiter).filter(Boolean);
|
|
87554
88588
|
const existingSet = new Set(existing);
|
|
87555
|
-
const toAdd = candidates.filter((d) => !existingSet.has(d) && (0,
|
|
88589
|
+
const toAdd = candidates.filter((d) => !existingSet.has(d) && (0, import_node_fs36.existsSync)(d));
|
|
87556
88590
|
if (toAdd.length > 0) {
|
|
87557
|
-
process.env.PATH = [...existing, ...toAdd].join(
|
|
88591
|
+
process.env.PATH = [...existing, ...toAdd].join(import_node_path54.default.delimiter);
|
|
87558
88592
|
}
|
|
87559
88593
|
}
|
|
87560
88594
|
augmentProcessPathWithCommonDirs();
|
|
@@ -87574,15 +88608,15 @@ function bootHookStatus() {
|
|
|
87574
88608
|
const uid = process.getuid?.();
|
|
87575
88609
|
if (uid === void 0 || uid === 0) return { status: "unknown" };
|
|
87576
88610
|
const home = process.env.HOME ?? (0, import_node_os26.homedir)();
|
|
87577
|
-
const agents =
|
|
88611
|
+
const agents = import_node_path54.default.join(home, "Library", "LaunchAgents");
|
|
87578
88612
|
const candidates = [
|
|
87579
|
-
{ label: "com.mrrlin.director-bridge", plist:
|
|
87580
|
-
{ label: "com.PM2", plist:
|
|
88613
|
+
{ label: "com.mrrlin.director-bridge", plist: import_node_path54.default.join(agents, "com.mrrlin.director-bridge.plist") },
|
|
88614
|
+
{ label: "com.PM2", plist: import_node_path54.default.join(agents, `pm2.${(0, import_node_os26.userInfo)().username}.plist`) }
|
|
87581
88615
|
];
|
|
87582
88616
|
for (const candidate of candidates) {
|
|
87583
88617
|
const printed = (0, import_node_child_process27.spawnSync)("launchctl", ["print", `gui/${uid}/${candidate.label}`], { encoding: "utf8" });
|
|
87584
88618
|
if (printed.status !== 0) continue;
|
|
87585
|
-
if (!(0,
|
|
88619
|
+
if (!(0, import_node_fs36.existsSync)(candidate.plist)) continue;
|
|
87586
88620
|
const out = printed.stdout ?? "";
|
|
87587
88621
|
const runs = /^\s*runs\s*=\s*(\d+)/m.exec(out);
|
|
87588
88622
|
const exitCode = /^\s*last exit code\s*=\s*(-?\d+)/m.exec(out);
|
|
@@ -87598,16 +88632,16 @@ function realLaunchAgentDeps() {
|
|
|
87598
88632
|
home: process.env.HOME ?? (0, import_node_os26.homedir)(),
|
|
87599
88633
|
uid: process.getuid?.() ?? 0,
|
|
87600
88634
|
pm2Path: whichBin("pm2") ?? "pm2",
|
|
87601
|
-
nodeDir:
|
|
88635
|
+
nodeDir: import_node_path54.default.dirname(process.execPath),
|
|
87602
88636
|
mkdirp: (dir) => {
|
|
87603
|
-
(0,
|
|
88637
|
+
(0, import_node_fs36.mkdirSync)(dir, { recursive: true });
|
|
87604
88638
|
},
|
|
87605
88639
|
writeFile: (p, c, mode) => {
|
|
87606
|
-
(0,
|
|
87607
|
-
(0,
|
|
87608
|
-
(0,
|
|
88640
|
+
(0, import_node_fs36.mkdirSync)(import_node_path54.default.join(process.env.HOME ?? (0, import_node_os26.homedir)(), ".mrrlin", "director-bridge"), { recursive: true, mode: 448 });
|
|
88641
|
+
(0, import_node_fs36.writeFileSync)(p, c, { mode });
|
|
88642
|
+
(0, import_node_fs36.chmodSync)(p, mode);
|
|
87609
88643
|
},
|
|
87610
|
-
removeFile: (p) => (0,
|
|
88644
|
+
removeFile: (p) => (0, import_node_fs36.rmSync)(p, { force: true }),
|
|
87611
88645
|
launchctl: (args) => ({ status: (0, import_node_child_process27.spawnSync)("launchctl", args, { encoding: "utf8" }).status })
|
|
87612
88646
|
};
|
|
87613
88647
|
}
|
|
@@ -87718,7 +88752,7 @@ function realDoctorDeps() {
|
|
|
87718
88752
|
verifyReadiness: (provider) => verifyProviderReadiness(provider, runnerFor(provider)),
|
|
87719
88753
|
readFile: (p) => {
|
|
87720
88754
|
try {
|
|
87721
|
-
return (0,
|
|
88755
|
+
return (0, import_node_fs36.readFileSync)(p, "utf8");
|
|
87722
88756
|
} catch {
|
|
87723
88757
|
return null;
|
|
87724
88758
|
}
|
|
@@ -88003,8 +89037,8 @@ async function main() {
|
|
|
88003
89037
|
}
|
|
88004
89038
|
}
|
|
88005
89039
|
try {
|
|
88006
|
-
const codexHome = process.env.CODEX_HOME ??
|
|
88007
|
-
(0,
|
|
89040
|
+
const codexHome = process.env.CODEX_HOME ?? import_node_path54.default.join(process.env.HOME ?? (0, import_node_os26.homedir)(), ".codex");
|
|
89041
|
+
(0, import_node_fs36.rmSync)(import_node_path54.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
|
|
88008
89042
|
} catch {
|
|
88009
89043
|
}
|
|
88010
89044
|
const claudeResult = await installClaude({ binPath, force, serveEnv });
|
|
@@ -88082,13 +89116,13 @@ async function main() {
|
|
|
88082
89116
|
env: process.env,
|
|
88083
89117
|
cwd: process.cwd(),
|
|
88084
89118
|
writeFile: (p, c) => {
|
|
88085
|
-
(0,
|
|
88086
|
-
(0,
|
|
89119
|
+
(0, import_node_fs36.mkdirSync)(import_node_path54.default.dirname(p), { recursive: true, mode: 448 });
|
|
89120
|
+
(0, import_node_fs36.writeFileSync)(p, c, { mode: 384 });
|
|
88087
89121
|
},
|
|
88088
|
-
writeExclusiveFile: (p, c) => (0,
|
|
89122
|
+
writeExclusiveFile: (p, c) => (0, import_node_fs36.writeFileSync)(p, c, { flag: "wx", mode: 384 }),
|
|
88089
89123
|
listDir: (p) => {
|
|
88090
89124
|
try {
|
|
88091
|
-
return (0,
|
|
89125
|
+
return (0, import_node_fs36.readdirSync)(p);
|
|
88092
89126
|
} catch {
|
|
88093
89127
|
return null;
|
|
88094
89128
|
}
|
|
@@ -88099,7 +89133,7 @@ async function main() {
|
|
|
88099
89133
|
// value", never a failed install. See readExistingTelemetryDefaultProject.
|
|
88100
89134
|
readFile: (p) => {
|
|
88101
89135
|
try {
|
|
88102
|
-
return (0,
|
|
89136
|
+
return (0, import_node_fs36.readFileSync)(p, "utf8");
|
|
88103
89137
|
} catch {
|
|
88104
89138
|
return null;
|
|
88105
89139
|
}
|
|
@@ -88120,14 +89154,14 @@ async function main() {
|
|
|
88120
89154
|
runPm2: (a) => ({ code: pm2Runner(a).code }),
|
|
88121
89155
|
removeFile: (p) => {
|
|
88122
89156
|
try {
|
|
88123
|
-
(0,
|
|
89157
|
+
(0, import_node_fs36.rmSync)(p, { force: true });
|
|
88124
89158
|
} catch {
|
|
88125
89159
|
}
|
|
88126
89160
|
},
|
|
88127
89161
|
purgeSecret: purge,
|
|
88128
89162
|
secretPath: agentCredentialPath(),
|
|
88129
89163
|
tokenPath: operatorTokenPath(),
|
|
88130
|
-
ecoPath:
|
|
89164
|
+
ecoPath: import_node_path54.default.join(process.env.HOME ?? (0, import_node_os26.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
|
|
88131
89165
|
log: (m) => process.stderr.write(`[mrrlin-mcp uninstall-service] ${m}
|
|
88132
89166
|
`)
|
|
88133
89167
|
});
|
|
@@ -88142,14 +89176,14 @@ async function main() {
|
|
|
88142
89176
|
runPm2: (a) => ({ code: pm2Runner(a).code }),
|
|
88143
89177
|
removeFile: (p) => {
|
|
88144
89178
|
try {
|
|
88145
|
-
(0,
|
|
89179
|
+
(0, import_node_fs36.rmSync)(p, { force: true });
|
|
88146
89180
|
} catch {
|
|
88147
89181
|
}
|
|
88148
89182
|
},
|
|
88149
89183
|
purgeSecret: true,
|
|
88150
89184
|
secretPath: agentCredentialPath(),
|
|
88151
89185
|
tokenPath: operatorTokenPath(),
|
|
88152
|
-
ecoPath:
|
|
89186
|
+
ecoPath: import_node_path54.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
|
|
88153
89187
|
log: log2
|
|
88154
89188
|
});
|
|
88155
89189
|
let codexOk = true;
|
|
@@ -88169,7 +89203,7 @@ async function main() {
|
|
|
88169
89203
|
log2(`codex config NOT modified: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
88170
89204
|
}
|
|
88171
89205
|
try {
|
|
88172
|
-
(0,
|
|
89206
|
+
(0, import_node_fs36.rmSync)(import_node_path54.default.join(home, ".mrrlin"), { recursive: true, force: true });
|
|
88173
89207
|
} catch {
|
|
88174
89208
|
}
|
|
88175
89209
|
log2("removed ~/.mrrlin");
|
|
@@ -88210,7 +89244,7 @@ ${HELP_TEXT}`);
|
|
|
88210
89244
|
}
|
|
88211
89245
|
}
|
|
88212
89246
|
function resolveSelfBinPath() {
|
|
88213
|
-
return
|
|
89247
|
+
return import_node_path53.default.resolve(process.argv[1] ?? process.execPath);
|
|
88214
89248
|
}
|
|
88215
89249
|
main().catch((error51) => {
|
|
88216
89250
|
process.stderr.write(`mrrlin-mcp fatal error: ${error51 instanceof Error ? error51.message : String(error51)}
|