@mrrlin-dev/mcp 0.4.256 → 0.4.258
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 +174 -108
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -17592,6 +17592,9 @@ var init_token_keys = __esm({
|
|
|
17592
17592
|
});
|
|
17593
17593
|
|
|
17594
17594
|
// ../../packages/schemas/dist/session.js
|
|
17595
|
+
function canonLogin(login) {
|
|
17596
|
+
return login.trim().replace(/^@/, "").toLowerCase();
|
|
17597
|
+
}
|
|
17595
17598
|
var sessionEmailSchema, operatorSessionSchema, WEB_SESSION_TTL_MS, WEB_SESSION_TTL_SECONDS, ENTITLEMENT_FRESHNESS_MS, AGENT_SESSION_TTL_MS;
|
|
17596
17599
|
var init_session = __esm({
|
|
17597
17600
|
"../../packages/schemas/dist/session.js"() {
|
|
@@ -68093,7 +68096,7 @@ var require_websocket2 = __commonJS({
|
|
|
68093
68096
|
var http6 = require("http");
|
|
68094
68097
|
var net11 = require("net");
|
|
68095
68098
|
var tls2 = require("tls");
|
|
68096
|
-
var { randomBytes: randomBytes6, createHash:
|
|
68099
|
+
var { randomBytes: randomBytes6, createHash: createHash15 } = require("crypto");
|
|
68097
68100
|
var { Duplex: Duplex2, Readable: Readable2 } = require("stream");
|
|
68098
68101
|
var { URL: URL2 } = require("url");
|
|
68099
68102
|
var PerMessageDeflate2 = require_permessage_deflate2();
|
|
@@ -68761,7 +68764,7 @@ var require_websocket2 = __commonJS({
|
|
|
68761
68764
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
68762
68765
|
return;
|
|
68763
68766
|
}
|
|
68764
|
-
const digest =
|
|
68767
|
+
const digest = createHash15("sha1").update(key + GUID).digest("base64");
|
|
68765
68768
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
68766
68769
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
68767
68770
|
return;
|
|
@@ -69130,7 +69133,7 @@ var require_websocket_server = __commonJS({
|
|
|
69130
69133
|
var EventEmitter4 = require("events");
|
|
69131
69134
|
var http6 = require("http");
|
|
69132
69135
|
var { Duplex: Duplex2 } = require("stream");
|
|
69133
|
-
var { createHash:
|
|
69136
|
+
var { createHash: createHash15 } = require("crypto");
|
|
69134
69137
|
var extension2 = require_extension();
|
|
69135
69138
|
var PerMessageDeflate2 = require_permessage_deflate2();
|
|
69136
69139
|
var subprotocol2 = require_subprotocol();
|
|
@@ -69437,7 +69440,7 @@ var require_websocket_server = __commonJS({
|
|
|
69437
69440
|
);
|
|
69438
69441
|
}
|
|
69439
69442
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
69440
|
-
const digest =
|
|
69443
|
+
const digest = createHash15("sha1").update(key + GUID).digest("base64");
|
|
69441
69444
|
const headers = [
|
|
69442
69445
|
"HTTP/1.1 101 Switching Protocols",
|
|
69443
69446
|
"Upgrade: websocket",
|
|
@@ -69639,7 +69642,7 @@ var init_install_linux = __esm({
|
|
|
69639
69642
|
|
|
69640
69643
|
// src/drain-service/journal.ts
|
|
69641
69644
|
function writeAtomic(dir, name, content) {
|
|
69642
|
-
const temp = (0, import_node_path41.join)(dir, `.${name}.${
|
|
69645
|
+
const temp = (0, import_node_path41.join)(dir, `.${name}.${import_node_crypto30.default.randomUUID()}.tmp`);
|
|
69643
69646
|
const fd = (0, import_node_fs30.openSync)(temp, "wx", 416);
|
|
69644
69647
|
try {
|
|
69645
69648
|
(0, import_node_fs30.writeSync)(fd, content);
|
|
@@ -69674,11 +69677,11 @@ function readSpool(spoolDir) {
|
|
|
69674
69677
|
}
|
|
69675
69678
|
return out;
|
|
69676
69679
|
}
|
|
69677
|
-
var
|
|
69680
|
+
var import_node_crypto30, import_node_fs30, import_node_path41, DrainJournal;
|
|
69678
69681
|
var init_journal = __esm({
|
|
69679
69682
|
"src/drain-service/journal.ts"() {
|
|
69680
69683
|
"use strict";
|
|
69681
|
-
|
|
69684
|
+
import_node_crypto30 = __toESM(require("node:crypto"), 1);
|
|
69682
69685
|
import_node_fs30 = require("node:fs");
|
|
69683
69686
|
import_node_path41 = require("node:path");
|
|
69684
69687
|
init_dist();
|
|
@@ -69992,7 +69995,7 @@ var init_client = __esm({
|
|
|
69992
69995
|
|
|
69993
69996
|
// src/drain-service/statements.ts
|
|
69994
69997
|
function generateDrainKey() {
|
|
69995
|
-
const { privateKey, publicKey } =
|
|
69998
|
+
const { privateKey, publicKey } = import_node_crypto31.default.generateKeyPairSync("ec", { namedCurve: "P-256" });
|
|
69996
69999
|
return {
|
|
69997
70000
|
privatePem: privateKey.export({ format: "pem", type: "pkcs8" }).toString(),
|
|
69998
70001
|
spkiBase64: publicKey.export({ format: "der", type: "spki" }).toString("base64")
|
|
@@ -70000,8 +70003,8 @@ function generateDrainKey() {
|
|
|
70000
70003
|
}
|
|
70001
70004
|
function signDrainStatement(privatePem, statement) {
|
|
70002
70005
|
const parsed = parseDrainStatement(statement);
|
|
70003
|
-
const signature =
|
|
70004
|
-
key:
|
|
70006
|
+
const signature = import_node_crypto31.default.sign("sha256", drainStatementSigningBytes(parsed), {
|
|
70007
|
+
key: import_node_crypto31.default.createPrivateKey(privatePem),
|
|
70005
70008
|
dsaEncoding: "ieee-p1363"
|
|
70006
70009
|
}).toString("base64url");
|
|
70007
70010
|
return { statement: parsed, signature };
|
|
@@ -70013,21 +70016,21 @@ function enrollmentSql(agentCredentialId, spkiBase64) {
|
|
|
70013
70016
|
if (!/^[A-Za-z0-9+/]+={0,2}$/.test(spkiBase64)) throw new Error("invalid SPKI encoding");
|
|
70014
70017
|
return `select mrrlin_private.enroll_drain_service('${agentCredentialId}', '${spkiBase64}');`;
|
|
70015
70018
|
}
|
|
70016
|
-
var
|
|
70019
|
+
var import_node_crypto31;
|
|
70017
70020
|
var init_statements = __esm({
|
|
70018
70021
|
"src/drain-service/statements.ts"() {
|
|
70019
70022
|
"use strict";
|
|
70020
|
-
|
|
70023
|
+
import_node_crypto31 = __toESM(require("node:crypto"), 1);
|
|
70021
70024
|
init_dist();
|
|
70022
70025
|
}
|
|
70023
70026
|
});
|
|
70024
70027
|
|
|
70025
70028
|
// src/drain-service/linux-service.ts
|
|
70026
|
-
var
|
|
70029
|
+
var import_node_crypto32, import_node_child_process26, import_node_fs32, import_node_net9, LinuxDrainService;
|
|
70027
70030
|
var init_linux_service = __esm({
|
|
70028
70031
|
"src/drain-service/linux-service.ts"() {
|
|
70029
70032
|
"use strict";
|
|
70030
|
-
|
|
70033
|
+
import_node_crypto32 = __toESM(require("node:crypto"), 1);
|
|
70031
70034
|
import_node_child_process26 = require("node:child_process");
|
|
70032
70035
|
import_node_fs32 = require("node:fs");
|
|
70033
70036
|
import_node_net9 = __toESM(require("node:net"), 1);
|
|
@@ -70049,7 +70052,7 @@ var init_linux_service = __esm({
|
|
|
70049
70052
|
}
|
|
70050
70053
|
this.journal = new DrainJournal(config2.journalDir, config2.spoolDir);
|
|
70051
70054
|
}
|
|
70052
|
-
instance = `svc-${
|
|
70055
|
+
instance = `svc-${import_node_crypto32.default.randomUUID().slice(0, 8)}`;
|
|
70053
70056
|
key;
|
|
70054
70057
|
journal;
|
|
70055
70058
|
active = /* @__PURE__ */ new Map();
|
|
@@ -70218,13 +70221,13 @@ var init_linux_service = __esm({
|
|
|
70218
70221
|
|
|
70219
70222
|
// src/drain-service/install-windows.ts
|
|
70220
70223
|
function serviceSid(name) {
|
|
70221
|
-
const hash3 =
|
|
70224
|
+
const hash3 = import_node_crypto33.default.createHash("sha1").update(Buffer.from(name.toUpperCase(), "utf16le")).digest();
|
|
70222
70225
|
const parts = [];
|
|
70223
70226
|
for (let offset = 0; offset < 20; offset += 4) parts.push(hash3.readUInt32LE(offset));
|
|
70224
70227
|
return `S-1-5-80-${parts.join("-")}`;
|
|
70225
70228
|
}
|
|
70226
70229
|
function generateWindowsDrainKey() {
|
|
70227
|
-
const { privateKey, publicKey } =
|
|
70230
|
+
const { privateKey, publicKey } = import_node_crypto33.default.generateKeyPairSync("ec", { namedCurve: "P-256" });
|
|
70228
70231
|
const jwk = privateKey.export({ format: "jwk" });
|
|
70229
70232
|
const header = Buffer.alloc(8);
|
|
70230
70233
|
header.writeUInt32LE(844317509, 0);
|
|
@@ -70338,11 +70341,11 @@ function defaultWindowsPaths(env, serviceName = WINDOWS_SERVICE) {
|
|
|
70338
70341
|
windowsDir: env.SystemRoot ?? env.windir ?? "C:\\Windows"
|
|
70339
70342
|
};
|
|
70340
70343
|
}
|
|
70341
|
-
var
|
|
70344
|
+
var import_node_crypto33, import_node_path43, WINDOWS_SERVICE, WINDOWS_PIPE, ADMINS, SYSTEM, SID, SERVICE_NAME, windowsConfigPath;
|
|
70342
70345
|
var init_install_windows = __esm({
|
|
70343
70346
|
"src/drain-service/install-windows.ts"() {
|
|
70344
70347
|
"use strict";
|
|
70345
|
-
|
|
70348
|
+
import_node_crypto33 = __toESM(require("node:crypto"), 1);
|
|
70346
70349
|
import_node_path43 = require("node:path");
|
|
70347
70350
|
WINDOWS_SERVICE = "MrrlinDrain";
|
|
70348
70351
|
WINDOWS_PIPE = "\\\\.\\pipe\\mrrlin-drain";
|
|
@@ -70413,8 +70416,8 @@ async function runWindowsVerify(out, version2) {
|
|
|
70413
70416
|
const env = process.env;
|
|
70414
70417
|
const paths = defaultWindowsPaths(env, CHECK_SERVICE);
|
|
70415
70418
|
const outDir = (0, import_node_path44.join)(paths.dataDir, "..", `${CHECK_SERVICE}-out`);
|
|
70416
|
-
const user = `mrrlinchk${
|
|
70417
|
-
const password = `Mc!${
|
|
70419
|
+
const user = `mrrlinchk${import_node_crypto34.default.randomBytes(3).toString("hex")}`;
|
|
70420
|
+
const password = `Mc!${import_node_crypto34.default.randomBytes(18).toString("base64url")}9a`;
|
|
70418
70421
|
const reportPath = (0, import_node_path44.join)(outDir, "report.json");
|
|
70419
70422
|
const cleanup = [];
|
|
70420
70423
|
let report = null;
|
|
@@ -70521,8 +70524,8 @@ function countMarker(marker) {
|
|
|
70521
70524
|
return Number(powershell(script).trim()) || 0;
|
|
70522
70525
|
}
|
|
70523
70526
|
function pingMarker() {
|
|
70524
|
-
const count2 = String(4e3 +
|
|
70525
|
-
const wait = String(1e3 +
|
|
70527
|
+
const count2 = String(4e3 + import_node_crypto34.default.randomInt(5e3));
|
|
70528
|
+
const wait = String(1e3 + import_node_crypto34.default.randomInt(9e3));
|
|
70526
70529
|
return { marker: `-n ${count2} -w ${wait} 127.0.0.1`, args: ["-n", count2, "-w", wait, "127.0.0.1"], count: count2 };
|
|
70527
70530
|
}
|
|
70528
70531
|
async function runVerifyClient(args, out, version2) {
|
|
@@ -70540,12 +70543,12 @@ async function runVerifyClient(args, out, version2) {
|
|
|
70540
70543
|
}
|
|
70541
70544
|
const expectedVersion = flag2("version") ?? version2;
|
|
70542
70545
|
const spki = (0, import_node_fs33.readFileSync)((0, import_node_path44.join)(outDir, "spki.txt"), "utf8").trim();
|
|
70543
|
-
const publicKey =
|
|
70546
|
+
const publicKey = import_node_crypto34.default.createPublicKey({ key: Buffer.from(spki, "base64"), format: "der", type: "spki" });
|
|
70544
70547
|
const elevated = () => isElevatedFromWhoami(run4(["whoami", "/groups"], { allowFail: true }));
|
|
70545
70548
|
const verifiedKind = (signed) => {
|
|
70546
70549
|
try {
|
|
70547
70550
|
const parsed = parseSignedDrainStatement(signed);
|
|
70548
|
-
const ok =
|
|
70551
|
+
const ok = import_node_crypto34.default.verify(
|
|
70549
70552
|
"sha256",
|
|
70550
70553
|
drainStatementSigningBytes(parsed.statement),
|
|
70551
70554
|
{ key: publicKey, dsaEncoding: "ieee-p1363" },
|
|
@@ -70558,13 +70561,13 @@ async function runVerifyClient(args, out, version2) {
|
|
|
70558
70561
|
};
|
|
70559
70562
|
const verifies = (signed) => verifiedKind(signed) !== null;
|
|
70560
70563
|
const open2 = (leaseRemainingMs = 6e5) => {
|
|
70561
|
-
const supervisionId =
|
|
70564
|
+
const supervisionId = import_node_crypto34.default.randomUUID();
|
|
70562
70565
|
return startDrainSupervision(pipe2, {
|
|
70563
70566
|
supervisionId,
|
|
70564
70567
|
projectSlug: "drain-check",
|
|
70565
70568
|
runId: `ER-${supervisionId.slice(0, 8)}`,
|
|
70566
70569
|
leaseId: "EL-check",
|
|
70567
|
-
nonce:
|
|
70570
|
+
nonce: import_node_crypto34.default.randomBytes(18).toString("base64url"),
|
|
70568
70571
|
leaseRemainingMs
|
|
70569
70572
|
}, { expectedVersion, elevated, timeoutMs: 3e4 });
|
|
70570
70573
|
};
|
|
@@ -70757,12 +70760,12 @@ async function runVerifyClient(args, out, version2) {
|
|
|
70757
70760
|
out.write("done\n");
|
|
70758
70761
|
return 0;
|
|
70759
70762
|
}
|
|
70760
|
-
var import_node_child_process27,
|
|
70763
|
+
var import_node_child_process27, import_node_crypto34, import_node_fs33, import_node_os21, import_node_path44, CHECK_SERVICE, CHECK_PIPE, UNKNOWN_RATE_LIMIT, CHARACTERIZATION_RUNS, EXPECTED_SCENARIOS, powershell, delay4;
|
|
70761
70764
|
var init_windows_verify = __esm({
|
|
70762
70765
|
"src/drain-service/windows-verify.ts"() {
|
|
70763
70766
|
"use strict";
|
|
70764
70767
|
import_node_child_process27 = require("node:child_process");
|
|
70765
|
-
|
|
70768
|
+
import_node_crypto34 = __toESM(require("node:crypto"), 1);
|
|
70766
70769
|
import_node_fs33 = require("node:fs");
|
|
70767
70770
|
import_node_os21 = require("node:os");
|
|
70768
70771
|
import_node_path44 = require("node:path");
|
|
@@ -70791,6 +70794,7 @@ var init_windows_verify = __esm({
|
|
|
70791
70794
|
var cli_exports = {};
|
|
70792
70795
|
__export(cli_exports, {
|
|
70793
70796
|
WINDOWS_DRAIN_VERIFIED: () => WINDOWS_DRAIN_VERIFIED,
|
|
70797
|
+
drainServiceEndpointFor: () => drainServiceEndpointFor,
|
|
70794
70798
|
drainServiceStatus: () => drainServiceStatus,
|
|
70795
70799
|
readDrainServiceEndpoint: () => readDrainServiceEndpoint,
|
|
70796
70800
|
runDrainServiceCli: () => runDrainServiceCli
|
|
@@ -70918,14 +70922,35 @@ Processes the provider starts outside the attempt tree (docker, pm2, user servic
|
|
|
70918
70922
|
`);
|
|
70919
70923
|
return 0;
|
|
70920
70924
|
}
|
|
70921
|
-
function
|
|
70922
|
-
|
|
70923
|
-
|
|
70924
|
-
|
|
70925
|
-
|
|
70926
|
-
|
|
70927
|
-
|
|
70925
|
+
function drainServiceEndpointFor(platform, readConfig, env = process.env) {
|
|
70926
|
+
const parse9 = (path42) => {
|
|
70927
|
+
const raw = readConfig(path42);
|
|
70928
|
+
if (raw === null) return null;
|
|
70929
|
+
try {
|
|
70930
|
+
const value = JSON.parse(raw);
|
|
70931
|
+
return value && typeof value === "object" ? value : null;
|
|
70932
|
+
} catch {
|
|
70933
|
+
return null;
|
|
70934
|
+
}
|
|
70935
|
+
};
|
|
70936
|
+
if (platform === "linux") {
|
|
70937
|
+
const config2 = parse9(CONFIG);
|
|
70938
|
+
return config2 && typeof config2.socketPath === "string" && typeof config2.spoolDir === "string" ? { socketPath: config2.socketPath, spoolDir: config2.spoolDir, elevated: sudoNonInteractiveSucceeds } : null;
|
|
70939
|
+
}
|
|
70940
|
+
if (platform === "win32" && WINDOWS_DRAIN_VERIFIED) {
|
|
70941
|
+
const config2 = parse9(windowsConfigPath(env));
|
|
70942
|
+
return config2 && typeof config2.pipeName === "string" && config2.pipeName.startsWith("\\\\.\\pipe\\") && typeof config2.spoolDir === "string" && /^[A-Za-z]:\\/.test(config2.spoolDir) ? { socketPath: config2.pipeName, spoolDir: config2.spoolDir, elevated: windowsIsElevated } : null;
|
|
70928
70943
|
}
|
|
70944
|
+
return null;
|
|
70945
|
+
}
|
|
70946
|
+
function readDrainServiceEndpoint() {
|
|
70947
|
+
return drainServiceEndpointFor(process.platform, (path42) => {
|
|
70948
|
+
try {
|
|
70949
|
+
return (0, import_node_fs34.existsSync)(path42) ? (0, import_node_fs34.readFileSync)(path42, "utf8") : null;
|
|
70950
|
+
} catch {
|
|
70951
|
+
return null;
|
|
70952
|
+
}
|
|
70953
|
+
});
|
|
70929
70954
|
}
|
|
70930
70955
|
async function drainServiceStatus(version2) {
|
|
70931
70956
|
if (process.platform === "win32") {
|
|
@@ -71175,7 +71200,7 @@ var init_cli = __esm({
|
|
|
71175
71200
|
PREFIX = "/opt/mrrlin-drain";
|
|
71176
71201
|
CONFIG = `${PREFIX}/config.json`;
|
|
71177
71202
|
UNIT = "/etc/systemd/system/mrrlin-drain.service";
|
|
71178
|
-
WINDOWS_DRAIN_VERIFIED =
|
|
71203
|
+
WINDOWS_DRAIN_VERIFIED = true;
|
|
71179
71204
|
}
|
|
71180
71205
|
});
|
|
71181
71206
|
|
|
@@ -105669,6 +105694,13 @@ function createOwnedSdkOperation(options) {
|
|
|
105669
105694
|
};
|
|
105670
105695
|
}
|
|
105671
105696
|
|
|
105697
|
+
// src/bridge-account-key.ts
|
|
105698
|
+
var import_node_crypto24 = require("node:crypto");
|
|
105699
|
+
init_dist();
|
|
105700
|
+
function bridgeAccountKey(principal) {
|
|
105701
|
+
return (0, import_node_crypto24.createHash)("sha256").update(canonLogin(principal)).digest("hex").slice(0, 16);
|
|
105702
|
+
}
|
|
105703
|
+
|
|
105672
105704
|
// src/bridge-scoped-run-read.ts
|
|
105673
105705
|
function createScopedRunRead(options) {
|
|
105674
105706
|
const stream = createOwnedStreamingFetch(options.scope, options.apiBaseUrl);
|
|
@@ -105714,11 +105746,11 @@ function bindScopedRunRead(client, read) {
|
|
|
105714
105746
|
var import_node_fs42 = __toESM(require("node:fs"), 1);
|
|
105715
105747
|
|
|
105716
105748
|
// src/executor-thread-instructions.ts
|
|
105717
|
-
var
|
|
105749
|
+
var import_node_crypto25 = require("node:crypto");
|
|
105718
105750
|
var import_node_fs23 = require("node:fs");
|
|
105719
105751
|
var import_node_path31 = require("node:path");
|
|
105720
105752
|
function instructionHash(instructions) {
|
|
105721
|
-
return (0,
|
|
105753
|
+
return (0, import_node_crypto25.createHash)("sha256").update(instructions ?? "").digest("hex").slice(0, 16);
|
|
105722
105754
|
}
|
|
105723
105755
|
var MAX_ENTRIES = 1e4;
|
|
105724
105756
|
function createExecutorThreadInstructionStore(path42, warn = (message) => process.stderr.write(`${message}
|
|
@@ -105776,7 +105808,7 @@ var import_node_http5 = __toESM(require("node:http"), 1);
|
|
|
105776
105808
|
var import_node_os28 = __toESM(require("node:os"), 1);
|
|
105777
105809
|
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
105778
105810
|
var import_node_child_process32 = require("node:child_process");
|
|
105779
|
-
var
|
|
105811
|
+
var import_node_crypto40 = __toESM(require("node:crypto"), 1);
|
|
105780
105812
|
|
|
105781
105813
|
// src/turn-replay-buffer.ts
|
|
105782
105814
|
var DEFAULT_MAX_EVENTS = 2e3;
|
|
@@ -106260,7 +106292,7 @@ function createTurnLock() {
|
|
|
106260
106292
|
|
|
106261
106293
|
// src/self-update.ts
|
|
106262
106294
|
var import_node_child_process23 = require("node:child_process");
|
|
106263
|
-
var
|
|
106295
|
+
var import_node_crypto26 = require("node:crypto");
|
|
106264
106296
|
var import_node_fs25 = require("node:fs");
|
|
106265
106297
|
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
106266
106298
|
var import_semver3 = __toESM(require_semver2(), 1);
|
|
@@ -106568,7 +106600,7 @@ function readIntervalEnv(name, fallback) {
|
|
|
106568
106600
|
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
106569
106601
|
}
|
|
106570
106602
|
function sha2562(buf) {
|
|
106571
|
-
return (0,
|
|
106603
|
+
return (0, import_node_crypto26.createHash)("sha256").update(buf).digest("hex");
|
|
106572
106604
|
}
|
|
106573
106605
|
function startSelfUpdate(deps) {
|
|
106574
106606
|
const log2 = deps.log ?? (() => {
|
|
@@ -106864,7 +106896,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106864
106896
|
}
|
|
106865
106897
|
|
|
106866
106898
|
// src/_generated/version.ts
|
|
106867
|
-
var PKG_VERSION = "0.4.
|
|
106899
|
+
var PKG_VERSION = "0.4.258";
|
|
106868
106900
|
|
|
106869
106901
|
// src/bridge-allowed-origins.ts
|
|
106870
106902
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -106896,7 +106928,7 @@ function readDirectorBridgeAllowedOrigins(env = process.env) {
|
|
|
106896
106928
|
init_dist();
|
|
106897
106929
|
|
|
106898
106930
|
// src/receipt-signing.ts
|
|
106899
|
-
var
|
|
106931
|
+
var import_node_crypto27 = __toESM(require("node:crypto"), 1);
|
|
106900
106932
|
var FIXTURE_SIGNING_KEY_ID = "ed25519:fixture:default";
|
|
106901
106933
|
var FIXTURE_PRIVATE_KEY_BASE64 = "MC4CAQAwBQYDK2VwBCIEIFnZBWdVAlsGODDrzXF2wQxO4mBVB/AEos6tYJzg/C/+";
|
|
106902
106934
|
function canonicalizeJson2(obj) {
|
|
@@ -106917,7 +106949,7 @@ function canonicalBytes(obj) {
|
|
|
106917
106949
|
return Buffer.from(canonicalizeJson2(obj), "utf8");
|
|
106918
106950
|
}
|
|
106919
106951
|
function sha256Hex(data) {
|
|
106920
|
-
return
|
|
106952
|
+
return import_node_crypto27.default.createHash("sha256").update(data).digest("hex");
|
|
106921
106953
|
}
|
|
106922
106954
|
var LocalEd25519SigningProvider = class {
|
|
106923
106955
|
keyId;
|
|
@@ -106930,9 +106962,9 @@ var LocalEd25519SigningProvider = class {
|
|
|
106930
106962
|
if (options.privateKey) {
|
|
106931
106963
|
if (typeof options.privateKey === "string") {
|
|
106932
106964
|
if (options.privateKey.includes("-----BEGIN")) {
|
|
106933
|
-
this.privateKey =
|
|
106965
|
+
this.privateKey = import_node_crypto27.default.createPrivateKey(options.privateKey);
|
|
106934
106966
|
} else {
|
|
106935
|
-
this.privateKey =
|
|
106967
|
+
this.privateKey = import_node_crypto27.default.createPrivateKey({
|
|
106936
106968
|
key: Buffer.from(options.privateKey, "base64"),
|
|
106937
106969
|
format: "der",
|
|
106938
106970
|
type: "pkcs8"
|
|
@@ -106941,10 +106973,10 @@ var LocalEd25519SigningProvider = class {
|
|
|
106941
106973
|
} else {
|
|
106942
106974
|
this.privateKey = options.privateKey;
|
|
106943
106975
|
}
|
|
106944
|
-
const pub =
|
|
106976
|
+
const pub = import_node_crypto27.default.createPublicKey(this.privateKey);
|
|
106945
106977
|
this.publicKeyBase64 = pub.export({ type: "spki", format: "der" }).toString("base64");
|
|
106946
106978
|
} else {
|
|
106947
|
-
const pair =
|
|
106979
|
+
const pair = import_node_crypto27.default.generateKeyPairSync("ed25519");
|
|
106948
106980
|
this.privateKey = pair.privateKey;
|
|
106949
106981
|
this.publicKeyBase64 = pair.publicKey.export({ type: "spki", format: "der" }).toString("base64");
|
|
106950
106982
|
}
|
|
@@ -106967,7 +106999,7 @@ var LocalEd25519SigningProvider = class {
|
|
|
106967
106999
|
throw new Error(`KEY_COMPROMISED: signing key ${this.keyId} is compromised: ${this.compromiseReason}`);
|
|
106968
107000
|
}
|
|
106969
107001
|
const bytes3 = canonicalBytes(payload);
|
|
106970
|
-
const signature =
|
|
107002
|
+
const signature = import_node_crypto27.default.sign(null, bytes3, this.privateKey).toString("base64");
|
|
106971
107003
|
return {
|
|
106972
107004
|
keyId: this.keyId,
|
|
106973
107005
|
signature,
|
|
@@ -106978,8 +107010,8 @@ var LocalEd25519SigningProvider = class {
|
|
|
106978
107010
|
try {
|
|
106979
107011
|
const bytes3 = canonicalBytes(payload);
|
|
106980
107012
|
const sigBuffer = Buffer.from(signature, "base64");
|
|
106981
|
-
const pubKey = publicKeySpkiBase64 ?
|
|
106982
|
-
return
|
|
107013
|
+
const pubKey = publicKeySpkiBase64 ? import_node_crypto27.default.createPublicKey({ key: Buffer.from(publicKeySpkiBase64, "base64"), format: "der", type: "spki" }) : import_node_crypto27.default.createPublicKey(this.privateKey);
|
|
107014
|
+
return import_node_crypto27.default.verify(null, bytes3, pubKey, sigBuffer);
|
|
106983
107015
|
} catch {
|
|
106984
107016
|
return false;
|
|
106985
107017
|
}
|
|
@@ -106993,8 +107025,8 @@ function verifySettlementReceiptV2(receipt, publicKeyBase64) {
|
|
|
106993
107025
|
if (keyBuffer.length === 32) {
|
|
106994
107026
|
keyBuffer = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), keyBuffer]);
|
|
106995
107027
|
}
|
|
106996
|
-
const pubKey =
|
|
106997
|
-
return
|
|
107028
|
+
const pubKey = import_node_crypto27.default.createPublicKey({ key: keyBuffer, format: "der", type: "spki" });
|
|
107029
|
+
return import_node_crypto27.default.verify(null, bytes3, pubKey, sigBuffer);
|
|
106998
107030
|
} catch {
|
|
106999
107031
|
return false;
|
|
107000
107032
|
}
|
|
@@ -109448,7 +109480,7 @@ async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, ol
|
|
|
109448
109480
|
}
|
|
109449
109481
|
|
|
109450
109482
|
// src/telemetry/turn-aggregator.ts
|
|
109451
|
-
var
|
|
109483
|
+
var import_node_crypto28 = require("node:crypto");
|
|
109452
109484
|
var import_promises16 = require("node:fs/promises");
|
|
109453
109485
|
var import_node_path38 = require("node:path");
|
|
109454
109486
|
var BRIDGE_FILE_RE = /^bridge-(\d{4}-\d{2}-\d{2})\.jsonl$/;
|
|
@@ -109606,7 +109638,7 @@ async function foldClosedDays(stateDir, today) {
|
|
|
109606
109638
|
await (0, import_promises16.mkdir)(telemetryDir, { recursive: true });
|
|
109607
109639
|
for (const [slug, rows] of rowsByProject) {
|
|
109608
109640
|
const finalPath = (0, import_node_path38.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
|
|
109609
|
-
const tmpPath = `${finalPath}.tmp-${process.pid}-${(0,
|
|
109641
|
+
const tmpPath = `${finalPath}.tmp-${process.pid}-${(0, import_node_crypto28.randomBytes)(6).toString("hex")}`;
|
|
109610
109642
|
try {
|
|
109611
109643
|
await (0, import_promises16.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
|
|
109612
109644
|
await (0, import_promises16.rename)(tmpPath, finalPath);
|
|
@@ -109623,7 +109655,7 @@ var import_promises17 = require("node:fs/promises");
|
|
|
109623
109655
|
var import_node_path40 = require("node:path");
|
|
109624
109656
|
|
|
109625
109657
|
// src/telemetry/installation-id.ts
|
|
109626
|
-
var
|
|
109658
|
+
var import_node_crypto29 = require("node:crypto");
|
|
109627
109659
|
var import_node_fs28 = require("node:fs");
|
|
109628
109660
|
var import_node_path39 = require("node:path");
|
|
109629
109661
|
var FILE_NAME = "installation-id";
|
|
@@ -109638,7 +109670,7 @@ function resolveInstallationId(stateDir) {
|
|
|
109638
109670
|
id = (0, import_node_fs28.readFileSync)(path42, "utf8").trim();
|
|
109639
109671
|
if (!UUID2.test(id)) throw new Error("unusable");
|
|
109640
109672
|
} catch {
|
|
109641
|
-
id = (0,
|
|
109673
|
+
id = (0, import_node_crypto29.randomUUID)();
|
|
109642
109674
|
(0, import_node_fs28.mkdirSync)((0, import_node_path39.dirname)(path42), { recursive: true });
|
|
109643
109675
|
(0, import_node_fs28.writeFileSync)(path42, `${id}
|
|
109644
109676
|
`, "utf8");
|
|
@@ -109899,7 +109931,7 @@ function setSelectedProvider(value) {
|
|
|
109899
109931
|
// src/execution-consumer.ts
|
|
109900
109932
|
var import_node_perf_hooks = require("node:perf_hooks");
|
|
109901
109933
|
var import_node_child_process30 = require("node:child_process");
|
|
109902
|
-
var
|
|
109934
|
+
var import_node_crypto36 = __toESM(require("node:crypto"), 1);
|
|
109903
109935
|
var import_promises19 = require("node:fs/promises");
|
|
109904
109936
|
var import_node_os23 = require("node:os");
|
|
109905
109937
|
var import_node_path48 = __toESM(require("node:path"), 1);
|
|
@@ -109909,7 +109941,7 @@ init_client();
|
|
|
109909
109941
|
init_cli();
|
|
109910
109942
|
|
|
109911
109943
|
// src/drain-service/release.ts
|
|
109912
|
-
var
|
|
109944
|
+
var import_node_crypto35 = __toESM(require("node:crypto"), 1);
|
|
109913
109945
|
var import_node_fs35 = require("node:fs");
|
|
109914
109946
|
var import_node_path46 = require("node:path");
|
|
109915
109947
|
var UUID4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
@@ -109937,7 +109969,7 @@ function worktreeGitdir(checkout) {
|
|
|
109937
109969
|
function writeWorktreePin(worktreeRoot, checkout, owner, generation) {
|
|
109938
109970
|
const pin = {
|
|
109939
109971
|
v: 1,
|
|
109940
|
-
pinId:
|
|
109972
|
+
pinId: import_node_crypto35.default.randomUUID(),
|
|
109941
109973
|
supervisionId: checkId(owner.supervisionId, "supervision"),
|
|
109942
109974
|
projectSlug: owner.projectSlug,
|
|
109943
109975
|
runId: owner.runId,
|
|
@@ -109980,7 +110012,7 @@ function listWorktreePins(worktreeRoot) {
|
|
|
109980
110012
|
return out;
|
|
109981
110013
|
}
|
|
109982
110014
|
function pinDigest(pin) {
|
|
109983
|
-
return
|
|
110015
|
+
return import_node_crypto35.default.createHash("sha256").update(JSON.stringify(pin)).digest("hex");
|
|
109984
110016
|
}
|
|
109985
110017
|
function verifyWorktreePin(worktreeRoot, supervisionId) {
|
|
109986
110018
|
let pin;
|
|
@@ -112755,7 +112787,7 @@ function isBridgeGeneratedArtifact(artifact) {
|
|
|
112755
112787
|
return typeof payload === "object" && payload !== null && "event" in payload;
|
|
112756
112788
|
}
|
|
112757
112789
|
function newArtifactId() {
|
|
112758
|
-
return `EA-${
|
|
112790
|
+
return `EA-${import_node_crypto36.default.randomUUID()}`;
|
|
112759
112791
|
}
|
|
112760
112792
|
var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
|
|
112761
112793
|
function isBlastRadiusFloorPath(path42) {
|
|
@@ -113108,7 +113140,7 @@ async function readApprovedMixedCodeSpec(client, projectSlug, runId, runApproval
|
|
|
113108
113140
|
if (!matches(task)) throw changed();
|
|
113109
113141
|
const read = async () => {
|
|
113110
113142
|
const page = await client.getWikiPage(projectSlug, runApproval.specPageId);
|
|
113111
|
-
if (page.id !== runApproval.specPageId || page.folder !== "Specs" || page.taskId !== task.id || page.specReady !== true ||
|
|
113143
|
+
if (page.id !== runApproval.specPageId || page.folder !== "Specs" || page.taskId !== task.id || page.specReady !== true || import_node_crypto36.default.createHash("sha256").update(page.markdownBody, "utf8").digest("hex") !== runApproval.specContentHash) {
|
|
113112
113144
|
throw changed();
|
|
113113
113145
|
}
|
|
113114
113146
|
const current2 = await client.getTask(projectSlug, task.id);
|
|
@@ -113332,7 +113364,7 @@ function defaultDrainSupervisor() {
|
|
|
113332
113364
|
if (!endpoint) return null;
|
|
113333
113365
|
return {
|
|
113334
113366
|
healthy: async () => (await drainServiceStatus(PKG_VERSION)).state === "healthy",
|
|
113335
|
-
start: (start) => startDrainSupervision(endpoint.socketPath, start, { expectedVersion: PKG_VERSION }),
|
|
113367
|
+
start: (start) => startDrainSupervision(endpoint.socketPath, start, { expectedVersion: PKG_VERSION, elevated: endpoint.elevated }),
|
|
113336
113368
|
relay: (relay) => relaySpool(endpoint.spoolDir, relay)
|
|
113337
113369
|
};
|
|
113338
113370
|
}
|
|
@@ -113354,7 +113386,7 @@ async function openDrainSupervision(client, supervisor, projectSlug, runId, leas
|
|
|
113354
113386
|
}));
|
|
113355
113387
|
await supervisor.relay(relayThrough(client)).catch((error51) => warn("drain_spool_relay_failed", error51));
|
|
113356
113388
|
if (!client.registerSupervision || !client.relayDrainStatement) return "refused";
|
|
113357
|
-
const nonce =
|
|
113389
|
+
const nonce = import_node_crypto36.default.randomBytes(24).toString("base64url");
|
|
113358
113390
|
let supervisionId;
|
|
113359
113391
|
try {
|
|
113360
113392
|
supervisionId = await client.registerSupervision(projectSlug, runId, leaseId, nonce);
|
|
@@ -113462,16 +113494,19 @@ function f54ProgressRequested(env = process.env) {
|
|
|
113462
113494
|
function resolveF54ProgressLease(containable, env = process.env) {
|
|
113463
113495
|
return f54ProgressRequested(env) && containable;
|
|
113464
113496
|
}
|
|
113465
|
-
async function claimIsContainable(deps, supervisor) {
|
|
113466
|
-
if (deps
|
|
113467
|
-
|
|
113468
|
-
|
|
113469
|
-
|
|
113470
|
-
|
|
113471
|
-
|
|
113472
|
-
|
|
113497
|
+
async function claimIsContainable(deps, supervisor, platform = process.platform) {
|
|
113498
|
+
if (await launcherContains(deps, platform)) return true;
|
|
113499
|
+
if (deps.verifyContainment && platform !== "win32") return false;
|
|
113500
|
+
return (platform === "linux" || platform === "win32") && supervisor !== null && await supervisor.healthy().catch(() => false);
|
|
113501
|
+
}
|
|
113502
|
+
async function launcherContains(deps, platform) {
|
|
113503
|
+
if (!deps.verifyContainment && platform !== "win32") return false;
|
|
113504
|
+
try {
|
|
113505
|
+
await (deps.verifyContainment ?? verifyOwnedExecutionContainment)();
|
|
113506
|
+
return true;
|
|
113507
|
+
} catch {
|
|
113508
|
+
return false;
|
|
113473
113509
|
}
|
|
113474
|
-
return process.platform === "linux" && supervisor !== null && await supervisor.healthy().catch(() => false);
|
|
113475
113510
|
}
|
|
113476
113511
|
async function driveRun(deps, projectSlug, runId, shutdown) {
|
|
113477
113512
|
if (shutdown?.aborted) return;
|
|
@@ -113499,7 +113534,7 @@ async function driveRun(deps, projectSlug, runId, shutdown) {
|
|
|
113499
113534
|
return;
|
|
113500
113535
|
}
|
|
113501
113536
|
await deps.client.createInboxItem(projectSlug, {
|
|
113502
|
-
id: `II-${
|
|
113537
|
+
id: `II-${import_node_crypto36.default.randomUUID()}`,
|
|
113503
113538
|
kind: "handoff",
|
|
113504
113539
|
taskId: claimed.taskId,
|
|
113505
113540
|
body: `Execution run ${runId} was claimed but returned no leaseId. This indicates DB/API corruption and requires operator attention.`
|
|
@@ -113522,7 +113557,7 @@ async function driveRun(deps, projectSlug, runId, shutdown) {
|
|
|
113522
113557
|
await releaseUnstartedClaim("drain_supervision_unavailable");
|
|
113523
113558
|
return;
|
|
113524
113559
|
}
|
|
113525
|
-
if (progressLease && !supervision && process.platform
|
|
113560
|
+
if (progressLease && !supervision && !await launcherContains(deps, process.platform)) {
|
|
113526
113561
|
await releaseUnstartedClaim("drain_supervision_unavailable");
|
|
113527
113562
|
return;
|
|
113528
113563
|
}
|
|
@@ -115208,7 +115243,7 @@ ${coldClosureInstruction}` : workInstruction;
|
|
|
115208
115243
|
taskId: task.id,
|
|
115209
115244
|
runId,
|
|
115210
115245
|
outcome: "completed",
|
|
115211
|
-
nonce:
|
|
115246
|
+
nonce: import_node_crypto36.default.randomUUID(),
|
|
115212
115247
|
artifacts: []
|
|
115213
115248
|
}
|
|
115214
115249
|
);
|
|
@@ -115788,7 +115823,7 @@ ${lines2}`
|
|
|
115788
115823
|
taskId: task.id,
|
|
115789
115824
|
runId,
|
|
115790
115825
|
outcome: parsedResult.outcome,
|
|
115791
|
-
nonce:
|
|
115826
|
+
nonce: import_node_crypto36.default.randomUUID(),
|
|
115792
115827
|
artifacts: [
|
|
115793
115828
|
{
|
|
115794
115829
|
artifactId: pageId,
|
|
@@ -116218,7 +116253,7 @@ async function deliverLocalRun(deps, input) {
|
|
|
116218
116253
|
projectSlug,
|
|
116219
116254
|
taskId: task.id,
|
|
116220
116255
|
runId,
|
|
116221
|
-
idempotencyKey:
|
|
116256
|
+
idempotencyKey: import_node_crypto36.default.randomUUID(),
|
|
116222
116257
|
artifactId: artifact?.id ?? artifactId,
|
|
116223
116258
|
leaseId
|
|
116224
116259
|
});
|
|
@@ -116279,7 +116314,7 @@ async function deliverLocalRun(deps, input) {
|
|
|
116279
116314
|
taskId: task.id,
|
|
116280
116315
|
runId,
|
|
116281
116316
|
outcome: "completed",
|
|
116282
|
-
nonce:
|
|
116317
|
+
nonce: import_node_crypto36.default.randomUUID(),
|
|
116283
116318
|
artifacts: [{ artifactId: artifact?.id ?? artifactId, storageVersion: "1", contentHash, kind: "verification" }]
|
|
116284
116319
|
}
|
|
116285
116320
|
);
|
|
@@ -116651,7 +116686,7 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
|
|
|
116651
116686
|
}
|
|
116652
116687
|
try {
|
|
116653
116688
|
await deps.client.createInboxItem(projectSlug, {
|
|
116654
|
-
id: `II-${
|
|
116689
|
+
id: `II-${import_node_crypto36.default.randomUUID()}`,
|
|
116655
116690
|
kind: "handoff",
|
|
116656
116691
|
taskId: task.id,
|
|
116657
116692
|
body: `Task ${task.id} (${task.title}) still needs operator follow-up: ${reason}. Mrrlin could not move the task back to Handoff needed automatically.`
|
|
@@ -116686,7 +116721,7 @@ async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
|
|
|
116686
116721
|
}
|
|
116687
116722
|
try {
|
|
116688
116723
|
await deps.client.createInboxItem(projectSlug, {
|
|
116689
|
-
id: `II-${
|
|
116724
|
+
id: `II-${import_node_crypto36.default.randomUUID()}`,
|
|
116690
116725
|
kind: "handoff",
|
|
116691
116726
|
taskId: task.id,
|
|
116692
116727
|
body: `Execution run ${runId} for task ${task.id} (${task.title}) needs operator attention: ${reason}`
|
|
@@ -116890,7 +116925,7 @@ async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId
|
|
|
116890
116925
|
});
|
|
116891
116926
|
if (isRollbackReconciliation) return;
|
|
116892
116927
|
await deps.client.createInboxItem(projectSlug, {
|
|
116893
|
-
id: `II-${
|
|
116928
|
+
id: `II-${import_node_crypto36.default.randomUUID()}`,
|
|
116894
116929
|
kind: "handoff",
|
|
116895
116930
|
taskId: task.id,
|
|
116896
116931
|
body: `Deploy gate for run ${runId} (task ${task.id} \u2014 ${task.title}) needs operator attention: ${reason}`
|
|
@@ -116909,7 +116944,7 @@ function maxLeaseReclaims() {
|
|
|
116909
116944
|
}
|
|
116910
116945
|
|
|
116911
116946
|
// src/async-job-consumer.ts
|
|
116912
|
-
var
|
|
116947
|
+
var import_node_crypto37 = __toESM(require("node:crypto"), 1);
|
|
116913
116948
|
var import_promises20 = require("node:timers/promises");
|
|
116914
116949
|
init_dist();
|
|
116915
116950
|
init_dist2();
|
|
@@ -117250,7 +117285,7 @@ async function driveClaimableAsyncJob(deps, projectSlug, jobId, preClaimJob, sec
|
|
|
117250
117285
|
if (heartbeatPending) await heartbeatPending;
|
|
117251
117286
|
if (!checkOwnership()) return;
|
|
117252
117287
|
const requestedAt = elapsed();
|
|
117253
|
-
beginRequestId = reportAction ?
|
|
117288
|
+
beginRequestId = reportAction ? import_node_crypto37.default.randomUUID() : void 0;
|
|
117254
117289
|
const begun = reportAction && beginRequestId ? await retryReport({
|
|
117255
117290
|
action: "begin",
|
|
117256
117291
|
requestId: beginRequestId,
|
|
@@ -117359,7 +117394,7 @@ async function driveClaimableAsyncJob(deps, projectSlug, jobId, preClaimJob, sec
|
|
|
117359
117394
|
const delivery = descriptor2.onComplete(outcome, input, completionContext);
|
|
117360
117395
|
if (!delivery.suppressInbox) {
|
|
117361
117396
|
await deps.client.createInboxItem(projectSlug, {
|
|
117362
|
-
id: delivery.id ?? `II-${
|
|
117397
|
+
id: delivery.id ?? `II-${import_node_crypto37.default.randomUUID()}`,
|
|
117363
117398
|
kind: delivery.kind,
|
|
117364
117399
|
body: delivery.body,
|
|
117365
117400
|
...delivery.taskId ? { taskId: delivery.taskId } : {},
|
|
@@ -117418,13 +117453,13 @@ async function deriveRequestedHash(client, toolName2, input) {
|
|
|
117418
117453
|
if (input.requestedHash) return input.requestedHash;
|
|
117419
117454
|
if (toolName2 === "run_spec_consensus" && input.pageId) {
|
|
117420
117455
|
const page = await client.getWikiPage(input.projectSlug, input.pageId);
|
|
117421
|
-
return page.contentHash ??
|
|
117456
|
+
return page.contentHash ?? import_node_crypto37.default.createHash("sha256").update(page.markdownBody).digest("hex");
|
|
117422
117457
|
}
|
|
117423
117458
|
if (toolName2 === "draft_task_spec" && input.taskId) {
|
|
117424
117459
|
const task = await client.getTask(input.projectSlug, input.taskId);
|
|
117425
|
-
return task.updatedAt ??
|
|
117460
|
+
return task.updatedAt ?? import_node_crypto37.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
|
|
117426
117461
|
}
|
|
117427
|
-
return
|
|
117462
|
+
return import_node_crypto37.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
|
|
117428
117463
|
}
|
|
117429
117464
|
async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId), shutdown) {
|
|
117430
117465
|
if (shutdown?.aborted) return;
|
|
@@ -118092,7 +118127,7 @@ init_install_public_mcp();
|
|
|
118092
118127
|
|
|
118093
118128
|
// src/connections/oauth-callback.ts
|
|
118094
118129
|
var import_node_http3 = __toESM(require("node:http"), 1);
|
|
118095
|
-
var
|
|
118130
|
+
var import_node_crypto38 = __toESM(require("node:crypto"), 1);
|
|
118096
118131
|
var activeFlowsByConnectionId = /* @__PURE__ */ new Map();
|
|
118097
118132
|
function getOAuthFlow(connectionId) {
|
|
118098
118133
|
return activeFlowsByConnectionId.get(connectionId);
|
|
@@ -118116,7 +118151,7 @@ async function startOAuthFlow(options) {
|
|
|
118116
118151
|
authorizationGeneration: options.authorizationGeneration ?? 1
|
|
118117
118152
|
});
|
|
118118
118153
|
}
|
|
118119
|
-
const flowId =
|
|
118154
|
+
const flowId = import_node_crypto38.default.randomUUID();
|
|
118120
118155
|
const timeoutMs = options.timeoutMs ?? 10 * 60 * 1e3;
|
|
118121
118156
|
const createdAt = Date.now();
|
|
118122
118157
|
const expiresAt = createdAt + timeoutMs;
|
|
@@ -123547,7 +123582,7 @@ var import_node_tls = __toESM(require("node:tls"), 1);
|
|
|
123547
123582
|
var import_node_fs39 = __toESM(require("node:fs"), 1);
|
|
123548
123583
|
var import_node_os26 = __toESM(require("node:os"), 1);
|
|
123549
123584
|
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
123550
|
-
var
|
|
123585
|
+
var import_node_crypto39 = __toESM(require("node:crypto"), 1);
|
|
123551
123586
|
var import_node_zlib2 = __toESM(require("node:zlib"), 1);
|
|
123552
123587
|
|
|
123553
123588
|
// src/verification-egress-policy.ts
|
|
@@ -123904,7 +123939,7 @@ function createBrokerSocketPath(runId, nonce, baseDirs = process.platform === "w
|
|
|
123904
123939
|
throw new Error(`BROKER_SOCKET_ERROR: no temp directory gives a socket path within ${MAX_UNIX_SOCKET_PATH_BYTES} bytes`);
|
|
123905
123940
|
}
|
|
123906
123941
|
async function createVerificationBrokerSession(options) {
|
|
123907
|
-
const nonce =
|
|
123942
|
+
const nonce = import_node_crypto39.default.randomBytes(16).toString("hex");
|
|
123908
123943
|
let createdDir = null;
|
|
123909
123944
|
let socketPath = options.socketPath;
|
|
123910
123945
|
if (!socketPath) {
|
|
@@ -125225,9 +125260,9 @@ function readCodexFallbackModels() {
|
|
|
125225
125260
|
return [...models.values()];
|
|
125226
125261
|
}
|
|
125227
125262
|
function selfUpdateInboxItemId(offeredVersion) {
|
|
125228
|
-
if (!offeredVersion) return `II-MCPUPD-${(0,
|
|
125263
|
+
if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto40.randomUUID)()}`;
|
|
125229
125264
|
if (/^[A-Za-z0-9._-]+$/.test(offeredVersion)) return `II-MCPUPD-${offeredVersion}`;
|
|
125230
|
-
const hash3 =
|
|
125265
|
+
const hash3 = import_node_crypto40.default.createHash("sha256").update(offeredVersion).digest("hex").slice(0, 10);
|
|
125231
125266
|
return `II-MCPUPD-${offeredVersion.replace(/[^A-Za-z0-9._-]/g, "-")}-${hash3}`;
|
|
125232
125267
|
}
|
|
125233
125268
|
function neutralCheckoutCwd(stateDir) {
|
|
@@ -125905,7 +125940,7 @@ async function recoverSingleLanding(client, checkoutPath, projectSlug, runId, re
|
|
|
125905
125940
|
return false;
|
|
125906
125941
|
}
|
|
125907
125942
|
const checkoutRealPath = import_node_fs42.default.realpathSync(checkoutPath);
|
|
125908
|
-
const currentCheckoutDigest =
|
|
125943
|
+
const currentCheckoutDigest = import_node_crypto40.default.createHash("sha256").update(checkoutRealPath).digest("hex");
|
|
125909
125944
|
if (git3.checkout_digest !== currentCheckoutDigest) {
|
|
125910
125945
|
return false;
|
|
125911
125946
|
}
|
|
@@ -126126,7 +126161,7 @@ function createBridgeRequestListener(opts) {
|
|
|
126126
126161
|
res.end(JSON.stringify({ ok: false, error: "Origin not allowed." }));
|
|
126127
126162
|
return;
|
|
126128
126163
|
}
|
|
126129
|
-
const nonce =
|
|
126164
|
+
const nonce = import_node_crypto40.default.randomBytes(16).toString("base64url");
|
|
126130
126165
|
res.writeHead(200, { "content-type": "application/json" });
|
|
126131
126166
|
const publicHost = host === "0.0.0.0" ? "127.0.0.1" : host;
|
|
126132
126167
|
res.end(JSON.stringify({ ok: true, wsUrl: `ws://${publicHost}:${port}/ws`, token, nonce }));
|
|
@@ -126140,7 +126175,7 @@ function sessionIdOf(msg) {
|
|
|
126140
126175
|
return typeof id === "string" ? id : null;
|
|
126141
126176
|
}
|
|
126142
126177
|
function attachBridgeWss(server, opts) {
|
|
126143
|
-
const { token, allowedOrigins, onReady, logger, onPaired, bridgeInstanceId, selfUpdate, codex } = opts;
|
|
126178
|
+
const { token, allowedOrigins, onReady, logger, onPaired, bridgeInstanceId, selfUpdate, codex, getAccountKey } = opts;
|
|
126144
126179
|
const wss = new import_websocket_server.default({
|
|
126145
126180
|
server,
|
|
126146
126181
|
path: "/ws",
|
|
@@ -126214,6 +126249,10 @@ function attachBridgeWss(server, opts) {
|
|
|
126214
126249
|
type: "ready",
|
|
126215
126250
|
bridgeVersion: 1,
|
|
126216
126251
|
...bridgeInstanceId ? { bridgeInstanceId } : {},
|
|
126252
|
+
...(() => {
|
|
126253
|
+
const accountKey = getAccountKey?.() ?? null;
|
|
126254
|
+
return accountKey ? { accountKey } : {};
|
|
126255
|
+
})(),
|
|
126217
126256
|
...selfUpdate ? {
|
|
126218
126257
|
version: selfUpdate.version,
|
|
126219
126258
|
binSha: selfUpdate.binSha,
|
|
@@ -126423,7 +126462,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
126423
126462
|
}
|
|
126424
126463
|
}
|
|
126425
126464
|
socket.on("message", async (data) => {
|
|
126426
|
-
const spanId =
|
|
126465
|
+
const spanId = import_node_crypto40.default.randomUUID();
|
|
126427
126466
|
if (logCtx) {
|
|
126428
126467
|
logCtx.span.id = spanId;
|
|
126429
126468
|
logCtx.span.at = Date.now();
|
|
@@ -126904,7 +126943,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
126904
126943
|
let desiredInstructionHash = null;
|
|
126905
126944
|
try {
|
|
126906
126945
|
const startParams = deps.buildStartParams(msg, desiredModel);
|
|
126907
|
-
desiredInstructionHash =
|
|
126946
|
+
desiredInstructionHash = import_node_crypto40.default.createHash("sha256").update(startParams.baseInstructions ?? "").digest("hex");
|
|
126908
126947
|
if (!thread) {
|
|
126909
126948
|
const newThread = {
|
|
126910
126949
|
threadId: "",
|
|
@@ -126988,7 +127027,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
126988
127027
|
thread.inFlight = true;
|
|
126989
127028
|
pendingTurnSessions.delete(directorSessionId);
|
|
126990
127029
|
thread.replay = createReplayBuffer({
|
|
126991
|
-
turnId: (0,
|
|
127030
|
+
turnId: (0, import_node_crypto40.randomUUID)(),
|
|
126992
127031
|
spanId,
|
|
126993
127032
|
...deps.retentionMs !== void 0 ? { retentionMs: deps.retentionMs } : {},
|
|
126994
127033
|
...deps.ackLingerMs !== void 0 ? { ackLingerMs: deps.ackLingerMs } : {}
|
|
@@ -128171,7 +128210,7 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
|
|
|
128171
128210
|
};
|
|
128172
128211
|
const sessionSinks = createSessionSinkRegistry();
|
|
128173
128212
|
const tombstones = /* @__PURE__ */ new Map();
|
|
128174
|
-
const bridgeInstanceId = (0,
|
|
128213
|
+
const bridgeInstanceId = (0, import_node_crypto40.randomUUID)();
|
|
128175
128214
|
const boundReviewProject = process.env.MRRLIN_F37_REVIEW_WORKER_PROJECT?.trim();
|
|
128176
128215
|
const boundReviewSecret = process.env.MRRLIN_F37_REVIEW_WORKER_SECRET?.trim();
|
|
128177
128216
|
const boundReviewProvider = boundReviewProject && boundReviewSecret ? createAgentTokenProvider({ secret: boundReviewSecret, baseUrl: apiBaseUrl }) : void 0;
|
|
@@ -128536,10 +128575,18 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
|
|
|
128536
128575
|
const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
|
|
128537
128576
|
let bridgeBinShaShort = "unknown00000";
|
|
128538
128577
|
try {
|
|
128539
|
-
bridgeBinShaShort =
|
|
128578
|
+
bridgeBinShaShort = import_node_crypto40.default.createHash("sha256").update(import_node_fs42.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
|
|
128540
128579
|
} catch {
|
|
128541
128580
|
}
|
|
128581
|
+
let accountKey = null;
|
|
128582
|
+
if (tokenProvider) {
|
|
128583
|
+
void client.getMyAccount().then((account) => {
|
|
128584
|
+
accountKey = bridgeAccountKey(account.data.principal);
|
|
128585
|
+
}).catch(() => {
|
|
128586
|
+
});
|
|
128587
|
+
}
|
|
128542
128588
|
const bridgeWss = attachBridgeWss(server, {
|
|
128589
|
+
getAccountKey: () => accountKey,
|
|
128543
128590
|
token: config2.token,
|
|
128544
128591
|
allowedOrigins: config2.allowedOrigins,
|
|
128545
128592
|
host: config2.host,
|
|
@@ -129044,7 +129091,7 @@ function timingSafeTokenEqual(provided, expected) {
|
|
|
129044
129091
|
const a = Buffer.from(provided);
|
|
129045
129092
|
const b = Buffer.from(expected);
|
|
129046
129093
|
if (a.length !== b.length) return false;
|
|
129047
|
-
return
|
|
129094
|
+
return import_node_crypto40.default.timingSafeEqual(a, b);
|
|
129048
129095
|
}
|
|
129049
129096
|
function createWorkerDispatchListener(workerToken, driveRunNow, driveAsyncNow, shutdown) {
|
|
129050
129097
|
return (req, res) => {
|
|
@@ -129116,7 +129163,7 @@ function readOrCreateBridgeToken(stateDir) {
|
|
|
129116
129163
|
} catch {
|
|
129117
129164
|
}
|
|
129118
129165
|
import_node_fs42.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
|
|
129119
|
-
const token =
|
|
129166
|
+
const token = import_node_crypto40.default.randomBytes(32).toString("base64url");
|
|
129120
129167
|
import_node_fs42.default.writeFileSync(tokenPath, `${token}
|
|
129121
129168
|
`, { mode: 384 });
|
|
129122
129169
|
return token;
|
|
@@ -131344,7 +131391,9 @@ var CONNECT_EXIT = {
|
|
|
131344
131391
|
unsupportedOs: 4,
|
|
131345
131392
|
setupFailed: 5,
|
|
131346
131393
|
healthTimeout: 6,
|
|
131347
|
-
apiUnreachable: 7
|
|
131394
|
+
apiUnreachable: 7,
|
|
131395
|
+
/** The stored credential works and belongs to another Mrrlin account; nothing was changed. */
|
|
131396
|
+
otherAccount: 8
|
|
131348
131397
|
};
|
|
131349
131398
|
function spawnRedacted(command, args, opts, sinks) {
|
|
131350
131399
|
return new Promise((resolve4) => {
|
|
@@ -131394,7 +131443,7 @@ async function runConnect(argv, deps) {
|
|
|
131394
131443
|
const say = (message) => deps.log(`[mrrlin-mcp connect] ${message}`);
|
|
131395
131444
|
const code = parseCode(argv);
|
|
131396
131445
|
if (!code) {
|
|
131397
|
-
say("Usage: mrrlin-mcp connect --code <setup code>");
|
|
131446
|
+
say("Usage: mrrlin-mcp connect --code <setup code> [--switch-account]");
|
|
131398
131447
|
return 2;
|
|
131399
131448
|
}
|
|
131400
131449
|
const baseBody = {
|
|
@@ -131404,12 +131453,19 @@ async function runConnect(argv, deps) {
|
|
|
131404
131453
|
cliVersion: deps.cliVersion
|
|
131405
131454
|
};
|
|
131406
131455
|
const stored = deps.readSecret();
|
|
131456
|
+
const switchAccount = argv.includes("--switch-account");
|
|
131407
131457
|
let result;
|
|
131408
131458
|
try {
|
|
131409
131459
|
try {
|
|
131410
131460
|
result = await deps.redeem(stored ? { ...baseBody, credentialSecret: stored } : baseBody);
|
|
131411
131461
|
} catch (error51) {
|
|
131412
131462
|
if (!stored || !isUnauthorized(error51)) throw error51;
|
|
131463
|
+
if (!switchAccount && await deps.credentialStillWorks(stored) !== false) {
|
|
131464
|
+
say(
|
|
131465
|
+
"This computer's Mrrlin helper is already connected to a Mrrlin account, and this setup code could not be added to it. Either the code has expired (ask Mrrlin for a new setup message), or it belongs to a different Mrrlin account. Connecting this computer to that account would disconnect the current one, and its work would stop on this computer. Ask the person first; if they confirm, run this command again with --switch-account."
|
|
131466
|
+
);
|
|
131467
|
+
return CONNECT_EXIT.otherAccount;
|
|
131468
|
+
}
|
|
131413
131469
|
result = await deps.redeem(baseBody);
|
|
131414
131470
|
}
|
|
131415
131471
|
} catch (error51) {
|
|
@@ -132130,6 +132186,16 @@ function realConnectDeps() {
|
|
|
132130
132186
|
readSecret: () => readAgentSecret(),
|
|
132131
132187
|
persistSecret: persistAgentSecret,
|
|
132132
132188
|
redeem: (body) => createMrrlinClient({ baseUrl: readConfiguredApiBaseUrl() }).redeemSetupCode(body),
|
|
132189
|
+
// The normal token exchange: true when the stored credential still authenticates, false when
|
|
132190
|
+
// the API refuses it, "unknown" when the check itself fails (connect then refuses to switch).
|
|
132191
|
+
credentialStillWorks: async (secret) => {
|
|
132192
|
+
try {
|
|
132193
|
+
await defaultExchange(secret, readConfiguredApiBaseUrl());
|
|
132194
|
+
return true;
|
|
132195
|
+
} catch (error51) {
|
|
132196
|
+
return error51 instanceof AgentTokenProviderError && error51.code === "REVOKED_OR_EXPIRED" ? false : "unknown";
|
|
132197
|
+
}
|
|
132198
|
+
},
|
|
132133
132199
|
spawn: async (args, o) => {
|
|
132134
132200
|
return spawnRedacted(
|
|
132135
132201
|
process.execPath,
|