@mrrlin-dev/mcp 0.3.51 → 0.3.54
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 +1459 -446
- package/package.json +5 -5
package/dist/bin.cjs
CHANGED
|
@@ -4273,7 +4273,7 @@ var require_websocket = __commonJS({
|
|
|
4273
4273
|
var http2 = require("http");
|
|
4274
4274
|
var net = require("net");
|
|
4275
4275
|
var tls = require("tls");
|
|
4276
|
-
var { randomBytes: randomBytes4, createHash:
|
|
4276
|
+
var { randomBytes: randomBytes4, createHash: createHash5 } = require("crypto");
|
|
4277
4277
|
var { Duplex, Readable } = require("stream");
|
|
4278
4278
|
var { URL: URL2 } = require("url");
|
|
4279
4279
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -4941,7 +4941,7 @@ var require_websocket = __commonJS({
|
|
|
4941
4941
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
4942
4942
|
return;
|
|
4943
4943
|
}
|
|
4944
|
-
const digest =
|
|
4944
|
+
const digest = createHash5("sha1").update(key + GUID).digest("base64");
|
|
4945
4945
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
4946
4946
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
4947
4947
|
return;
|
|
@@ -5310,7 +5310,7 @@ var require_websocket_server = __commonJS({
|
|
|
5310
5310
|
var EventEmitter3 = require("events");
|
|
5311
5311
|
var http2 = require("http");
|
|
5312
5312
|
var { Duplex } = require("stream");
|
|
5313
|
-
var { createHash:
|
|
5313
|
+
var { createHash: createHash5 } = require("crypto");
|
|
5314
5314
|
var extension2 = require_extension();
|
|
5315
5315
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
5316
5316
|
var subprotocol2 = require_subprotocol();
|
|
@@ -5617,7 +5617,7 @@ var require_websocket_server = __commonJS({
|
|
|
5617
5617
|
);
|
|
5618
5618
|
}
|
|
5619
5619
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
5620
|
-
const digest =
|
|
5620
|
+
const digest = createHash5("sha1").update(key + GUID).digest("base64");
|
|
5621
5621
|
const headers = [
|
|
5622
5622
|
"HTTP/1.1 101 Switching Protocols",
|
|
5623
5623
|
"Upgrade: websocket",
|
|
@@ -7703,54 +7703,54 @@ var require_polyfills = __commonJS({
|
|
|
7703
7703
|
}
|
|
7704
7704
|
var chdir;
|
|
7705
7705
|
module2.exports = patch;
|
|
7706
|
-
function patch(
|
|
7706
|
+
function patch(fs9) {
|
|
7707
7707
|
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
7708
|
-
patchLchmod(
|
|
7709
|
-
}
|
|
7710
|
-
if (!
|
|
7711
|
-
patchLutimes(
|
|
7712
|
-
}
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7722
|
-
|
|
7723
|
-
|
|
7724
|
-
|
|
7725
|
-
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
if (
|
|
7732
|
-
|
|
7708
|
+
patchLchmod(fs9);
|
|
7709
|
+
}
|
|
7710
|
+
if (!fs9.lutimes) {
|
|
7711
|
+
patchLutimes(fs9);
|
|
7712
|
+
}
|
|
7713
|
+
fs9.chown = chownFix(fs9.chown);
|
|
7714
|
+
fs9.fchown = chownFix(fs9.fchown);
|
|
7715
|
+
fs9.lchown = chownFix(fs9.lchown);
|
|
7716
|
+
fs9.chmod = chmodFix(fs9.chmod);
|
|
7717
|
+
fs9.fchmod = chmodFix(fs9.fchmod);
|
|
7718
|
+
fs9.lchmod = chmodFix(fs9.lchmod);
|
|
7719
|
+
fs9.chownSync = chownFixSync(fs9.chownSync);
|
|
7720
|
+
fs9.fchownSync = chownFixSync(fs9.fchownSync);
|
|
7721
|
+
fs9.lchownSync = chownFixSync(fs9.lchownSync);
|
|
7722
|
+
fs9.chmodSync = chmodFixSync(fs9.chmodSync);
|
|
7723
|
+
fs9.fchmodSync = chmodFixSync(fs9.fchmodSync);
|
|
7724
|
+
fs9.lchmodSync = chmodFixSync(fs9.lchmodSync);
|
|
7725
|
+
fs9.stat = statFix(fs9.stat);
|
|
7726
|
+
fs9.fstat = statFix(fs9.fstat);
|
|
7727
|
+
fs9.lstat = statFix(fs9.lstat);
|
|
7728
|
+
fs9.statSync = statFixSync(fs9.statSync);
|
|
7729
|
+
fs9.fstatSync = statFixSync(fs9.fstatSync);
|
|
7730
|
+
fs9.lstatSync = statFixSync(fs9.lstatSync);
|
|
7731
|
+
if (fs9.chmod && !fs9.lchmod) {
|
|
7732
|
+
fs9.lchmod = function(path19, mode, cb) {
|
|
7733
7733
|
if (cb) process.nextTick(cb);
|
|
7734
7734
|
};
|
|
7735
|
-
|
|
7735
|
+
fs9.lchmodSync = function() {
|
|
7736
7736
|
};
|
|
7737
7737
|
}
|
|
7738
|
-
if (
|
|
7739
|
-
|
|
7738
|
+
if (fs9.chown && !fs9.lchown) {
|
|
7739
|
+
fs9.lchown = function(path19, uid, gid, cb) {
|
|
7740
7740
|
if (cb) process.nextTick(cb);
|
|
7741
7741
|
};
|
|
7742
|
-
|
|
7742
|
+
fs9.lchownSync = function() {
|
|
7743
7743
|
};
|
|
7744
7744
|
}
|
|
7745
7745
|
if (platform === "win32") {
|
|
7746
|
-
|
|
7746
|
+
fs9.rename = typeof fs9.rename !== "function" ? fs9.rename : function(fs$rename) {
|
|
7747
7747
|
function rename(from, to, cb) {
|
|
7748
7748
|
var start = Date.now();
|
|
7749
7749
|
var backoff = 0;
|
|
7750
7750
|
fs$rename(from, to, function CB(er) {
|
|
7751
7751
|
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
7752
7752
|
setTimeout(function() {
|
|
7753
|
-
|
|
7753
|
+
fs9.stat(to, function(stater, st) {
|
|
7754
7754
|
if (stater && stater.code === "ENOENT")
|
|
7755
7755
|
fs$rename(from, to, CB);
|
|
7756
7756
|
else
|
|
@@ -7766,9 +7766,9 @@ var require_polyfills = __commonJS({
|
|
|
7766
7766
|
}
|
|
7767
7767
|
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
|
|
7768
7768
|
return rename;
|
|
7769
|
-
}(
|
|
7769
|
+
}(fs9.rename);
|
|
7770
7770
|
}
|
|
7771
|
-
|
|
7771
|
+
fs9.read = typeof fs9.read !== "function" ? fs9.read : function(fs$read) {
|
|
7772
7772
|
function read(fd, buffer, offset, length, position, callback_) {
|
|
7773
7773
|
var callback;
|
|
7774
7774
|
if (callback_ && typeof callback_ === "function") {
|
|
@@ -7776,22 +7776,22 @@ var require_polyfills = __commonJS({
|
|
|
7776
7776
|
callback = function(er, _, __) {
|
|
7777
7777
|
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
7778
7778
|
eagCounter++;
|
|
7779
|
-
return fs$read.call(
|
|
7779
|
+
return fs$read.call(fs9, fd, buffer, offset, length, position, callback);
|
|
7780
7780
|
}
|
|
7781
7781
|
callback_.apply(this, arguments);
|
|
7782
7782
|
};
|
|
7783
7783
|
}
|
|
7784
|
-
return fs$read.call(
|
|
7784
|
+
return fs$read.call(fs9, fd, buffer, offset, length, position, callback);
|
|
7785
7785
|
}
|
|
7786
7786
|
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
7787
7787
|
return read;
|
|
7788
|
-
}(
|
|
7789
|
-
|
|
7788
|
+
}(fs9.read);
|
|
7789
|
+
fs9.readSync = typeof fs9.readSync !== "function" ? fs9.readSync : /* @__PURE__ */ function(fs$readSync) {
|
|
7790
7790
|
return function(fd, buffer, offset, length, position) {
|
|
7791
7791
|
var eagCounter = 0;
|
|
7792
7792
|
while (true) {
|
|
7793
7793
|
try {
|
|
7794
|
-
return fs$readSync.call(
|
|
7794
|
+
return fs$readSync.call(fs9, fd, buffer, offset, length, position);
|
|
7795
7795
|
} catch (er) {
|
|
7796
7796
|
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
7797
7797
|
eagCounter++;
|
|
@@ -7801,11 +7801,11 @@ var require_polyfills = __commonJS({
|
|
|
7801
7801
|
}
|
|
7802
7802
|
}
|
|
7803
7803
|
};
|
|
7804
|
-
}(
|
|
7805
|
-
function patchLchmod(
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7804
|
+
}(fs9.readSync);
|
|
7805
|
+
function patchLchmod(fs10) {
|
|
7806
|
+
fs10.lchmod = function(path19, mode, callback) {
|
|
7807
|
+
fs10.open(
|
|
7808
|
+
path19,
|
|
7809
7809
|
constants.O_WRONLY | constants.O_SYMLINK,
|
|
7810
7810
|
mode,
|
|
7811
7811
|
function(err, fd) {
|
|
@@ -7813,80 +7813,80 @@ var require_polyfills = __commonJS({
|
|
|
7813
7813
|
if (callback) callback(err);
|
|
7814
7814
|
return;
|
|
7815
7815
|
}
|
|
7816
|
-
|
|
7817
|
-
|
|
7816
|
+
fs10.fchmod(fd, mode, function(err2) {
|
|
7817
|
+
fs10.close(fd, function(err22) {
|
|
7818
7818
|
if (callback) callback(err2 || err22);
|
|
7819
7819
|
});
|
|
7820
7820
|
});
|
|
7821
7821
|
}
|
|
7822
7822
|
);
|
|
7823
7823
|
};
|
|
7824
|
-
|
|
7825
|
-
var fd =
|
|
7824
|
+
fs10.lchmodSync = function(path19, mode) {
|
|
7825
|
+
var fd = fs10.openSync(path19, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
7826
7826
|
var threw = true;
|
|
7827
7827
|
var ret;
|
|
7828
7828
|
try {
|
|
7829
|
-
ret =
|
|
7829
|
+
ret = fs10.fchmodSync(fd, mode);
|
|
7830
7830
|
threw = false;
|
|
7831
7831
|
} finally {
|
|
7832
7832
|
if (threw) {
|
|
7833
7833
|
try {
|
|
7834
|
-
|
|
7834
|
+
fs10.closeSync(fd);
|
|
7835
7835
|
} catch (er) {
|
|
7836
7836
|
}
|
|
7837
7837
|
} else {
|
|
7838
|
-
|
|
7838
|
+
fs10.closeSync(fd);
|
|
7839
7839
|
}
|
|
7840
7840
|
}
|
|
7841
7841
|
return ret;
|
|
7842
7842
|
};
|
|
7843
7843
|
}
|
|
7844
|
-
function patchLutimes(
|
|
7845
|
-
if (constants.hasOwnProperty("O_SYMLINK") &&
|
|
7846
|
-
|
|
7847
|
-
|
|
7844
|
+
function patchLutimes(fs10) {
|
|
7845
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs10.futimes) {
|
|
7846
|
+
fs10.lutimes = function(path19, at, mt, cb) {
|
|
7847
|
+
fs10.open(path19, constants.O_SYMLINK, function(er, fd) {
|
|
7848
7848
|
if (er) {
|
|
7849
7849
|
if (cb) cb(er);
|
|
7850
7850
|
return;
|
|
7851
7851
|
}
|
|
7852
|
-
|
|
7853
|
-
|
|
7852
|
+
fs10.futimes(fd, at, mt, function(er2) {
|
|
7853
|
+
fs10.close(fd, function(er22) {
|
|
7854
7854
|
if (cb) cb(er2 || er22);
|
|
7855
7855
|
});
|
|
7856
7856
|
});
|
|
7857
7857
|
});
|
|
7858
7858
|
};
|
|
7859
|
-
|
|
7860
|
-
var fd =
|
|
7859
|
+
fs10.lutimesSync = function(path19, at, mt) {
|
|
7860
|
+
var fd = fs10.openSync(path19, constants.O_SYMLINK);
|
|
7861
7861
|
var ret;
|
|
7862
7862
|
var threw = true;
|
|
7863
7863
|
try {
|
|
7864
|
-
ret =
|
|
7864
|
+
ret = fs10.futimesSync(fd, at, mt);
|
|
7865
7865
|
threw = false;
|
|
7866
7866
|
} finally {
|
|
7867
7867
|
if (threw) {
|
|
7868
7868
|
try {
|
|
7869
|
-
|
|
7869
|
+
fs10.closeSync(fd);
|
|
7870
7870
|
} catch (er) {
|
|
7871
7871
|
}
|
|
7872
7872
|
} else {
|
|
7873
|
-
|
|
7873
|
+
fs10.closeSync(fd);
|
|
7874
7874
|
}
|
|
7875
7875
|
}
|
|
7876
7876
|
return ret;
|
|
7877
7877
|
};
|
|
7878
|
-
} else if (
|
|
7879
|
-
|
|
7878
|
+
} else if (fs10.futimes) {
|
|
7879
|
+
fs10.lutimes = function(_a3, _b, _c, cb) {
|
|
7880
7880
|
if (cb) process.nextTick(cb);
|
|
7881
7881
|
};
|
|
7882
|
-
|
|
7882
|
+
fs10.lutimesSync = function() {
|
|
7883
7883
|
};
|
|
7884
7884
|
}
|
|
7885
7885
|
}
|
|
7886
7886
|
function chmodFix(orig) {
|
|
7887
7887
|
if (!orig) return orig;
|
|
7888
7888
|
return function(target, mode, cb) {
|
|
7889
|
-
return orig.call(
|
|
7889
|
+
return orig.call(fs9, target, mode, function(er) {
|
|
7890
7890
|
if (chownErOk(er)) er = null;
|
|
7891
7891
|
if (cb) cb.apply(this, arguments);
|
|
7892
7892
|
});
|
|
@@ -7896,7 +7896,7 @@ var require_polyfills = __commonJS({
|
|
|
7896
7896
|
if (!orig) return orig;
|
|
7897
7897
|
return function(target, mode) {
|
|
7898
7898
|
try {
|
|
7899
|
-
return orig.call(
|
|
7899
|
+
return orig.call(fs9, target, mode);
|
|
7900
7900
|
} catch (er) {
|
|
7901
7901
|
if (!chownErOk(er)) throw er;
|
|
7902
7902
|
}
|
|
@@ -7905,7 +7905,7 @@ var require_polyfills = __commonJS({
|
|
|
7905
7905
|
function chownFix(orig) {
|
|
7906
7906
|
if (!orig) return orig;
|
|
7907
7907
|
return function(target, uid, gid, cb) {
|
|
7908
|
-
return orig.call(
|
|
7908
|
+
return orig.call(fs9, target, uid, gid, function(er) {
|
|
7909
7909
|
if (chownErOk(er)) er = null;
|
|
7910
7910
|
if (cb) cb.apply(this, arguments);
|
|
7911
7911
|
});
|
|
@@ -7915,7 +7915,7 @@ var require_polyfills = __commonJS({
|
|
|
7915
7915
|
if (!orig) return orig;
|
|
7916
7916
|
return function(target, uid, gid) {
|
|
7917
7917
|
try {
|
|
7918
|
-
return orig.call(
|
|
7918
|
+
return orig.call(fs9, target, uid, gid);
|
|
7919
7919
|
} catch (er) {
|
|
7920
7920
|
if (!chownErOk(er)) throw er;
|
|
7921
7921
|
}
|
|
@@ -7935,13 +7935,13 @@ var require_polyfills = __commonJS({
|
|
|
7935
7935
|
}
|
|
7936
7936
|
if (cb) cb.apply(this, arguments);
|
|
7937
7937
|
}
|
|
7938
|
-
return options ? orig.call(
|
|
7938
|
+
return options ? orig.call(fs9, target, options, callback) : orig.call(fs9, target, callback);
|
|
7939
7939
|
};
|
|
7940
7940
|
}
|
|
7941
7941
|
function statFixSync(orig) {
|
|
7942
7942
|
if (!orig) return orig;
|
|
7943
7943
|
return function(target, options) {
|
|
7944
|
-
var stats = options ? orig.call(
|
|
7944
|
+
var stats = options ? orig.call(fs9, target, options) : orig.call(fs9, target);
|
|
7945
7945
|
if (stats) {
|
|
7946
7946
|
if (stats.uid < 0) stats.uid += 4294967296;
|
|
7947
7947
|
if (stats.gid < 0) stats.gid += 4294967296;
|
|
@@ -7970,16 +7970,16 @@ var require_legacy_streams = __commonJS({
|
|
|
7970
7970
|
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js"(exports2, module2) {
|
|
7971
7971
|
var Stream = require("stream").Stream;
|
|
7972
7972
|
module2.exports = legacy;
|
|
7973
|
-
function legacy(
|
|
7973
|
+
function legacy(fs9) {
|
|
7974
7974
|
return {
|
|
7975
7975
|
ReadStream,
|
|
7976
7976
|
WriteStream
|
|
7977
7977
|
};
|
|
7978
|
-
function ReadStream(
|
|
7979
|
-
if (!(this instanceof ReadStream)) return new ReadStream(
|
|
7978
|
+
function ReadStream(path19, options) {
|
|
7979
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path19, options);
|
|
7980
7980
|
Stream.call(this);
|
|
7981
7981
|
var self = this;
|
|
7982
|
-
this.path =
|
|
7982
|
+
this.path = path19;
|
|
7983
7983
|
this.fd = null;
|
|
7984
7984
|
this.readable = true;
|
|
7985
7985
|
this.paused = false;
|
|
@@ -8013,7 +8013,7 @@ var require_legacy_streams = __commonJS({
|
|
|
8013
8013
|
});
|
|
8014
8014
|
return;
|
|
8015
8015
|
}
|
|
8016
|
-
|
|
8016
|
+
fs9.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
8017
8017
|
if (err) {
|
|
8018
8018
|
self.emit("error", err);
|
|
8019
8019
|
self.readable = false;
|
|
@@ -8024,10 +8024,10 @@ var require_legacy_streams = __commonJS({
|
|
|
8024
8024
|
self._read();
|
|
8025
8025
|
});
|
|
8026
8026
|
}
|
|
8027
|
-
function WriteStream(
|
|
8028
|
-
if (!(this instanceof WriteStream)) return new WriteStream(
|
|
8027
|
+
function WriteStream(path19, options) {
|
|
8028
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path19, options);
|
|
8029
8029
|
Stream.call(this);
|
|
8030
|
-
this.path =
|
|
8030
|
+
this.path = path19;
|
|
8031
8031
|
this.fd = null;
|
|
8032
8032
|
this.writable = true;
|
|
8033
8033
|
this.flags = "w";
|
|
@@ -8052,7 +8052,7 @@ var require_legacy_streams = __commonJS({
|
|
|
8052
8052
|
this.busy = false;
|
|
8053
8053
|
this._queue = [];
|
|
8054
8054
|
if (this.fd === null) {
|
|
8055
|
-
this._open =
|
|
8055
|
+
this._open = fs9.open;
|
|
8056
8056
|
this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
|
|
8057
8057
|
this.flush();
|
|
8058
8058
|
}
|
|
@@ -8087,7 +8087,7 @@ var require_clone = __commonJS({
|
|
|
8087
8087
|
// ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
|
|
8088
8088
|
var require_graceful_fs = __commonJS({
|
|
8089
8089
|
"../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
|
|
8090
|
-
var
|
|
8090
|
+
var fs9 = require("fs");
|
|
8091
8091
|
var polyfills = require_polyfills();
|
|
8092
8092
|
var legacy = require_legacy_streams();
|
|
8093
8093
|
var clone2 = require_clone();
|
|
@@ -8119,12 +8119,12 @@ var require_graceful_fs = __commonJS({
|
|
|
8119
8119
|
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
8120
8120
|
console.error(m);
|
|
8121
8121
|
};
|
|
8122
|
-
if (!
|
|
8122
|
+
if (!fs9[gracefulQueue]) {
|
|
8123
8123
|
queue = global[gracefulQueue] || [];
|
|
8124
|
-
publishQueue(
|
|
8125
|
-
|
|
8124
|
+
publishQueue(fs9, queue);
|
|
8125
|
+
fs9.close = function(fs$close) {
|
|
8126
8126
|
function close(fd, cb) {
|
|
8127
|
-
return fs$close.call(
|
|
8127
|
+
return fs$close.call(fs9, fd, function(err) {
|
|
8128
8128
|
if (!err) {
|
|
8129
8129
|
resetQueue();
|
|
8130
8130
|
}
|
|
@@ -8136,48 +8136,48 @@ var require_graceful_fs = __commonJS({
|
|
|
8136
8136
|
value: fs$close
|
|
8137
8137
|
});
|
|
8138
8138
|
return close;
|
|
8139
|
-
}(
|
|
8140
|
-
|
|
8139
|
+
}(fs9.close);
|
|
8140
|
+
fs9.closeSync = function(fs$closeSync) {
|
|
8141
8141
|
function closeSync(fd) {
|
|
8142
|
-
fs$closeSync.apply(
|
|
8142
|
+
fs$closeSync.apply(fs9, arguments);
|
|
8143
8143
|
resetQueue();
|
|
8144
8144
|
}
|
|
8145
8145
|
Object.defineProperty(closeSync, previousSymbol, {
|
|
8146
8146
|
value: fs$closeSync
|
|
8147
8147
|
});
|
|
8148
8148
|
return closeSync;
|
|
8149
|
-
}(
|
|
8149
|
+
}(fs9.closeSync);
|
|
8150
8150
|
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
|
|
8151
8151
|
process.on("exit", function() {
|
|
8152
|
-
debug(
|
|
8153
|
-
require("assert").equal(
|
|
8152
|
+
debug(fs9[gracefulQueue]);
|
|
8153
|
+
require("assert").equal(fs9[gracefulQueue].length, 0);
|
|
8154
8154
|
});
|
|
8155
8155
|
}
|
|
8156
8156
|
}
|
|
8157
8157
|
var queue;
|
|
8158
8158
|
if (!global[gracefulQueue]) {
|
|
8159
|
-
publishQueue(global,
|
|
8160
|
-
}
|
|
8161
|
-
module2.exports = patch(clone2(
|
|
8162
|
-
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !
|
|
8163
|
-
module2.exports = patch(
|
|
8164
|
-
|
|
8165
|
-
}
|
|
8166
|
-
function patch(
|
|
8167
|
-
polyfills(
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
var fs$readFile =
|
|
8172
|
-
|
|
8173
|
-
function readFile2(
|
|
8159
|
+
publishQueue(global, fs9[gracefulQueue]);
|
|
8160
|
+
}
|
|
8161
|
+
module2.exports = patch(clone2(fs9));
|
|
8162
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs9.__patched) {
|
|
8163
|
+
module2.exports = patch(fs9);
|
|
8164
|
+
fs9.__patched = true;
|
|
8165
|
+
}
|
|
8166
|
+
function patch(fs10) {
|
|
8167
|
+
polyfills(fs10);
|
|
8168
|
+
fs10.gracefulify = patch;
|
|
8169
|
+
fs10.createReadStream = createReadStream;
|
|
8170
|
+
fs10.createWriteStream = createWriteStream;
|
|
8171
|
+
var fs$readFile = fs10.readFile;
|
|
8172
|
+
fs10.readFile = readFile2;
|
|
8173
|
+
function readFile2(path19, options, cb) {
|
|
8174
8174
|
if (typeof options === "function")
|
|
8175
8175
|
cb = options, options = null;
|
|
8176
|
-
return go$readFile(
|
|
8177
|
-
function go$readFile(
|
|
8178
|
-
return fs$readFile(
|
|
8176
|
+
return go$readFile(path19, options, cb);
|
|
8177
|
+
function go$readFile(path20, options2, cb2, startTime) {
|
|
8178
|
+
return fs$readFile(path20, options2, function(err) {
|
|
8179
8179
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
8180
|
-
enqueue([go$readFile, [
|
|
8180
|
+
enqueue([go$readFile, [path20, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
8181
8181
|
else {
|
|
8182
8182
|
if (typeof cb2 === "function")
|
|
8183
8183
|
cb2.apply(this, arguments);
|
|
@@ -8185,16 +8185,16 @@ var require_graceful_fs = __commonJS({
|
|
|
8185
8185
|
});
|
|
8186
8186
|
}
|
|
8187
8187
|
}
|
|
8188
|
-
var fs$writeFile =
|
|
8189
|
-
|
|
8190
|
-
function writeFile(
|
|
8188
|
+
var fs$writeFile = fs10.writeFile;
|
|
8189
|
+
fs10.writeFile = writeFile;
|
|
8190
|
+
function writeFile(path19, data, options, cb) {
|
|
8191
8191
|
if (typeof options === "function")
|
|
8192
8192
|
cb = options, options = null;
|
|
8193
|
-
return go$writeFile(
|
|
8194
|
-
function go$writeFile(
|
|
8195
|
-
return fs$writeFile(
|
|
8193
|
+
return go$writeFile(path19, data, options, cb);
|
|
8194
|
+
function go$writeFile(path20, data2, options2, cb2, startTime) {
|
|
8195
|
+
return fs$writeFile(path20, data2, options2, function(err) {
|
|
8196
8196
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
8197
|
-
enqueue([go$writeFile, [
|
|
8197
|
+
enqueue([go$writeFile, [path20, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
8198
8198
|
else {
|
|
8199
8199
|
if (typeof cb2 === "function")
|
|
8200
8200
|
cb2.apply(this, arguments);
|
|
@@ -8202,17 +8202,17 @@ var require_graceful_fs = __commonJS({
|
|
|
8202
8202
|
});
|
|
8203
8203
|
}
|
|
8204
8204
|
}
|
|
8205
|
-
var fs$appendFile =
|
|
8205
|
+
var fs$appendFile = fs10.appendFile;
|
|
8206
8206
|
if (fs$appendFile)
|
|
8207
|
-
|
|
8208
|
-
function appendFile(
|
|
8207
|
+
fs10.appendFile = appendFile;
|
|
8208
|
+
function appendFile(path19, data, options, cb) {
|
|
8209
8209
|
if (typeof options === "function")
|
|
8210
8210
|
cb = options, options = null;
|
|
8211
|
-
return go$appendFile(
|
|
8212
|
-
function go$appendFile(
|
|
8213
|
-
return fs$appendFile(
|
|
8211
|
+
return go$appendFile(path19, data, options, cb);
|
|
8212
|
+
function go$appendFile(path20, data2, options2, cb2, startTime) {
|
|
8213
|
+
return fs$appendFile(path20, data2, options2, function(err) {
|
|
8214
8214
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
8215
|
-
enqueue([go$appendFile, [
|
|
8215
|
+
enqueue([go$appendFile, [path20, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
8216
8216
|
else {
|
|
8217
8217
|
if (typeof cb2 === "function")
|
|
8218
8218
|
cb2.apply(this, arguments);
|
|
@@ -8220,9 +8220,9 @@ var require_graceful_fs = __commonJS({
|
|
|
8220
8220
|
});
|
|
8221
8221
|
}
|
|
8222
8222
|
}
|
|
8223
|
-
var fs$copyFile =
|
|
8223
|
+
var fs$copyFile = fs10.copyFile;
|
|
8224
8224
|
if (fs$copyFile)
|
|
8225
|
-
|
|
8225
|
+
fs10.copyFile = copyFile;
|
|
8226
8226
|
function copyFile(src, dest, flags, cb) {
|
|
8227
8227
|
if (typeof flags === "function") {
|
|
8228
8228
|
cb = flags;
|
|
@@ -8240,34 +8240,34 @@ var require_graceful_fs = __commonJS({
|
|
|
8240
8240
|
});
|
|
8241
8241
|
}
|
|
8242
8242
|
}
|
|
8243
|
-
var fs$readdir =
|
|
8244
|
-
|
|
8243
|
+
var fs$readdir = fs10.readdir;
|
|
8244
|
+
fs10.readdir = readdir2;
|
|
8245
8245
|
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
8246
|
-
function readdir2(
|
|
8246
|
+
function readdir2(path19, options, cb) {
|
|
8247
8247
|
if (typeof options === "function")
|
|
8248
8248
|
cb = options, options = null;
|
|
8249
|
-
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(
|
|
8250
|
-
return fs$readdir(
|
|
8251
|
-
|
|
8249
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path20, options2, cb2, startTime) {
|
|
8250
|
+
return fs$readdir(path20, fs$readdirCallback(
|
|
8251
|
+
path20,
|
|
8252
8252
|
options2,
|
|
8253
8253
|
cb2,
|
|
8254
8254
|
startTime
|
|
8255
8255
|
));
|
|
8256
|
-
} : function go$readdir2(
|
|
8257
|
-
return fs$readdir(
|
|
8258
|
-
|
|
8256
|
+
} : function go$readdir2(path20, options2, cb2, startTime) {
|
|
8257
|
+
return fs$readdir(path20, options2, fs$readdirCallback(
|
|
8258
|
+
path20,
|
|
8259
8259
|
options2,
|
|
8260
8260
|
cb2,
|
|
8261
8261
|
startTime
|
|
8262
8262
|
));
|
|
8263
8263
|
};
|
|
8264
|
-
return go$readdir(
|
|
8265
|
-
function fs$readdirCallback(
|
|
8264
|
+
return go$readdir(path19, options, cb);
|
|
8265
|
+
function fs$readdirCallback(path20, options2, cb2, startTime) {
|
|
8266
8266
|
return function(err, files) {
|
|
8267
8267
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
8268
8268
|
enqueue([
|
|
8269
8269
|
go$readdir,
|
|
8270
|
-
[
|
|
8270
|
+
[path20, options2, cb2],
|
|
8271
8271
|
err,
|
|
8272
8272
|
startTime || Date.now(),
|
|
8273
8273
|
Date.now()
|
|
@@ -8282,21 +8282,21 @@ var require_graceful_fs = __commonJS({
|
|
|
8282
8282
|
}
|
|
8283
8283
|
}
|
|
8284
8284
|
if (process.version.substr(0, 4) === "v0.8") {
|
|
8285
|
-
var legStreams = legacy(
|
|
8285
|
+
var legStreams = legacy(fs10);
|
|
8286
8286
|
ReadStream = legStreams.ReadStream;
|
|
8287
8287
|
WriteStream = legStreams.WriteStream;
|
|
8288
8288
|
}
|
|
8289
|
-
var fs$ReadStream =
|
|
8289
|
+
var fs$ReadStream = fs10.ReadStream;
|
|
8290
8290
|
if (fs$ReadStream) {
|
|
8291
8291
|
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
8292
8292
|
ReadStream.prototype.open = ReadStream$open;
|
|
8293
8293
|
}
|
|
8294
|
-
var fs$WriteStream =
|
|
8294
|
+
var fs$WriteStream = fs10.WriteStream;
|
|
8295
8295
|
if (fs$WriteStream) {
|
|
8296
8296
|
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
8297
8297
|
WriteStream.prototype.open = WriteStream$open;
|
|
8298
8298
|
}
|
|
8299
|
-
Object.defineProperty(
|
|
8299
|
+
Object.defineProperty(fs10, "ReadStream", {
|
|
8300
8300
|
get: function() {
|
|
8301
8301
|
return ReadStream;
|
|
8302
8302
|
},
|
|
@@ -8306,7 +8306,7 @@ var require_graceful_fs = __commonJS({
|
|
|
8306
8306
|
enumerable: true,
|
|
8307
8307
|
configurable: true
|
|
8308
8308
|
});
|
|
8309
|
-
Object.defineProperty(
|
|
8309
|
+
Object.defineProperty(fs10, "WriteStream", {
|
|
8310
8310
|
get: function() {
|
|
8311
8311
|
return WriteStream;
|
|
8312
8312
|
},
|
|
@@ -8317,7 +8317,7 @@ var require_graceful_fs = __commonJS({
|
|
|
8317
8317
|
configurable: true
|
|
8318
8318
|
});
|
|
8319
8319
|
var FileReadStream = ReadStream;
|
|
8320
|
-
Object.defineProperty(
|
|
8320
|
+
Object.defineProperty(fs10, "FileReadStream", {
|
|
8321
8321
|
get: function() {
|
|
8322
8322
|
return FileReadStream;
|
|
8323
8323
|
},
|
|
@@ -8328,7 +8328,7 @@ var require_graceful_fs = __commonJS({
|
|
|
8328
8328
|
configurable: true
|
|
8329
8329
|
});
|
|
8330
8330
|
var FileWriteStream = WriteStream;
|
|
8331
|
-
Object.defineProperty(
|
|
8331
|
+
Object.defineProperty(fs10, "FileWriteStream", {
|
|
8332
8332
|
get: function() {
|
|
8333
8333
|
return FileWriteStream;
|
|
8334
8334
|
},
|
|
@@ -8338,7 +8338,7 @@ var require_graceful_fs = __commonJS({
|
|
|
8338
8338
|
enumerable: true,
|
|
8339
8339
|
configurable: true
|
|
8340
8340
|
});
|
|
8341
|
-
function ReadStream(
|
|
8341
|
+
function ReadStream(path19, options) {
|
|
8342
8342
|
if (this instanceof ReadStream)
|
|
8343
8343
|
return fs$ReadStream.apply(this, arguments), this;
|
|
8344
8344
|
else
|
|
@@ -8358,7 +8358,7 @@ var require_graceful_fs = __commonJS({
|
|
|
8358
8358
|
}
|
|
8359
8359
|
});
|
|
8360
8360
|
}
|
|
8361
|
-
function WriteStream(
|
|
8361
|
+
function WriteStream(path19, options) {
|
|
8362
8362
|
if (this instanceof WriteStream)
|
|
8363
8363
|
return fs$WriteStream.apply(this, arguments), this;
|
|
8364
8364
|
else
|
|
@@ -8376,22 +8376,22 @@ var require_graceful_fs = __commonJS({
|
|
|
8376
8376
|
}
|
|
8377
8377
|
});
|
|
8378
8378
|
}
|
|
8379
|
-
function createReadStream(
|
|
8380
|
-
return new
|
|
8379
|
+
function createReadStream(path19, options) {
|
|
8380
|
+
return new fs10.ReadStream(path19, options);
|
|
8381
8381
|
}
|
|
8382
|
-
function createWriteStream(
|
|
8383
|
-
return new
|
|
8382
|
+
function createWriteStream(path19, options) {
|
|
8383
|
+
return new fs10.WriteStream(path19, options);
|
|
8384
8384
|
}
|
|
8385
|
-
var fs$open =
|
|
8386
|
-
|
|
8387
|
-
function open(
|
|
8385
|
+
var fs$open = fs10.open;
|
|
8386
|
+
fs10.open = open;
|
|
8387
|
+
function open(path19, flags, mode, cb) {
|
|
8388
8388
|
if (typeof mode === "function")
|
|
8389
8389
|
cb = mode, mode = null;
|
|
8390
|
-
return go$open(
|
|
8391
|
-
function go$open(
|
|
8392
|
-
return fs$open(
|
|
8390
|
+
return go$open(path19, flags, mode, cb);
|
|
8391
|
+
function go$open(path20, flags2, mode2, cb2, startTime) {
|
|
8392
|
+
return fs$open(path20, flags2, mode2, function(err, fd) {
|
|
8393
8393
|
if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
|
|
8394
|
-
enqueue([go$open, [
|
|
8394
|
+
enqueue([go$open, [path20, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
|
|
8395
8395
|
else {
|
|
8396
8396
|
if (typeof cb2 === "function")
|
|
8397
8397
|
cb2.apply(this, arguments);
|
|
@@ -8399,20 +8399,20 @@ var require_graceful_fs = __commonJS({
|
|
|
8399
8399
|
});
|
|
8400
8400
|
}
|
|
8401
8401
|
}
|
|
8402
|
-
return
|
|
8402
|
+
return fs10;
|
|
8403
8403
|
}
|
|
8404
8404
|
function enqueue(elem) {
|
|
8405
8405
|
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
8406
|
-
|
|
8406
|
+
fs9[gracefulQueue].push(elem);
|
|
8407
8407
|
retry();
|
|
8408
8408
|
}
|
|
8409
8409
|
var retryTimer;
|
|
8410
8410
|
function resetQueue() {
|
|
8411
8411
|
var now = Date.now();
|
|
8412
|
-
for (var i = 0; i <
|
|
8413
|
-
if (
|
|
8414
|
-
|
|
8415
|
-
|
|
8412
|
+
for (var i = 0; i < fs9[gracefulQueue].length; ++i) {
|
|
8413
|
+
if (fs9[gracefulQueue][i].length > 2) {
|
|
8414
|
+
fs9[gracefulQueue][i][3] = now;
|
|
8415
|
+
fs9[gracefulQueue][i][4] = now;
|
|
8416
8416
|
}
|
|
8417
8417
|
}
|
|
8418
8418
|
retry();
|
|
@@ -8420,9 +8420,9 @@ var require_graceful_fs = __commonJS({
|
|
|
8420
8420
|
function retry() {
|
|
8421
8421
|
clearTimeout(retryTimer);
|
|
8422
8422
|
retryTimer = void 0;
|
|
8423
|
-
if (
|
|
8423
|
+
if (fs9[gracefulQueue].length === 0)
|
|
8424
8424
|
return;
|
|
8425
|
-
var elem =
|
|
8425
|
+
var elem = fs9[gracefulQueue].shift();
|
|
8426
8426
|
var fn = elem[0];
|
|
8427
8427
|
var args = elem[1];
|
|
8428
8428
|
var err = elem[2];
|
|
@@ -8444,7 +8444,7 @@ var require_graceful_fs = __commonJS({
|
|
|
8444
8444
|
debug("RETRY", fn.name, args);
|
|
8445
8445
|
fn.apply(null, args.concat([startTime]));
|
|
8446
8446
|
} else {
|
|
8447
|
-
|
|
8447
|
+
fs9[gracefulQueue].push(elem);
|
|
8448
8448
|
}
|
|
8449
8449
|
}
|
|
8450
8450
|
if (retryTimer === void 0) {
|
|
@@ -8879,10 +8879,10 @@ var require_mtime_precision = __commonJS({
|
|
|
8879
8879
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/mtime-precision.js"(exports2, module2) {
|
|
8880
8880
|
"use strict";
|
|
8881
8881
|
var cacheSymbol = Symbol();
|
|
8882
|
-
function probe(file2,
|
|
8883
|
-
const cachedPrecision =
|
|
8882
|
+
function probe(file2, fs9, callback) {
|
|
8883
|
+
const cachedPrecision = fs9[cacheSymbol];
|
|
8884
8884
|
if (cachedPrecision) {
|
|
8885
|
-
return
|
|
8885
|
+
return fs9.stat(file2, (err, stat2) => {
|
|
8886
8886
|
if (err) {
|
|
8887
8887
|
return callback(err);
|
|
8888
8888
|
}
|
|
@@ -8890,16 +8890,16 @@ var require_mtime_precision = __commonJS({
|
|
|
8890
8890
|
});
|
|
8891
8891
|
}
|
|
8892
8892
|
const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
8893
|
-
|
|
8893
|
+
fs9.utimes(file2, mtime, mtime, (err) => {
|
|
8894
8894
|
if (err) {
|
|
8895
8895
|
return callback(err);
|
|
8896
8896
|
}
|
|
8897
|
-
|
|
8897
|
+
fs9.stat(file2, (err2, stat2) => {
|
|
8898
8898
|
if (err2) {
|
|
8899
8899
|
return callback(err2);
|
|
8900
8900
|
}
|
|
8901
8901
|
const precision = stat2.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
8902
|
-
Object.defineProperty(
|
|
8902
|
+
Object.defineProperty(fs9, cacheSymbol, { value: precision });
|
|
8903
8903
|
callback(null, stat2.mtime, precision);
|
|
8904
8904
|
});
|
|
8905
8905
|
});
|
|
@@ -8920,8 +8920,8 @@ var require_mtime_precision = __commonJS({
|
|
|
8920
8920
|
var require_lockfile = __commonJS({
|
|
8921
8921
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/lockfile.js"(exports2, module2) {
|
|
8922
8922
|
"use strict";
|
|
8923
|
-
var
|
|
8924
|
-
var
|
|
8923
|
+
var path19 = require("path");
|
|
8924
|
+
var fs9 = require_graceful_fs();
|
|
8925
8925
|
var retry = require_retry2();
|
|
8926
8926
|
var onExit = require_signal_exit();
|
|
8927
8927
|
var mtimePrecision = require_mtime_precision();
|
|
@@ -8931,7 +8931,7 @@ var require_lockfile = __commonJS({
|
|
|
8931
8931
|
}
|
|
8932
8932
|
function resolveCanonicalPath(file2, options, callback) {
|
|
8933
8933
|
if (!options.realpath) {
|
|
8934
|
-
return callback(null,
|
|
8934
|
+
return callback(null, path19.resolve(file2));
|
|
8935
8935
|
}
|
|
8936
8936
|
options.fs.realpath(file2, callback);
|
|
8937
8937
|
}
|
|
@@ -9052,7 +9052,7 @@ var require_lockfile = __commonJS({
|
|
|
9052
9052
|
update: null,
|
|
9053
9053
|
realpath: true,
|
|
9054
9054
|
retries: 0,
|
|
9055
|
-
fs:
|
|
9055
|
+
fs: fs9,
|
|
9056
9056
|
onCompromised: (err) => {
|
|
9057
9057
|
throw err;
|
|
9058
9058
|
},
|
|
@@ -9096,7 +9096,7 @@ var require_lockfile = __commonJS({
|
|
|
9096
9096
|
}
|
|
9097
9097
|
function unlock(file2, options, callback) {
|
|
9098
9098
|
options = {
|
|
9099
|
-
fs:
|
|
9099
|
+
fs: fs9,
|
|
9100
9100
|
realpath: true,
|
|
9101
9101
|
...options
|
|
9102
9102
|
};
|
|
@@ -9118,7 +9118,7 @@ var require_lockfile = __commonJS({
|
|
|
9118
9118
|
options = {
|
|
9119
9119
|
stale: 1e4,
|
|
9120
9120
|
realpath: true,
|
|
9121
|
-
fs:
|
|
9121
|
+
fs: fs9,
|
|
9122
9122
|
...options
|
|
9123
9123
|
};
|
|
9124
9124
|
options.stale = Math.max(options.stale || 0, 2e3);
|
|
@@ -9157,16 +9157,16 @@ var require_lockfile = __commonJS({
|
|
|
9157
9157
|
var require_adapter = __commonJS({
|
|
9158
9158
|
"../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/adapter.js"(exports2, module2) {
|
|
9159
9159
|
"use strict";
|
|
9160
|
-
var
|
|
9161
|
-
function createSyncFs(
|
|
9160
|
+
var fs9 = require_graceful_fs();
|
|
9161
|
+
function createSyncFs(fs10) {
|
|
9162
9162
|
const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
|
|
9163
|
-
const newFs = { ...
|
|
9163
|
+
const newFs = { ...fs10 };
|
|
9164
9164
|
methods.forEach((method) => {
|
|
9165
9165
|
newFs[method] = (...args) => {
|
|
9166
9166
|
const callback = args.pop();
|
|
9167
9167
|
let ret;
|
|
9168
9168
|
try {
|
|
9169
|
-
ret =
|
|
9169
|
+
ret = fs10[`${method}Sync`](...args);
|
|
9170
9170
|
} catch (err) {
|
|
9171
9171
|
return callback(err);
|
|
9172
9172
|
}
|
|
@@ -9204,7 +9204,7 @@ var require_adapter = __commonJS({
|
|
|
9204
9204
|
}
|
|
9205
9205
|
function toSyncOptions(options) {
|
|
9206
9206
|
options = { ...options };
|
|
9207
|
-
options.fs = createSyncFs(options.fs ||
|
|
9207
|
+
options.fs = createSyncFs(options.fs || fs9);
|
|
9208
9208
|
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
|
|
9209
9209
|
throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
9210
9210
|
}
|
|
@@ -10795,10 +10795,10 @@ var require_segments = __commonJS({
|
|
|
10795
10795
|
const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
|
|
10796
10796
|
const nodes = buildNodes(segs);
|
|
10797
10797
|
const graph = buildGraph(nodes, version2);
|
|
10798
|
-
const
|
|
10798
|
+
const path19 = dijkstra.find_path(graph.map, "start", "end");
|
|
10799
10799
|
const optimizedSegs = [];
|
|
10800
|
-
for (let i = 1; i <
|
|
10801
|
-
optimizedSegs.push(graph.table[
|
|
10800
|
+
for (let i = 1; i < path19.length - 1; i++) {
|
|
10801
|
+
optimizedSegs.push(graph.table[path19[i]].node);
|
|
10802
10802
|
}
|
|
10803
10803
|
return exports2.fromArray(mergeSegments(optimizedSegs));
|
|
10804
10804
|
};
|
|
@@ -13234,7 +13234,7 @@ var require_utils2 = __commonJS({
|
|
|
13234
13234
|
// ../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js
|
|
13235
13235
|
var require_png2 = __commonJS({
|
|
13236
13236
|
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/png.js"(exports2) {
|
|
13237
|
-
var
|
|
13237
|
+
var fs9 = require("fs");
|
|
13238
13238
|
var PNG = require_png().PNG;
|
|
13239
13239
|
var Utils = require_utils2();
|
|
13240
13240
|
exports2.render = function render(qrData, options) {
|
|
@@ -13275,7 +13275,7 @@ var require_png2 = __commonJS({
|
|
|
13275
13275
|
});
|
|
13276
13276
|
png.pack();
|
|
13277
13277
|
};
|
|
13278
|
-
exports2.renderToFile = function renderToFile(
|
|
13278
|
+
exports2.renderToFile = function renderToFile(path19, qrData, options, cb) {
|
|
13279
13279
|
if (typeof cb === "undefined") {
|
|
13280
13280
|
cb = options;
|
|
13281
13281
|
options = void 0;
|
|
@@ -13286,7 +13286,7 @@ var require_png2 = __commonJS({
|
|
|
13286
13286
|
called = true;
|
|
13287
13287
|
cb.apply(null, args);
|
|
13288
13288
|
};
|
|
13289
|
-
const stream =
|
|
13289
|
+
const stream = fs9.createWriteStream(path19);
|
|
13290
13290
|
stream.on("error", done);
|
|
13291
13291
|
stream.on("close", done);
|
|
13292
13292
|
exports2.renderToFileStream(stream, qrData, options);
|
|
@@ -13348,14 +13348,14 @@ var require_utf8 = __commonJS({
|
|
|
13348
13348
|
}
|
|
13349
13349
|
return output3;
|
|
13350
13350
|
};
|
|
13351
|
-
exports2.renderToFile = function renderToFile(
|
|
13351
|
+
exports2.renderToFile = function renderToFile(path19, qrData, options, cb) {
|
|
13352
13352
|
if (typeof cb === "undefined") {
|
|
13353
13353
|
cb = options;
|
|
13354
13354
|
options = void 0;
|
|
13355
13355
|
}
|
|
13356
|
-
const
|
|
13356
|
+
const fs9 = require("fs");
|
|
13357
13357
|
const utf8 = exports2.render(qrData, options);
|
|
13358
|
-
|
|
13358
|
+
fs9.writeFile(path19, utf8, cb);
|
|
13359
13359
|
};
|
|
13360
13360
|
}
|
|
13361
13361
|
});
|
|
@@ -13476,7 +13476,7 @@ var require_svg_tag = __commonJS({
|
|
|
13476
13476
|
return str;
|
|
13477
13477
|
}
|
|
13478
13478
|
function qrToPath(data, size, margin) {
|
|
13479
|
-
let
|
|
13479
|
+
let path19 = "";
|
|
13480
13480
|
let moveBy = 0;
|
|
13481
13481
|
let newRow = false;
|
|
13482
13482
|
let lineLength = 0;
|
|
@@ -13487,19 +13487,19 @@ var require_svg_tag = __commonJS({
|
|
|
13487
13487
|
if (data[i]) {
|
|
13488
13488
|
lineLength++;
|
|
13489
13489
|
if (!(i > 0 && col > 0 && data[i - 1])) {
|
|
13490
|
-
|
|
13490
|
+
path19 += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
|
|
13491
13491
|
moveBy = 0;
|
|
13492
13492
|
newRow = false;
|
|
13493
13493
|
}
|
|
13494
13494
|
if (!(col + 1 < size && data[i + 1])) {
|
|
13495
|
-
|
|
13495
|
+
path19 += svgCmd("h", lineLength);
|
|
13496
13496
|
lineLength = 0;
|
|
13497
13497
|
}
|
|
13498
13498
|
} else {
|
|
13499
13499
|
moveBy++;
|
|
13500
13500
|
}
|
|
13501
13501
|
}
|
|
13502
|
-
return
|
|
13502
|
+
return path19;
|
|
13503
13503
|
}
|
|
13504
13504
|
exports2.render = function render(qrData, options, cb) {
|
|
13505
13505
|
const opts = Utils.getOptions(options);
|
|
@@ -13507,10 +13507,10 @@ var require_svg_tag = __commonJS({
|
|
|
13507
13507
|
const data = qrData.modules.data;
|
|
13508
13508
|
const qrcodesize = size + opts.margin * 2;
|
|
13509
13509
|
const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>';
|
|
13510
|
-
const
|
|
13510
|
+
const path19 = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
|
|
13511
13511
|
const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"';
|
|
13512
13512
|
const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" ';
|
|
13513
|
-
const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg +
|
|
13513
|
+
const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path19 + "</svg>\n";
|
|
13514
13514
|
if (typeof cb === "function") {
|
|
13515
13515
|
cb(null, svgTag);
|
|
13516
13516
|
}
|
|
@@ -13524,15 +13524,15 @@ var require_svg = __commonJS({
|
|
|
13524
13524
|
"../../node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/renderer/svg.js"(exports2) {
|
|
13525
13525
|
var svgTagRenderer = require_svg_tag();
|
|
13526
13526
|
exports2.render = svgTagRenderer.render;
|
|
13527
|
-
exports2.renderToFile = function renderToFile(
|
|
13527
|
+
exports2.renderToFile = function renderToFile(path19, qrData, options, cb) {
|
|
13528
13528
|
if (typeof cb === "undefined") {
|
|
13529
13529
|
cb = options;
|
|
13530
13530
|
options = void 0;
|
|
13531
13531
|
}
|
|
13532
|
-
const
|
|
13532
|
+
const fs9 = require("fs");
|
|
13533
13533
|
const svgTag = exports2.render(qrData, options);
|
|
13534
13534
|
const xmlStr = '<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">' + svgTag;
|
|
13535
|
-
|
|
13535
|
+
fs9.writeFile(path19, xmlStr, cb);
|
|
13536
13536
|
};
|
|
13537
13537
|
}
|
|
13538
13538
|
});
|
|
@@ -13690,8 +13690,8 @@ var require_server = __commonJS({
|
|
|
13690
13690
|
cb
|
|
13691
13691
|
};
|
|
13692
13692
|
}
|
|
13693
|
-
function getTypeFromFilename(
|
|
13694
|
-
return
|
|
13693
|
+
function getTypeFromFilename(path19) {
|
|
13694
|
+
return path19.slice((path19.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase();
|
|
13695
13695
|
}
|
|
13696
13696
|
function getRendererFromType(type) {
|
|
13697
13697
|
switch (type) {
|
|
@@ -13755,17 +13755,17 @@ var require_server = __commonJS({
|
|
|
13755
13755
|
const renderer = getRendererFromType(params.opts.type);
|
|
13756
13756
|
return render(renderer.renderToBuffer, text, params);
|
|
13757
13757
|
};
|
|
13758
|
-
exports2.toFile = function toFile(
|
|
13759
|
-
if (typeof
|
|
13758
|
+
exports2.toFile = function toFile(path19, text, opts, cb) {
|
|
13759
|
+
if (typeof path19 !== "string" || !(typeof text === "string" || typeof text === "object")) {
|
|
13760
13760
|
throw new Error("Invalid argument");
|
|
13761
13761
|
}
|
|
13762
13762
|
if (arguments.length < 3 && !canPromise()) {
|
|
13763
13763
|
throw new Error("Too few arguments provided");
|
|
13764
13764
|
}
|
|
13765
13765
|
const params = checkParams(text, opts, cb);
|
|
13766
|
-
const type = params.opts.type || getTypeFromFilename(
|
|
13766
|
+
const type = params.opts.type || getTypeFromFilename(path19);
|
|
13767
13767
|
const renderer = getRendererFromType(type);
|
|
13768
|
-
const renderToFile = renderer.renderToFile.bind(null,
|
|
13768
|
+
const renderToFile = renderer.renderToFile.bind(null, path19);
|
|
13769
13769
|
return render(renderToFile, text, params);
|
|
13770
13770
|
};
|
|
13771
13771
|
exports2.toFileStream = function toFileStream(stream, text, opts) {
|
|
@@ -16983,8 +16983,8 @@ var require_utils3 = __commonJS({
|
|
|
16983
16983
|
}
|
|
16984
16984
|
return ind;
|
|
16985
16985
|
}
|
|
16986
|
-
function removeDotSegments(
|
|
16987
|
-
let input =
|
|
16986
|
+
function removeDotSegments(path19) {
|
|
16987
|
+
let input = path19;
|
|
16988
16988
|
const output3 = [];
|
|
16989
16989
|
let nextSlash = -1;
|
|
16990
16990
|
let len = 0;
|
|
@@ -17236,8 +17236,8 @@ var require_schemes = __commonJS({
|
|
|
17236
17236
|
wsComponent.secure = void 0;
|
|
17237
17237
|
}
|
|
17238
17238
|
if (wsComponent.resourceName) {
|
|
17239
|
-
const [
|
|
17240
|
-
wsComponent.path =
|
|
17239
|
+
const [path19, query] = wsComponent.resourceName.split("?");
|
|
17240
|
+
wsComponent.path = path19 && path19 !== "/" ? path19 : void 0;
|
|
17241
17241
|
wsComponent.query = query;
|
|
17242
17242
|
wsComponent.resourceName = void 0;
|
|
17243
17243
|
}
|
|
@@ -20630,12 +20630,12 @@ var require_dist = __commonJS({
|
|
|
20630
20630
|
throw new Error(`Unknown format "${name}"`);
|
|
20631
20631
|
return f;
|
|
20632
20632
|
};
|
|
20633
|
-
function addFormats(ajv, list,
|
|
20633
|
+
function addFormats(ajv, list, fs9, exportName) {
|
|
20634
20634
|
var _a3;
|
|
20635
20635
|
var _b;
|
|
20636
20636
|
(_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
20637
20637
|
for (const f of list)
|
|
20638
|
-
ajv.addFormat(f,
|
|
20638
|
+
ajv.addFormat(f, fs9[f]);
|
|
20639
20639
|
}
|
|
20640
20640
|
module2.exports = exports2 = formatsPlugin;
|
|
20641
20641
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -20644,11 +20644,11 @@ var require_dist = __commonJS({
|
|
|
20644
20644
|
});
|
|
20645
20645
|
|
|
20646
20646
|
// src/bin.ts
|
|
20647
|
-
var import_node_path22 = __toESM(require("node:path"), 1);
|
|
20648
|
-
var import_node_child_process13 = require("node:child_process");
|
|
20649
|
-
var import_node_fs15 = require("node:fs");
|
|
20650
|
-
var import_node_os12 = require("node:os");
|
|
20651
20647
|
var import_node_path23 = __toESM(require("node:path"), 1);
|
|
20648
|
+
var import_node_child_process13 = require("node:child_process");
|
|
20649
|
+
var import_node_fs16 = require("node:fs");
|
|
20650
|
+
var import_node_os13 = require("node:os");
|
|
20651
|
+
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
20652
20652
|
|
|
20653
20653
|
// src/install-codex.ts
|
|
20654
20654
|
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
@@ -21153,12 +21153,12 @@ ${block}`;
|
|
|
21153
21153
|
}
|
|
21154
21154
|
|
|
21155
21155
|
// src/director-bridge.ts
|
|
21156
|
-
var
|
|
21156
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
21157
21157
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
21158
|
-
var
|
|
21159
|
-
var
|
|
21158
|
+
var import_node_os9 = __toESM(require("node:os"), 1);
|
|
21159
|
+
var import_node_path18 = __toESM(require("node:path"), 1);
|
|
21160
21160
|
var import_node_child_process10 = require("node:child_process");
|
|
21161
|
-
var
|
|
21161
|
+
var import_node_crypto8 = __toESM(require("node:crypto"), 1);
|
|
21162
21162
|
|
|
21163
21163
|
// src/turn-replay-buffer.ts
|
|
21164
21164
|
var DEFAULT_MAX_EVENTS = 2e3;
|
|
@@ -22713,10 +22713,10 @@ function mergeDefs(...defs) {
|
|
|
22713
22713
|
function cloneDef(schema) {
|
|
22714
22714
|
return mergeDefs(schema._zod.def);
|
|
22715
22715
|
}
|
|
22716
|
-
function getElementAtPath(obj,
|
|
22717
|
-
if (!
|
|
22716
|
+
function getElementAtPath(obj, path19) {
|
|
22717
|
+
if (!path19)
|
|
22718
22718
|
return obj;
|
|
22719
|
-
return
|
|
22719
|
+
return path19.reduce((acc, key) => acc?.[key], obj);
|
|
22720
22720
|
}
|
|
22721
22721
|
function promiseAllObject(promisesObj) {
|
|
22722
22722
|
const keys = Object.keys(promisesObj);
|
|
@@ -23125,11 +23125,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
23125
23125
|
}
|
|
23126
23126
|
return false;
|
|
23127
23127
|
}
|
|
23128
|
-
function prefixIssues(
|
|
23128
|
+
function prefixIssues(path19, issues) {
|
|
23129
23129
|
return issues.map((iss) => {
|
|
23130
23130
|
var _a3;
|
|
23131
23131
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
23132
|
-
iss.path.unshift(
|
|
23132
|
+
iss.path.unshift(path19);
|
|
23133
23133
|
return iss;
|
|
23134
23134
|
});
|
|
23135
23135
|
}
|
|
@@ -23276,16 +23276,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
23276
23276
|
}
|
|
23277
23277
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
23278
23278
|
const fieldErrors = { _errors: [] };
|
|
23279
|
-
const processError = (error52,
|
|
23279
|
+
const processError = (error52, path19 = []) => {
|
|
23280
23280
|
for (const issue2 of error52.issues) {
|
|
23281
23281
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
23282
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
23282
|
+
issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
|
|
23283
23283
|
} else if (issue2.code === "invalid_key") {
|
|
23284
|
-
processError({ issues: issue2.issues }, [...
|
|
23284
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
23285
23285
|
} else if (issue2.code === "invalid_element") {
|
|
23286
|
-
processError({ issues: issue2.issues }, [...
|
|
23286
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
23287
23287
|
} else {
|
|
23288
|
-
const fullpath = [...
|
|
23288
|
+
const fullpath = [...path19, ...issue2.path];
|
|
23289
23289
|
if (fullpath.length === 0) {
|
|
23290
23290
|
fieldErrors._errors.push(mapper(issue2));
|
|
23291
23291
|
} else {
|
|
@@ -23312,17 +23312,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
23312
23312
|
}
|
|
23313
23313
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
23314
23314
|
const result = { errors: [] };
|
|
23315
|
-
const processError = (error52,
|
|
23315
|
+
const processError = (error52, path19 = []) => {
|
|
23316
23316
|
var _a3, _b;
|
|
23317
23317
|
for (const issue2 of error52.issues) {
|
|
23318
23318
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
23319
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
23319
|
+
issue2.errors.map((issues) => processError({ issues }, [...path19, ...issue2.path]));
|
|
23320
23320
|
} else if (issue2.code === "invalid_key") {
|
|
23321
|
-
processError({ issues: issue2.issues }, [...
|
|
23321
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
23322
23322
|
} else if (issue2.code === "invalid_element") {
|
|
23323
|
-
processError({ issues: issue2.issues }, [...
|
|
23323
|
+
processError({ issues: issue2.issues }, [...path19, ...issue2.path]);
|
|
23324
23324
|
} else {
|
|
23325
|
-
const fullpath = [...
|
|
23325
|
+
const fullpath = [...path19, ...issue2.path];
|
|
23326
23326
|
if (fullpath.length === 0) {
|
|
23327
23327
|
result.errors.push(mapper(issue2));
|
|
23328
23328
|
continue;
|
|
@@ -23354,8 +23354,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
23354
23354
|
}
|
|
23355
23355
|
function toDotPath(_path) {
|
|
23356
23356
|
const segs = [];
|
|
23357
|
-
const
|
|
23358
|
-
for (const seg of
|
|
23357
|
+
const path19 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
23358
|
+
for (const seg of path19) {
|
|
23359
23359
|
if (typeof seg === "number")
|
|
23360
23360
|
segs.push(`[${seg}]`);
|
|
23361
23361
|
else if (typeof seg === "symbol")
|
|
@@ -36047,13 +36047,13 @@ function resolveRef(ref, ctx) {
|
|
|
36047
36047
|
if (!ref.startsWith("#")) {
|
|
36048
36048
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
36049
36049
|
}
|
|
36050
|
-
const
|
|
36051
|
-
if (
|
|
36050
|
+
const path19 = ref.slice(1).split("/").filter(Boolean);
|
|
36051
|
+
if (path19.length === 0) {
|
|
36052
36052
|
return ctx.rootSchema;
|
|
36053
36053
|
}
|
|
36054
36054
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
36055
|
-
if (
|
|
36056
|
-
const key =
|
|
36055
|
+
if (path19[0] === defsKey) {
|
|
36056
|
+
const key = path19[1];
|
|
36057
36057
|
if (!key || !ctx.defs[key]) {
|
|
36058
36058
|
throw new Error(`Reference not found: ${ref}`);
|
|
36059
36059
|
}
|
|
@@ -36499,6 +36499,7 @@ var openApiOperationIds = {
|
|
|
36499
36499
|
deleteTaskDependency: "deleteTaskDependency",
|
|
36500
36500
|
getExecutionRun: "getExecutionRun",
|
|
36501
36501
|
getProjectSchedulerPolicy: "getProjectSchedulerPolicy",
|
|
36502
|
+
getProjectDeployWorkflow: "getProjectDeployWorkflow",
|
|
36502
36503
|
getSchedulerPendingTasks: "getSchedulerPendingTasks",
|
|
36503
36504
|
wakeDirector: "wakeDirector",
|
|
36504
36505
|
getGithubInstallationRepositories: "getGithubInstallationRepositories",
|
|
@@ -36530,6 +36531,7 @@ var openApiOperationIds = {
|
|
|
36530
36531
|
searchKnowledge: "searchKnowledge",
|
|
36531
36532
|
updateExecutionRun: "updateExecutionRun",
|
|
36532
36533
|
upsertProjectSchedulerPolicy: "upsertProjectSchedulerPolicy",
|
|
36534
|
+
upsertProjectDeployWorkflow: "upsertProjectDeployWorkflow",
|
|
36533
36535
|
updatePlan: "updatePlan",
|
|
36534
36536
|
updateTask: "updateTask",
|
|
36535
36537
|
updateWikiPage: "updateWikiPage",
|
|
@@ -36807,7 +36809,8 @@ var mrrlinExecutionRunStatusSchema = external_exports.enum([
|
|
|
36807
36809
|
"done",
|
|
36808
36810
|
"failed",
|
|
36809
36811
|
"handoff_requested",
|
|
36810
|
-
"handoff_queued"
|
|
36812
|
+
"handoff_queued",
|
|
36813
|
+
"cancelled"
|
|
36811
36814
|
]);
|
|
36812
36815
|
var mrrlinExecutionArtifactKindSchema = external_exports.enum([
|
|
36813
36816
|
"plan",
|
|
@@ -37045,7 +37048,11 @@ var mrrlinProjectSnapshotSchema = external_exports.object({
|
|
|
37045
37048
|
wikiPages: external_exports.array(mrrlinWikiPageSchema).default([])
|
|
37046
37049
|
});
|
|
37047
37050
|
var mrrlinTaskCreateSchema = external_exports.object({
|
|
37048
|
-
|
|
37051
|
+
// Auto-deploy design Part B: input-optional (NOT .default("off")) so createTask can tell
|
|
37052
|
+
// "caller omitted this" apart from "caller explicitly chose off" -- omitted falls through to
|
|
37053
|
+
// the project's default_auto_deploy; the tasks column itself still defaults to 'off' at the
|
|
37054
|
+
// SQL level for any direct-insert path that bypasses createTask entirely.
|
|
37055
|
+
autoDeploy: mrrlinAutoDeploySchema.optional(),
|
|
37049
37056
|
// Input-optional so existing createTask call sites need no churn; createTask fills 'code' for the
|
|
37050
37057
|
// INSERT (the pg column is NOT NULL, so a concrete value is required, not undefined→NULL).
|
|
37051
37058
|
domain: mrrlinTaskDomainSchema.optional(),
|
|
@@ -37639,6 +37646,10 @@ var mrrlinProjectSchedulerPolicySchema = external_exports.object({
|
|
|
37639
37646
|
createdAt: external_exports.string().datetime(),
|
|
37640
37647
|
// Slice 3 Part E: combined per-UTC-day cap on scheduler-enqueued draft/consensus jobs.
|
|
37641
37648
|
dailyAutonomousJobBudget: external_exports.number().int().nonnegative(),
|
|
37649
|
+
// Auto-deploy design Part B: copied into tasks.autoDeploy at task-creation time when the
|
|
37650
|
+
// caller doesn't specify one. 'prod' is a legal value here (the DB CHECK allows it) but the
|
|
37651
|
+
// Settings UI never offers it as a project default -- only reachable per task.
|
|
37652
|
+
defaultAutoDeploy: mrrlinAutoDeploySchema,
|
|
37642
37653
|
eligibleAutonomyLevels: external_exports.array(mrrlinAutonomyLevelSchema).min(1),
|
|
37643
37654
|
// Slice 3 Part E: cap on concurrently active scheduler-created (ER-SCHED-*) runs.
|
|
37644
37655
|
maxConcurrentAutonomousRuns: external_exports.number().int().nonnegative(),
|
|
@@ -37654,6 +37665,7 @@ var mrrlinProjectSchedulerPolicyUpsertSchema = external_exports.object({
|
|
|
37654
37665
|
autoSpecApproval: mrrlinAutoSpecApprovalSchema.optional(),
|
|
37655
37666
|
cadenceSeconds: external_exports.number().int().positive().nullable().optional(),
|
|
37656
37667
|
dailyAutonomousJobBudget: external_exports.number().int().nonnegative().optional(),
|
|
37668
|
+
defaultAutoDeploy: mrrlinAutoDeploySchema.optional(),
|
|
37657
37669
|
eligibleAutonomyLevels: external_exports.array(mrrlinAutonomyLevelSchema).min(1).optional(),
|
|
37658
37670
|
maxConcurrentAutonomousRuns: external_exports.number().int().nonnegative().optional(),
|
|
37659
37671
|
prodGraceSeconds: external_exports.number().int().nonnegative().optional(),
|
|
@@ -37665,6 +37677,38 @@ var mrrlinProjectSchedulerPolicyUpsertSchema = external_exports.object({
|
|
|
37665
37677
|
var projectSchedulerPolicyResponseSchema = external_exports.object({
|
|
37666
37678
|
data: mrrlinProjectSchedulerPolicySchema
|
|
37667
37679
|
});
|
|
37680
|
+
var mrrlinDeployWorkflowEnvSchema = external_exports.enum(["dev", "prod"]);
|
|
37681
|
+
var mrrlinDeployWorkflowSourceSchema = external_exports.enum(["agent", "operator"]);
|
|
37682
|
+
var mrrlinDeployWorkflowStateSchema = external_exports.enum(["resolved", "ambiguous"]);
|
|
37683
|
+
var mrrlinProjectDeployWorkflowSchema = external_exports.object({
|
|
37684
|
+
projectSlug: mrrlinProjectSlugSchema,
|
|
37685
|
+
env: mrrlinDeployWorkflowEnvSchema,
|
|
37686
|
+
workflowId: external_exports.number().int().positive().nullable(),
|
|
37687
|
+
workflowPath: external_exports.string().nullable(),
|
|
37688
|
+
reason: external_exports.string().nullable(),
|
|
37689
|
+
source: mrrlinDeployWorkflowSourceSchema.nullable(),
|
|
37690
|
+
state: mrrlinDeployWorkflowStateSchema,
|
|
37691
|
+
activeSetFingerprint: external_exports.string().nullable(),
|
|
37692
|
+
reverifyRequested: external_exports.boolean(),
|
|
37693
|
+
resolvedAt: external_exports.string().datetime().nullable(),
|
|
37694
|
+
createdAt: external_exports.string().datetime(),
|
|
37695
|
+
updatedAt: external_exports.string().datetime()
|
|
37696
|
+
});
|
|
37697
|
+
var mrrlinProjectDeployWorkflowUpsertSchema = external_exports.object({
|
|
37698
|
+
workflowId: external_exports.number().int().positive().nullable(),
|
|
37699
|
+
workflowPath: external_exports.string().nullable().optional(),
|
|
37700
|
+
reason: external_exports.string().nullable().optional(),
|
|
37701
|
+
state: mrrlinDeployWorkflowStateSchema.optional(),
|
|
37702
|
+
activeSetFingerprint: external_exports.string().nullable().optional(),
|
|
37703
|
+
reverifyRequested: external_exports.boolean().optional()
|
|
37704
|
+
}).refine((value) => (value.state ?? "resolved") !== "resolved" || value.workflowId !== null, {
|
|
37705
|
+
message: "A resolved deploy-workflow row requires a non-null workflowId."
|
|
37706
|
+
}).refine((value) => (value.state ?? "resolved") !== "ambiguous" || value.workflowId === null, {
|
|
37707
|
+
message: "An ambiguous deploy-workflow row must not carry a workflowId."
|
|
37708
|
+
});
|
|
37709
|
+
var projectDeployWorkflowResponseSchema = external_exports.object({
|
|
37710
|
+
data: mrrlinProjectDeployWorkflowSchema
|
|
37711
|
+
});
|
|
37668
37712
|
var mrrlinSchedulerPendingReasonSchema = external_exports.enum([
|
|
37669
37713
|
"follow_up_due",
|
|
37670
37714
|
"verification_due",
|
|
@@ -38055,18 +38099,18 @@ function createMrrlinClient(config2) {
|
|
|
38055
38099
|
const customFetch = config2.fetch ?? globalThis.fetch;
|
|
38056
38100
|
const baseUrl = config2.baseUrl.replace(/\/$/, "");
|
|
38057
38101
|
const token = config2.token;
|
|
38058
|
-
async function request(
|
|
38102
|
+
async function request(path19, init) {
|
|
38059
38103
|
const method = init?.method ?? "GET";
|
|
38060
38104
|
const headers = new Headers(init?.headers ?? {});
|
|
38061
38105
|
if (token && !headers.has("authorization")) {
|
|
38062
38106
|
headers.set("authorization", `Bearer ${token}`);
|
|
38063
38107
|
}
|
|
38064
|
-
const response = await customFetch(`${baseUrl}${
|
|
38108
|
+
const response = await customFetch(`${baseUrl}${path19}`, { ...init, headers });
|
|
38065
38109
|
if (!response.ok) {
|
|
38066
38110
|
const body = await response.text();
|
|
38067
38111
|
let code = `HTTP_${response.status}`;
|
|
38068
38112
|
let violations = null;
|
|
38069
|
-
let message = `Mrrlin API ${method} ${
|
|
38113
|
+
let message = `Mrrlin API ${method} ${path19} failed: ${response.status}`;
|
|
38070
38114
|
try {
|
|
38071
38115
|
const parsed = JSON.parse(body);
|
|
38072
38116
|
const violationsParsed = apiViolationsErrorSchema.safeParse(parsed);
|
|
@@ -38086,7 +38130,7 @@ function createMrrlinClient(config2) {
|
|
|
38086
38130
|
throw new MrrlinApiError({
|
|
38087
38131
|
code,
|
|
38088
38132
|
method,
|
|
38089
|
-
path:
|
|
38133
|
+
path: path19,
|
|
38090
38134
|
responseBody: body,
|
|
38091
38135
|
status: response.status,
|
|
38092
38136
|
violations,
|
|
@@ -38341,7 +38385,7 @@ function createMrrlinClient(config2) {
|
|
|
38341
38385
|
return taskEventListResponseSchema.parse(body).data;
|
|
38342
38386
|
},
|
|
38343
38387
|
async listTasks(projectSlug, filters = {}) {
|
|
38344
|
-
const
|
|
38388
|
+
const path19 = appendQuery(`${projectPath(projectSlug)}/tasks`, {
|
|
38345
38389
|
assignee: filters.assignee,
|
|
38346
38390
|
autonomyLevel: filters.autonomyLevel,
|
|
38347
38391
|
blockedBy: filters.blockedBy,
|
|
@@ -38353,7 +38397,7 @@ function createMrrlinClient(config2) {
|
|
|
38353
38397
|
subcategory: filters.subcategory,
|
|
38354
38398
|
type: filters.type
|
|
38355
38399
|
});
|
|
38356
|
-
const body = await request(
|
|
38400
|
+
const body = await request(path19);
|
|
38357
38401
|
return taskListResponseSchema.parse(body).data;
|
|
38358
38402
|
},
|
|
38359
38403
|
async listTaxonomy(projectSlug) {
|
|
@@ -38361,22 +38405,22 @@ function createMrrlinClient(config2) {
|
|
|
38361
38405
|
return taxonomyListResponseSchema.parse(body).data;
|
|
38362
38406
|
},
|
|
38363
38407
|
async listWikiPages(projectSlug, filters = {}) {
|
|
38364
|
-
const
|
|
38408
|
+
const path19 = appendQuery(`${projectPath(projectSlug)}/wiki`, {
|
|
38365
38409
|
folder: filters.folder,
|
|
38366
38410
|
q: filters.q,
|
|
38367
38411
|
taskId: filters.taskId
|
|
38368
38412
|
});
|
|
38369
|
-
const body = await request(
|
|
38413
|
+
const body = await request(path19);
|
|
38370
38414
|
return wikiPageListResponseSchema.parse(body).data;
|
|
38371
38415
|
},
|
|
38372
38416
|
async searchWikiPages(projectSlug, query) {
|
|
38373
|
-
const
|
|
38417
|
+
const path19 = appendQuery(`${projectPath(projectSlug)}/wiki/search`, {
|
|
38374
38418
|
folder: query.folder,
|
|
38375
38419
|
limit: query.limit === void 0 ? void 0 : String(query.limit),
|
|
38376
38420
|
pathPrefix: query.pathPrefix,
|
|
38377
38421
|
q: query.q
|
|
38378
38422
|
});
|
|
38379
|
-
const body = await request(
|
|
38423
|
+
const body = await request(path19);
|
|
38380
38424
|
return wikiPageSearchResponseSchema.parse(body).data;
|
|
38381
38425
|
},
|
|
38382
38426
|
async updatePlan(projectSlug, planId, patch) {
|
|
@@ -38721,6 +38765,25 @@ function createMrrlinClient(config2) {
|
|
|
38721
38765
|
});
|
|
38722
38766
|
return projectSchedulerPolicyResponseSchema.parse(body).data;
|
|
38723
38767
|
},
|
|
38768
|
+
async getProjectDeployWorkflow(projectSlug, env) {
|
|
38769
|
+
try {
|
|
38770
|
+
const body = await request(`${projectPath(projectSlug)}/deploy-workflows/${env}`);
|
|
38771
|
+
return projectDeployWorkflowResponseSchema.parse(body).data;
|
|
38772
|
+
} catch (error51) {
|
|
38773
|
+
if (error51 instanceof MrrlinApiError && error51.status === 404 && error51.code === "DEPLOY_WORKFLOW_UNSET") {
|
|
38774
|
+
return null;
|
|
38775
|
+
}
|
|
38776
|
+
throw error51;
|
|
38777
|
+
}
|
|
38778
|
+
},
|
|
38779
|
+
async upsertProjectDeployWorkflow(projectSlug, env, input) {
|
|
38780
|
+
const body = await request(`${projectPath(projectSlug)}/deploy-workflows/${env}`, {
|
|
38781
|
+
body: JSON.stringify(input),
|
|
38782
|
+
headers: { "content-type": "application/json" },
|
|
38783
|
+
method: "PUT"
|
|
38784
|
+
});
|
|
38785
|
+
return projectDeployWorkflowResponseSchema.parse(body).data;
|
|
38786
|
+
},
|
|
38724
38787
|
async getSchedulerPendingTasks(projectSlug) {
|
|
38725
38788
|
const body = await request(`${projectPath(projectSlug)}/scheduler/pending`);
|
|
38726
38789
|
return schedulerPendingTasksResponseSchema.parse(body).data;
|
|
@@ -39259,7 +39322,7 @@ function startCodexProbe(deps = {}) {
|
|
|
39259
39322
|
}
|
|
39260
39323
|
|
|
39261
39324
|
// src/_generated/version.ts
|
|
39262
|
-
var PKG_VERSION = "0.3.
|
|
39325
|
+
var PKG_VERSION = "0.3.54";
|
|
39263
39326
|
|
|
39264
39327
|
// src/api-base-url-migrate.ts
|
|
39265
39328
|
var import_node_fs2 = __toESM(require("node:fs"), 1);
|
|
@@ -39789,9 +39852,6 @@ function startSchedulerTickLoop(deps) {
|
|
|
39789
39852
|
};
|
|
39790
39853
|
}
|
|
39791
39854
|
|
|
39792
|
-
// src/agent-pool-loop.ts
|
|
39793
|
-
var import_node_child_process5 = require("node:child_process");
|
|
39794
|
-
|
|
39795
39855
|
// src/agent-pool-snapshot.ts
|
|
39796
39856
|
function normalizeLastUsedAt(value) {
|
|
39797
39857
|
if (value === void 0 || value === null) return null;
|
|
@@ -39904,6 +39964,9 @@ async function collectAgentPoolSnapshot(deps) {
|
|
|
39904
39964
|
);
|
|
39905
39965
|
}
|
|
39906
39966
|
|
|
39967
|
+
// src/external-agents-spawn.ts
|
|
39968
|
+
var import_node_child_process5 = require("node:child_process");
|
|
39969
|
+
|
|
39907
39970
|
// src/external-agents-bin.ts
|
|
39908
39971
|
function resolveExternalAgentsCliInvocation(override) {
|
|
39909
39972
|
if (override && override.trim()) return { command: override, prefixArgs: [] };
|
|
@@ -39917,50 +39980,113 @@ function resolveExternalAgentsCliInvocation(override) {
|
|
|
39917
39980
|
}
|
|
39918
39981
|
}
|
|
39919
39982
|
|
|
39920
|
-
// src/
|
|
39921
|
-
|
|
39922
|
-
|
|
39923
|
-
|
|
39924
|
-
|
|
39925
|
-
|
|
39926
|
-
|
|
39927
|
-
|
|
39983
|
+
// src/external-agents-spawn.ts
|
|
39984
|
+
function runExternalAgentsCli(args, opts) {
|
|
39985
|
+
let command;
|
|
39986
|
+
let prefixArgs;
|
|
39987
|
+
let source;
|
|
39988
|
+
let triedPath;
|
|
39989
|
+
if (opts.envCliPath && opts.envCliPath.trim()) {
|
|
39990
|
+
command = "node";
|
|
39991
|
+
prefixArgs = [opts.envCliPath];
|
|
39992
|
+
source = "env";
|
|
39993
|
+
triedPath = opts.envCliPath;
|
|
39994
|
+
} else {
|
|
39995
|
+
({ command, prefixArgs } = resolveExternalAgentsCliInvocation());
|
|
39996
|
+
source = command === "node" && prefixArgs.length === 1 ? "bundled" : "path";
|
|
39997
|
+
triedPath = source === "bundled" ? prefixArgs[0] ?? "" : "external-agents (PATH)";
|
|
39998
|
+
}
|
|
39999
|
+
const useStdin = opts.stdinValue !== void 0;
|
|
40000
|
+
const stdioConfig = useStdin ? ["pipe", "pipe", "pipe"] : ["ignore", "pipe", "pipe"];
|
|
39928
40001
|
return new Promise((resolve) => {
|
|
39929
40002
|
let stdout = "";
|
|
40003
|
+
let stderr = "";
|
|
39930
40004
|
let settled = false;
|
|
40005
|
+
let timedOut = false;
|
|
39931
40006
|
const done = (code) => {
|
|
39932
40007
|
if (!settled) {
|
|
39933
40008
|
settled = true;
|
|
39934
|
-
resolve({ stdout, code });
|
|
40009
|
+
resolve({ stdout, stderr, code, timedOut, source, triedPath });
|
|
39935
40010
|
}
|
|
39936
40011
|
};
|
|
40012
|
+
let spawned;
|
|
39937
40013
|
try {
|
|
39938
|
-
|
|
39939
|
-
|
|
40014
|
+
spawned = (0, import_node_child_process5.spawn)(command, [...prefixArgs, ...args], { stdio: stdioConfig });
|
|
40015
|
+
} catch {
|
|
40016
|
+
done(1);
|
|
40017
|
+
return;
|
|
40018
|
+
}
|
|
40019
|
+
const child = spawned;
|
|
40020
|
+
let sigkillTimer = null;
|
|
40021
|
+
let budgetTimer = null;
|
|
40022
|
+
if (useStdin && child.stdin) {
|
|
40023
|
+
child.stdin.on("error", () => {
|
|
40024
|
+
});
|
|
40025
|
+
child.stdin.write(opts.stdinValue);
|
|
40026
|
+
child.stdin.end();
|
|
40027
|
+
}
|
|
40028
|
+
child.stdout?.on("data", (d) => {
|
|
40029
|
+
stdout += d.toString();
|
|
40030
|
+
if (stdout.length > 2e5) stdout = stdout.slice(-2e5);
|
|
40031
|
+
});
|
|
40032
|
+
child.stderr?.on("data", (d) => {
|
|
40033
|
+
stderr += d.toString();
|
|
40034
|
+
if (stderr.length > 2e5) stderr = stderr.slice(-2e5);
|
|
40035
|
+
});
|
|
40036
|
+
budgetTimer = setTimeout(() => {
|
|
40037
|
+
budgetTimer = null;
|
|
40038
|
+
timedOut = true;
|
|
40039
|
+
try {
|
|
40040
|
+
child.kill("SIGTERM");
|
|
40041
|
+
} catch {
|
|
40042
|
+
}
|
|
40043
|
+
sigkillTimer = setTimeout(() => {
|
|
40044
|
+
sigkillTimer = null;
|
|
39940
40045
|
try {
|
|
39941
40046
|
child.kill("SIGKILL");
|
|
39942
40047
|
} catch {
|
|
39943
40048
|
}
|
|
39944
|
-
|
|
39945
|
-
|
|
39946
|
-
timer.unref?.();
|
|
39947
|
-
child.stdout.on("data", (d) => {
|
|
39948
|
-
stdout += d.toString();
|
|
39949
|
-
if (stdout.length > 2e5) stdout = stdout.slice(-2e5);
|
|
39950
|
-
});
|
|
39951
|
-
child.on("error", () => {
|
|
39952
|
-
clearTimeout(timer);
|
|
39953
|
-
done(1);
|
|
39954
|
-
});
|
|
39955
|
-
child.on("close", (code) => {
|
|
39956
|
-
clearTimeout(timer);
|
|
39957
|
-
done(code ?? 1);
|
|
39958
|
-
});
|
|
39959
|
-
} catch {
|
|
40049
|
+
}, 2e3);
|
|
40050
|
+
sigkillTimer.unref?.();
|
|
39960
40051
|
done(1);
|
|
39961
|
-
}
|
|
40052
|
+
}, opts.budgetMs);
|
|
40053
|
+
budgetTimer.unref?.();
|
|
40054
|
+
child.on("error", () => {
|
|
40055
|
+
if (budgetTimer) {
|
|
40056
|
+
clearTimeout(budgetTimer);
|
|
40057
|
+
budgetTimer = null;
|
|
40058
|
+
}
|
|
40059
|
+
if (sigkillTimer) {
|
|
40060
|
+
clearTimeout(sigkillTimer);
|
|
40061
|
+
sigkillTimer = null;
|
|
40062
|
+
}
|
|
40063
|
+
done(1);
|
|
40064
|
+
});
|
|
40065
|
+
child.on("close", (code) => {
|
|
40066
|
+
if (budgetTimer) {
|
|
40067
|
+
clearTimeout(budgetTimer);
|
|
40068
|
+
budgetTimer = null;
|
|
40069
|
+
}
|
|
40070
|
+
if (sigkillTimer) {
|
|
40071
|
+
clearTimeout(sigkillTimer);
|
|
40072
|
+
sigkillTimer = null;
|
|
40073
|
+
}
|
|
40074
|
+
done(code ?? 1);
|
|
40075
|
+
});
|
|
39962
40076
|
});
|
|
39963
40077
|
}
|
|
40078
|
+
|
|
40079
|
+
// src/agent-pool-loop.ts
|
|
40080
|
+
var DEFAULT_INTERVAL_MS2 = 6e4;
|
|
40081
|
+
function agentPoolLoopDisabled(env = process.env) {
|
|
40082
|
+
return env["MRRLIN_BRIDGE_AGENT_POOL_DISABLE"] === "1";
|
|
40083
|
+
}
|
|
40084
|
+
function defaultRunCli(args) {
|
|
40085
|
+
return runExternalAgentsCli(args, {
|
|
40086
|
+
budgetMs: 5e3,
|
|
40087
|
+
envCliPath: process.env["EXTERNAL_AGENTS_CLI"]
|
|
40088
|
+
}).then(({ stdout, code }) => ({ stdout, code }));
|
|
40089
|
+
}
|
|
39964
40090
|
async function runAgentPoolCycle(deps) {
|
|
39965
40091
|
try {
|
|
39966
40092
|
const snapshot = await collectAgentPoolSnapshot({
|
|
@@ -39998,7 +40124,7 @@ function startAgentPoolLoop(deps) {
|
|
|
39998
40124
|
|
|
39999
40125
|
// src/execution-consumer.ts
|
|
40000
40126
|
var import_node_child_process9 = require("node:child_process");
|
|
40001
|
-
var
|
|
40127
|
+
var import_node_crypto5 = __toESM(require("node:crypto"), 1);
|
|
40002
40128
|
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
40003
40129
|
var import_node_util = require("node:util");
|
|
40004
40130
|
|
|
@@ -40873,8 +40999,117 @@ You revise a deliverable to address the accepted issues so it satisfies the acce
|
|
|
40873
40999
|
};
|
|
40874
41000
|
}
|
|
40875
41001
|
|
|
40876
|
-
// src/
|
|
41002
|
+
// src/consensus/deliverable-gate-outcome.ts
|
|
41003
|
+
function mapDeliverableGateResult(result) {
|
|
41004
|
+
switch (result.outcome) {
|
|
41005
|
+
case "DELIVERABLE_CHANGED_DURING_REVIEW":
|
|
41006
|
+
return {
|
|
41007
|
+
action: "retry",
|
|
41008
|
+
reason: "the deliverable's wiki page changed underneath an in-progress review (DELIVERABLE_CHANGED_DURING_REVIEW)"
|
|
41009
|
+
};
|
|
41010
|
+
case "CONSENSUS_UNAVAILABLE":
|
|
41011
|
+
return {
|
|
41012
|
+
action: "retry",
|
|
41013
|
+
reason: "reviewers were unavailable (provider/quota) during the deliverable review (CONSENSUS_UNAVAILABLE)"
|
|
41014
|
+
};
|
|
41015
|
+
case "CONSENSUS_BLOCKED": {
|
|
41016
|
+
const clarifications = result.clarifications ?? [];
|
|
41017
|
+
if (clarifications.length > 0) {
|
|
41018
|
+
return {
|
|
41019
|
+
action: "questions",
|
|
41020
|
+
clarifications,
|
|
41021
|
+
reason: "reviewers did not converge; unresolved scope/ambiguity/correctness issues were filed as operator questions (CONSENSUS_BLOCKED)"
|
|
41022
|
+
};
|
|
41023
|
+
}
|
|
41024
|
+
return {
|
|
41025
|
+
action: "handoff",
|
|
41026
|
+
reason: "reviewers did not converge and raised no clarification-eligible issues (CONSENSUS_BLOCKED)"
|
|
41027
|
+
};
|
|
41028
|
+
}
|
|
41029
|
+
case "MISSING_ACCEPTANCE_CRITERIA":
|
|
41030
|
+
return {
|
|
41031
|
+
action: "handoff",
|
|
41032
|
+
reason: "the linked spec has no parseable `## Acceptance criteria` checklist (MISSING_ACCEPTANCE_CRITERIA)"
|
|
41033
|
+
};
|
|
41034
|
+
// CONVERGED/SKIPPED (success paths) should never reach this function — both consumers
|
|
41035
|
+
// special-case them first. Degrade to a safe handoff rather than throwing so a future
|
|
41036
|
+
// caller mistake is visible to the operator instead of crashing the run.
|
|
41037
|
+
default:
|
|
41038
|
+
return {
|
|
41039
|
+
action: "handoff",
|
|
41040
|
+
reason: `unexpected outcome routed to mapDeliverableGateResult: ${result.outcome}`
|
|
41041
|
+
};
|
|
41042
|
+
}
|
|
41043
|
+
}
|
|
41044
|
+
|
|
41045
|
+
// src/consensus/deliverable-gate-questions.ts
|
|
40877
41046
|
var import_node_crypto3 = require("node:crypto");
|
|
41047
|
+
function buildDeliverableQuestionOptions(category) {
|
|
41048
|
+
if (category === "correctness") {
|
|
41049
|
+
return [
|
|
41050
|
+
{
|
|
41051
|
+
label: "Deliverable is correct",
|
|
41052
|
+
description: "The flagged claim is accurate as written; no change needed.",
|
|
41053
|
+
answer: "Confirm the deliverable's content is correct as written; the reviewer's concern does not require a change."
|
|
41054
|
+
},
|
|
41055
|
+
{
|
|
41056
|
+
label: "Deliverable needs correction",
|
|
41057
|
+
description: "The flagged claim is wrong or unsupported; the deliverable needs revision.",
|
|
41058
|
+
answer: "The deliverable is incorrect here and must be revised to fix the flagged claim before it can be accepted."
|
|
41059
|
+
}
|
|
41060
|
+
];
|
|
41061
|
+
}
|
|
41062
|
+
if (category === "scope") {
|
|
41063
|
+
return [
|
|
41064
|
+
{
|
|
41065
|
+
label: "Coverage is sufficient",
|
|
41066
|
+
description: "The deliverable's current coverage of the acceptance criteria is sufficient as written.",
|
|
41067
|
+
answer: "Accept the deliverable's current scope/coverage as sufficient against the acceptance criteria."
|
|
41068
|
+
},
|
|
41069
|
+
{
|
|
41070
|
+
label: "Coverage is missing",
|
|
41071
|
+
description: "The deliverable is missing required coverage and needs revision to address it.",
|
|
41072
|
+
answer: "The deliverable is missing required coverage and must be revised to address the flagged gap."
|
|
41073
|
+
}
|
|
41074
|
+
];
|
|
41075
|
+
}
|
|
41076
|
+
return [
|
|
41077
|
+
{
|
|
41078
|
+
label: "Interpretation is fine",
|
|
41079
|
+
description: "The deliverable's current interpretation of the ambiguous point is acceptable as written.",
|
|
41080
|
+
answer: "Accept the deliverable's current interpretation of the ambiguous point as written."
|
|
41081
|
+
},
|
|
41082
|
+
{
|
|
41083
|
+
label: "Needs clarification",
|
|
41084
|
+
description: "The ambiguous point needs to be resolved and the deliverable revised accordingly.",
|
|
41085
|
+
answer: "The deliverable must be revised to resolve the flagged ambiguity explicitly."
|
|
41086
|
+
}
|
|
41087
|
+
];
|
|
41088
|
+
}
|
|
41089
|
+
async function fileDeliverableGateQuestions(client, projectSlug, taskId, clarifications) {
|
|
41090
|
+
let filed = 0;
|
|
41091
|
+
for (const clarification of clarifications) {
|
|
41092
|
+
const id = `II-${taskId}-deliverable-gate-${(0, import_node_crypto3.createHash)("sha256").update(clarification.question).digest("hex").slice(0, 10)}`;
|
|
41093
|
+
try {
|
|
41094
|
+
await client.createInboxItem(projectSlug, {
|
|
41095
|
+
id,
|
|
41096
|
+
kind: "question",
|
|
41097
|
+
taskId,
|
|
41098
|
+
body: clarification.question,
|
|
41099
|
+
origin: "gate",
|
|
41100
|
+
questionOptions: buildDeliverableQuestionOptions(clarification.category)
|
|
41101
|
+
});
|
|
41102
|
+
filed += 1;
|
|
41103
|
+
} catch (error51) {
|
|
41104
|
+
const message = error51 instanceof Error ? error51.message : String(error51);
|
|
41105
|
+
if (/inbox_items_pkey/.test(message)) filed += 1;
|
|
41106
|
+
}
|
|
41107
|
+
}
|
|
41108
|
+
return filed;
|
|
41109
|
+
}
|
|
41110
|
+
|
|
41111
|
+
// src/async-tools/draft-spec.ts
|
|
41112
|
+
var import_node_crypto4 = require("node:crypto");
|
|
40878
41113
|
var DRAFT_SPEC_TOOL_NAME = "draft_task_spec";
|
|
40879
41114
|
var SPECS_FOLDER = "Specs";
|
|
40880
41115
|
var DRAFT_SPEC_TLDR_MAX_CHARS = 300;
|
|
@@ -41151,7 +41386,7 @@ function onComplete(outcome, input) {
|
|
|
41151
41386
|
};
|
|
41152
41387
|
}
|
|
41153
41388
|
const summary = outcome.error;
|
|
41154
|
-
const hash3 = (0,
|
|
41389
|
+
const hash3 = (0, import_node_crypto4.createHash)("sha256").update(summary).digest("hex").slice(0, 10);
|
|
41155
41390
|
return {
|
|
41156
41391
|
kind: "info",
|
|
41157
41392
|
id: `II-sched-draft-failed-${input.taskId}-${hash3}`,
|
|
@@ -41276,6 +41511,17 @@ function gateEnvSequence(autoDeploy) {
|
|
|
41276
41511
|
if (autoDeploy === "prod") return ["dev", "prod"];
|
|
41277
41512
|
return [];
|
|
41278
41513
|
}
|
|
41514
|
+
function effectiveGateEnvSequence(autoDeploy, artifacts) {
|
|
41515
|
+
const policy = gateEnvSequence(autoDeploy);
|
|
41516
|
+
const envs = ["dev", "prod"];
|
|
41517
|
+
const union2 = new Set(policy);
|
|
41518
|
+
for (const env of envs) {
|
|
41519
|
+
if (latestByEnv(artifacts, "deploy_attempt", env, { realAttemptsOnly: true })) {
|
|
41520
|
+
union2.add(env);
|
|
41521
|
+
}
|
|
41522
|
+
}
|
|
41523
|
+
return envs.filter((env) => union2.has(env));
|
|
41524
|
+
}
|
|
41279
41525
|
function deployApprovalItemId(runId, env) {
|
|
41280
41526
|
return `II-deploy-approve-${env}-${runId}`;
|
|
41281
41527
|
}
|
|
@@ -41343,7 +41589,7 @@ async function resolveProdGrace(deps, projectSlug, run3, task, artifacts) {
|
|
|
41343
41589
|
const graceUntil = new Date(nowMs + seconds * 1e3);
|
|
41344
41590
|
const cancelId = graceCancelItemId(run3.id);
|
|
41345
41591
|
await deps.client.appendExecutionArtifact(projectSlug, run3.id, {
|
|
41346
|
-
id: `deploy-grace-${run3.id}`,
|
|
41592
|
+
id: `EA-deploy-grace-${run3.id}`,
|
|
41347
41593
|
kind: "deploy_attempt",
|
|
41348
41594
|
payload: {
|
|
41349
41595
|
env: "prod",
|
|
@@ -41403,7 +41649,7 @@ async function tryProdAutoRevert(deps, projectSlug, run3, task) {
|
|
|
41403
41649
|
const lastGood = await findLastGoodProdAttempt(deps.client, projectSlug, task, run3.id);
|
|
41404
41650
|
if (!lastGood) return null;
|
|
41405
41651
|
await deps.client.appendExecutionArtifact(projectSlug, run3.id, {
|
|
41406
|
-
id: `deploy-revert-${run3.id}`,
|
|
41652
|
+
id: `EA-deploy-revert-${run3.id}`,
|
|
41407
41653
|
kind: "deploy_attempt",
|
|
41408
41654
|
payload: {
|
|
41409
41655
|
env: "prod",
|
|
@@ -41424,10 +41670,39 @@ async function tryProdAutoRevert(deps, projectSlug, run3, task) {
|
|
|
41424
41670
|
return null;
|
|
41425
41671
|
}
|
|
41426
41672
|
}
|
|
41673
|
+
function computeActiveSetFingerprint(workflows) {
|
|
41674
|
+
return workflows.map((workflow) => `${workflow.id}:${workflow.path}`).sort().join(",");
|
|
41675
|
+
}
|
|
41676
|
+
async function resolveWorkflowId(deps, projectSlug, run3, env) {
|
|
41677
|
+
const pinned = env === "dev" ? run3.devWorkflowId : run3.prodWorkflowId;
|
|
41678
|
+
if (pinned) return { workflowId: pinned, source: null, resolvedFromStore: false };
|
|
41679
|
+
const row = await deps.client.getProjectDeployWorkflow(projectSlug, env);
|
|
41680
|
+
if (!row || row.state !== "resolved" || row.workflowId === null) {
|
|
41681
|
+
return { workflowId: null, source: null, resolvedFromStore: false };
|
|
41682
|
+
}
|
|
41683
|
+
if (row.source !== "operator") {
|
|
41684
|
+
const liveWorkflows = await deps.client.listGithubWorkflows(projectSlug);
|
|
41685
|
+
const activeWorkflows = liveWorkflows.filter((workflow) => workflow.state === "active");
|
|
41686
|
+
const isLive = activeWorkflows.some((workflow) => String(workflow.id) === String(row.workflowId));
|
|
41687
|
+
if (!isLive) return { workflowId: null, source: null, resolvedFromStore: false };
|
|
41688
|
+
const liveFingerprint = computeActiveSetFingerprint(activeWorkflows);
|
|
41689
|
+
if (!row.reverifyRequested && row.activeSetFingerprint !== null && liveFingerprint !== row.activeSetFingerprint) {
|
|
41690
|
+
await deps.client.upsertProjectDeployWorkflow(projectSlug, env, {
|
|
41691
|
+
workflowId: row.workflowId,
|
|
41692
|
+
workflowPath: row.workflowPath,
|
|
41693
|
+
reason: row.reason,
|
|
41694
|
+
state: row.state,
|
|
41695
|
+
activeSetFingerprint: row.activeSetFingerprint,
|
|
41696
|
+
reverifyRequested: true
|
|
41697
|
+
});
|
|
41698
|
+
}
|
|
41699
|
+
}
|
|
41700
|
+
return { workflowId: row.workflowId, source: row.source, resolvedFromStore: true };
|
|
41701
|
+
}
|
|
41427
41702
|
async function runDeployGateTick(deps, projectSlug, run3, task) {
|
|
41428
|
-
const sequence = gateEnvSequence(task.autoDeploy);
|
|
41429
|
-
if (sequence.length === 0) return { kind: "noop", reason: "auto_deploy=off" };
|
|
41430
41703
|
const artifacts = await deps.client.listExecutionArtifacts(projectSlug, run3.id);
|
|
41704
|
+
const sequence = effectiveGateEnvSequence(task.autoDeploy, artifacts);
|
|
41705
|
+
if (sequence.length === 0) return { kind: "noop", reason: "auto_deploy=off" };
|
|
41431
41706
|
let activeEnv = null;
|
|
41432
41707
|
for (const env2 of sequence) {
|
|
41433
41708
|
const verification = latestByEnv(artifacts, "verification", env2);
|
|
@@ -41444,7 +41719,8 @@ async function runDeployGateTick(deps, projectSlug, run3, task) {
|
|
|
41444
41719
|
return { kind: "done" };
|
|
41445
41720
|
}
|
|
41446
41721
|
const env = activeEnv;
|
|
41447
|
-
const
|
|
41722
|
+
const resolution = await resolveWorkflowId(deps, projectSlug, run3, env);
|
|
41723
|
+
const workflowId = resolution.workflowId;
|
|
41448
41724
|
const attempt = latestByEnv(artifacts, "deploy_attempt", env, { realAttemptsOnly: true });
|
|
41449
41725
|
if (!attempt) {
|
|
41450
41726
|
if (await autonomyPaused(deps.client)) {
|
|
@@ -41480,7 +41756,7 @@ async function runDeployGateTick(deps, projectSlug, run3, task) {
|
|
|
41480
41756
|
}
|
|
41481
41757
|
const dispatchedAt = deps.now().toISOString();
|
|
41482
41758
|
await deps.client.appendExecutionArtifact(projectSlug, run3.id, {
|
|
41483
|
-
id: `deploy-${env}-${attemptIndex(artifacts, env) + 1}`,
|
|
41759
|
+
id: `EA-deploy-${env}-${attemptIndex(artifacts, env) + 1}`,
|
|
41484
41760
|
kind: "deploy_attempt",
|
|
41485
41761
|
payload: { env, workflowId, branch: run3.branch ?? "", dispatchedAt }
|
|
41486
41762
|
});
|
|
@@ -41490,9 +41766,23 @@ async function runDeployGateTick(deps, projectSlug, run3, task) {
|
|
|
41490
41766
|
try {
|
|
41491
41767
|
await deps.client.dispatchTaskDeploy(projectSlug, task.id, { env, ref: run3.branch, workflowId: String(workflowId) });
|
|
41492
41768
|
} catch (error51) {
|
|
41769
|
+
if (resolution.source === "operator") {
|
|
41770
|
+
await deps.handoff(
|
|
41771
|
+
projectSlug,
|
|
41772
|
+
task,
|
|
41773
|
+
run3,
|
|
41774
|
+
`deploy_workflow_operator_choice_stale:${env}:${String(error51).slice(0, 120)}`
|
|
41775
|
+
);
|
|
41776
|
+
return { kind: "handoff", reason: `deploy_workflow_operator_choice_stale:${env}` };
|
|
41777
|
+
}
|
|
41493
41778
|
await deps.handoff(projectSlug, task, run3, `workflow_dispatch_failed:${env}:${String(error51).slice(0, 120)}`);
|
|
41494
41779
|
return { kind: "handoff", reason: `workflow_dispatch_failed:${env}` };
|
|
41495
41780
|
}
|
|
41781
|
+
if (resolution.resolvedFromStore) {
|
|
41782
|
+
await deps.client.updateExecutionRun(projectSlug, run3.id, {
|
|
41783
|
+
[env === "dev" ? "devWorkflowId" : "prodWorkflowId"]: workflowId
|
|
41784
|
+
});
|
|
41785
|
+
}
|
|
41496
41786
|
return { kind: "dispatched", env };
|
|
41497
41787
|
}
|
|
41498
41788
|
const runStatus = await deps.client.getGithubWorkflowRunLatest(projectSlug, {
|
|
@@ -41543,7 +41833,7 @@ async function runDeployGateTick(deps, projectSlug, run3, task) {
|
|
|
41543
41833
|
run: run3
|
|
41544
41834
|
});
|
|
41545
41835
|
await deps.client.appendExecutionArtifact(projectSlug, run3.id, {
|
|
41546
|
-
id: `verification-${env}-${attemptIndex(artifacts, env, "verification") + 1}`,
|
|
41836
|
+
id: `EA-verification-${env}-${attemptIndex(artifacts, env, "verification") + 1}`,
|
|
41547
41837
|
kind: "verification",
|
|
41548
41838
|
payload: { env, verdict: verdict.verdict, summary: verdict.summary, turnRef: verdict.turnRef }
|
|
41549
41839
|
});
|
|
@@ -41726,6 +42016,20 @@ async function pushRunBranch(opts, execGit = defaultGitExec) {
|
|
|
41726
42016
|
const run3 = () => doPushRunBranch(opts, execGit);
|
|
41727
42017
|
return opts.alreadyLocked ? run3() : withCheckoutLock(opts.locksDir, opts.slug, run3);
|
|
41728
42018
|
}
|
|
42019
|
+
async function hasCommitsToPush(opts, execGit = defaultGitExec) {
|
|
42020
|
+
const baseEnv = {
|
|
42021
|
+
PATH: process.env.PATH ?? "",
|
|
42022
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
42023
|
+
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
42024
|
+
GIT_CONFIG_SYSTEM: "/dev/null",
|
|
42025
|
+
GIT_CONFIG_NOSYSTEM: "1"
|
|
42026
|
+
};
|
|
42027
|
+
const count2 = execGit(
|
|
42028
|
+
["-C", opts.worktreePath, "rev-list", "--count", `origin/${opts.defaultBranch}..HEAD`],
|
|
42029
|
+
baseEnv
|
|
42030
|
+
).trim();
|
|
42031
|
+
return Number(count2) > 0;
|
|
42032
|
+
}
|
|
41729
42033
|
async function doPushRunBranch(opts, execGit) {
|
|
41730
42034
|
const branch = worktreeBranch(opts.runId);
|
|
41731
42035
|
const baseEnv = {
|
|
@@ -41856,6 +42160,13 @@ var EXECUTION_TURN_BUDGET_PREFIX = "Execution turn exceeded the run wall-clock b
|
|
|
41856
42160
|
var EXECUTION_TURN_TIMEOUT_RETRY_CODE = "execution_turn_timeout_retry";
|
|
41857
42161
|
var EXECUTION_TURN_TIMEOUT_RETRY_SUMMARY = "Execution turn timed out; requeued for one automatic retry.";
|
|
41858
42162
|
var EXECUTION_TURN_TIMEOUT_RETRY_CURSOR = "execution_turn_timeout_retry:1";
|
|
42163
|
+
var DELIVERABLE_GATE_RETRY_CODE = "deliverable_gate_retry";
|
|
42164
|
+
var DELIVERABLE_GATE_RETRY_CURSOR_PREFIX = "deliverable_gate_retry:";
|
|
42165
|
+
var DELIVERABLE_GATE_RETRY_MAX_ATTEMPTS = 3;
|
|
42166
|
+
var DELIVERABLE_GATE_RETRYABLE_REASON_PREFIXES = [
|
|
42167
|
+
"deliverable_gate_deliverable_changed_during_review",
|
|
42168
|
+
"deliverable_gate_consensus_unavailable"
|
|
42169
|
+
];
|
|
41859
42170
|
var AWAITING_MERGE_STATUS_RETRY_DELAYS_MS = [50, 100];
|
|
41860
42171
|
function readPositiveIntEnv(name, fallback) {
|
|
41861
42172
|
const raw = (process.env[name] ?? "").trim();
|
|
@@ -41887,6 +42198,17 @@ function executionTurnBudgetMessage(budgetMs) {
|
|
|
41887
42198
|
function isExecutionTurnTimeoutReason(reason) {
|
|
41888
42199
|
return reason.startsWith(EXECUTION_TURN_TIMEOUT_PREFIX) || reason.startsWith(EXECUTION_TURN_STALL_PREFIX);
|
|
41889
42200
|
}
|
|
42201
|
+
function isDeliverableGateRetryableReason(reason) {
|
|
42202
|
+
return DELIVERABLE_GATE_RETRYABLE_REASON_PREFIXES.some((prefix) => reason.startsWith(prefix));
|
|
42203
|
+
}
|
|
42204
|
+
function deliverableGateRetryAttempt(checkpointCursor) {
|
|
42205
|
+
if (!checkpointCursor || !checkpointCursor.startsWith(DELIVERABLE_GATE_RETRY_CURSOR_PREFIX)) return 0;
|
|
42206
|
+
const parsed = Number.parseInt(checkpointCursor.slice(DELIVERABLE_GATE_RETRY_CURSOR_PREFIX.length), 10);
|
|
42207
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : 0;
|
|
42208
|
+
}
|
|
42209
|
+
function deliverableGateRetryCursor(attempt) {
|
|
42210
|
+
return `${DELIVERABLE_GATE_RETRY_CURSOR_PREFIX}${attempt}`;
|
|
42211
|
+
}
|
|
41890
42212
|
function contextMaxArtifacts() {
|
|
41891
42213
|
return readPositiveIntEnv("MRRLIN_DIRECTOR_BRIDGE_CONTEXT_MAX_ARTIFACTS", DEFAULT_CONTEXT_MAX_ARTIFACTS);
|
|
41892
42214
|
}
|
|
@@ -41915,8 +42237,10 @@ function buildCompletionTurnPrompt(taskId, currentStatus) {
|
|
|
41915
42237
|
" to the open run if you haven't already.",
|
|
41916
42238
|
"",
|
|
41917
42239
|
"If the work is NOT complete \u2014 be honest, do not close incomplete work:",
|
|
41918
|
-
"1. Call update_task with the
|
|
41919
|
-
"
|
|
42240
|
+
"1. Call update_task with the status that matches why it is not complete, and explain what remains",
|
|
42241
|
+
" in the notes:",
|
|
42242
|
+
" - if the code work itself is done and only a PR or merge remains, use status=awaiting_verification;",
|
|
42243
|
+
" - if you are blocked and need an operator decision before the work can continue, use status=needs_human.",
|
|
41920
42244
|
"2. Append a handoff_judgement artifact explaining what the operator needs to do.",
|
|
41921
42245
|
"",
|
|
41922
42246
|
"You must pick one of these paths \u2014 do not leave the task in_progress."
|
|
@@ -41940,6 +42264,9 @@ var BASE_INSTRUCTIONS_PREFIX = [
|
|
|
41940
42264
|
"- For a CODE task the run opens a draft PR for you after your turn; opening that PR is NOT",
|
|
41941
42265
|
" completion. Do NOT set closed_done for code work \u2014 leave the task open; the run parks at",
|
|
41942
42266
|
" `pull_request` (waiting for merge) and the operator merges. Closure happens after merge.",
|
|
42267
|
+
"- Pick the right open status when you stop a CODE task: if the code work itself is done and only a",
|
|
42268
|
+
" PR or merge remains, leave the task at `awaiting_verification`; if you are blocked and a human",
|
|
42269
|
+
" must decide before the work can continue, leave it at `needs_human`.",
|
|
41943
42270
|
"",
|
|
41944
42271
|
"File artifacts:",
|
|
41945
42272
|
"- When your output is a file (markdown report, HTML, screenshot), upload it with",
|
|
@@ -42014,7 +42341,35 @@ var EXECUTOR_BASE_INSTRUCTIONS = [
|
|
|
42014
42341
|
"You MUST verify every delegated result against the actual files and tests before it lands \u2014",
|
|
42015
42342
|
"pool models are lower-reliability and a wrong delegated edit is YOUR responsibility; never",
|
|
42016
42343
|
"commit unverified delegated output. If dispatch fails or the pool is unavailable, do the",
|
|
42017
|
-
"work yourself \u2014 never block the run on the pool."
|
|
42344
|
+
"work yourself \u2014 never block the run on the pool.",
|
|
42345
|
+
"",
|
|
42346
|
+
// Auto-deploy design Part C (2026-08-04), C4: the workflow-resolution procedure. Only relevant
|
|
42347
|
+
// when the deploy gate has parked this run on a missing/stale workflow id for one environment —
|
|
42348
|
+
// most turns will never need this. This choice becomes durable project state (record_deploy_workflow
|
|
42349
|
+
// writes project_deploy_workflow), not a per-run decision, so resolve it AT MOST ONCE per
|
|
42350
|
+
// project+environment, only when actually needed (lazy, per env — do not speculatively resolve
|
|
42351
|
+
// prod when only dev was asked for).
|
|
42352
|
+
"If your context shows the deploy gate parked on a missing or stale workflow id for an",
|
|
42353
|
+
"environment, resolve it once with this fail-closed procedure \u2014 do this AT MOST ONCE per",
|
|
42354
|
+
"project+environment; it becomes durable project state, not a per-run choice:",
|
|
42355
|
+
'1. Call `list_github_workflows` and keep only candidates with state: "active". A workflow\'s',
|
|
42356
|
+
" name is NOT evidence it deploys anything \u2014 e.g. this repo also has `publish` (ships an npm",
|
|
42357
|
+
" package) and `bootstrap-changelog`; picking by name resemblance can dispatch the wrong thing.",
|
|
42358
|
+
"2. For each active candidate, read its file at `<worktree>/<path>` \u2014 the list API's `path` is",
|
|
42359
|
+
" already repo-root-relative (e.g. `.github/workflows/deploy.yml`), so do NOT prefix it again",
|
|
42360
|
+
" with `.github/workflows/`. Require an explicit `workflow_dispatch` trigger \u2014 a workflow you",
|
|
42361
|
+
" cannot confirm is dispatchable this way is not a candidate.",
|
|
42362
|
+
"3. Require positive evidence from the workflow's own steps that it deploys THIS project \u2014 not",
|
|
42363
|
+
" just a plausible-sounding name.",
|
|
42364
|
+
"4. Exactly one confirmed candidate \u2192 call `record_deploy_workflow` with that workflowId (state",
|
|
42365
|
+
' defaults to "resolved") and a one-sentence reason. The server captures its own snapshot of',
|
|
42366
|
+
" the live active-workflow set at write time \u2014 you do not need to compute or pass one; hand-",
|
|
42367
|
+
" assembling it yourself would risk a format mismatch against what the deploy gate recomputes",
|
|
42368
|
+
" later, silently disabling the drift check. Append a `checkpoint` artifact with the same pick",
|
|
42369
|
+
" + reason so the decision stays auditable.",
|
|
42370
|
+
"5. Zero confirmed candidates, or more than one \u2192 call `record_deploy_workflow` with",
|
|
42371
|
+
' workflowId: null and state: "ambiguous", and file a clarifying question through the normal',
|
|
42372
|
+
" inbox question path. Do NOT guess between multiple plausible candidates."
|
|
42018
42373
|
].join("\n");
|
|
42019
42374
|
function artifactKindForEvent(event) {
|
|
42020
42375
|
switch (event.type) {
|
|
@@ -42030,6 +42385,7 @@ function artifactKindForEvent(event) {
|
|
|
42030
42385
|
}
|
|
42031
42386
|
}
|
|
42032
42387
|
var COMPLETED_TASK_STATUSES = /* @__PURE__ */ new Set(["closed_done"]);
|
|
42388
|
+
var CODE_PR_READY_TASK_STATUSES = /* @__PURE__ */ new Set(["closed_done", "awaiting_verification"]);
|
|
42033
42389
|
var COMPLETION_EVIDENCE_KINDS = /* @__PURE__ */ new Set([
|
|
42034
42390
|
"checkpoint",
|
|
42035
42391
|
"test_result",
|
|
@@ -42047,11 +42403,11 @@ function isBridgeGeneratedArtifact(artifact) {
|
|
|
42047
42403
|
return typeof payload === "object" && payload !== null && "event" in payload;
|
|
42048
42404
|
}
|
|
42049
42405
|
function newArtifactId() {
|
|
42050
|
-
return `EA-${
|
|
42406
|
+
return `EA-${import_node_crypto5.default.randomUUID()}`;
|
|
42051
42407
|
}
|
|
42052
42408
|
var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
|
|
42053
|
-
function isBlastRadiusFloorPath(
|
|
42054
|
-
return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(
|
|
42409
|
+
function isBlastRadiusFloorPath(path19) {
|
|
42410
|
+
return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path19));
|
|
42055
42411
|
}
|
|
42056
42412
|
var execFileAsync = (0, import_node_util.promisify)(import_node_child_process9.execFile);
|
|
42057
42413
|
async function defaultListRunDiffPaths(opts) {
|
|
@@ -42131,9 +42487,25 @@ async function gatherContext(client, projectSlug, task, openRunId) {
|
|
|
42131
42487
|
autonomyEvents
|
|
42132
42488
|
};
|
|
42133
42489
|
}
|
|
42134
|
-
async function
|
|
42490
|
+
async function deployWorkflowReverifyNotice(client, projectSlug) {
|
|
42491
|
+
const envs = ["dev", "prod"];
|
|
42492
|
+
const flagged = [];
|
|
42493
|
+
for (const env of envs) {
|
|
42494
|
+
try {
|
|
42495
|
+
const row = await client.getProjectDeployWorkflow(projectSlug, env);
|
|
42496
|
+
if (row?.reverifyRequested) flagged.push(env);
|
|
42497
|
+
} catch {
|
|
42498
|
+
}
|
|
42499
|
+
}
|
|
42500
|
+
if (flagged.length === 0) return "";
|
|
42501
|
+
return `
|
|
42502
|
+
|
|
42503
|
+
## Deploy workflow re-verification needed
|
|
42504
|
+
The GitHub Actions workflow set changed since the deploy workflow was last confirmed for: ${flagged.join(", ")}. Re-run the workflow-resolution procedure (list_github_workflows -> confirm -> record_deploy_workflow) for ${flagged.length === 1 ? "this environment" : "these environments"} if you have a worktree this turn \u2014 this is a hint, not a blocker, so it is fine to skip if unrelated work is more urgent this turn.`;
|
|
42505
|
+
}
|
|
42506
|
+
async function assertRunCompletionReady(deps, projectSlug, taskId, runId, allowedStatuses) {
|
|
42135
42507
|
const task = await deps.client.getTask(projectSlug, taskId);
|
|
42136
|
-
if (!
|
|
42508
|
+
if (!allowedStatuses.has(task.status)) {
|
|
42137
42509
|
return {
|
|
42138
42510
|
ok: false,
|
|
42139
42511
|
reason: `Codex turn completed but task ${task.id} remained in status ${task.status}.`,
|
|
@@ -42264,7 +42636,7 @@ async function driveRun(deps, projectSlug, runId) {
|
|
|
42264
42636
|
if (!claimed) return;
|
|
42265
42637
|
if (!claimed.leaseId) {
|
|
42266
42638
|
await deps.client.createInboxItem(projectSlug, {
|
|
42267
|
-
id: `II-${
|
|
42639
|
+
id: `II-${import_node_crypto5.default.randomUUID()}`,
|
|
42268
42640
|
kind: "handoff",
|
|
42269
42641
|
taskId: claimed.taskId,
|
|
42270
42642
|
body: `Execution run ${runId} was claimed but returned no leaseId. This indicates DB/API corruption and requires operator attention.`
|
|
@@ -42313,7 +42685,7 @@ async function driveRun(deps, projectSlug, runId) {
|
|
|
42313
42685
|
}
|
|
42314
42686
|
const compactEnabled = (process.env.MRRLIN_MCP_COMPACT_DISABLE ?? "").trim() !== "1";
|
|
42315
42687
|
const context = await gatherContext(deps.client, projectSlug, task, runId);
|
|
42316
|
-
|
|
42688
|
+
let bundle = renderContextBundle(
|
|
42317
42689
|
compactEnabled ? {
|
|
42318
42690
|
...context,
|
|
42319
42691
|
compact: {
|
|
@@ -42322,10 +42694,12 @@ async function driveRun(deps, projectSlug, runId) {
|
|
|
42322
42694
|
}
|
|
42323
42695
|
} : context
|
|
42324
42696
|
);
|
|
42697
|
+
bundle += await deployWorkflowReverifyNotice(deps.client, projectSlug);
|
|
42325
42698
|
const checkout = deps.checkoutRegistry?.get(projectSlug) ?? null;
|
|
42326
42699
|
let sandbox = "read-only";
|
|
42327
42700
|
let turnCwd = deps.codexCwd ?? null;
|
|
42328
42701
|
let worktreePath = null;
|
|
42702
|
+
let resolvedDefaultBranch = null;
|
|
42329
42703
|
let useExecutor = false;
|
|
42330
42704
|
let codex;
|
|
42331
42705
|
let disposeCodex = () => {
|
|
@@ -42343,13 +42717,14 @@ async function driveRun(deps, projectSlug, runId) {
|
|
|
42343
42717
|
try {
|
|
42344
42718
|
const createWt = deps.createRunWorktree ?? createRunWorktree;
|
|
42345
42719
|
const getDefaultBranch = deps.getDefaultBranch ?? (async () => "main");
|
|
42720
|
+
resolvedDefaultBranch = await getDefaultBranch(projectSlug);
|
|
42346
42721
|
worktreePath = await createWt({
|
|
42347
42722
|
checkout: checkout.path,
|
|
42348
42723
|
worktreeRoot: deps.worktreeRoot ?? "/tmp/mrrlin-worktrees",
|
|
42349
42724
|
locksDir: deps.locksDir ?? "/tmp/mrrlin-locks",
|
|
42350
42725
|
slug: projectSlug,
|
|
42351
42726
|
runId,
|
|
42352
|
-
defaultBranch:
|
|
42727
|
+
defaultBranch: resolvedDefaultBranch
|
|
42353
42728
|
});
|
|
42354
42729
|
if (!await runHasLease(deps, projectSlug, runId, leaseId)) return;
|
|
42355
42730
|
await deps.client.updateExecutionRun(projectSlug, runId, {
|
|
@@ -42433,7 +42808,8 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
|
|
|
42433
42808
|
await failRun(deps, projectSlug, task, runId, leaseId, outcome.error);
|
|
42434
42809
|
return;
|
|
42435
42810
|
}
|
|
42436
|
-
|
|
42811
|
+
const prReadyStatuses = useExecutor ? CODE_PR_READY_TASK_STATUSES : COMPLETED_TASK_STATUSES;
|
|
42812
|
+
let readiness = await assertRunCompletionReady(deps, projectSlug, task.id, runId, prReadyStatuses);
|
|
42437
42813
|
if (!readiness.ok) {
|
|
42438
42814
|
const completionBudget = Math.min(completionTurnBudgetMs(), remainingTurnBudgetMs());
|
|
42439
42815
|
if (isCompletionTurnDisabled() || completionBudget < completionTurnMinBudgetMs()) {
|
|
@@ -42466,7 +42842,7 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
|
|
|
42466
42842
|
await failRun(deps, projectSlug, readiness.task, runId, leaseId, completionOutcome.error);
|
|
42467
42843
|
return;
|
|
42468
42844
|
}
|
|
42469
|
-
readiness = await assertRunCompletionReady(deps, projectSlug, task.id, runId);
|
|
42845
|
+
readiness = await assertRunCompletionReady(deps, projectSlug, task.id, runId, prReadyStatuses);
|
|
42470
42846
|
if (!readiness.ok) {
|
|
42471
42847
|
await failRun(deps, projectSlug, readiness.task, runId, leaseId, readiness.reason);
|
|
42472
42848
|
return;
|
|
@@ -42478,6 +42854,19 @@ Continue executing task ${task.id}. Make the next concrete increment of progress
|
|
|
42478
42854
|
return;
|
|
42479
42855
|
}
|
|
42480
42856
|
if (!await runHasLease(deps, projectSlug, runId, leaseId)) return;
|
|
42857
|
+
const hasCommitsFn = deps.hasCommitsToPush ?? hasCommitsToPush;
|
|
42858
|
+
const defaultBranchForPush = resolvedDefaultBranch ?? "main";
|
|
42859
|
+
if (!await hasCommitsFn({ worktreePath, defaultBranch: defaultBranchForPush })) {
|
|
42860
|
+
await failRun(
|
|
42861
|
+
deps,
|
|
42862
|
+
projectSlug,
|
|
42863
|
+
readiness.task,
|
|
42864
|
+
runId,
|
|
42865
|
+
leaseId,
|
|
42866
|
+
`no_commits_to_push: run ${runId} has no commits on ${worktreeBranch(runId)} ahead of origin/${defaultBranchForPush} \u2014 nothing to push.`
|
|
42867
|
+
);
|
|
42868
|
+
return;
|
|
42869
|
+
}
|
|
42481
42870
|
let review = null;
|
|
42482
42871
|
if (deps.selfReviewTurn) {
|
|
42483
42872
|
review = await deps.selfReviewTurn(codex, worktreePath, readiness.task);
|
|
@@ -42788,9 +43177,9 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2)
|
|
|
42788
43177
|
);
|
|
42789
43178
|
return;
|
|
42790
43179
|
}
|
|
42791
|
-
let
|
|
43180
|
+
let gateResult;
|
|
42792
43181
|
try {
|
|
42793
|
-
|
|
43182
|
+
gateResult = await deps.runDeliverableGate({ projectSlug, taskId: task.id, runId, deliverablePageId: pageId });
|
|
42794
43183
|
} catch (error51) {
|
|
42795
43184
|
await failRun(
|
|
42796
43185
|
deps,
|
|
@@ -42802,14 +43191,19 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2)
|
|
|
42802
43191
|
);
|
|
42803
43192
|
return;
|
|
42804
43193
|
}
|
|
42805
|
-
if (
|
|
43194
|
+
if (gateResult.outcome !== "CONVERGED") {
|
|
43195
|
+
const mapped = mapDeliverableGateResult(gateResult);
|
|
43196
|
+
if (mapped.action === "questions") {
|
|
43197
|
+
await fileDeliverableGateQuestions(deps.client, projectSlug, task.id, mapped.clarifications).catch(() => {
|
|
43198
|
+
});
|
|
43199
|
+
}
|
|
42806
43200
|
await failRun(
|
|
42807
43201
|
deps,
|
|
42808
43202
|
projectSlug,
|
|
42809
43203
|
task,
|
|
42810
43204
|
runId,
|
|
42811
43205
|
leaseId,
|
|
42812
|
-
`deliverable_gate_${
|
|
43206
|
+
`deliverable_gate_${gateResult.outcome.toLowerCase()}: ${mapped.reason}`
|
|
42813
43207
|
);
|
|
42814
43208
|
return;
|
|
42815
43209
|
}
|
|
@@ -42858,6 +43252,33 @@ async function failRun(deps, projectSlug, task, runId, leaseId, reason) {
|
|
|
42858
43252
|
} catch {
|
|
42859
43253
|
}
|
|
42860
43254
|
}
|
|
43255
|
+
if (isDeliverableGateRetryableReason(reason)) {
|
|
43256
|
+
const attempt = deliverableGateRetryAttempt(currentRun.checkpointCursor) + 1;
|
|
43257
|
+
if (attempt <= DELIVERABLE_GATE_RETRY_MAX_ATTEMPTS) {
|
|
43258
|
+
try {
|
|
43259
|
+
await deps.client.updateExecutionRun(projectSlug, runId, {
|
|
43260
|
+
status: "pending",
|
|
43261
|
+
leaseId: null,
|
|
43262
|
+
checkpointCursor: deliverableGateRetryCursor(attempt)
|
|
43263
|
+
});
|
|
43264
|
+
await deps.client.appendExecutionArtifact(projectSlug, runId, {
|
|
43265
|
+
id: newArtifactId(),
|
|
43266
|
+
kind: "error",
|
|
43267
|
+
payload: {
|
|
43268
|
+
code: DELIVERABLE_GATE_RETRY_CODE,
|
|
43269
|
+
source: "execution-consumer",
|
|
43270
|
+
attempt,
|
|
43271
|
+
maxAttempts: DELIVERABLE_GATE_RETRY_MAX_ATTEMPTS,
|
|
43272
|
+
reason,
|
|
43273
|
+
summary: `Deliverable review hit a transient outcome; requeued for automatic retry ${attempt}/${DELIVERABLE_GATE_RETRY_MAX_ATTEMPTS}.`
|
|
43274
|
+
}
|
|
43275
|
+
}).catch(() => {
|
|
43276
|
+
});
|
|
43277
|
+
return;
|
|
43278
|
+
} catch {
|
|
43279
|
+
}
|
|
43280
|
+
}
|
|
43281
|
+
}
|
|
42861
43282
|
try {
|
|
42862
43283
|
await deps.client.createExecutionRunHandoff(projectSlug, runId, { reason });
|
|
42863
43284
|
} catch {
|
|
@@ -42897,7 +43318,7 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
|
|
|
42897
43318
|
}
|
|
42898
43319
|
try {
|
|
42899
43320
|
await deps.client.createInboxItem(projectSlug, {
|
|
42900
|
-
id: `II-${
|
|
43321
|
+
id: `II-${import_node_crypto5.default.randomUUID()}`,
|
|
42901
43322
|
kind: "handoff",
|
|
42902
43323
|
taskId: task.id,
|
|
42903
43324
|
body: `Task ${task.id} (${task.title}) still needs operator follow-up: ${reason}. Mrrlin could not move the task back to Handoff needed automatically.`
|
|
@@ -42932,7 +43353,7 @@ async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
|
|
|
42932
43353
|
}
|
|
42933
43354
|
try {
|
|
42934
43355
|
await deps.client.createInboxItem(projectSlug, {
|
|
42935
|
-
id: `II-${
|
|
43356
|
+
id: `II-${import_node_crypto5.default.randomUUID()}`,
|
|
42936
43357
|
kind: "handoff",
|
|
42937
43358
|
taskId: task.id,
|
|
42938
43359
|
body: `Execution run ${runId} for task ${task.id} (${task.title}) needs operator attention: ${reason}`
|
|
@@ -43021,7 +43442,7 @@ async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId
|
|
|
43021
43442
|
}).catch(() => {
|
|
43022
43443
|
});
|
|
43023
43444
|
await deps.client.createInboxItem(projectSlug, {
|
|
43024
|
-
id: `II-${
|
|
43445
|
+
id: `II-${import_node_crypto5.default.randomUUID()}`,
|
|
43025
43446
|
kind: "handoff",
|
|
43026
43447
|
taskId: task.id,
|
|
43027
43448
|
body: `Deploy gate for run ${runId} (task ${task.id} \u2014 ${task.title}) needs operator attention: ${reason}`
|
|
@@ -43037,7 +43458,7 @@ function claimIntervalMs() {
|
|
|
43037
43458
|
}
|
|
43038
43459
|
|
|
43039
43460
|
// src/async-job-consumer.ts
|
|
43040
|
-
var
|
|
43461
|
+
var import_node_crypto6 = __toESM(require("node:crypto"), 1);
|
|
43041
43462
|
|
|
43042
43463
|
// src/async-tools/registry.ts
|
|
43043
43464
|
var registry2 = /* @__PURE__ */ new Map();
|
|
@@ -43121,7 +43542,7 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
|
|
|
43121
43542
|
const delivery = descriptor2.onComplete(outcome, input);
|
|
43122
43543
|
if (!delivery.suppressInbox) {
|
|
43123
43544
|
await deps.client.createInboxItem(projectSlug, {
|
|
43124
|
-
id: delivery.id ?? `II-${
|
|
43545
|
+
id: delivery.id ?? `II-${import_node_crypto6.default.randomUUID()}`,
|
|
43125
43546
|
kind: delivery.kind,
|
|
43126
43547
|
body: delivery.body,
|
|
43127
43548
|
...delivery.taskId ? { taskId: delivery.taskId } : {}
|
|
@@ -43134,13 +43555,13 @@ async function deriveRequestedHash(client, toolName, input) {
|
|
|
43134
43555
|
if (input.requestedHash) return input.requestedHash;
|
|
43135
43556
|
if (toolName === "run_spec_consensus" && input.pageId) {
|
|
43136
43557
|
const page = await client.getWikiPage(input.projectSlug, input.pageId);
|
|
43137
|
-
return page.contentHash ??
|
|
43558
|
+
return page.contentHash ?? import_node_crypto6.default.createHash("sha256").update(page.markdownBody).digest("hex");
|
|
43138
43559
|
}
|
|
43139
43560
|
if (toolName === "draft_task_spec" && input.taskId) {
|
|
43140
43561
|
const task = await client.getTask(input.projectSlug, input.taskId);
|
|
43141
|
-
return task.updatedAt ??
|
|
43562
|
+
return task.updatedAt ?? import_node_crypto6.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
|
|
43142
43563
|
}
|
|
43143
|
-
return
|
|
43564
|
+
return import_node_crypto6.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
|
|
43144
43565
|
}
|
|
43145
43566
|
async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId)) {
|
|
43146
43567
|
const projects = await deps.client.listProjects();
|
|
@@ -43381,6 +43802,15 @@ async function runDeliverableGate(_target, deps) {
|
|
|
43381
43802
|
rounds: result.rounds,
|
|
43382
43803
|
contentHash: currentHash
|
|
43383
43804
|
});
|
|
43805
|
+
if (result.outcome === "CONSENSUS_BLOCKED") {
|
|
43806
|
+
const accepted = result.history.at(-1)?.accepted ?? [];
|
|
43807
|
+
const clarifications = accepted.filter((issue2) => issue2.category === "scope" || issue2.category === "ambiguity" || issue2.category === "correctness").map((issue2) => ({
|
|
43808
|
+
question: issue2.text,
|
|
43809
|
+
whyBlocking: `reviewer raised a ${issue2.category} issue`,
|
|
43810
|
+
category: issue2.category
|
|
43811
|
+
}));
|
|
43812
|
+
return clarifications.length > 0 ? { outcome: "CONSENSUS_BLOCKED", rounds: result.rounds, clarifications } : { outcome: "CONSENSUS_BLOCKED", rounds: result.rounds };
|
|
43813
|
+
}
|
|
43384
43814
|
return { outcome: result.outcome, rounds: result.rounds };
|
|
43385
43815
|
}
|
|
43386
43816
|
|
|
@@ -43629,7 +44059,7 @@ function chatTurnMaxMs() {
|
|
|
43629
44059
|
}
|
|
43630
44060
|
|
|
43631
44061
|
// src/worker-token.ts
|
|
43632
|
-
var
|
|
44062
|
+
var import_node_crypto7 = require("node:crypto");
|
|
43633
44063
|
var import_node_fs9 = require("node:fs");
|
|
43634
44064
|
var import_node_os6 = __toESM(require("node:os"), 1);
|
|
43635
44065
|
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
@@ -43660,7 +44090,7 @@ function readOrCreateWorkerToken() {
|
|
|
43660
44090
|
if (existing) return existing;
|
|
43661
44091
|
const dir = workerDir();
|
|
43662
44092
|
(0, import_node_fs9.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
43663
|
-
const token = (0,
|
|
44093
|
+
const token = (0, import_node_crypto7.randomBytes)(32).toString("hex");
|
|
43664
44094
|
(0, import_node_fs9.writeFileSync)(workerTokenPath(), `${token}
|
|
43665
44095
|
`, { encoding: "utf8", mode: 384 });
|
|
43666
44096
|
return token;
|
|
@@ -47241,9 +47671,9 @@ var DirectorRelay = class {
|
|
|
47241
47671
|
|
|
47242
47672
|
// src/remote-phone-relay.ts
|
|
47243
47673
|
function loadOrCreateAgentDeviceKey() {
|
|
47244
|
-
const
|
|
47674
|
+
const path19 = (0, import_node_path14.join)((0, import_node_os7.homedir)(), ".mrrlin", "agent-device-key");
|
|
47245
47675
|
try {
|
|
47246
|
-
const raw = JSON.parse((0, import_node_fs10.readFileSync)(
|
|
47676
|
+
const raw = JSON.parse((0, import_node_fs10.readFileSync)(path19, "utf8"));
|
|
47247
47677
|
if (typeof raw.priv === "string" && typeof raw.pub === "string") {
|
|
47248
47678
|
return { privateKey: fromBase64Url(raw.priv), publicKey: fromBase64Url(raw.pub) };
|
|
47249
47679
|
}
|
|
@@ -47253,7 +47683,7 @@ function loadOrCreateAgentDeviceKey() {
|
|
|
47253
47683
|
try {
|
|
47254
47684
|
(0, import_node_fs10.mkdirSync)((0, import_node_path14.join)((0, import_node_os7.homedir)(), ".mrrlin"), { recursive: true });
|
|
47255
47685
|
(0, import_node_fs10.writeFileSync)(
|
|
47256
|
-
|
|
47686
|
+
path19,
|
|
47257
47687
|
JSON.stringify({ priv: toBase64Url(kp.privateKey), pub: toBase64Url(kp.publicKey) }),
|
|
47258
47688
|
{ mode: 384 }
|
|
47259
47689
|
);
|
|
@@ -47476,9 +47906,9 @@ var CheckoutRegistry = class {
|
|
|
47476
47906
|
get(slug) {
|
|
47477
47907
|
return this.read()[slug] ?? null;
|
|
47478
47908
|
}
|
|
47479
|
-
confirm(slug,
|
|
47909
|
+
confirm(slug, path19, now) {
|
|
47480
47910
|
const all = this.read();
|
|
47481
|
-
all[slug] = { path:
|
|
47911
|
+
all[slug] = { path: path19, confirmedAt: now };
|
|
47482
47912
|
(0, import_node_fs11.writeFileSync)(this.file, JSON.stringify(all, null, 2));
|
|
47483
47913
|
}
|
|
47484
47914
|
};
|
|
@@ -47807,6 +48237,362 @@ function createBridgeLogger(stateDir, env = process.env) {
|
|
|
47807
48237
|
};
|
|
47808
48238
|
}
|
|
47809
48239
|
|
|
48240
|
+
// src/external-agents-scrub.ts
|
|
48241
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
48242
|
+
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
48243
|
+
var import_node_path17 = __toESM(require("node:path"), 1);
|
|
48244
|
+
var REDACTION = "[REDACTED]";
|
|
48245
|
+
var SHORT_VALUE_THRESHOLD = 8;
|
|
48246
|
+
var KEYS_ENV_PATH = () => import_node_path17.default.join(import_node_os8.default.homedir(), ".local", "state", "external-agents", "keys.env");
|
|
48247
|
+
var keysEnvCache = null;
|
|
48248
|
+
function readKeysEnv() {
|
|
48249
|
+
const filePath = KEYS_ENV_PATH();
|
|
48250
|
+
let mtimeMs = 0;
|
|
48251
|
+
try {
|
|
48252
|
+
mtimeMs = import_node_fs13.default.statSync(filePath).mtimeMs;
|
|
48253
|
+
} catch {
|
|
48254
|
+
mtimeMs = 0;
|
|
48255
|
+
}
|
|
48256
|
+
if (keysEnvCache && keysEnvCache.mtimeMs === mtimeMs) {
|
|
48257
|
+
return keysEnvCache.map;
|
|
48258
|
+
}
|
|
48259
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
48260
|
+
try {
|
|
48261
|
+
const content = import_node_fs13.default.readFileSync(filePath, "utf8");
|
|
48262
|
+
for (const rawLine of content.split(/\r?\n/)) {
|
|
48263
|
+
const line = rawLine.trim();
|
|
48264
|
+
if (line === "" || line.startsWith("#")) continue;
|
|
48265
|
+
const eq = line.indexOf("=");
|
|
48266
|
+
if (eq === -1) continue;
|
|
48267
|
+
const key = line.slice(0, eq).trim();
|
|
48268
|
+
const value = line.slice(eq + 1);
|
|
48269
|
+
if (key === "") continue;
|
|
48270
|
+
map2.set(key, value);
|
|
48271
|
+
}
|
|
48272
|
+
} catch {
|
|
48273
|
+
}
|
|
48274
|
+
keysEnvCache = { mtimeMs, map: map2 };
|
|
48275
|
+
return map2;
|
|
48276
|
+
}
|
|
48277
|
+
function buildScrubSet(opts) {
|
|
48278
|
+
const result = /* @__PURE__ */ new Set();
|
|
48279
|
+
const fileMap = readKeysEnv();
|
|
48280
|
+
for (const name of opts.registryEnvNames) {
|
|
48281
|
+
const fromFile = fileMap.get(name);
|
|
48282
|
+
if (fromFile !== void 0 && fromFile !== "") {
|
|
48283
|
+
result.add(fromFile);
|
|
48284
|
+
}
|
|
48285
|
+
const fromEnv = process.env[name];
|
|
48286
|
+
if (fromEnv !== void 0 && fromEnv !== "") {
|
|
48287
|
+
result.add(fromEnv);
|
|
48288
|
+
}
|
|
48289
|
+
}
|
|
48290
|
+
for (const value of opts.inFlightValues ?? []) {
|
|
48291
|
+
result.add(value);
|
|
48292
|
+
}
|
|
48293
|
+
return result;
|
|
48294
|
+
}
|
|
48295
|
+
function escapeRegExp(literal2) {
|
|
48296
|
+
return literal2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
48297
|
+
}
|
|
48298
|
+
function jsonEscapedVariant(value) {
|
|
48299
|
+
const json2 = JSON.stringify(value);
|
|
48300
|
+
return json2.slice(1, -1);
|
|
48301
|
+
}
|
|
48302
|
+
function percentEncodedVariant(value) {
|
|
48303
|
+
try {
|
|
48304
|
+
return encodeURIComponent(value);
|
|
48305
|
+
} catch {
|
|
48306
|
+
return null;
|
|
48307
|
+
}
|
|
48308
|
+
}
|
|
48309
|
+
function collectVariants(scrubSet) {
|
|
48310
|
+
const variants = /* @__PURE__ */ new Set();
|
|
48311
|
+
for (const value of scrubSet) {
|
|
48312
|
+
if (value === "") continue;
|
|
48313
|
+
variants.add(value);
|
|
48314
|
+
const jsonForm = jsonEscapedVariant(value);
|
|
48315
|
+
if (jsonForm !== "") variants.add(jsonForm);
|
|
48316
|
+
const percentForm = percentEncodedVariant(value);
|
|
48317
|
+
if (percentForm !== null && percentForm !== "") variants.add(percentForm);
|
|
48318
|
+
}
|
|
48319
|
+
return [...variants];
|
|
48320
|
+
}
|
|
48321
|
+
function buildScrubRegex(scrubSet) {
|
|
48322
|
+
const variants = collectVariants(scrubSet);
|
|
48323
|
+
if (variants.length === 0) return null;
|
|
48324
|
+
variants.sort((a, b) => b.length - a.length);
|
|
48325
|
+
const alternatives = variants.map((variant) => {
|
|
48326
|
+
const escaped = escapeRegExp(variant);
|
|
48327
|
+
if (variant.length >= SHORT_VALUE_THRESHOLD) {
|
|
48328
|
+
return escaped;
|
|
48329
|
+
}
|
|
48330
|
+
return `(?<![A-Za-z0-9_])${escaped}(?![A-Za-z0-9_])`;
|
|
48331
|
+
});
|
|
48332
|
+
return new RegExp(alternatives.join("|"), "g");
|
|
48333
|
+
}
|
|
48334
|
+
function scrubString(input, regex) {
|
|
48335
|
+
return input.replace(regex, REDACTION);
|
|
48336
|
+
}
|
|
48337
|
+
function isPlainObject3(value) {
|
|
48338
|
+
if (typeof value !== "object" || value === null) return false;
|
|
48339
|
+
const proto = Object.getPrototypeOf(value);
|
|
48340
|
+
return proto === Object.prototype || proto === null;
|
|
48341
|
+
}
|
|
48342
|
+
function scrubValue(value, regex) {
|
|
48343
|
+
if (typeof value === "string") {
|
|
48344
|
+
return regex === null ? value : scrubString(value, regex);
|
|
48345
|
+
}
|
|
48346
|
+
if (Array.isArray(value)) {
|
|
48347
|
+
return value.map((item) => scrubValue(item, regex));
|
|
48348
|
+
}
|
|
48349
|
+
if (isPlainObject3(value)) {
|
|
48350
|
+
const out = {};
|
|
48351
|
+
for (const [key, child] of Object.entries(value)) {
|
|
48352
|
+
out[key] = scrubValue(child, regex);
|
|
48353
|
+
}
|
|
48354
|
+
return out;
|
|
48355
|
+
}
|
|
48356
|
+
return value;
|
|
48357
|
+
}
|
|
48358
|
+
function scrubDeep(value, scrubSet) {
|
|
48359
|
+
const regex = buildScrubRegex(scrubSet);
|
|
48360
|
+
return scrubValue(value, regex);
|
|
48361
|
+
}
|
|
48362
|
+
|
|
48363
|
+
// src/external-agents-handlers.ts
|
|
48364
|
+
var BUDGET_STATE_MS = 1e4;
|
|
48365
|
+
var BUDGET_PROBE_MS = 6e4;
|
|
48366
|
+
var BUDGET_AUDIT_MS = 18e4;
|
|
48367
|
+
var BUDGET_TOGGLE_MS = 1e4;
|
|
48368
|
+
var BUDGET_ADD_MODEL_MS = 1e4;
|
|
48369
|
+
var BUDGET_SET_CREDENTIAL_MS = 1e4;
|
|
48370
|
+
var BUDGET_DISPATCH_MS = 3e5;
|
|
48371
|
+
var ENV_NAME_RE = /^[A-Z0-9_]+$/;
|
|
48372
|
+
var MAX_PROMPT_LEN = 8192;
|
|
48373
|
+
var TOGGLE_MIN_VERSION = "0.34.0";
|
|
48374
|
+
function invalidInput(field, reason) {
|
|
48375
|
+
return { ok: false, error: { code: "invalid_input", fields: { [field]: reason } } };
|
|
48376
|
+
}
|
|
48377
|
+
function tryParseJson(s) {
|
|
48378
|
+
try {
|
|
48379
|
+
return { ok: true, value: JSON.parse(s) };
|
|
48380
|
+
} catch {
|
|
48381
|
+
return { ok: false };
|
|
48382
|
+
}
|
|
48383
|
+
}
|
|
48384
|
+
function classifyCliFailure(result) {
|
|
48385
|
+
if (result.timedOut) return { code: "timeout" };
|
|
48386
|
+
const stderrLc = result.stderr.toLowerCase();
|
|
48387
|
+
const notFound = stderrLc.includes("command not found") || stderrLc.includes("enoent") || result.code === 1 && result.stdout === "" && result.stderr === "";
|
|
48388
|
+
const error51 = notFound ? { code: "cli_not_found", triedPaths: [result.triedPath] } : { code: "cli_broken" };
|
|
48389
|
+
if (result.stderr) error51.detail = result.stderr;
|
|
48390
|
+
return error51;
|
|
48391
|
+
}
|
|
48392
|
+
function finalizeReply(reply, scrubSet) {
|
|
48393
|
+
return scrubDeep(reply, scrubSet);
|
|
48394
|
+
}
|
|
48395
|
+
function defaultScrubSet(deps) {
|
|
48396
|
+
return buildScrubSet({ registryEnvNames: deps.registryEnvNames });
|
|
48397
|
+
}
|
|
48398
|
+
function extractRegistryEnvNames(agents) {
|
|
48399
|
+
const names = /* @__PURE__ */ new Set();
|
|
48400
|
+
for (const entry of agents) {
|
|
48401
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
48402
|
+
const auth = entry["auth"];
|
|
48403
|
+
if (typeof auth === "string" && auth.startsWith("env:")) {
|
|
48404
|
+
names.add(auth.slice("env:".length));
|
|
48405
|
+
}
|
|
48406
|
+
}
|
|
48407
|
+
return [...names];
|
|
48408
|
+
}
|
|
48409
|
+
async function handleAgentsState(deps, request) {
|
|
48410
|
+
if (request.since !== void 0) {
|
|
48411
|
+
if (Number.isNaN(new Date(request.since).getTime())) {
|
|
48412
|
+
return finalizeReply(invalidInput("since", "not a valid ISO timestamp"), defaultScrubSet(deps));
|
|
48413
|
+
}
|
|
48414
|
+
}
|
|
48415
|
+
const status = await deps.run(["status", "--json"], { budgetMs: BUDGET_STATE_MS });
|
|
48416
|
+
if (status.code !== 0) {
|
|
48417
|
+
return finalizeReply({ ok: false, error: classifyCliFailure(status) }, defaultScrubSet(deps));
|
|
48418
|
+
}
|
|
48419
|
+
const statusParsed = tryParseJson(status.stdout);
|
|
48420
|
+
if (!statusParsed.ok || !Array.isArray(statusParsed.value)) {
|
|
48421
|
+
return finalizeReply(
|
|
48422
|
+
{ ok: false, error: { code: "cli_broken", detail: status.stderr || void 0 } },
|
|
48423
|
+
defaultScrubSet(deps)
|
|
48424
|
+
);
|
|
48425
|
+
}
|
|
48426
|
+
const agents = statusParsed.value;
|
|
48427
|
+
const stateScrubSet = buildScrubSet({
|
|
48428
|
+
registryEnvNames: [...deps.registryEnvNames, ...extractRegistryEnvNames(agents)]
|
|
48429
|
+
});
|
|
48430
|
+
const statsArgs = ["stats", "--json", ...request.since ? ["--since", request.since] : []];
|
|
48431
|
+
const stats = await deps.run(statsArgs, { budgetMs: BUDGET_STATE_MS });
|
|
48432
|
+
let totals = null;
|
|
48433
|
+
if (stats.code === 0) {
|
|
48434
|
+
const statsParsed = tryParseJson(stats.stdout);
|
|
48435
|
+
if (statsParsed.ok) totals = statsParsed.value;
|
|
48436
|
+
}
|
|
48437
|
+
return finalizeReply(
|
|
48438
|
+
{ ok: true, data: { agents, totals, cli: { path: null, version: null, source: status.source } } },
|
|
48439
|
+
stateScrubSet
|
|
48440
|
+
);
|
|
48441
|
+
}
|
|
48442
|
+
async function handleAgentsProbe(deps, request) {
|
|
48443
|
+
const scrubSet = defaultScrubSet(deps);
|
|
48444
|
+
if (deps.lastKnownState === null || !deps.lastKnownState.agentIds.includes(request.id)) {
|
|
48445
|
+
return finalizeReply(invalidInput("id", "unknown agent id"), scrubSet);
|
|
48446
|
+
}
|
|
48447
|
+
const result = await deps.run(["probe", request.id], { budgetMs: BUDGET_PROBE_MS });
|
|
48448
|
+
if (result.code !== 0) {
|
|
48449
|
+
return finalizeReply({ ok: false, error: classifyCliFailure(result) }, scrubSet);
|
|
48450
|
+
}
|
|
48451
|
+
const parsed = tryParseJson(result.stdout);
|
|
48452
|
+
if (!parsed.ok) {
|
|
48453
|
+
return finalizeReply({ ok: false, error: { code: "cli_broken", detail: result.stderr || void 0 } }, scrubSet);
|
|
48454
|
+
}
|
|
48455
|
+
return finalizeReply({ ok: true, data: parsed.value }, scrubSet);
|
|
48456
|
+
}
|
|
48457
|
+
async function handleAgentsAudit(deps, request) {
|
|
48458
|
+
const scrubSet = defaultScrubSet(deps);
|
|
48459
|
+
if (deps.lastKnownState === null) {
|
|
48460
|
+
return finalizeReply(invalidInput("provider", "call agents-state before agents-audit"), scrubSet);
|
|
48461
|
+
}
|
|
48462
|
+
if (request.provider !== void 0 && !deps.lastKnownState.providers.includes(request.provider)) {
|
|
48463
|
+
return finalizeReply(invalidInput("provider", "unknown provider"), scrubSet);
|
|
48464
|
+
}
|
|
48465
|
+
const auditArgs = ["audit", "--json", ...request.provider ? ["--provider", request.provider] : []];
|
|
48466
|
+
const result = await deps.run(auditArgs, { budgetMs: BUDGET_AUDIT_MS });
|
|
48467
|
+
if (result.code !== 0) {
|
|
48468
|
+
return finalizeReply({ ok: false, error: classifyCliFailure(result) }, scrubSet);
|
|
48469
|
+
}
|
|
48470
|
+
const parsed = tryParseJson(result.stdout);
|
|
48471
|
+
if (!parsed.ok) {
|
|
48472
|
+
return finalizeReply({ ok: false, error: { code: "cli_broken", detail: result.stderr || void 0 } }, scrubSet);
|
|
48473
|
+
}
|
|
48474
|
+
return finalizeReply({ ok: true, data: parsed.value }, scrubSet);
|
|
48475
|
+
}
|
|
48476
|
+
async function handleAgentsToggle(deps, request) {
|
|
48477
|
+
const scrubSet = defaultScrubSet(deps);
|
|
48478
|
+
if (deps.lastKnownState === null || !deps.lastKnownState.agentIds.includes(request.id)) {
|
|
48479
|
+
return finalizeReply(invalidInput("id", "unknown agent id"), scrubSet);
|
|
48480
|
+
}
|
|
48481
|
+
const result = await deps.run(
|
|
48482
|
+
["toggle", request.id, request.enabled ? "--enabled" : "--disabled"],
|
|
48483
|
+
{ budgetMs: BUDGET_TOGGLE_MS }
|
|
48484
|
+
);
|
|
48485
|
+
if (result.code !== 0) {
|
|
48486
|
+
const stderrLc = result.stderr.toLowerCase();
|
|
48487
|
+
if (stderrLc.includes("unknown subcommand") || stderrLc.includes("unknown command")) {
|
|
48488
|
+
return finalizeReply(
|
|
48489
|
+
{
|
|
48490
|
+
ok: false,
|
|
48491
|
+
error: {
|
|
48492
|
+
code: "cli_outdated",
|
|
48493
|
+
detail: `the toggle control requires external-agents >= ${TOGGLE_MIN_VERSION}`
|
|
48494
|
+
}
|
|
48495
|
+
},
|
|
48496
|
+
scrubSet
|
|
48497
|
+
);
|
|
48498
|
+
}
|
|
48499
|
+
return finalizeReply({ ok: false, error: classifyCliFailure(result) }, scrubSet);
|
|
48500
|
+
}
|
|
48501
|
+
return finalizeReply({ ok: true, data: { id: request.id, enabled: request.enabled } }, scrubSet);
|
|
48502
|
+
}
|
|
48503
|
+
async function handleAgentsAddModel(deps, request) {
|
|
48504
|
+
const scrubSet = defaultScrubSet(deps);
|
|
48505
|
+
if (!ENV_NAME_RE.test(request.env)) {
|
|
48506
|
+
return finalizeReply(invalidInput("env", "must match /^[A-Z0-9_]+$/"), scrubSet);
|
|
48507
|
+
}
|
|
48508
|
+
try {
|
|
48509
|
+
new URL(request.url);
|
|
48510
|
+
} catch {
|
|
48511
|
+
return finalizeReply(invalidInput("url", "not a valid URL"), scrubSet);
|
|
48512
|
+
}
|
|
48513
|
+
if (deps.lastKnownState === null) {
|
|
48514
|
+
return finalizeReply(invalidInput("id", "call agents-state before agents-add-model"), scrubSet);
|
|
48515
|
+
}
|
|
48516
|
+
if (deps.lastKnownState.agentIds.includes(request.id)) {
|
|
48517
|
+
return finalizeReply(invalidInput("id", "an agent with this id already exists"), scrubSet);
|
|
48518
|
+
}
|
|
48519
|
+
const args = [
|
|
48520
|
+
"add-model",
|
|
48521
|
+
"--id",
|
|
48522
|
+
request.id,
|
|
48523
|
+
"--provider",
|
|
48524
|
+
request.provider,
|
|
48525
|
+
"--url",
|
|
48526
|
+
request.url,
|
|
48527
|
+
"--model",
|
|
48528
|
+
request.model,
|
|
48529
|
+
"--env",
|
|
48530
|
+
request.env,
|
|
48531
|
+
...request.tier ? ["--tier", request.tier] : [],
|
|
48532
|
+
...request.tags?.length ? ["--tags", request.tags.join(",")] : []
|
|
48533
|
+
];
|
|
48534
|
+
const result = await deps.run(args, { budgetMs: BUDGET_ADD_MODEL_MS });
|
|
48535
|
+
if (result.code !== 0) {
|
|
48536
|
+
return finalizeReply({ ok: false, error: classifyCliFailure(result) }, scrubSet);
|
|
48537
|
+
}
|
|
48538
|
+
return finalizeReply({ ok: true, data: { id: request.id } }, scrubSet);
|
|
48539
|
+
}
|
|
48540
|
+
async function handleAgentsSetCredential(deps, request) {
|
|
48541
|
+
const scrubSet = buildScrubSet({
|
|
48542
|
+
registryEnvNames: deps.registryEnvNames,
|
|
48543
|
+
inFlightValues: [request.value]
|
|
48544
|
+
});
|
|
48545
|
+
if (deps.lastKnownState === null) {
|
|
48546
|
+
return finalizeReply(invalidInput("env", "call agents-state before agents-set-credential"), scrubSet);
|
|
48547
|
+
}
|
|
48548
|
+
if (!ENV_NAME_RE.test(request.env)) {
|
|
48549
|
+
return finalizeReply(invalidInput("env", "must match /^[A-Z0-9_]+$/"), scrubSet);
|
|
48550
|
+
}
|
|
48551
|
+
if (request.value === "") {
|
|
48552
|
+
return finalizeReply(invalidInput("value", "must not be empty"), scrubSet);
|
|
48553
|
+
}
|
|
48554
|
+
const result = await deps.run(["set-credential", request.env, "-"], {
|
|
48555
|
+
stdinValue: request.value,
|
|
48556
|
+
budgetMs: BUDGET_SET_CREDENTIAL_MS
|
|
48557
|
+
});
|
|
48558
|
+
if (result.code !== 0) {
|
|
48559
|
+
return finalizeReply({ ok: false, error: classifyCliFailure(result) }, scrubSet);
|
|
48560
|
+
}
|
|
48561
|
+
return finalizeReply({ ok: true, data: { env: request.env } }, scrubSet);
|
|
48562
|
+
}
|
|
48563
|
+
var DISPATCH_ALLOWED_KEYS = /* @__PURE__ */ new Set(["id", "prompt", "transport", "effort"]);
|
|
48564
|
+
async function handleAgentsDispatch(deps, request) {
|
|
48565
|
+
const scrubSet = defaultScrubSet(deps);
|
|
48566
|
+
for (const key of Object.keys(request)) {
|
|
48567
|
+
if (!DISPATCH_ALLOWED_KEYS.has(key)) {
|
|
48568
|
+
return finalizeReply(invalidInput(key, "unexpected field"), scrubSet);
|
|
48569
|
+
}
|
|
48570
|
+
}
|
|
48571
|
+
if (deps.lastKnownState === null || !deps.lastKnownState.agentIds.includes(request.id)) {
|
|
48572
|
+
return finalizeReply(invalidInput("id", "unknown agent id"), scrubSet);
|
|
48573
|
+
}
|
|
48574
|
+
if (request.prompt.length > MAX_PROMPT_LEN) {
|
|
48575
|
+
return finalizeReply(invalidInput("prompt", `must be at most ${MAX_PROMPT_LEN} characters`), scrubSet);
|
|
48576
|
+
}
|
|
48577
|
+
const args = [
|
|
48578
|
+
"dispatch",
|
|
48579
|
+
request.id,
|
|
48580
|
+
"--json",
|
|
48581
|
+
...request.transport ? ["--transport", request.transport] : [],
|
|
48582
|
+
...request.effort ? ["--effort", request.effort] : [],
|
|
48583
|
+
request.prompt
|
|
48584
|
+
];
|
|
48585
|
+
const result = await deps.run(args, { budgetMs: BUDGET_DISPATCH_MS });
|
|
48586
|
+
if (result.code !== 0) {
|
|
48587
|
+
return finalizeReply({ ok: false, error: classifyCliFailure(result) }, scrubSet);
|
|
48588
|
+
}
|
|
48589
|
+
const parsed = tryParseJson(result.stdout);
|
|
48590
|
+
if (!parsed.ok) {
|
|
48591
|
+
return finalizeReply({ ok: false, error: { code: "cli_broken", detail: result.stderr || void 0 } }, scrubSet);
|
|
48592
|
+
}
|
|
48593
|
+
return finalizeReply({ ok: true, data: parsed.value }, scrubSet);
|
|
48594
|
+
}
|
|
48595
|
+
|
|
47810
48596
|
// src/director-bridge.ts
|
|
47811
48597
|
var JSON_GPT_MODEL_REF_RE = /"(?:slug|model)"\s*:\s*"(gpt-[a-z0-9.-]+)"/gi;
|
|
47812
48598
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -47864,7 +48650,7 @@ function addBridgeModel(target, model) {
|
|
|
47864
48650
|
}
|
|
47865
48651
|
function readTextIfExists(filePath) {
|
|
47866
48652
|
try {
|
|
47867
|
-
return
|
|
48653
|
+
return import_node_fs14.default.readFileSync(filePath, "utf8");
|
|
47868
48654
|
} catch {
|
|
47869
48655
|
return null;
|
|
47870
48656
|
}
|
|
@@ -47875,9 +48661,9 @@ function readKnownGptSlugsFromTomlFile(filePath) {
|
|
|
47875
48661
|
return Array.from(raw.matchAll(/^\s*model\s*=\s*"([^"]+)"/gm)).map((match) => match[1]?.trim() ?? "").filter(isSelectableModelSlug);
|
|
47876
48662
|
}
|
|
47877
48663
|
function readCodexFallbackModels() {
|
|
47878
|
-
const codexHome = process.env.CODEX_HOME?.trim() ||
|
|
48664
|
+
const codexHome = process.env.CODEX_HOME?.trim() || import_node_path18.default.join(import_node_os9.default.homedir(), ".codex");
|
|
47879
48665
|
const models = /* @__PURE__ */ new Map();
|
|
47880
|
-
const cachePath =
|
|
48666
|
+
const cachePath = import_node_path18.default.join(codexHome, "models_cache.json");
|
|
47881
48667
|
const cacheRaw = readTextIfExists(cachePath);
|
|
47882
48668
|
if (cacheRaw) {
|
|
47883
48669
|
try {
|
|
@@ -47927,7 +48713,7 @@ function readCodexFallbackModels() {
|
|
|
47927
48713
|
);
|
|
47928
48714
|
}
|
|
47929
48715
|
}
|
|
47930
|
-
for (const slug of readKnownGptSlugsFromTomlFile(
|
|
48716
|
+
for (const slug of readKnownGptSlugsFromTomlFile(import_node_path18.default.join(codexHome, "config.toml"))) {
|
|
47931
48717
|
addBridgeModel(
|
|
47932
48718
|
models,
|
|
47933
48719
|
mapBridgeModel({
|
|
@@ -47941,11 +48727,11 @@ function readCodexFallbackModels() {
|
|
|
47941
48727
|
})
|
|
47942
48728
|
);
|
|
47943
48729
|
}
|
|
47944
|
-
const automationsDir =
|
|
48730
|
+
const automationsDir = import_node_path18.default.join(codexHome, "automations");
|
|
47945
48731
|
try {
|
|
47946
|
-
for (const entry of
|
|
48732
|
+
for (const entry of import_node_fs14.default.readdirSync(automationsDir, { withFileTypes: true })) {
|
|
47947
48733
|
if (!entry.isDirectory()) continue;
|
|
47948
|
-
for (const slug of readKnownGptSlugsFromTomlFile(
|
|
48734
|
+
for (const slug of readKnownGptSlugsFromTomlFile(import_node_path18.default.join(automationsDir, entry.name, "automation.toml"))) {
|
|
47949
48735
|
addBridgeModel(
|
|
47950
48736
|
models,
|
|
47951
48737
|
mapBridgeModel({
|
|
@@ -47965,9 +48751,9 @@ function readCodexFallbackModels() {
|
|
|
47965
48751
|
return [...models.values()];
|
|
47966
48752
|
}
|
|
47967
48753
|
function neutralCheckoutCwd(stateDir) {
|
|
47968
|
-
const dir =
|
|
48754
|
+
const dir = import_node_path18.default.join(stateDir, "no-checkout");
|
|
47969
48755
|
try {
|
|
47970
|
-
|
|
48756
|
+
import_node_fs14.default.mkdirSync(dir, { recursive: true });
|
|
47971
48757
|
} catch {
|
|
47972
48758
|
}
|
|
47973
48759
|
return dir;
|
|
@@ -47986,6 +48772,27 @@ function buildThreadStartParams(msg, config2, desiredModel) {
|
|
|
47986
48772
|
"transcript. Just call the tools and reply with the outcome \u2014 start your reply with the result.",
|
|
47987
48773
|
"When creating or updating tasks, always provide `autonomyLevel` and `autonomyReason`.",
|
|
47988
48774
|
"",
|
|
48775
|
+
"Turn lifecycle \u2014 what you can and cannot do between turns:",
|
|
48776
|
+
"- Your turn ends the moment you stop producing output. You CANNOT start a new turn yourself:",
|
|
48777
|
+
" no timer and no scheduler wakes you up. Only a new operator message starts the next turn.",
|
|
48778
|
+
'- Therefore NEVER end a reply with a promise to keep working \u2014 no "continuing to the next one',
|
|
48779
|
+
` automatically", "I'll proceed now", "working on it", in ANY language. If you say it and then`,
|
|
48780
|
+
" stop, the work silently never happens and the operator waits forever for a reply that will",
|
|
48781
|
+
" never come.",
|
|
48782
|
+
"- When the operator hands you a batch (several links, tasks, or pages), process EVERY item in",
|
|
48783
|
+
" the SAME turn: keep calling tools item by item, then report all results together at the end.",
|
|
48784
|
+
"- A turn is bounded (~30 minutes of wall clock, and a finite reply size), so never open-endedly",
|
|
48785
|
+
" commit to a huge batch. If it holds more than ~8 items, or individual items need heavy",
|
|
48786
|
+
" fetching or analysis, split it UP FRONT: say how you are splitting it, do the first slice,",
|
|
48787
|
+
" then ask to continue. Splitting deliberately beats being cut off mid-batch and losing the work.",
|
|
48788
|
+
"- Whenever you stop short of the full batch, stop at a clean boundary and END with an explicit",
|
|
48789
|
+
' request to continue, naming exactly where you stopped (e.g. "done 2 of 7 \u2014 say `continue`',
|
|
48790
|
+
` and I'll take 3-7"). An explicit ask is correct; a promise to self-continue is a bug.`,
|
|
48791
|
+
"- Exception: when a tool's OWN instructions say its result will arrive in the inbox (e.g. spec",
|
|
48792
|
+
" consensus returning `queued`), ending the turn IS correct \u2014 a real asynchronous mechanism",
|
|
48793
|
+
" delivers that result later. This exception covers ONLY inbox-delivered results; it is never",
|
|
48794
|
+
" license to end a turn while work you must do yourself is still outstanding.",
|
|
48795
|
+
"",
|
|
47989
48796
|
"Task description quality contract \u2014 every task you create or update via create_task or update_task:",
|
|
47990
48797
|
"- Title: short, actionable, human-readable. Describe what needs to happen, not internal jargon.",
|
|
47991
48798
|
' Good: "Audit crawled-not-indexed pages and fix 404 errors"',
|
|
@@ -48283,7 +49090,7 @@ async function runOrphanWorktreeSweep(client, opts) {
|
|
|
48283
49090
|
const cutoff = Date.now() - worktreeRetentionMs();
|
|
48284
49091
|
const isReapable = (worktreePath) => {
|
|
48285
49092
|
try {
|
|
48286
|
-
return
|
|
49093
|
+
return import_node_fs14.default.statSync(worktreePath).mtimeMs < cutoff;
|
|
48287
49094
|
} catch {
|
|
48288
49095
|
return false;
|
|
48289
49096
|
}
|
|
@@ -48321,8 +49128,8 @@ async function runOrphanWorktreeSweep(client, opts) {
|
|
|
48321
49128
|
}
|
|
48322
49129
|
}
|
|
48323
49130
|
function readStateDir() {
|
|
48324
|
-
if (process.env.CODEX_HOME) return
|
|
48325
|
-
return
|
|
49131
|
+
if (process.env.CODEX_HOME) return import_node_path18.default.join(process.env.CODEX_HOME, "mrrlin", "director-bridge");
|
|
49132
|
+
return import_node_path18.default.join(import_node_os9.default.homedir(), ".mrrlin", "director-bridge");
|
|
48326
49133
|
}
|
|
48327
49134
|
function readAllowedOrigins() {
|
|
48328
49135
|
const raw = (process.env.MRRLIN_DIRECTOR_BRIDGE_ALLOWED_ORIGINS ?? "").trim();
|
|
@@ -48397,7 +49204,7 @@ function createBridgeRequestListener(opts) {
|
|
|
48397
49204
|
res.end(JSON.stringify({ ok: false, error: "Origin not allowed." }));
|
|
48398
49205
|
return;
|
|
48399
49206
|
}
|
|
48400
|
-
const nonce =
|
|
49207
|
+
const nonce = import_node_crypto8.default.randomBytes(16).toString("base64url");
|
|
48401
49208
|
res.writeHead(200, { "content-type": "application/json" });
|
|
48402
49209
|
res.end(JSON.stringify({ ok: true, wsUrl: `ws://${host}:${port}/ws`, token, nonce }));
|
|
48403
49210
|
return;
|
|
@@ -48521,6 +49328,45 @@ function createBridgeMessageHandler(deps) {
|
|
|
48521
49328
|
for (const id of boundSessions) deps.unbindSessionSink?.(id, send);
|
|
48522
49329
|
boundSessions.clear();
|
|
48523
49330
|
});
|
|
49331
|
+
let externalAgentsRegistryEnvNames = [];
|
|
49332
|
+
let externalAgentsLastKnownState = null;
|
|
49333
|
+
function deriveLastKnownState(agents) {
|
|
49334
|
+
const agentIds = [];
|
|
49335
|
+
const providers = /* @__PURE__ */ new Set();
|
|
49336
|
+
for (const entry of agents) {
|
|
49337
|
+
if (typeof entry !== "object" || entry === null) continue;
|
|
49338
|
+
const rec = entry;
|
|
49339
|
+
if (typeof rec.id === "string") agentIds.push(rec.id);
|
|
49340
|
+
if (typeof rec.provider === "string") providers.add(rec.provider);
|
|
49341
|
+
}
|
|
49342
|
+
return { agentIds, providers: [...providers] };
|
|
49343
|
+
}
|
|
49344
|
+
async function probeAgentsUsingEnvVar(handlerDeps, envVar) {
|
|
49345
|
+
try {
|
|
49346
|
+
const before = await handleAgentsState(handlerDeps, {});
|
|
49347
|
+
if (!before.ok) return;
|
|
49348
|
+
const matchingIds = before.data.agents.filter((entry) => typeof entry === "object" && entry !== null).filter((entry) => entry.auth === `env:${envVar}`).map((entry) => entry.id).filter((id) => typeof id === "string");
|
|
49349
|
+
const lastKnownState = deriveLastKnownState(before.data.agents);
|
|
49350
|
+
await Promise.all(
|
|
49351
|
+
matchingIds.map((id) => handleAgentsProbe({ ...handlerDeps, lastKnownState }, { id }))
|
|
49352
|
+
);
|
|
49353
|
+
} catch {
|
|
49354
|
+
}
|
|
49355
|
+
}
|
|
49356
|
+
async function withPoolStateReread(handlerDeps, reply) {
|
|
49357
|
+
if (!reply.ok) return reply;
|
|
49358
|
+
try {
|
|
49359
|
+
const reRead = await handleAgentsState(handlerDeps, {});
|
|
49360
|
+
if (reRead.ok) {
|
|
49361
|
+
externalAgentsRegistryEnvNames = extractRegistryEnvNames(reRead.data.agents);
|
|
49362
|
+
externalAgentsLastKnownState = deriveLastKnownState(reRead.data.agents);
|
|
49363
|
+
return { ...reply, poolState: reRead.data };
|
|
49364
|
+
}
|
|
49365
|
+
return { ...reply, poolState: null };
|
|
49366
|
+
} catch {
|
|
49367
|
+
return { ...reply, poolState: null };
|
|
49368
|
+
}
|
|
49369
|
+
}
|
|
48524
49370
|
function logResumeRejected(sessionId, reason) {
|
|
48525
49371
|
logCtx?.logger.logOut({
|
|
48526
49372
|
spanId: logCtx.span.id,
|
|
@@ -48635,7 +49481,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
48635
49481
|
}
|
|
48636
49482
|
}
|
|
48637
49483
|
socket.on("message", async (data) => {
|
|
48638
|
-
const spanId =
|
|
49484
|
+
const spanId = import_node_crypto8.default.randomUUID();
|
|
48639
49485
|
if (logCtx) {
|
|
48640
49486
|
logCtx.span.id = spanId;
|
|
48641
49487
|
logCtx.span.at = Date.now();
|
|
@@ -48672,7 +49518,10 @@ function createBridgeMessageHandler(deps) {
|
|
|
48672
49518
|
spanId,
|
|
48673
49519
|
sessionId: sid,
|
|
48674
49520
|
type: typeof msg.type === "string" ? msg.type : "<unknown>",
|
|
48675
|
-
|
|
49521
|
+
// Structural credential removal: the set-credential message carries a raw secret in
|
|
49522
|
+
// `value` that must never reach the structured log. Redact that one field for that one
|
|
49523
|
+
// message type only; every other message's payload is logged unchanged.
|
|
49524
|
+
payload: msg.type === "agents-set-credential" ? { ...msg, value: "[REDACTED]" } : msg
|
|
48676
49525
|
});
|
|
48677
49526
|
if (msg.type === "ping") {
|
|
48678
49527
|
sendForSpan({ type: "pong" });
|
|
@@ -48683,6 +49532,142 @@ function createBridgeMessageHandler(deps) {
|
|
|
48683
49532
|
sendForSpan({ type: "pairing-qr", ...result });
|
|
48684
49533
|
return;
|
|
48685
49534
|
}
|
|
49535
|
+
if (msg.type === "agents-state") {
|
|
49536
|
+
if (!deps.runExternalAgentsCli) {
|
|
49537
|
+
sendForSpan({ type: "agents-state", ok: false, error: { code: "bridge_offline", detail: "external-agents is not configured on this bridge" } });
|
|
49538
|
+
return;
|
|
49539
|
+
}
|
|
49540
|
+
const handlerDeps = {
|
|
49541
|
+
run: deps.runExternalAgentsCli,
|
|
49542
|
+
registryEnvNames: externalAgentsRegistryEnvNames,
|
|
49543
|
+
lastKnownState: externalAgentsLastKnownState
|
|
49544
|
+
};
|
|
49545
|
+
const req = msg;
|
|
49546
|
+
const reply = await handleAgentsState(handlerDeps, req.since !== void 0 ? { since: req.since } : {});
|
|
49547
|
+
if (reply.ok) {
|
|
49548
|
+
externalAgentsRegistryEnvNames = extractRegistryEnvNames(reply.data.agents);
|
|
49549
|
+
externalAgentsLastKnownState = deriveLastKnownState(reply.data.agents);
|
|
49550
|
+
}
|
|
49551
|
+
sendForSpan({ type: "agents-state", ...reply });
|
|
49552
|
+
return;
|
|
49553
|
+
}
|
|
49554
|
+
if (msg.type === "agents-probe") {
|
|
49555
|
+
if (!deps.runExternalAgentsCli) {
|
|
49556
|
+
sendForSpan({ type: "agents-probe", ok: false, error: { code: "bridge_offline", detail: "external-agents is not configured on this bridge" } });
|
|
49557
|
+
return;
|
|
49558
|
+
}
|
|
49559
|
+
const handlerDeps = {
|
|
49560
|
+
run: deps.runExternalAgentsCli,
|
|
49561
|
+
registryEnvNames: externalAgentsRegistryEnvNames,
|
|
49562
|
+
lastKnownState: externalAgentsLastKnownState
|
|
49563
|
+
};
|
|
49564
|
+
const req = msg;
|
|
49565
|
+
const reply = await withPoolStateReread(handlerDeps, await handleAgentsProbe(handlerDeps, { id: req.id }));
|
|
49566
|
+
sendForSpan({ type: "agents-probe", ...reply });
|
|
49567
|
+
return;
|
|
49568
|
+
}
|
|
49569
|
+
if (msg.type === "agents-audit") {
|
|
49570
|
+
if (!deps.runExternalAgentsCli) {
|
|
49571
|
+
sendForSpan({ type: "agents-audit", ok: false, error: { code: "bridge_offline", detail: "external-agents is not configured on this bridge" } });
|
|
49572
|
+
return;
|
|
49573
|
+
}
|
|
49574
|
+
const handlerDeps = {
|
|
49575
|
+
run: deps.runExternalAgentsCli,
|
|
49576
|
+
registryEnvNames: externalAgentsRegistryEnvNames,
|
|
49577
|
+
lastKnownState: externalAgentsLastKnownState
|
|
49578
|
+
};
|
|
49579
|
+
const req = msg;
|
|
49580
|
+
const reply = await withPoolStateReread(
|
|
49581
|
+
handlerDeps,
|
|
49582
|
+
await handleAgentsAudit(handlerDeps, req.provider !== void 0 ? { provider: req.provider } : {})
|
|
49583
|
+
);
|
|
49584
|
+
sendForSpan({ type: "agents-audit", ...reply });
|
|
49585
|
+
return;
|
|
49586
|
+
}
|
|
49587
|
+
if (msg.type === "agents-toggle") {
|
|
49588
|
+
if (!deps.runExternalAgentsCli) {
|
|
49589
|
+
sendForSpan({ type: "agents-toggle", ok: false, error: { code: "bridge_offline", detail: "external-agents is not configured on this bridge" } });
|
|
49590
|
+
return;
|
|
49591
|
+
}
|
|
49592
|
+
const handlerDeps = {
|
|
49593
|
+
run: deps.runExternalAgentsCli,
|
|
49594
|
+
registryEnvNames: externalAgentsRegistryEnvNames,
|
|
49595
|
+
lastKnownState: externalAgentsLastKnownState
|
|
49596
|
+
};
|
|
49597
|
+
const req = msg;
|
|
49598
|
+
const reply = await withPoolStateReread(
|
|
49599
|
+
handlerDeps,
|
|
49600
|
+
await handleAgentsToggle(handlerDeps, { id: req.id, enabled: req.enabled })
|
|
49601
|
+
);
|
|
49602
|
+
sendForSpan({ type: "agents-toggle", ...reply });
|
|
49603
|
+
return;
|
|
49604
|
+
}
|
|
49605
|
+
if (msg.type === "agents-add-model") {
|
|
49606
|
+
if (!deps.runExternalAgentsCli) {
|
|
49607
|
+
sendForSpan({ type: "agents-add-model", ok: false, error: { code: "bridge_offline", detail: "external-agents is not configured on this bridge" } });
|
|
49608
|
+
return;
|
|
49609
|
+
}
|
|
49610
|
+
const handlerDeps = {
|
|
49611
|
+
run: deps.runExternalAgentsCli,
|
|
49612
|
+
registryEnvNames: externalAgentsRegistryEnvNames,
|
|
49613
|
+
lastKnownState: externalAgentsLastKnownState
|
|
49614
|
+
};
|
|
49615
|
+
const req = msg;
|
|
49616
|
+
const reply = await withPoolStateReread(
|
|
49617
|
+
handlerDeps,
|
|
49618
|
+
await handleAgentsAddModel(handlerDeps, {
|
|
49619
|
+
id: req.id,
|
|
49620
|
+
provider: req.provider,
|
|
49621
|
+
model: req.model,
|
|
49622
|
+
url: req.url,
|
|
49623
|
+
env: req.env,
|
|
49624
|
+
...req.tier !== void 0 ? { tier: req.tier } : {},
|
|
49625
|
+
...req.tags !== void 0 ? { tags: req.tags } : {}
|
|
49626
|
+
})
|
|
49627
|
+
);
|
|
49628
|
+
sendForSpan({ type: "agents-add-model", ...reply });
|
|
49629
|
+
return;
|
|
49630
|
+
}
|
|
49631
|
+
if (msg.type === "agents-set-credential") {
|
|
49632
|
+
if (!deps.runExternalAgentsCli) {
|
|
49633
|
+
sendForSpan({ type: "agents-set-credential", ok: false, error: { code: "bridge_offline", detail: "external-agents is not configured on this bridge" } });
|
|
49634
|
+
return;
|
|
49635
|
+
}
|
|
49636
|
+
const handlerDeps = {
|
|
49637
|
+
run: deps.runExternalAgentsCli,
|
|
49638
|
+
registryEnvNames: externalAgentsRegistryEnvNames,
|
|
49639
|
+
lastKnownState: externalAgentsLastKnownState
|
|
49640
|
+
};
|
|
49641
|
+
const req = msg;
|
|
49642
|
+
const setCredResult = await handleAgentsSetCredential(handlerDeps, { env: req.env, value: req.value });
|
|
49643
|
+
if (setCredResult.ok) await probeAgentsUsingEnvVar(handlerDeps, req.env);
|
|
49644
|
+
const reply = await withPoolStateReread(handlerDeps, setCredResult);
|
|
49645
|
+
sendForSpan({ type: "agents-set-credential", ...reply });
|
|
49646
|
+
return;
|
|
49647
|
+
}
|
|
49648
|
+
if (msg.type === "agents-dispatch") {
|
|
49649
|
+
if (!deps.runExternalAgentsCli) {
|
|
49650
|
+
sendForSpan({ type: "agents-dispatch", ok: false, error: { code: "bridge_offline", detail: "external-agents is not configured on this bridge" } });
|
|
49651
|
+
return;
|
|
49652
|
+
}
|
|
49653
|
+
const handlerDeps = {
|
|
49654
|
+
run: deps.runExternalAgentsCli,
|
|
49655
|
+
registryEnvNames: externalAgentsRegistryEnvNames,
|
|
49656
|
+
lastKnownState: externalAgentsLastKnownState
|
|
49657
|
+
};
|
|
49658
|
+
const req = msg;
|
|
49659
|
+
const reply = await withPoolStateReread(
|
|
49660
|
+
handlerDeps,
|
|
49661
|
+
await handleAgentsDispatch(handlerDeps, {
|
|
49662
|
+
id: req.id,
|
|
49663
|
+
prompt: req.prompt,
|
|
49664
|
+
...req.transport !== void 0 ? { transport: req.transport } : {},
|
|
49665
|
+
...req.effort !== void 0 ? { effort: req.effort } : {}
|
|
49666
|
+
})
|
|
49667
|
+
);
|
|
49668
|
+
sendForSpan({ type: "agents-dispatch", ...reply });
|
|
49669
|
+
return;
|
|
49670
|
+
}
|
|
48686
49671
|
if (msg.type === "bootstrap") {
|
|
48687
49672
|
let models = null;
|
|
48688
49673
|
let rateLimits = null;
|
|
@@ -48948,7 +49933,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
48948
49933
|
thread.inFlight = true;
|
|
48949
49934
|
pendingTurnSessions.delete(directorSessionId);
|
|
48950
49935
|
thread.replay = createReplayBuffer({
|
|
48951
|
-
turnId: (0,
|
|
49936
|
+
turnId: (0, import_node_crypto8.randomUUID)(),
|
|
48952
49937
|
spanId,
|
|
48953
49938
|
...deps.retentionMs !== void 0 ? { retentionMs: deps.retentionMs } : {},
|
|
48954
49939
|
...deps.ackLingerMs !== void 0 ? { ackLingerMs: deps.ackLingerMs } : {}
|
|
@@ -49353,8 +50338,8 @@ async function startDirectorBridge() {
|
|
|
49353
50338
|
codexCwd: config2.codexCwd,
|
|
49354
50339
|
codexExecutable: config2.codexExecutable,
|
|
49355
50340
|
checkoutRegistry,
|
|
49356
|
-
worktreeRoot:
|
|
49357
|
-
locksDir:
|
|
50341
|
+
worktreeRoot: import_node_path18.default.join(config2.stateDir, "worktrees"),
|
|
50342
|
+
locksDir: import_node_path18.default.join(config2.stateDir, "locks"),
|
|
49358
50343
|
// Wire the executor server for code-execution runs. Each run gets its own app-server
|
|
49359
50344
|
// process at the run worktree, running UNRESTRICTED from the real ~/.codex (owner
|
|
49360
50345
|
// no-sandbox decision — auth + mrrlin MCP come from the operator config).
|
|
@@ -49390,13 +50375,13 @@ async function startDirectorBridge() {
|
|
|
49390
50375
|
// egressDomains is retained in the seam signature (verification-turn.ts still computes the
|
|
49391
50376
|
// env host) but no longer constrains anything — the executor is unrestricted.
|
|
49392
50377
|
startSandbox: async (_egressDomains) => {
|
|
49393
|
-
const cwd =
|
|
50378
|
+
const cwd = import_node_fs14.default.mkdtempSync(import_node_path18.default.join(import_node_os9.default.tmpdir(), "mrrlin-verify-"));
|
|
49394
50379
|
let handle;
|
|
49395
50380
|
try {
|
|
49396
50381
|
handle = await startExecutorServer({ worktree: cwd });
|
|
49397
50382
|
} catch (error51) {
|
|
49398
50383
|
try {
|
|
49399
|
-
|
|
50384
|
+
import_node_fs14.default.rmSync(cwd, { recursive: true, force: true });
|
|
49400
50385
|
} catch {
|
|
49401
50386
|
}
|
|
49402
50387
|
throw error51;
|
|
@@ -49407,7 +50392,7 @@ async function startDirectorBridge() {
|
|
|
49407
50392
|
dispose: () => {
|
|
49408
50393
|
handle.dispose();
|
|
49409
50394
|
try {
|
|
49410
|
-
|
|
50395
|
+
import_node_fs14.default.rmSync(cwd, { recursive: true, force: true });
|
|
49411
50396
|
} catch {
|
|
49412
50397
|
}
|
|
49413
50398
|
}
|
|
@@ -49435,7 +50420,7 @@ async function startDirectorBridge() {
|
|
|
49435
50420
|
};
|
|
49436
50421
|
const sessionSinks = createSessionSinkRegistry();
|
|
49437
50422
|
const tombstones = /* @__PURE__ */ new Map();
|
|
49438
|
-
const bridgeInstanceId = (0,
|
|
50423
|
+
const bridgeInstanceId = (0, import_node_crypto8.randomUUID)();
|
|
49439
50424
|
const asyncConsumerDeps = {
|
|
49440
50425
|
client,
|
|
49441
50426
|
runExclusive: wrappedTurnLock.runExclusive,
|
|
@@ -49589,7 +50574,7 @@ async function startDirectorBridge() {
|
|
|
49589
50574
|
fileUpdateInboxItem: async (projectSlug) => {
|
|
49590
50575
|
const body = selfUpdateHandle.updateInboxBody();
|
|
49591
50576
|
if (!body) return;
|
|
49592
|
-
const id = `II-MCPUPD-${(0,
|
|
50577
|
+
const id = `II-MCPUPD-${(0, import_node_crypto8.randomUUID)()}`;
|
|
49593
50578
|
try {
|
|
49594
50579
|
const row = await client.createInboxItem(projectSlug, { id, kind: "question", body });
|
|
49595
50580
|
process.stderr.write(
|
|
@@ -49610,12 +50595,15 @@ async function startDirectorBridge() {
|
|
|
49610
50595
|
`
|
|
49611
50596
|
);
|
|
49612
50597
|
}
|
|
49613
|
-
}
|
|
50598
|
+
},
|
|
50599
|
+
// External-agents control plane: the real spawn runner, with the EXTERNAL_AGENTS_CLI operator
|
|
50600
|
+
// escape hatch bound here (the handlers stay spawn-free and this is the only production seam).
|
|
50601
|
+
runExternalAgentsCli: (args, opts) => runExternalAgentsCli(args, { ...opts, envCliPath: process.env["EXTERNAL_AGENTS_CLI"] })
|
|
49614
50602
|
};
|
|
49615
50603
|
const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
|
|
49616
50604
|
let bridgeBinShaShort = "unknown00000";
|
|
49617
50605
|
try {
|
|
49618
|
-
bridgeBinShaShort =
|
|
50606
|
+
bridgeBinShaShort = import_node_crypto8.default.createHash("sha256").update(import_node_fs14.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
|
|
49619
50607
|
} catch {
|
|
49620
50608
|
}
|
|
49621
50609
|
attachBridgeWss(server, {
|
|
@@ -49744,8 +50732,8 @@ async function startDirectorBridge() {
|
|
|
49744
50732
|
enqueueRun(
|
|
49745
50733
|
() => runOrphanWorktreeSweep(client, {
|
|
49746
50734
|
checkoutRegistry,
|
|
49747
|
-
worktreeRoot:
|
|
49748
|
-
locksDir:
|
|
50735
|
+
worktreeRoot: import_node_path18.default.join(config2.stateDir, "worktrees"),
|
|
50736
|
+
locksDir: import_node_path18.default.join(config2.stateDir, "locks")
|
|
49749
50737
|
})
|
|
49750
50738
|
);
|
|
49751
50739
|
enqueueRun(async () => {
|
|
@@ -49985,7 +50973,7 @@ function timingSafeTokenEqual(provided, expected) {
|
|
|
49985
50973
|
const a = Buffer.from(provided);
|
|
49986
50974
|
const b = Buffer.from(expected);
|
|
49987
50975
|
if (a.length !== b.length) return false;
|
|
49988
|
-
return
|
|
50976
|
+
return import_node_crypto8.default.timingSafeEqual(a, b);
|
|
49989
50977
|
}
|
|
49990
50978
|
function readDispatchBody(req) {
|
|
49991
50979
|
return new Promise((resolve, reject) => {
|
|
@@ -50007,15 +50995,15 @@ function readDispatchBody(req) {
|
|
|
50007
50995
|
function readOrCreateBridgeToken(stateDir) {
|
|
50008
50996
|
const explicit = (process.env.MRRLIN_DIRECTOR_BRIDGE_TOKEN ?? "").trim();
|
|
50009
50997
|
if (explicit) return explicit;
|
|
50010
|
-
const tokenPath =
|
|
50998
|
+
const tokenPath = import_node_path18.default.join(stateDir, "token.txt");
|
|
50011
50999
|
try {
|
|
50012
|
-
const existing =
|
|
51000
|
+
const existing = import_node_fs14.default.readFileSync(tokenPath, "utf8").trim();
|
|
50013
51001
|
if (existing) return existing;
|
|
50014
51002
|
} catch {
|
|
50015
51003
|
}
|
|
50016
|
-
|
|
50017
|
-
const token =
|
|
50018
|
-
|
|
51004
|
+
import_node_fs14.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
|
|
51005
|
+
const token = import_node_crypto8.default.randomBytes(32).toString("base64url");
|
|
51006
|
+
import_node_fs14.default.writeFileSync(tokenPath, `${token}
|
|
50019
51007
|
`, { mode: 384 });
|
|
50020
51008
|
return token;
|
|
50021
51009
|
}
|
|
@@ -52588,7 +53576,7 @@ var Protocol = class {
|
|
|
52588
53576
|
};
|
|
52589
53577
|
}
|
|
52590
53578
|
};
|
|
52591
|
-
function
|
|
53579
|
+
function isPlainObject4(value) {
|
|
52592
53580
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
52593
53581
|
}
|
|
52594
53582
|
function mergeCapabilities(base, additional) {
|
|
@@ -52599,7 +53587,7 @@ function mergeCapabilities(base, additional) {
|
|
|
52599
53587
|
if (addValue === void 0)
|
|
52600
53588
|
continue;
|
|
52601
53589
|
const baseValue = result[k];
|
|
52602
|
-
if (
|
|
53590
|
+
if (isPlainObject4(baseValue) && isPlainObject4(addValue)) {
|
|
52603
53591
|
result[k] = { ...baseValue, ...addValue };
|
|
52604
53592
|
} else {
|
|
52605
53593
|
result[k] = addValue;
|
|
@@ -53397,19 +54385,19 @@ var StdioServerTransport = class {
|
|
|
53397
54385
|
};
|
|
53398
54386
|
|
|
53399
54387
|
// src/tools.ts
|
|
53400
|
-
var
|
|
54388
|
+
var import_node_crypto11 = require("node:crypto");
|
|
53401
54389
|
var import_promises3 = require("node:fs/promises");
|
|
53402
|
-
var
|
|
53403
|
-
var
|
|
53404
|
-
var
|
|
54390
|
+
var import_node_fs15 = require("node:fs");
|
|
54391
|
+
var import_node_path20 = __toESM(require("node:path"), 1);
|
|
54392
|
+
var import_node_os10 = __toESM(require("node:os"), 1);
|
|
53405
54393
|
var import_node_child_process12 = require("node:child_process");
|
|
53406
54394
|
|
|
53407
54395
|
// ../../packages/wiki/dist/index.js
|
|
53408
54396
|
var import_promises2 = __toESM(require("node:fs/promises"), 1);
|
|
53409
|
-
var
|
|
54397
|
+
var import_node_path19 = __toESM(require("node:path"), 1);
|
|
53410
54398
|
var INCLUDED_DOC_FOLDERS = /* @__PURE__ */ new Set(["_meta", "explanation", "how-to", "reference", "sdd", "tutorials"]);
|
|
53411
54399
|
function toPosixPath(input) {
|
|
53412
|
-
return input.split(
|
|
54400
|
+
return input.split(import_node_path19.default.sep).join("/");
|
|
53413
54401
|
}
|
|
53414
54402
|
function slugifyWikiSegment(input) {
|
|
53415
54403
|
return input.trim().toLowerCase().replace(/`/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -53423,12 +54411,12 @@ async function pathExists2(input) {
|
|
|
53423
54411
|
}
|
|
53424
54412
|
}
|
|
53425
54413
|
async function findWorkspaceRoot(start = process.cwd()) {
|
|
53426
|
-
let current =
|
|
54414
|
+
let current = import_node_path19.default.resolve(start);
|
|
53427
54415
|
while (true) {
|
|
53428
|
-
if (await pathExists2(
|
|
54416
|
+
if (await pathExists2(import_node_path19.default.join(current, "pnpm-workspace.yaml")) && await pathExists2(import_node_path19.default.join(current, "docs"))) {
|
|
53429
54417
|
return current;
|
|
53430
54418
|
}
|
|
53431
|
-
const parent =
|
|
54419
|
+
const parent = import_node_path19.default.dirname(current);
|
|
53432
54420
|
if (parent === current) {
|
|
53433
54421
|
throw new Error(`Unable to find Mrrlin workspace root from ${start}`);
|
|
53434
54422
|
}
|
|
@@ -53437,28 +54425,28 @@ async function findWorkspaceRoot(start = process.cwd()) {
|
|
|
53437
54425
|
}
|
|
53438
54426
|
async function resolveDocsRoot(input) {
|
|
53439
54427
|
if (input) {
|
|
53440
|
-
return
|
|
54428
|
+
return import_node_path19.default.resolve(input);
|
|
53441
54429
|
}
|
|
53442
54430
|
if (process.env.MRRLIN_DOCS_ROOT) {
|
|
53443
|
-
return
|
|
54431
|
+
return import_node_path19.default.resolve(process.env.MRRLIN_DOCS_ROOT);
|
|
53444
54432
|
}
|
|
53445
|
-
return
|
|
54433
|
+
return import_node_path19.default.join(await findWorkspaceRoot(), "docs");
|
|
53446
54434
|
}
|
|
53447
54435
|
async function resolveIndexPath(input) {
|
|
53448
54436
|
if (input) {
|
|
53449
|
-
return
|
|
54437
|
+
return import_node_path19.default.resolve(input);
|
|
53450
54438
|
}
|
|
53451
54439
|
if (process.env.MRRLIN_WIKI_INDEX_PATH) {
|
|
53452
|
-
return
|
|
54440
|
+
return import_node_path19.default.resolve(process.env.MRRLIN_WIKI_INDEX_PATH);
|
|
53453
54441
|
}
|
|
53454
54442
|
const workspaceRoot = await findWorkspaceRoot();
|
|
53455
|
-
return
|
|
54443
|
+
return import_node_path19.default.join(workspaceRoot, "apps", "web", "public", "wiki-index.json");
|
|
53456
54444
|
}
|
|
53457
54445
|
async function walkMarkdownFiles(root, dir = root) {
|
|
53458
54446
|
const entries = await import_promises2.default.readdir(dir, { withFileTypes: true });
|
|
53459
54447
|
const files = [];
|
|
53460
54448
|
for (const entry of entries) {
|
|
53461
|
-
const absolute =
|
|
54449
|
+
const absolute = import_node_path19.default.join(dir, entry.name);
|
|
53462
54450
|
if (entry.isDirectory()) {
|
|
53463
54451
|
files.push(...await walkMarkdownFiles(root, absolute));
|
|
53464
54452
|
continue;
|
|
@@ -53477,7 +54465,7 @@ function parseTitle(markdown, sourcePath) {
|
|
|
53477
54465
|
return title;
|
|
53478
54466
|
}
|
|
53479
54467
|
function documentFromFile(docsRoot, absolutePath, markdown) {
|
|
53480
|
-
const relativePath = toPosixPath(
|
|
54468
|
+
const relativePath = toPosixPath(import_node_path19.default.relative(docsRoot, absolutePath));
|
|
53481
54469
|
const [section, fileName] = relativePath.split("/");
|
|
53482
54470
|
if (!section || !fileName || !INCLUDED_DOC_FOLDERS.has(section)) {
|
|
53483
54471
|
return null;
|
|
@@ -54112,7 +55100,7 @@ async function resolveActiveRunHead(input, deps) {
|
|
|
54112
55100
|
}
|
|
54113
55101
|
|
|
54114
55102
|
// src/async-tools/consensus.ts
|
|
54115
|
-
var
|
|
55103
|
+
var import_node_crypto9 = require("node:crypto");
|
|
54116
55104
|
function normalizeClarificationQuestion(question) {
|
|
54117
55105
|
return question.replace(/\s+/g, " ").trim().replace(/[?.!]+$/, "").trim();
|
|
54118
55106
|
}
|
|
@@ -54289,9 +55277,9 @@ async function run(ctx, input) {
|
|
|
54289
55277
|
}
|
|
54290
55278
|
if (taskId) {
|
|
54291
55279
|
const scopeId = taskId;
|
|
54292
|
-
const groupId = clarifications.length > 1 ? `II-${scopeId}-gate-group-${(0,
|
|
55280
|
+
const groupId = clarifications.length > 1 ? `II-${scopeId}-gate-group-${(0, import_node_crypto9.createHash)("sha256").update(clarifications.map((c) => c.question).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
|
|
54293
55281
|
for (const clarification of clarifications) {
|
|
54294
|
-
const id = `II-${scopeId}-gate-${(0,
|
|
55282
|
+
const id = `II-${scopeId}-gate-${(0, import_node_crypto9.createHash)("sha256").update(clarification.question).digest("hex").slice(0, 10)}`;
|
|
54295
55283
|
try {
|
|
54296
55284
|
const questionOptions = buildGateQuestionOptions(clarification.question, clarification.category);
|
|
54297
55285
|
await ctx.client.createInboxItem(input.projectSlug, {
|
|
@@ -54309,9 +55297,9 @@ async function run(ctx, input) {
|
|
|
54309
55297
|
filedQuestionCount = clarifications.length;
|
|
54310
55298
|
} else if (planId) {
|
|
54311
55299
|
const scopeId = planId;
|
|
54312
|
-
const groupId = clarifications.length > 1 ? `II-${scopeId}-gate-group-${(0,
|
|
55300
|
+
const groupId = clarifications.length > 1 ? `II-${scopeId}-gate-group-${(0, import_node_crypto9.createHash)("sha256").update(clarifications.map((c) => c.question).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
|
|
54313
55301
|
for (const clarification of clarifications) {
|
|
54314
|
-
const id = `II-${scopeId}-gate-${(0,
|
|
55302
|
+
const id = `II-${scopeId}-gate-${(0, import_node_crypto9.createHash)("sha256").update(clarification.question).digest("hex").slice(0, 10)}`;
|
|
54315
55303
|
try {
|
|
54316
55304
|
const questionOptions = buildGateQuestionOptions(clarification.question, clarification.category);
|
|
54317
55305
|
await ctx.client.createInboxItem(input.projectSlug, {
|
|
@@ -54440,33 +55428,32 @@ async function run2(ctx, input) {
|
|
|
54440
55428
|
{ projectSlug: input.projectSlug, deliverablePageId: input.pageId },
|
|
54441
55429
|
deps
|
|
54442
55430
|
);
|
|
54443
|
-
|
|
54444
|
-
|
|
54445
|
-
case "SKIPPED":
|
|
54446
|
-
return { kind: "done", resultJson: JSON.stringify(result), finalReviewedHash: null };
|
|
54447
|
-
case "CONSENSUS_UNAVAILABLE":
|
|
54448
|
-
return { kind: "retry", failureReason: "provider_unavailable", error: "Deliverable consensus unavailable (provider/quota)." };
|
|
54449
|
-
case "DELIVERABLE_CHANGED_DURING_REVIEW":
|
|
54450
|
-
return { kind: "retry", failureReason: "spec_changed", error: "Deliverable changed during review." };
|
|
54451
|
-
case "MISSING_ACCEPTANCE_CRITERIA":
|
|
54452
|
-
return {
|
|
54453
|
-
kind: "failed",
|
|
54454
|
-
failureReason: "consensus_blocked",
|
|
54455
|
-
error: "Deliverable cannot be gated: the linked spec has no `## Acceptance criteria` checklist."
|
|
54456
|
-
};
|
|
54457
|
-
case "CONSENSUS_BLOCKED":
|
|
54458
|
-
return {
|
|
54459
|
-
kind: "failed",
|
|
54460
|
-
failureReason: "consensus_blocked",
|
|
54461
|
-
error: "Deliverable consensus blocked: reviewers did not converge against the acceptance criteria."
|
|
54462
|
-
};
|
|
54463
|
-
default:
|
|
54464
|
-
return {
|
|
54465
|
-
kind: "failed",
|
|
54466
|
-
failureReason: "provider_unavailable",
|
|
54467
|
-
error: `Unexpected deliverable consensus outcome: ${String(result.outcome)}`
|
|
54468
|
-
};
|
|
55431
|
+
if (result.outcome === "CONVERGED" || result.outcome === "SKIPPED") {
|
|
55432
|
+
return { kind: "done", resultJson: JSON.stringify(result), finalReviewedHash: null };
|
|
54469
55433
|
}
|
|
55434
|
+
const mapped = mapDeliverableGateResult(result);
|
|
55435
|
+
if (mapped.action === "retry") {
|
|
55436
|
+
return {
|
|
55437
|
+
kind: "retry",
|
|
55438
|
+
failureReason: result.outcome === "CONSENSUS_UNAVAILABLE" ? "provider_unavailable" : "spec_changed",
|
|
55439
|
+
error: mapped.reason
|
|
55440
|
+
};
|
|
55441
|
+
}
|
|
55442
|
+
let filedQuestionCount = 0;
|
|
55443
|
+
if (mapped.action === "questions") {
|
|
55444
|
+
const page = await ctx.client.getWikiPage(input.projectSlug, input.pageId);
|
|
55445
|
+
const taskId = page?.taskId ?? null;
|
|
55446
|
+
if (taskId) {
|
|
55447
|
+
filedQuestionCount = await fileDeliverableGateQuestions(ctx.client, input.projectSlug, taskId, mapped.clarifications);
|
|
55448
|
+
}
|
|
55449
|
+
}
|
|
55450
|
+
const error51 = filedQuestionCount > 0 ? `Consensus blocked on ${filedQuestionCount} clarification(s); filed as operator question(s).` : mapped.reason;
|
|
55451
|
+
return {
|
|
55452
|
+
kind: "failed",
|
|
55453
|
+
failureReason: "consensus_blocked",
|
|
55454
|
+
error: error51,
|
|
55455
|
+
filedQuestionCount
|
|
55456
|
+
};
|
|
54470
55457
|
}
|
|
54471
55458
|
function onComplete3(outcome, input) {
|
|
54472
55459
|
if (outcome.kind === "done") {
|
|
@@ -54486,6 +55473,14 @@ function onComplete3(outcome, input) {
|
|
|
54486
55473
|
body: `Deliverable consensus CONVERGED for Deliverables/${input.pageId}; it meets the acceptance criteria.`
|
|
54487
55474
|
};
|
|
54488
55475
|
}
|
|
55476
|
+
if (outcome.kind === "failed" && (outcome.filedQuestionCount ?? 0) > 0) {
|
|
55477
|
+
const n = outcome.filedQuestionCount ?? 0;
|
|
55478
|
+
return {
|
|
55479
|
+
kind: "info",
|
|
55480
|
+
suppressInbox: true,
|
|
55481
|
+
body: `Deliverable consensus blocked on Deliverables/${input.pageId}; filed ${n} clarifying question${n === 1 ? "" : "s"} \u2014 answer to unblock the run.`
|
|
55482
|
+
};
|
|
55483
|
+
}
|
|
54489
55484
|
return {
|
|
54490
55485
|
kind: "handoff",
|
|
54491
55486
|
body: `Deliverable consensus could not complete for Deliverables/${input.pageId}: ${outcome.error} Needs operator attention.`
|
|
@@ -54501,7 +55496,7 @@ var deliverableConsensusDescriptor = {
|
|
|
54501
55496
|
};
|
|
54502
55497
|
|
|
54503
55498
|
// src/async-tools/enqueue.ts
|
|
54504
|
-
var
|
|
55499
|
+
var import_node_crypto10 = __toESM(require("node:crypto"), 1);
|
|
54505
55500
|
async function enqueueAsyncTool(client, descriptor2, input) {
|
|
54506
55501
|
if (descriptor2.cachedResult) {
|
|
54507
55502
|
const cached2 = await descriptor2.cachedResult(client, input);
|
|
@@ -54514,7 +55509,7 @@ async function enqueueAsyncTool(client, descriptor2, input) {
|
|
|
54514
55509
|
if (active) {
|
|
54515
55510
|
return { status: "already_running", jobId: active.id, message: "Already running; will notify in inbox." };
|
|
54516
55511
|
}
|
|
54517
|
-
const jobId = `AJ-${
|
|
55512
|
+
const jobId = `AJ-${import_node_crypto10.default.randomUUID()}`;
|
|
54518
55513
|
try {
|
|
54519
55514
|
await client.createAsyncJob(input.projectSlug, {
|
|
54520
55515
|
id: jobId,
|
|
@@ -54602,6 +55597,7 @@ var mcpToolNames = {
|
|
|
54602
55597
|
searchKnowledge: "search_knowledge",
|
|
54603
55598
|
updateExecutionRun: "update_execution_run",
|
|
54604
55599
|
upsertProjectSchedulerPolicy: "upsert_project_scheduler_policy",
|
|
55600
|
+
recordDeployWorkflow: "record_deploy_workflow",
|
|
54605
55601
|
updatePlan: "update_plan",
|
|
54606
55602
|
updateTask: "update_task",
|
|
54607
55603
|
resetDirectorThread: "reset_director_thread",
|
|
@@ -55179,6 +56175,13 @@ var appendExecutionArtifactInputSchema = runScopedSchema.merge(mrrlinExecutionAr
|
|
|
55179
56175
|
var recordProducedUrlInputSchema = runScopedSchema.merge(mrrlinProducedUrlPayloadSchema);
|
|
55180
56176
|
var getProjectSchedulerPolicyInputSchema = projectScopedSchema;
|
|
55181
56177
|
var upsertProjectSchedulerPolicyInputSchema = projectScopedSchema.merge(mrrlinProjectSchedulerPolicyUpsertSchema);
|
|
56178
|
+
var recordDeployWorkflowInputSchema = projectScopedSchema.extend({
|
|
56179
|
+
env: mrrlinDeployWorkflowEnvSchema,
|
|
56180
|
+
workflowId: external_exports.number().int().positive().nullable(),
|
|
56181
|
+
workflowPath: external_exports.string().nullable().optional(),
|
|
56182
|
+
reason: external_exports.string().nullable().optional(),
|
|
56183
|
+
state: mrrlinDeployWorkflowStateSchema.optional()
|
|
56184
|
+
});
|
|
55182
56185
|
var getSchedulerPendingTasksInputSchema = projectScopedSchema;
|
|
55183
56186
|
var wakeDirectorInputSchema = projectScopedSchema.merge(wakeDirectorRequestSchema.partial());
|
|
55184
56187
|
var uploadArtifactInputSchema = projectScopedSchema.merge(
|
|
@@ -55261,6 +56264,7 @@ var mcpToolInputSchemas = {
|
|
|
55261
56264
|
[mcpToolNames.searchKnowledge]: searchKnowledgeInputSchema,
|
|
55262
56265
|
[mcpToolNames.updateExecutionRun]: updateExecutionRunInputSchema,
|
|
55263
56266
|
[mcpToolNames.upsertProjectSchedulerPolicy]: upsertProjectSchedulerPolicyInputSchema,
|
|
56267
|
+
[mcpToolNames.recordDeployWorkflow]: recordDeployWorkflowInputSchema,
|
|
55264
56268
|
[mcpToolNames.updatePlan]: updatePlanInputSchema,
|
|
55265
56269
|
[mcpToolNames.updateTask]: updateTaskInputSchema,
|
|
55266
56270
|
[mcpToolNames.resetDirectorThread]: resetDirectorThreadInputSchema,
|
|
@@ -55323,6 +56327,7 @@ var mcpToolOperationIds = {
|
|
|
55323
56327
|
[mcpToolNames.searchKnowledge]: openApiOperationIds.searchKnowledge,
|
|
55324
56328
|
[mcpToolNames.updateExecutionRun]: openApiOperationIds.updateExecutionRun,
|
|
55325
56329
|
[mcpToolNames.upsertProjectSchedulerPolicy]: openApiOperationIds.upsertProjectSchedulerPolicy,
|
|
56330
|
+
[mcpToolNames.recordDeployWorkflow]: openApiOperationIds.upsertProjectDeployWorkflow,
|
|
55326
56331
|
[mcpToolNames.updatePlan]: openApiOperationIds.updatePlan,
|
|
55327
56332
|
[mcpToolNames.updateTask]: openApiOperationIds.updateTask,
|
|
55328
56333
|
[mcpToolNames.resetDirectorThread]: openApiOperationIds.resetDirectorThread,
|
|
@@ -55386,6 +56391,7 @@ var mcpToolDescriptions = {
|
|
|
55386
56391
|
[mcpToolNames.updateExecutionRun]: "Update an execution run (status, branch, SHA, PR url, dev/prod workflow ids, checkpoint cursor). Transitioning to handoff_queued requires an approved handoff_judgement artifact.",
|
|
55387
56392
|
[mcpToolNames.getProjectSchedulerPolicy]: "Fetch the project scheduler policy: cadence floor, eligible autonomy levels, and optional wake_floor. Returns defaults if unset.",
|
|
55388
56393
|
[mcpToolNames.upsertProjectSchedulerPolicy]: "Upsert the project scheduler policy. Partial: only provided fields overwrite existing values.",
|
|
56394
|
+
[mcpToolNames.recordDeployWorkflow]: "Record which GitHub Actions workflow deploys this project for one environment (dev or prod), after confirming it via list_github_workflows + reading its file for a workflow_dispatch trigger. Call this AT MOST ONCE per environment per project, only when the deploy gate has parked on a missing/stale workflow id \u2014 this choice becomes durable project state, not a per-run decision. Pass workflowId=null and state='ambiguous' when zero or more than one candidate is confirmed dispatchable; otherwise pass the single confirmed workflowId with state='resolved' (the default). `source` is derived from your identity server-side \u2014 you cannot set it, and this call is always recorded as 'agent'.",
|
|
55389
56395
|
[mcpToolNames.getSchedulerPendingTasks]: "Return tasks the scheduler should wake now: ones with follow_up_at or verification_due_at passed, or the policy wake_floor reached, filtered by eligible autonomy levels.",
|
|
55390
56396
|
[mcpToolNames.wakeDirector]: "Wake Director once for a project: optionally dry-run scheduler evaluation or enqueue execution runs best-effort.",
|
|
55391
56397
|
[mcpToolNames.listInboxItems]: "List operator-inbox items for a project. Optional filters: kind, status.",
|
|
@@ -55965,7 +56971,7 @@ function createMrrlinTools(options) {
|
|
|
55965
56971
|
"PRODUCED_URL_RECORD_FAILED",
|
|
55966
56972
|
"Unable to record produced URL.",
|
|
55967
56973
|
async (c, { projectSlug, runId, url: url2, label }) => {
|
|
55968
|
-
const id = `EA-pu-${(0,
|
|
56974
|
+
const id = `EA-pu-${(0, import_node_crypto11.randomBytes)(4).toString("hex")}`;
|
|
55969
56975
|
const payload = label ? { url: url2, label } : { url: url2 };
|
|
55970
56976
|
return await c.appendExecutionArtifact(projectSlug, runId, {
|
|
55971
56977
|
id,
|
|
@@ -55988,6 +56994,13 @@ function createMrrlinTools(options) {
|
|
|
55988
56994
|
"Unable to upsert project scheduler policy.",
|
|
55989
56995
|
async (c, { projectSlug, ...input }) => await c.upsertProjectSchedulerPolicy(projectSlug, input)
|
|
55990
56996
|
),
|
|
56997
|
+
[mcpToolNames.recordDeployWorkflow]: makeTool(
|
|
56998
|
+
client,
|
|
56999
|
+
mcpToolNames.recordDeployWorkflow,
|
|
57000
|
+
"DEPLOY_WORKFLOW_RECORD_FAILED",
|
|
57001
|
+
"Unable to record the project's deploy workflow choice.",
|
|
57002
|
+
async (c, { projectSlug, env, ...input }) => await c.upsertProjectDeployWorkflow(projectSlug, env, input)
|
|
57003
|
+
),
|
|
55991
57004
|
[mcpToolNames.getSchedulerPendingTasks]: makeTool(
|
|
55992
57005
|
client,
|
|
55993
57006
|
mcpToolNames.getSchedulerPendingTasks,
|
|
@@ -56032,7 +57045,7 @@ function createMrrlinTools(options) {
|
|
|
56032
57045
|
"ARTIFACT_FILE_UPLOAD_FAILED",
|
|
56033
57046
|
"Unable to upload artifact file.",
|
|
56034
57047
|
async (c, { projectSlug, path: filePath, class: artifactClass, taskId, runId, description }) => {
|
|
56035
|
-
const extension2 =
|
|
57048
|
+
const extension2 = import_node_path20.default.extname(filePath).toLowerCase();
|
|
56036
57049
|
const contentType = ARTIFACT_EXTENSION_TYPES[extension2];
|
|
56037
57050
|
if (!contentType) {
|
|
56038
57051
|
throw new McpToolCodedError(
|
|
@@ -56060,7 +57073,7 @@ function createMrrlinTools(options) {
|
|
|
56060
57073
|
"Artifact exceeds 5MB; split or summarize instead."
|
|
56061
57074
|
);
|
|
56062
57075
|
}
|
|
56063
|
-
const filename =
|
|
57076
|
+
const filename = import_node_path20.default.basename(filePath);
|
|
56064
57077
|
const created = await c.createArtifactFile(projectSlug, {
|
|
56065
57078
|
class: artifactClass,
|
|
56066
57079
|
contentType,
|
|
@@ -56143,7 +57156,7 @@ function createMrrlinTools(options) {
|
|
|
56143
57156
|
"Unable to register local checkout.",
|
|
56144
57157
|
async (_c, { projectSlug, path: checkoutPath, repo }) => {
|
|
56145
57158
|
const trimmedPath = checkoutPath.trim();
|
|
56146
|
-
if (!
|
|
57159
|
+
if (!import_node_path20.default.isAbsolute(trimmedPath)) {
|
|
56147
57160
|
throw new McpToolCodedError(
|
|
56148
57161
|
"LOCAL_CHECKOUT_PATH_NOT_ABSOLUTE",
|
|
56149
57162
|
`Path must be absolute, got: ${trimmedPath}`
|
|
@@ -56151,7 +57164,7 @@ function createMrrlinTools(options) {
|
|
|
56151
57164
|
}
|
|
56152
57165
|
let resolvedPath;
|
|
56153
57166
|
try {
|
|
56154
|
-
resolvedPath = (0,
|
|
57167
|
+
resolvedPath = (0, import_node_fs15.realpathSync)(trimmedPath);
|
|
56155
57168
|
} catch {
|
|
56156
57169
|
throw new McpToolCodedError(
|
|
56157
57170
|
"LOCAL_CHECKOUT_PATH_NOT_FOUND",
|
|
@@ -56178,7 +57191,7 @@ function createMrrlinTools(options) {
|
|
|
56178
57191
|
`Origin remote ${remoteUrl} does not match repo ${repo}.`
|
|
56179
57192
|
);
|
|
56180
57193
|
}
|
|
56181
|
-
const stateDir = process.env.CODEX_HOME ?
|
|
57194
|
+
const stateDir = process.env.CODEX_HOME ? import_node_path20.default.join(process.env.CODEX_HOME, "mrrlin", "director-bridge") : import_node_path20.default.join(import_node_os10.default.homedir(), ".mrrlin", "director-bridge");
|
|
56182
57195
|
const registry3 = new CheckoutRegistry(stateDir);
|
|
56183
57196
|
const confirmedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
56184
57197
|
registry3.confirm(projectSlug, resolvedPath, confirmedAt);
|
|
@@ -56400,8 +57413,8 @@ function runSetCredential(args) {
|
|
|
56400
57413
|
}
|
|
56401
57414
|
|
|
56402
57415
|
// src/install-service.ts
|
|
56403
|
-
var
|
|
56404
|
-
var
|
|
57416
|
+
var import_node_os11 = __toESM(require("node:os"), 1);
|
|
57417
|
+
var import_node_path21 = __toESM(require("node:path"), 1);
|
|
56405
57418
|
function installService(deps) {
|
|
56406
57419
|
if (!deps.hasSecret()) {
|
|
56407
57420
|
deps.log("No agent credential found. Issue one in Settings, then run: mrrlin-mcp set-credential '<secret>'.");
|
|
@@ -56412,7 +57425,7 @@ function installService(deps) {
|
|
|
56412
57425
|
deps.log(resolved.reason);
|
|
56413
57426
|
return { ok: false };
|
|
56414
57427
|
}
|
|
56415
|
-
const home = deps.env.HOME ??
|
|
57428
|
+
const home = deps.env.HOME ?? import_node_os11.default.homedir();
|
|
56416
57429
|
const bins = ["node", "codex", "mrrlin-mcp"].map((b) => deps.which(b));
|
|
56417
57430
|
if (bins.some((b) => !b)) {
|
|
56418
57431
|
deps.log("Could not resolve absolute paths for node/codex/mrrlin-mcp on PATH. Install them or fix PATH.");
|
|
@@ -56423,7 +57436,7 @@ function installService(deps) {
|
|
|
56423
57436
|
return { ok: false };
|
|
56424
57437
|
}
|
|
56425
57438
|
const resolvedBins = bins.filter((b) => b !== null);
|
|
56426
|
-
const pathEnv = Array.from(new Set(resolvedBins.map((b) =>
|
|
57439
|
+
const pathEnv = Array.from(new Set(resolvedBins.map((b) => import_node_path21.default.dirname(b)))).join(":");
|
|
56427
57440
|
const text = renderEcosystemConfig({
|
|
56428
57441
|
cwd: resolved.cwd,
|
|
56429
57442
|
home,
|
|
@@ -56432,7 +57445,7 @@ function installService(deps) {
|
|
|
56432
57445
|
staging: deps.env.MRRLIN_STAGING === "1",
|
|
56433
57446
|
apiBaseUrl: deps.env.MRRLIN_API_BASE_URL?.trim() || void 0
|
|
56434
57447
|
});
|
|
56435
|
-
const ecoPath =
|
|
57448
|
+
const ecoPath = import_node_path21.default.join(home, ".mrrlin", "ecosystem.config.cjs");
|
|
56436
57449
|
deps.writeFile(ecoPath, text);
|
|
56437
57450
|
const start = deps.runPm2(["startOrReload", ecoPath]);
|
|
56438
57451
|
if (start.code !== 0) {
|
|
@@ -56463,13 +57476,13 @@ function uninstallService(deps) {
|
|
|
56463
57476
|
|
|
56464
57477
|
// src/uninstall-codex.ts
|
|
56465
57478
|
var import_promises4 = __toESM(require("node:fs/promises"), 1);
|
|
56466
|
-
var
|
|
56467
|
-
var
|
|
57479
|
+
var import_node_os12 = __toESM(require("node:os"), 1);
|
|
57480
|
+
var import_node_path22 = __toESM(require("node:path"), 1);
|
|
56468
57481
|
var toml2 = __toESM(require_toml(), 1);
|
|
56469
57482
|
function resolveCodexHome2(options) {
|
|
56470
57483
|
if (options.codexHome) return options.codexHome;
|
|
56471
57484
|
if (process.env.CODEX_HOME) return process.env.CODEX_HOME;
|
|
56472
|
-
return
|
|
57485
|
+
return import_node_path22.default.join(options.homeDir ?? import_node_os12.default.homedir(), ".codex");
|
|
56473
57486
|
}
|
|
56474
57487
|
async function pathExists3(target) {
|
|
56475
57488
|
try {
|
|
@@ -56482,7 +57495,7 @@ async function pathExists3(target) {
|
|
|
56482
57495
|
var MRRLIN_BLOCK_RE = /(^|\n)\[mcp_servers\.(?:mrrlin(?:-browser)?|external-agents)(?:\]|\.[^\]\n]*\])[\s\S]*?(?=\n\[|$)/g;
|
|
56483
57496
|
async function uninstallCodex(options = {}) {
|
|
56484
57497
|
const codexHome = resolveCodexHome2(options);
|
|
56485
|
-
const configPath =
|
|
57498
|
+
const configPath = import_node_path22.default.join(codexHome, "config.toml");
|
|
56486
57499
|
const removePrompts = async () => uninstallPrompts(codexHome, options.promptNames ?? []);
|
|
56487
57500
|
if (!await pathExists3(configPath)) {
|
|
56488
57501
|
return { action: "missing", configPath, prompts: await removePrompts() };
|
|
@@ -56510,10 +57523,10 @@ async function uninstallCodex(options = {}) {
|
|
|
56510
57523
|
}
|
|
56511
57524
|
async function uninstallPrompts(codexHome, names) {
|
|
56512
57525
|
if (names.length === 0) return [];
|
|
56513
|
-
const promptsDir =
|
|
57526
|
+
const promptsDir = import_node_path22.default.join(codexHome, "prompts");
|
|
56514
57527
|
const out = [];
|
|
56515
57528
|
for (const name of names) {
|
|
56516
|
-
const promptPath =
|
|
57529
|
+
const promptPath = import_node_path22.default.join(promptsDir, `${name}.md`);
|
|
56517
57530
|
try {
|
|
56518
57531
|
await import_promises4.default.unlink(promptPath);
|
|
56519
57532
|
out.push({ name, action: "removed", promptPath });
|
|
@@ -56766,8 +57779,8 @@ async function main() {
|
|
|
56766
57779
|
}
|
|
56767
57780
|
}
|
|
56768
57781
|
try {
|
|
56769
|
-
const codexHome = process.env.CODEX_HOME ??
|
|
56770
|
-
(0,
|
|
57782
|
+
const codexHome = process.env.CODEX_HOME ?? import_node_path24.default.join(process.env.HOME ?? (0, import_node_os13.homedir)(), ".codex");
|
|
57783
|
+
(0, import_node_fs16.rmSync)(import_node_path24.default.join(codexHome, "prompts", "report-issue.md"), { force: true });
|
|
56771
57784
|
} catch {
|
|
56772
57785
|
}
|
|
56773
57786
|
return;
|
|
@@ -56797,8 +57810,8 @@ async function main() {
|
|
|
56797
57810
|
env: process.env,
|
|
56798
57811
|
cwd: process.cwd(),
|
|
56799
57812
|
writeFile: (p, c) => {
|
|
56800
|
-
(0,
|
|
56801
|
-
(0,
|
|
57813
|
+
(0, import_node_fs16.mkdirSync)(import_node_path24.default.dirname(p), { recursive: true, mode: 448 });
|
|
57814
|
+
(0, import_node_fs16.writeFileSync)(p, c, { mode: 384 });
|
|
56802
57815
|
},
|
|
56803
57816
|
runPm2: pm2Runner,
|
|
56804
57817
|
which: whichBin,
|
|
@@ -56815,35 +57828,35 @@ async function main() {
|
|
|
56815
57828
|
runPm2: (a) => ({ code: pm2Runner(a).code }),
|
|
56816
57829
|
removeFile: (p) => {
|
|
56817
57830
|
try {
|
|
56818
|
-
(0,
|
|
57831
|
+
(0, import_node_fs16.rmSync)(p, { force: true });
|
|
56819
57832
|
} catch {
|
|
56820
57833
|
}
|
|
56821
57834
|
},
|
|
56822
57835
|
purgeSecret: purge,
|
|
56823
57836
|
secretPath: agentCredentialPath(),
|
|
56824
57837
|
tokenPath: operatorTokenPath(),
|
|
56825
|
-
ecoPath:
|
|
57838
|
+
ecoPath: import_node_path24.default.join(process.env.HOME ?? (0, import_node_os13.homedir)(), ".mrrlin", "ecosystem.config.cjs"),
|
|
56826
57839
|
log: (m) => process.stderr.write(`[mrrlin-mcp uninstall-service] ${m}
|
|
56827
57840
|
`)
|
|
56828
57841
|
});
|
|
56829
57842
|
return;
|
|
56830
57843
|
}
|
|
56831
57844
|
case "uninstall": {
|
|
56832
|
-
const home = process.env.HOME ?? (0,
|
|
57845
|
+
const home = process.env.HOME ?? (0, import_node_os13.homedir)();
|
|
56833
57846
|
const log = (m) => process.stderr.write(`[mrrlin-mcp uninstall] ${m}
|
|
56834
57847
|
`);
|
|
56835
57848
|
uninstallService({
|
|
56836
57849
|
runPm2: (a) => ({ code: pm2Runner(a).code }),
|
|
56837
57850
|
removeFile: (p) => {
|
|
56838
57851
|
try {
|
|
56839
|
-
(0,
|
|
57852
|
+
(0, import_node_fs16.rmSync)(p, { force: true });
|
|
56840
57853
|
} catch {
|
|
56841
57854
|
}
|
|
56842
57855
|
},
|
|
56843
57856
|
purgeSecret: true,
|
|
56844
57857
|
secretPath: agentCredentialPath(),
|
|
56845
57858
|
tokenPath: operatorTokenPath(),
|
|
56846
|
-
ecoPath:
|
|
57859
|
+
ecoPath: import_node_path24.default.join(home, ".mrrlin", "ecosystem.config.cjs"),
|
|
56847
57860
|
log
|
|
56848
57861
|
});
|
|
56849
57862
|
let codexOk = true;
|
|
@@ -56863,7 +57876,7 @@ async function main() {
|
|
|
56863
57876
|
log(`codex config NOT modified: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
56864
57877
|
}
|
|
56865
57878
|
try {
|
|
56866
|
-
(0,
|
|
57879
|
+
(0, import_node_fs16.rmSync)(import_node_path24.default.join(home, ".mrrlin"), { recursive: true, force: true });
|
|
56867
57880
|
} catch {
|
|
56868
57881
|
}
|
|
56869
57882
|
log("removed ~/.mrrlin");
|
|
@@ -56904,7 +57917,7 @@ ${HELP_TEXT}`);
|
|
|
56904
57917
|
}
|
|
56905
57918
|
}
|
|
56906
57919
|
function resolveSelfBinPath() {
|
|
56907
|
-
return
|
|
57920
|
+
return import_node_path23.default.resolve(process.argv[1] ?? process.execPath);
|
|
56908
57921
|
}
|
|
56909
57922
|
main().catch((error51) => {
|
|
56910
57923
|
process.stderr.write(`mrrlin-mcp fatal error: ${error51 instanceof Error ? error51.message : String(error51)}
|