@mrrlin-dev/mcp 0.4.256 → 0.4.257
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 +130 -89
- 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");
|
|
@@ -105669,6 +105672,13 @@ function createOwnedSdkOperation(options) {
|
|
|
105669
105672
|
};
|
|
105670
105673
|
}
|
|
105671
105674
|
|
|
105675
|
+
// src/bridge-account-key.ts
|
|
105676
|
+
var import_node_crypto24 = require("node:crypto");
|
|
105677
|
+
init_dist();
|
|
105678
|
+
function bridgeAccountKey(principal) {
|
|
105679
|
+
return (0, import_node_crypto24.createHash)("sha256").update(canonLogin(principal)).digest("hex").slice(0, 16);
|
|
105680
|
+
}
|
|
105681
|
+
|
|
105672
105682
|
// src/bridge-scoped-run-read.ts
|
|
105673
105683
|
function createScopedRunRead(options) {
|
|
105674
105684
|
const stream = createOwnedStreamingFetch(options.scope, options.apiBaseUrl);
|
|
@@ -105714,11 +105724,11 @@ function bindScopedRunRead(client, read) {
|
|
|
105714
105724
|
var import_node_fs42 = __toESM(require("node:fs"), 1);
|
|
105715
105725
|
|
|
105716
105726
|
// src/executor-thread-instructions.ts
|
|
105717
|
-
var
|
|
105727
|
+
var import_node_crypto25 = require("node:crypto");
|
|
105718
105728
|
var import_node_fs23 = require("node:fs");
|
|
105719
105729
|
var import_node_path31 = require("node:path");
|
|
105720
105730
|
function instructionHash(instructions) {
|
|
105721
|
-
return (0,
|
|
105731
|
+
return (0, import_node_crypto25.createHash)("sha256").update(instructions ?? "").digest("hex").slice(0, 16);
|
|
105722
105732
|
}
|
|
105723
105733
|
var MAX_ENTRIES = 1e4;
|
|
105724
105734
|
function createExecutorThreadInstructionStore(path42, warn = (message) => process.stderr.write(`${message}
|
|
@@ -105776,7 +105786,7 @@ var import_node_http5 = __toESM(require("node:http"), 1);
|
|
|
105776
105786
|
var import_node_os28 = __toESM(require("node:os"), 1);
|
|
105777
105787
|
var import_node_path56 = __toESM(require("node:path"), 1);
|
|
105778
105788
|
var import_node_child_process32 = require("node:child_process");
|
|
105779
|
-
var
|
|
105789
|
+
var import_node_crypto40 = __toESM(require("node:crypto"), 1);
|
|
105780
105790
|
|
|
105781
105791
|
// src/turn-replay-buffer.ts
|
|
105782
105792
|
var DEFAULT_MAX_EVENTS = 2e3;
|
|
@@ -106260,7 +106270,7 @@ function createTurnLock() {
|
|
|
106260
106270
|
|
|
106261
106271
|
// src/self-update.ts
|
|
106262
106272
|
var import_node_child_process23 = require("node:child_process");
|
|
106263
|
-
var
|
|
106273
|
+
var import_node_crypto26 = require("node:crypto");
|
|
106264
106274
|
var import_node_fs25 = require("node:fs");
|
|
106265
106275
|
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
106266
106276
|
var import_semver3 = __toESM(require_semver2(), 1);
|
|
@@ -106568,7 +106578,7 @@ function readIntervalEnv(name, fallback) {
|
|
|
106568
106578
|
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
106569
106579
|
}
|
|
106570
106580
|
function sha2562(buf) {
|
|
106571
|
-
return (0,
|
|
106581
|
+
return (0, import_node_crypto26.createHash)("sha256").update(buf).digest("hex");
|
|
106572
106582
|
}
|
|
106573
106583
|
function startSelfUpdate(deps) {
|
|
106574
106584
|
const log2 = deps.log ?? (() => {
|
|
@@ -106864,7 +106874,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106864
106874
|
}
|
|
106865
106875
|
|
|
106866
106876
|
// src/_generated/version.ts
|
|
106867
|
-
var PKG_VERSION = "0.4.
|
|
106877
|
+
var PKG_VERSION = "0.4.257";
|
|
106868
106878
|
|
|
106869
106879
|
// src/bridge-allowed-origins.ts
|
|
106870
106880
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -106896,7 +106906,7 @@ function readDirectorBridgeAllowedOrigins(env = process.env) {
|
|
|
106896
106906
|
init_dist();
|
|
106897
106907
|
|
|
106898
106908
|
// src/receipt-signing.ts
|
|
106899
|
-
var
|
|
106909
|
+
var import_node_crypto27 = __toESM(require("node:crypto"), 1);
|
|
106900
106910
|
var FIXTURE_SIGNING_KEY_ID = "ed25519:fixture:default";
|
|
106901
106911
|
var FIXTURE_PRIVATE_KEY_BASE64 = "MC4CAQAwBQYDK2VwBCIEIFnZBWdVAlsGODDrzXF2wQxO4mBVB/AEos6tYJzg/C/+";
|
|
106902
106912
|
function canonicalizeJson2(obj) {
|
|
@@ -106917,7 +106927,7 @@ function canonicalBytes(obj) {
|
|
|
106917
106927
|
return Buffer.from(canonicalizeJson2(obj), "utf8");
|
|
106918
106928
|
}
|
|
106919
106929
|
function sha256Hex(data) {
|
|
106920
|
-
return
|
|
106930
|
+
return import_node_crypto27.default.createHash("sha256").update(data).digest("hex");
|
|
106921
106931
|
}
|
|
106922
106932
|
var LocalEd25519SigningProvider = class {
|
|
106923
106933
|
keyId;
|
|
@@ -106930,9 +106940,9 @@ var LocalEd25519SigningProvider = class {
|
|
|
106930
106940
|
if (options.privateKey) {
|
|
106931
106941
|
if (typeof options.privateKey === "string") {
|
|
106932
106942
|
if (options.privateKey.includes("-----BEGIN")) {
|
|
106933
|
-
this.privateKey =
|
|
106943
|
+
this.privateKey = import_node_crypto27.default.createPrivateKey(options.privateKey);
|
|
106934
106944
|
} else {
|
|
106935
|
-
this.privateKey =
|
|
106945
|
+
this.privateKey = import_node_crypto27.default.createPrivateKey({
|
|
106936
106946
|
key: Buffer.from(options.privateKey, "base64"),
|
|
106937
106947
|
format: "der",
|
|
106938
106948
|
type: "pkcs8"
|
|
@@ -106941,10 +106951,10 @@ var LocalEd25519SigningProvider = class {
|
|
|
106941
106951
|
} else {
|
|
106942
106952
|
this.privateKey = options.privateKey;
|
|
106943
106953
|
}
|
|
106944
|
-
const pub =
|
|
106954
|
+
const pub = import_node_crypto27.default.createPublicKey(this.privateKey);
|
|
106945
106955
|
this.publicKeyBase64 = pub.export({ type: "spki", format: "der" }).toString("base64");
|
|
106946
106956
|
} else {
|
|
106947
|
-
const pair =
|
|
106957
|
+
const pair = import_node_crypto27.default.generateKeyPairSync("ed25519");
|
|
106948
106958
|
this.privateKey = pair.privateKey;
|
|
106949
106959
|
this.publicKeyBase64 = pair.publicKey.export({ type: "spki", format: "der" }).toString("base64");
|
|
106950
106960
|
}
|
|
@@ -106967,7 +106977,7 @@ var LocalEd25519SigningProvider = class {
|
|
|
106967
106977
|
throw new Error(`KEY_COMPROMISED: signing key ${this.keyId} is compromised: ${this.compromiseReason}`);
|
|
106968
106978
|
}
|
|
106969
106979
|
const bytes3 = canonicalBytes(payload);
|
|
106970
|
-
const signature =
|
|
106980
|
+
const signature = import_node_crypto27.default.sign(null, bytes3, this.privateKey).toString("base64");
|
|
106971
106981
|
return {
|
|
106972
106982
|
keyId: this.keyId,
|
|
106973
106983
|
signature,
|
|
@@ -106978,8 +106988,8 @@ var LocalEd25519SigningProvider = class {
|
|
|
106978
106988
|
try {
|
|
106979
106989
|
const bytes3 = canonicalBytes(payload);
|
|
106980
106990
|
const sigBuffer = Buffer.from(signature, "base64");
|
|
106981
|
-
const pubKey = publicKeySpkiBase64 ?
|
|
106982
|
-
return
|
|
106991
|
+
const pubKey = publicKeySpkiBase64 ? import_node_crypto27.default.createPublicKey({ key: Buffer.from(publicKeySpkiBase64, "base64"), format: "der", type: "spki" }) : import_node_crypto27.default.createPublicKey(this.privateKey);
|
|
106992
|
+
return import_node_crypto27.default.verify(null, bytes3, pubKey, sigBuffer);
|
|
106983
106993
|
} catch {
|
|
106984
106994
|
return false;
|
|
106985
106995
|
}
|
|
@@ -106993,8 +107003,8 @@ function verifySettlementReceiptV2(receipt, publicKeyBase64) {
|
|
|
106993
107003
|
if (keyBuffer.length === 32) {
|
|
106994
107004
|
keyBuffer = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), keyBuffer]);
|
|
106995
107005
|
}
|
|
106996
|
-
const pubKey =
|
|
106997
|
-
return
|
|
107006
|
+
const pubKey = import_node_crypto27.default.createPublicKey({ key: keyBuffer, format: "der", type: "spki" });
|
|
107007
|
+
return import_node_crypto27.default.verify(null, bytes3, pubKey, sigBuffer);
|
|
106998
107008
|
} catch {
|
|
106999
107009
|
return false;
|
|
107000
107010
|
}
|
|
@@ -109448,7 +109458,7 @@ async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, ol
|
|
|
109448
109458
|
}
|
|
109449
109459
|
|
|
109450
109460
|
// src/telemetry/turn-aggregator.ts
|
|
109451
|
-
var
|
|
109461
|
+
var import_node_crypto28 = require("node:crypto");
|
|
109452
109462
|
var import_promises16 = require("node:fs/promises");
|
|
109453
109463
|
var import_node_path38 = require("node:path");
|
|
109454
109464
|
var BRIDGE_FILE_RE = /^bridge-(\d{4}-\d{2}-\d{2})\.jsonl$/;
|
|
@@ -109606,7 +109616,7 @@ async function foldClosedDays(stateDir, today) {
|
|
|
109606
109616
|
await (0, import_promises16.mkdir)(telemetryDir, { recursive: true });
|
|
109607
109617
|
for (const [slug, rows] of rowsByProject) {
|
|
109608
109618
|
const finalPath = (0, import_node_path38.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
|
|
109609
|
-
const tmpPath = `${finalPath}.tmp-${process.pid}-${(0,
|
|
109619
|
+
const tmpPath = `${finalPath}.tmp-${process.pid}-${(0, import_node_crypto28.randomBytes)(6).toString("hex")}`;
|
|
109610
109620
|
try {
|
|
109611
109621
|
await (0, import_promises16.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
|
|
109612
109622
|
await (0, import_promises16.rename)(tmpPath, finalPath);
|
|
@@ -109623,7 +109633,7 @@ var import_promises17 = require("node:fs/promises");
|
|
|
109623
109633
|
var import_node_path40 = require("node:path");
|
|
109624
109634
|
|
|
109625
109635
|
// src/telemetry/installation-id.ts
|
|
109626
|
-
var
|
|
109636
|
+
var import_node_crypto29 = require("node:crypto");
|
|
109627
109637
|
var import_node_fs28 = require("node:fs");
|
|
109628
109638
|
var import_node_path39 = require("node:path");
|
|
109629
109639
|
var FILE_NAME = "installation-id";
|
|
@@ -109638,7 +109648,7 @@ function resolveInstallationId(stateDir) {
|
|
|
109638
109648
|
id = (0, import_node_fs28.readFileSync)(path42, "utf8").trim();
|
|
109639
109649
|
if (!UUID2.test(id)) throw new Error("unusable");
|
|
109640
109650
|
} catch {
|
|
109641
|
-
id = (0,
|
|
109651
|
+
id = (0, import_node_crypto29.randomUUID)();
|
|
109642
109652
|
(0, import_node_fs28.mkdirSync)((0, import_node_path39.dirname)(path42), { recursive: true });
|
|
109643
109653
|
(0, import_node_fs28.writeFileSync)(path42, `${id}
|
|
109644
109654
|
`, "utf8");
|
|
@@ -109899,7 +109909,7 @@ function setSelectedProvider(value) {
|
|
|
109899
109909
|
// src/execution-consumer.ts
|
|
109900
109910
|
var import_node_perf_hooks = require("node:perf_hooks");
|
|
109901
109911
|
var import_node_child_process30 = require("node:child_process");
|
|
109902
|
-
var
|
|
109912
|
+
var import_node_crypto36 = __toESM(require("node:crypto"), 1);
|
|
109903
109913
|
var import_promises19 = require("node:fs/promises");
|
|
109904
109914
|
var import_node_os23 = require("node:os");
|
|
109905
109915
|
var import_node_path48 = __toESM(require("node:path"), 1);
|
|
@@ -109909,7 +109919,7 @@ init_client();
|
|
|
109909
109919
|
init_cli();
|
|
109910
109920
|
|
|
109911
109921
|
// src/drain-service/release.ts
|
|
109912
|
-
var
|
|
109922
|
+
var import_node_crypto35 = __toESM(require("node:crypto"), 1);
|
|
109913
109923
|
var import_node_fs35 = require("node:fs");
|
|
109914
109924
|
var import_node_path46 = require("node:path");
|
|
109915
109925
|
var UUID4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
@@ -109937,7 +109947,7 @@ function worktreeGitdir(checkout) {
|
|
|
109937
109947
|
function writeWorktreePin(worktreeRoot, checkout, owner, generation) {
|
|
109938
109948
|
const pin = {
|
|
109939
109949
|
v: 1,
|
|
109940
|
-
pinId:
|
|
109950
|
+
pinId: import_node_crypto35.default.randomUUID(),
|
|
109941
109951
|
supervisionId: checkId(owner.supervisionId, "supervision"),
|
|
109942
109952
|
projectSlug: owner.projectSlug,
|
|
109943
109953
|
runId: owner.runId,
|
|
@@ -109980,7 +109990,7 @@ function listWorktreePins(worktreeRoot) {
|
|
|
109980
109990
|
return out;
|
|
109981
109991
|
}
|
|
109982
109992
|
function pinDigest(pin) {
|
|
109983
|
-
return
|
|
109993
|
+
return import_node_crypto35.default.createHash("sha256").update(JSON.stringify(pin)).digest("hex");
|
|
109984
109994
|
}
|
|
109985
109995
|
function verifyWorktreePin(worktreeRoot, supervisionId) {
|
|
109986
109996
|
let pin;
|
|
@@ -112755,7 +112765,7 @@ function isBridgeGeneratedArtifact(artifact) {
|
|
|
112755
112765
|
return typeof payload === "object" && payload !== null && "event" in payload;
|
|
112756
112766
|
}
|
|
112757
112767
|
function newArtifactId() {
|
|
112758
|
-
return `EA-${
|
|
112768
|
+
return `EA-${import_node_crypto36.default.randomUUID()}`;
|
|
112759
112769
|
}
|
|
112760
112770
|
var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
|
|
112761
112771
|
function isBlastRadiusFloorPath(path42) {
|
|
@@ -113108,7 +113118,7 @@ async function readApprovedMixedCodeSpec(client, projectSlug, runId, runApproval
|
|
|
113108
113118
|
if (!matches(task)) throw changed();
|
|
113109
113119
|
const read = async () => {
|
|
113110
113120
|
const page = await client.getWikiPage(projectSlug, runApproval.specPageId);
|
|
113111
|
-
if (page.id !== runApproval.specPageId || page.folder !== "Specs" || page.taskId !== task.id || page.specReady !== true ||
|
|
113121
|
+
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
113122
|
throw changed();
|
|
113113
113123
|
}
|
|
113114
113124
|
const current2 = await client.getTask(projectSlug, task.id);
|
|
@@ -113354,7 +113364,7 @@ async function openDrainSupervision(client, supervisor, projectSlug, runId, leas
|
|
|
113354
113364
|
}));
|
|
113355
113365
|
await supervisor.relay(relayThrough(client)).catch((error51) => warn("drain_spool_relay_failed", error51));
|
|
113356
113366
|
if (!client.registerSupervision || !client.relayDrainStatement) return "refused";
|
|
113357
|
-
const nonce =
|
|
113367
|
+
const nonce = import_node_crypto36.default.randomBytes(24).toString("base64url");
|
|
113358
113368
|
let supervisionId;
|
|
113359
113369
|
try {
|
|
113360
113370
|
supervisionId = await client.registerSupervision(projectSlug, runId, leaseId, nonce);
|
|
@@ -113499,7 +113509,7 @@ async function driveRun(deps, projectSlug, runId, shutdown) {
|
|
|
113499
113509
|
return;
|
|
113500
113510
|
}
|
|
113501
113511
|
await deps.client.createInboxItem(projectSlug, {
|
|
113502
|
-
id: `II-${
|
|
113512
|
+
id: `II-${import_node_crypto36.default.randomUUID()}`,
|
|
113503
113513
|
kind: "handoff",
|
|
113504
113514
|
taskId: claimed.taskId,
|
|
113505
113515
|
body: `Execution run ${runId} was claimed but returned no leaseId. This indicates DB/API corruption and requires operator attention.`
|
|
@@ -115208,7 +115218,7 @@ ${coldClosureInstruction}` : workInstruction;
|
|
|
115208
115218
|
taskId: task.id,
|
|
115209
115219
|
runId,
|
|
115210
115220
|
outcome: "completed",
|
|
115211
|
-
nonce:
|
|
115221
|
+
nonce: import_node_crypto36.default.randomUUID(),
|
|
115212
115222
|
artifacts: []
|
|
115213
115223
|
}
|
|
115214
115224
|
);
|
|
@@ -115788,7 +115798,7 @@ ${lines2}`
|
|
|
115788
115798
|
taskId: task.id,
|
|
115789
115799
|
runId,
|
|
115790
115800
|
outcome: parsedResult.outcome,
|
|
115791
|
-
nonce:
|
|
115801
|
+
nonce: import_node_crypto36.default.randomUUID(),
|
|
115792
115802
|
artifacts: [
|
|
115793
115803
|
{
|
|
115794
115804
|
artifactId: pageId,
|
|
@@ -116218,7 +116228,7 @@ async function deliverLocalRun(deps, input) {
|
|
|
116218
116228
|
projectSlug,
|
|
116219
116229
|
taskId: task.id,
|
|
116220
116230
|
runId,
|
|
116221
|
-
idempotencyKey:
|
|
116231
|
+
idempotencyKey: import_node_crypto36.default.randomUUID(),
|
|
116222
116232
|
artifactId: artifact?.id ?? artifactId,
|
|
116223
116233
|
leaseId
|
|
116224
116234
|
});
|
|
@@ -116279,7 +116289,7 @@ async function deliverLocalRun(deps, input) {
|
|
|
116279
116289
|
taskId: task.id,
|
|
116280
116290
|
runId,
|
|
116281
116291
|
outcome: "completed",
|
|
116282
|
-
nonce:
|
|
116292
|
+
nonce: import_node_crypto36.default.randomUUID(),
|
|
116283
116293
|
artifacts: [{ artifactId: artifact?.id ?? artifactId, storageVersion: "1", contentHash, kind: "verification" }]
|
|
116284
116294
|
}
|
|
116285
116295
|
);
|
|
@@ -116651,7 +116661,7 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
|
|
|
116651
116661
|
}
|
|
116652
116662
|
try {
|
|
116653
116663
|
await deps.client.createInboxItem(projectSlug, {
|
|
116654
|
-
id: `II-${
|
|
116664
|
+
id: `II-${import_node_crypto36.default.randomUUID()}`,
|
|
116655
116665
|
kind: "handoff",
|
|
116656
116666
|
taskId: task.id,
|
|
116657
116667
|
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 +116696,7 @@ async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
|
|
|
116686
116696
|
}
|
|
116687
116697
|
try {
|
|
116688
116698
|
await deps.client.createInboxItem(projectSlug, {
|
|
116689
|
-
id: `II-${
|
|
116699
|
+
id: `II-${import_node_crypto36.default.randomUUID()}`,
|
|
116690
116700
|
kind: "handoff",
|
|
116691
116701
|
taskId: task.id,
|
|
116692
116702
|
body: `Execution run ${runId} for task ${task.id} (${task.title}) needs operator attention: ${reason}`
|
|
@@ -116890,7 +116900,7 @@ async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId
|
|
|
116890
116900
|
});
|
|
116891
116901
|
if (isRollbackReconciliation) return;
|
|
116892
116902
|
await deps.client.createInboxItem(projectSlug, {
|
|
116893
|
-
id: `II-${
|
|
116903
|
+
id: `II-${import_node_crypto36.default.randomUUID()}`,
|
|
116894
116904
|
kind: "handoff",
|
|
116895
116905
|
taskId: task.id,
|
|
116896
116906
|
body: `Deploy gate for run ${runId} (task ${task.id} \u2014 ${task.title}) needs operator attention: ${reason}`
|
|
@@ -116909,7 +116919,7 @@ function maxLeaseReclaims() {
|
|
|
116909
116919
|
}
|
|
116910
116920
|
|
|
116911
116921
|
// src/async-job-consumer.ts
|
|
116912
|
-
var
|
|
116922
|
+
var import_node_crypto37 = __toESM(require("node:crypto"), 1);
|
|
116913
116923
|
var import_promises20 = require("node:timers/promises");
|
|
116914
116924
|
init_dist();
|
|
116915
116925
|
init_dist2();
|
|
@@ -117250,7 +117260,7 @@ async function driveClaimableAsyncJob(deps, projectSlug, jobId, preClaimJob, sec
|
|
|
117250
117260
|
if (heartbeatPending) await heartbeatPending;
|
|
117251
117261
|
if (!checkOwnership()) return;
|
|
117252
117262
|
const requestedAt = elapsed();
|
|
117253
|
-
beginRequestId = reportAction ?
|
|
117263
|
+
beginRequestId = reportAction ? import_node_crypto37.default.randomUUID() : void 0;
|
|
117254
117264
|
const begun = reportAction && beginRequestId ? await retryReport({
|
|
117255
117265
|
action: "begin",
|
|
117256
117266
|
requestId: beginRequestId,
|
|
@@ -117359,7 +117369,7 @@ async function driveClaimableAsyncJob(deps, projectSlug, jobId, preClaimJob, sec
|
|
|
117359
117369
|
const delivery = descriptor2.onComplete(outcome, input, completionContext);
|
|
117360
117370
|
if (!delivery.suppressInbox) {
|
|
117361
117371
|
await deps.client.createInboxItem(projectSlug, {
|
|
117362
|
-
id: delivery.id ?? `II-${
|
|
117372
|
+
id: delivery.id ?? `II-${import_node_crypto37.default.randomUUID()}`,
|
|
117363
117373
|
kind: delivery.kind,
|
|
117364
117374
|
body: delivery.body,
|
|
117365
117375
|
...delivery.taskId ? { taskId: delivery.taskId } : {},
|
|
@@ -117418,13 +117428,13 @@ async function deriveRequestedHash(client, toolName2, input) {
|
|
|
117418
117428
|
if (input.requestedHash) return input.requestedHash;
|
|
117419
117429
|
if (toolName2 === "run_spec_consensus" && input.pageId) {
|
|
117420
117430
|
const page = await client.getWikiPage(input.projectSlug, input.pageId);
|
|
117421
|
-
return page.contentHash ??
|
|
117431
|
+
return page.contentHash ?? import_node_crypto37.default.createHash("sha256").update(page.markdownBody).digest("hex");
|
|
117422
117432
|
}
|
|
117423
117433
|
if (toolName2 === "draft_task_spec" && input.taskId) {
|
|
117424
117434
|
const task = await client.getTask(input.projectSlug, input.taskId);
|
|
117425
|
-
return task.updatedAt ??
|
|
117435
|
+
return task.updatedAt ?? import_node_crypto37.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
|
|
117426
117436
|
}
|
|
117427
|
-
return
|
|
117437
|
+
return import_node_crypto37.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
|
|
117428
117438
|
}
|
|
117429
117439
|
async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId), shutdown) {
|
|
117430
117440
|
if (shutdown?.aborted) return;
|
|
@@ -118092,7 +118102,7 @@ init_install_public_mcp();
|
|
|
118092
118102
|
|
|
118093
118103
|
// src/connections/oauth-callback.ts
|
|
118094
118104
|
var import_node_http3 = __toESM(require("node:http"), 1);
|
|
118095
|
-
var
|
|
118105
|
+
var import_node_crypto38 = __toESM(require("node:crypto"), 1);
|
|
118096
118106
|
var activeFlowsByConnectionId = /* @__PURE__ */ new Map();
|
|
118097
118107
|
function getOAuthFlow(connectionId) {
|
|
118098
118108
|
return activeFlowsByConnectionId.get(connectionId);
|
|
@@ -118116,7 +118126,7 @@ async function startOAuthFlow(options) {
|
|
|
118116
118126
|
authorizationGeneration: options.authorizationGeneration ?? 1
|
|
118117
118127
|
});
|
|
118118
118128
|
}
|
|
118119
|
-
const flowId =
|
|
118129
|
+
const flowId = import_node_crypto38.default.randomUUID();
|
|
118120
118130
|
const timeoutMs = options.timeoutMs ?? 10 * 60 * 1e3;
|
|
118121
118131
|
const createdAt = Date.now();
|
|
118122
118132
|
const expiresAt = createdAt + timeoutMs;
|
|
@@ -123547,7 +123557,7 @@ var import_node_tls = __toESM(require("node:tls"), 1);
|
|
|
123547
123557
|
var import_node_fs39 = __toESM(require("node:fs"), 1);
|
|
123548
123558
|
var import_node_os26 = __toESM(require("node:os"), 1);
|
|
123549
123559
|
var import_node_path53 = __toESM(require("node:path"), 1);
|
|
123550
|
-
var
|
|
123560
|
+
var import_node_crypto39 = __toESM(require("node:crypto"), 1);
|
|
123551
123561
|
var import_node_zlib2 = __toESM(require("node:zlib"), 1);
|
|
123552
123562
|
|
|
123553
123563
|
// src/verification-egress-policy.ts
|
|
@@ -123904,7 +123914,7 @@ function createBrokerSocketPath(runId, nonce, baseDirs = process.platform === "w
|
|
|
123904
123914
|
throw new Error(`BROKER_SOCKET_ERROR: no temp directory gives a socket path within ${MAX_UNIX_SOCKET_PATH_BYTES} bytes`);
|
|
123905
123915
|
}
|
|
123906
123916
|
async function createVerificationBrokerSession(options) {
|
|
123907
|
-
const nonce =
|
|
123917
|
+
const nonce = import_node_crypto39.default.randomBytes(16).toString("hex");
|
|
123908
123918
|
let createdDir = null;
|
|
123909
123919
|
let socketPath = options.socketPath;
|
|
123910
123920
|
if (!socketPath) {
|
|
@@ -125225,9 +125235,9 @@ function readCodexFallbackModels() {
|
|
|
125225
125235
|
return [...models.values()];
|
|
125226
125236
|
}
|
|
125227
125237
|
function selfUpdateInboxItemId(offeredVersion) {
|
|
125228
|
-
if (!offeredVersion) return `II-MCPUPD-${(0,
|
|
125238
|
+
if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto40.randomUUID)()}`;
|
|
125229
125239
|
if (/^[A-Za-z0-9._-]+$/.test(offeredVersion)) return `II-MCPUPD-${offeredVersion}`;
|
|
125230
|
-
const hash3 =
|
|
125240
|
+
const hash3 = import_node_crypto40.default.createHash("sha256").update(offeredVersion).digest("hex").slice(0, 10);
|
|
125231
125241
|
return `II-MCPUPD-${offeredVersion.replace(/[^A-Za-z0-9._-]/g, "-")}-${hash3}`;
|
|
125232
125242
|
}
|
|
125233
125243
|
function neutralCheckoutCwd(stateDir) {
|
|
@@ -125905,7 +125915,7 @@ async function recoverSingleLanding(client, checkoutPath, projectSlug, runId, re
|
|
|
125905
125915
|
return false;
|
|
125906
125916
|
}
|
|
125907
125917
|
const checkoutRealPath = import_node_fs42.default.realpathSync(checkoutPath);
|
|
125908
|
-
const currentCheckoutDigest =
|
|
125918
|
+
const currentCheckoutDigest = import_node_crypto40.default.createHash("sha256").update(checkoutRealPath).digest("hex");
|
|
125909
125919
|
if (git3.checkout_digest !== currentCheckoutDigest) {
|
|
125910
125920
|
return false;
|
|
125911
125921
|
}
|
|
@@ -126126,7 +126136,7 @@ function createBridgeRequestListener(opts) {
|
|
|
126126
126136
|
res.end(JSON.stringify({ ok: false, error: "Origin not allowed." }));
|
|
126127
126137
|
return;
|
|
126128
126138
|
}
|
|
126129
|
-
const nonce =
|
|
126139
|
+
const nonce = import_node_crypto40.default.randomBytes(16).toString("base64url");
|
|
126130
126140
|
res.writeHead(200, { "content-type": "application/json" });
|
|
126131
126141
|
const publicHost = host === "0.0.0.0" ? "127.0.0.1" : host;
|
|
126132
126142
|
res.end(JSON.stringify({ ok: true, wsUrl: `ws://${publicHost}:${port}/ws`, token, nonce }));
|
|
@@ -126140,7 +126150,7 @@ function sessionIdOf(msg) {
|
|
|
126140
126150
|
return typeof id === "string" ? id : null;
|
|
126141
126151
|
}
|
|
126142
126152
|
function attachBridgeWss(server, opts) {
|
|
126143
|
-
const { token, allowedOrigins, onReady, logger, onPaired, bridgeInstanceId, selfUpdate, codex } = opts;
|
|
126153
|
+
const { token, allowedOrigins, onReady, logger, onPaired, bridgeInstanceId, selfUpdate, codex, getAccountKey } = opts;
|
|
126144
126154
|
const wss = new import_websocket_server.default({
|
|
126145
126155
|
server,
|
|
126146
126156
|
path: "/ws",
|
|
@@ -126214,6 +126224,10 @@ function attachBridgeWss(server, opts) {
|
|
|
126214
126224
|
type: "ready",
|
|
126215
126225
|
bridgeVersion: 1,
|
|
126216
126226
|
...bridgeInstanceId ? { bridgeInstanceId } : {},
|
|
126227
|
+
...(() => {
|
|
126228
|
+
const accountKey = getAccountKey?.() ?? null;
|
|
126229
|
+
return accountKey ? { accountKey } : {};
|
|
126230
|
+
})(),
|
|
126217
126231
|
...selfUpdate ? {
|
|
126218
126232
|
version: selfUpdate.version,
|
|
126219
126233
|
binSha: selfUpdate.binSha,
|
|
@@ -126423,7 +126437,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
126423
126437
|
}
|
|
126424
126438
|
}
|
|
126425
126439
|
socket.on("message", async (data) => {
|
|
126426
|
-
const spanId =
|
|
126440
|
+
const spanId = import_node_crypto40.default.randomUUID();
|
|
126427
126441
|
if (logCtx) {
|
|
126428
126442
|
logCtx.span.id = spanId;
|
|
126429
126443
|
logCtx.span.at = Date.now();
|
|
@@ -126904,7 +126918,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
126904
126918
|
let desiredInstructionHash = null;
|
|
126905
126919
|
try {
|
|
126906
126920
|
const startParams = deps.buildStartParams(msg, desiredModel);
|
|
126907
|
-
desiredInstructionHash =
|
|
126921
|
+
desiredInstructionHash = import_node_crypto40.default.createHash("sha256").update(startParams.baseInstructions ?? "").digest("hex");
|
|
126908
126922
|
if (!thread) {
|
|
126909
126923
|
const newThread = {
|
|
126910
126924
|
threadId: "",
|
|
@@ -126988,7 +127002,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
126988
127002
|
thread.inFlight = true;
|
|
126989
127003
|
pendingTurnSessions.delete(directorSessionId);
|
|
126990
127004
|
thread.replay = createReplayBuffer({
|
|
126991
|
-
turnId: (0,
|
|
127005
|
+
turnId: (0, import_node_crypto40.randomUUID)(),
|
|
126992
127006
|
spanId,
|
|
126993
127007
|
...deps.retentionMs !== void 0 ? { retentionMs: deps.retentionMs } : {},
|
|
126994
127008
|
...deps.ackLingerMs !== void 0 ? { ackLingerMs: deps.ackLingerMs } : {}
|
|
@@ -128171,7 +128185,7 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
|
|
|
128171
128185
|
};
|
|
128172
128186
|
const sessionSinks = createSessionSinkRegistry();
|
|
128173
128187
|
const tombstones = /* @__PURE__ */ new Map();
|
|
128174
|
-
const bridgeInstanceId = (0,
|
|
128188
|
+
const bridgeInstanceId = (0, import_node_crypto40.randomUUID)();
|
|
128175
128189
|
const boundReviewProject = process.env.MRRLIN_F37_REVIEW_WORKER_PROJECT?.trim();
|
|
128176
128190
|
const boundReviewSecret = process.env.MRRLIN_F37_REVIEW_WORKER_SECRET?.trim();
|
|
128177
128191
|
const boundReviewProvider = boundReviewProject && boundReviewSecret ? createAgentTokenProvider({ secret: boundReviewSecret, baseUrl: apiBaseUrl }) : void 0;
|
|
@@ -128536,10 +128550,18 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
|
|
|
128536
128550
|
const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
|
|
128537
128551
|
let bridgeBinShaShort = "unknown00000";
|
|
128538
128552
|
try {
|
|
128539
|
-
bridgeBinShaShort =
|
|
128553
|
+
bridgeBinShaShort = import_node_crypto40.default.createHash("sha256").update(import_node_fs42.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
|
|
128540
128554
|
} catch {
|
|
128541
128555
|
}
|
|
128556
|
+
let accountKey = null;
|
|
128557
|
+
if (tokenProvider) {
|
|
128558
|
+
void client.getMyAccount().then((account) => {
|
|
128559
|
+
accountKey = bridgeAccountKey(account.data.principal);
|
|
128560
|
+
}).catch(() => {
|
|
128561
|
+
});
|
|
128562
|
+
}
|
|
128542
128563
|
const bridgeWss = attachBridgeWss(server, {
|
|
128564
|
+
getAccountKey: () => accountKey,
|
|
128543
128565
|
token: config2.token,
|
|
128544
128566
|
allowedOrigins: config2.allowedOrigins,
|
|
128545
128567
|
host: config2.host,
|
|
@@ -129044,7 +129066,7 @@ function timingSafeTokenEqual(provided, expected) {
|
|
|
129044
129066
|
const a = Buffer.from(provided);
|
|
129045
129067
|
const b = Buffer.from(expected);
|
|
129046
129068
|
if (a.length !== b.length) return false;
|
|
129047
|
-
return
|
|
129069
|
+
return import_node_crypto40.default.timingSafeEqual(a, b);
|
|
129048
129070
|
}
|
|
129049
129071
|
function createWorkerDispatchListener(workerToken, driveRunNow, driveAsyncNow, shutdown) {
|
|
129050
129072
|
return (req, res) => {
|
|
@@ -129116,7 +129138,7 @@ function readOrCreateBridgeToken(stateDir) {
|
|
|
129116
129138
|
} catch {
|
|
129117
129139
|
}
|
|
129118
129140
|
import_node_fs42.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
|
|
129119
|
-
const token =
|
|
129141
|
+
const token = import_node_crypto40.default.randomBytes(32).toString("base64url");
|
|
129120
129142
|
import_node_fs42.default.writeFileSync(tokenPath, `${token}
|
|
129121
129143
|
`, { mode: 384 });
|
|
129122
129144
|
return token;
|
|
@@ -131344,7 +131366,9 @@ var CONNECT_EXIT = {
|
|
|
131344
131366
|
unsupportedOs: 4,
|
|
131345
131367
|
setupFailed: 5,
|
|
131346
131368
|
healthTimeout: 6,
|
|
131347
|
-
apiUnreachable: 7
|
|
131369
|
+
apiUnreachable: 7,
|
|
131370
|
+
/** The stored credential works and belongs to another Mrrlin account; nothing was changed. */
|
|
131371
|
+
otherAccount: 8
|
|
131348
131372
|
};
|
|
131349
131373
|
function spawnRedacted(command, args, opts, sinks) {
|
|
131350
131374
|
return new Promise((resolve4) => {
|
|
@@ -131394,7 +131418,7 @@ async function runConnect(argv, deps) {
|
|
|
131394
131418
|
const say = (message) => deps.log(`[mrrlin-mcp connect] ${message}`);
|
|
131395
131419
|
const code = parseCode(argv);
|
|
131396
131420
|
if (!code) {
|
|
131397
|
-
say("Usage: mrrlin-mcp connect --code <setup code>");
|
|
131421
|
+
say("Usage: mrrlin-mcp connect --code <setup code> [--switch-account]");
|
|
131398
131422
|
return 2;
|
|
131399
131423
|
}
|
|
131400
131424
|
const baseBody = {
|
|
@@ -131404,12 +131428,19 @@ async function runConnect(argv, deps) {
|
|
|
131404
131428
|
cliVersion: deps.cliVersion
|
|
131405
131429
|
};
|
|
131406
131430
|
const stored = deps.readSecret();
|
|
131431
|
+
const switchAccount = argv.includes("--switch-account");
|
|
131407
131432
|
let result;
|
|
131408
131433
|
try {
|
|
131409
131434
|
try {
|
|
131410
131435
|
result = await deps.redeem(stored ? { ...baseBody, credentialSecret: stored } : baseBody);
|
|
131411
131436
|
} catch (error51) {
|
|
131412
131437
|
if (!stored || !isUnauthorized(error51)) throw error51;
|
|
131438
|
+
if (!switchAccount && await deps.credentialStillWorks(stored) !== false) {
|
|
131439
|
+
say(
|
|
131440
|
+
"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."
|
|
131441
|
+
);
|
|
131442
|
+
return CONNECT_EXIT.otherAccount;
|
|
131443
|
+
}
|
|
131413
131444
|
result = await deps.redeem(baseBody);
|
|
131414
131445
|
}
|
|
131415
131446
|
} catch (error51) {
|
|
@@ -132130,6 +132161,16 @@ function realConnectDeps() {
|
|
|
132130
132161
|
readSecret: () => readAgentSecret(),
|
|
132131
132162
|
persistSecret: persistAgentSecret,
|
|
132132
132163
|
redeem: (body) => createMrrlinClient({ baseUrl: readConfiguredApiBaseUrl() }).redeemSetupCode(body),
|
|
132164
|
+
// The normal token exchange: true when the stored credential still authenticates, false when
|
|
132165
|
+
// the API refuses it, "unknown" when the check itself fails (connect then refuses to switch).
|
|
132166
|
+
credentialStillWorks: async (secret) => {
|
|
132167
|
+
try {
|
|
132168
|
+
await defaultExchange(secret, readConfiguredApiBaseUrl());
|
|
132169
|
+
return true;
|
|
132170
|
+
} catch (error51) {
|
|
132171
|
+
return error51 instanceof AgentTokenProviderError && error51.code === "REVOKED_OR_EXPIRED" ? false : "unknown";
|
|
132172
|
+
}
|
|
132173
|
+
},
|
|
132133
132174
|
spawn: async (args, o) => {
|
|
132134
132175
|
return spawnRedacted(
|
|
132135
132176
|
process.execPath,
|