@mrrlin-dev/mcp 0.4.15 → 0.4.17
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 +142 -96
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -6246,7 +6246,7 @@ var require_websocket = __commonJS({
|
|
|
6246
6246
|
var http2 = require("http");
|
|
6247
6247
|
var net = require("net");
|
|
6248
6248
|
var tls = require("tls");
|
|
6249
|
-
var { randomBytes:
|
|
6249
|
+
var { randomBytes: randomBytes5, createHash: createHash5 } = require("crypto");
|
|
6250
6250
|
var { Duplex, Readable } = require("stream");
|
|
6251
6251
|
var { URL: URL2 } = require("url");
|
|
6252
6252
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -6784,7 +6784,7 @@ var require_websocket = __commonJS({
|
|
|
6784
6784
|
}
|
|
6785
6785
|
}
|
|
6786
6786
|
const defaultPort = isSecure ? 443 : 80;
|
|
6787
|
-
const key =
|
|
6787
|
+
const key = randomBytes5(16).toString("base64");
|
|
6788
6788
|
const request = isSecure ? https.request : http2.request;
|
|
6789
6789
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
6790
6790
|
let perMessageDeflate;
|
|
@@ -21476,7 +21476,7 @@ var import_node_http = __toESM(require("node:http"), 1);
|
|
|
21476
21476
|
var import_node_os11 = __toESM(require("node:os"), 1);
|
|
21477
21477
|
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
21478
21478
|
var import_node_child_process15 = require("node:child_process");
|
|
21479
|
-
var
|
|
21479
|
+
var import_node_crypto10 = __toESM(require("node:crypto"), 1);
|
|
21480
21480
|
|
|
21481
21481
|
// src/turn-replay-buffer.ts
|
|
21482
21482
|
var DEFAULT_MAX_EVENTS = 2e3;
|
|
@@ -41623,7 +41623,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
41623
41623
|
}
|
|
41624
41624
|
|
|
41625
41625
|
// src/_generated/version.ts
|
|
41626
|
-
var PKG_VERSION = "0.4.
|
|
41626
|
+
var PKG_VERSION = "0.4.17";
|
|
41627
41627
|
|
|
41628
41628
|
// src/api-base-url-migrate.ts
|
|
41629
41629
|
var import_node_fs3 = __toESM(require("node:fs"), 1);
|
|
@@ -42312,6 +42312,7 @@ async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, ol
|
|
|
42312
42312
|
}
|
|
42313
42313
|
|
|
42314
42314
|
// src/telemetry/turn-aggregator.ts
|
|
42315
|
+
var import_node_crypto3 = require("node:crypto");
|
|
42315
42316
|
var import_promises5 = require("node:fs/promises");
|
|
42316
42317
|
var import_node_path10 = require("node:path");
|
|
42317
42318
|
var BRIDGE_FILE_RE = /^bridge-(\d{4}-\d{2}-\d{2})\.jsonl$/;
|
|
@@ -42322,6 +42323,25 @@ var PLUMBING_COUNTER_KEY = {
|
|
|
42322
42323
|
buffer_stats: "bufferStats",
|
|
42323
42324
|
rate_limit_status: "rateLimitStatusRecords"
|
|
42324
42325
|
};
|
|
42326
|
+
function resolveOwnSlug(records) {
|
|
42327
|
+
for (const rec of records) {
|
|
42328
|
+
const slug = rec.projection?.projectSlug;
|
|
42329
|
+
if (slug) return slug;
|
|
42330
|
+
}
|
|
42331
|
+
return void 0;
|
|
42332
|
+
}
|
|
42333
|
+
function inheritSlug(seeds, index) {
|
|
42334
|
+
let preceding;
|
|
42335
|
+
let following;
|
|
42336
|
+
for (const seed of seeds) {
|
|
42337
|
+
if (seed.index < index) {
|
|
42338
|
+
if (!preceding || seed.index > preceding.index) preceding = seed;
|
|
42339
|
+
} else if (seed.index > index) {
|
|
42340
|
+
if (!following || seed.index < following.index) following = seed;
|
|
42341
|
+
}
|
|
42342
|
+
}
|
|
42343
|
+
return (preceding ?? following)?.slug;
|
|
42344
|
+
}
|
|
42325
42345
|
async function foldClosedDays(stateDir, today) {
|
|
42326
42346
|
const logsDir = (0, import_node_path10.join)(stateDir, "logs");
|
|
42327
42347
|
let entries;
|
|
@@ -42337,6 +42357,7 @@ async function foldClosedDays(stateDir, today) {
|
|
|
42337
42357
|
if (day === today) continue;
|
|
42338
42358
|
const raw = await (0, import_promises5.readFile)((0, import_node_path10.join)(logsDir, entry), "utf8");
|
|
42339
42359
|
const groups = /* @__PURE__ */ new Map();
|
|
42360
|
+
let groupCounter = 0;
|
|
42340
42361
|
for (const line of raw.split("\n")) {
|
|
42341
42362
|
const trimmed = line.trim();
|
|
42342
42363
|
if (!trimmed) continue;
|
|
@@ -42351,13 +42372,14 @@ async function foldClosedDays(stateDir, today) {
|
|
|
42351
42372
|
const key = `${sessionId === null ? 0 : 1}:${sessionId}:${turnId === null ? 0 : 1}:${turnId}`;
|
|
42352
42373
|
let group = groups.get(key);
|
|
42353
42374
|
if (!group) {
|
|
42354
|
-
group = { sessionId, turnId, records: [], projectionFailures: 0 };
|
|
42375
|
+
group = { sessionId, turnId, records: [], projectionFailures: 0, firstSeenIndex: groupCounter++ };
|
|
42355
42376
|
groups.set(key, group);
|
|
42356
42377
|
}
|
|
42357
42378
|
group.records.push(rec);
|
|
42358
42379
|
if (rec.projectionFailed === true) group.projectionFailures += 1;
|
|
42359
42380
|
}
|
|
42360
42381
|
const rowsByProject = /* @__PURE__ */ new Map();
|
|
42382
|
+
const pending = [];
|
|
42361
42383
|
for (const group of groups.values()) {
|
|
42362
42384
|
if (group.sessionId === null) continue;
|
|
42363
42385
|
const records = [...group.records].sort((a, b) => {
|
|
@@ -42368,15 +42390,7 @@ async function foldClosedDays(stateDir, today) {
|
|
|
42368
42390
|
if (bSeq === void 0) return -1;
|
|
42369
42391
|
return aSeq - bSeq;
|
|
42370
42392
|
});
|
|
42371
|
-
|
|
42372
|
-
for (const rec of records) {
|
|
42373
|
-
const slug = rec.projection?.projectSlug;
|
|
42374
|
-
if (slug) {
|
|
42375
|
-
projectSlug = slug;
|
|
42376
|
-
break;
|
|
42377
|
-
}
|
|
42378
|
-
}
|
|
42379
|
-
projectSlug ??= "_unattributed";
|
|
42393
|
+
const ownSlug = resolveOwnSlug(records);
|
|
42380
42394
|
const toolResults = records.filter((r) => r.projection?.kind === "tool_result");
|
|
42381
42395
|
const toolSequence = [];
|
|
42382
42396
|
for (const rec of records) {
|
|
@@ -42433,18 +42447,37 @@ async function foldClosedDays(stateDir, today) {
|
|
|
42433
42447
|
plumbing,
|
|
42434
42448
|
projectionFailures: group.projectionFailures
|
|
42435
42449
|
};
|
|
42436
|
-
|
|
42437
|
-
|
|
42438
|
-
|
|
42450
|
+
pending.push({ sessionId: group.sessionId, firstSeenIndex: group.firstSeenIndex, ownSlug, row });
|
|
42451
|
+
}
|
|
42452
|
+
const seedsBySession = /* @__PURE__ */ new Map();
|
|
42453
|
+
for (const item of pending) {
|
|
42454
|
+
if (item.ownSlug === void 0) continue;
|
|
42455
|
+
const seeds = seedsBySession.get(item.sessionId) ?? [];
|
|
42456
|
+
seeds.push({ index: item.firstSeenIndex, slug: item.ownSlug });
|
|
42457
|
+
seedsBySession.set(item.sessionId, seeds);
|
|
42458
|
+
}
|
|
42459
|
+
for (const item of pending) {
|
|
42460
|
+
const slug = item.ownSlug ?? inheritSlug(seedsBySession.get(item.sessionId) ?? [], item.firstSeenIndex) ?? // Neither the turn nor any turn of its session carries project evidence. Unchanged from
|
|
42461
|
+
// before this change: the partition stays `_unattributed`, and daily-uploader.ts is the one
|
|
42462
|
+
// that maps that partition name to MRRLIN_TELEMETRY_DEFAULT_PROJECT at upload time.
|
|
42463
|
+
"_unattributed";
|
|
42464
|
+
const rows = rowsByProject.get(slug) ?? [];
|
|
42465
|
+
rows.push(item.row);
|
|
42466
|
+
rowsByProject.set(slug, rows);
|
|
42439
42467
|
}
|
|
42440
42468
|
if (rowsByProject.size === 0) continue;
|
|
42441
42469
|
const telemetryDir = (0, import_node_path10.join)(stateDir, "telemetry");
|
|
42442
42470
|
await (0, import_promises5.mkdir)(telemetryDir, { recursive: true });
|
|
42443
42471
|
for (const [slug, rows] of rowsByProject) {
|
|
42444
42472
|
const finalPath = (0, import_node_path10.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
|
|
42445
|
-
const tmpPath = `${finalPath}.tmp`;
|
|
42446
|
-
|
|
42447
|
-
|
|
42473
|
+
const tmpPath = `${finalPath}.tmp-${process.pid}-${(0, import_node_crypto3.randomBytes)(6).toString("hex")}`;
|
|
42474
|
+
try {
|
|
42475
|
+
await (0, import_promises5.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
|
|
42476
|
+
await (0, import_promises5.rename)(tmpPath, finalPath);
|
|
42477
|
+
} finally {
|
|
42478
|
+
await (0, import_promises5.unlink)(tmpPath).catch(() => {
|
|
42479
|
+
});
|
|
42480
|
+
}
|
|
42448
42481
|
}
|
|
42449
42482
|
}
|
|
42450
42483
|
}
|
|
@@ -42454,7 +42487,7 @@ var import_promises6 = require("node:fs/promises");
|
|
|
42454
42487
|
var import_node_path12 = require("node:path");
|
|
42455
42488
|
|
|
42456
42489
|
// src/consensus/wiring.ts
|
|
42457
|
-
var
|
|
42490
|
+
var import_node_crypto4 = __toESM(require("node:crypto"), 1);
|
|
42458
42491
|
var import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
42459
42492
|
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
42460
42493
|
var import_node_url2 = require("node:url");
|
|
@@ -43981,7 +44014,7 @@ You revise a deliverable to address the accepted issues so it satisfies the acce
|
|
|
43981
44014
|
try {
|
|
43982
44015
|
const diagnostics = Array.isArray(r["diagnostics"]) ? r["diagnostics"] : void 0;
|
|
43983
44016
|
await client.appendExecutionArtifact(projectSlug, runId, {
|
|
43984
|
-
id: `EA-${
|
|
44017
|
+
id: `EA-${import_node_crypto4.default.randomUUID()}`,
|
|
43985
44018
|
kind: "verification",
|
|
43986
44019
|
payload: {
|
|
43987
44020
|
source: "deliverable-gate",
|
|
@@ -44539,7 +44572,7 @@ function setSelectedProvider(value) {
|
|
|
44539
44572
|
|
|
44540
44573
|
// src/execution-consumer.ts
|
|
44541
44574
|
var import_node_child_process12 = require("node:child_process");
|
|
44542
|
-
var
|
|
44575
|
+
var import_node_crypto6 = __toESM(require("node:crypto"), 1);
|
|
44543
44576
|
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
44544
44577
|
var import_node_util = require("node:util");
|
|
44545
44578
|
|
|
@@ -44608,7 +44641,7 @@ function mapDeliverableGateResult(result) {
|
|
|
44608
44641
|
}
|
|
44609
44642
|
|
|
44610
44643
|
// src/async-tools/draft-spec.ts
|
|
44611
|
-
var
|
|
44644
|
+
var import_node_crypto5 = require("node:crypto");
|
|
44612
44645
|
var DRAFT_SPEC_TOOL_NAME = "draft_task_spec";
|
|
44613
44646
|
var SPECS_FOLDER = "Specs";
|
|
44614
44647
|
var DRAFT_SPEC_TLDR_MAX_CHARS = 300;
|
|
@@ -45091,7 +45124,7 @@ function onComplete(outcome, input) {
|
|
|
45091
45124
|
};
|
|
45092
45125
|
}
|
|
45093
45126
|
const summary = outcome.error;
|
|
45094
|
-
const hash3 = (0,
|
|
45127
|
+
const hash3 = (0, import_node_crypto5.createHash)("sha256").update(summary).digest("hex").slice(0, 10);
|
|
45095
45128
|
return {
|
|
45096
45129
|
kind: "info",
|
|
45097
45130
|
id: `II-sched-draft-failed-${input.taskId}-${hash3}`,
|
|
@@ -46411,7 +46444,7 @@ function isBridgeGeneratedArtifact(artifact) {
|
|
|
46411
46444
|
return typeof payload === "object" && payload !== null && "event" in payload;
|
|
46412
46445
|
}
|
|
46413
46446
|
function newArtifactId() {
|
|
46414
|
-
return `EA-${
|
|
46447
|
+
return `EA-${import_node_crypto6.default.randomUUID()}`;
|
|
46415
46448
|
}
|
|
46416
46449
|
var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
|
|
46417
46450
|
function isBlastRadiusFloorPath(path22) {
|
|
@@ -46653,7 +46686,7 @@ async function driveRun(deps, projectSlug, runId) {
|
|
|
46653
46686
|
if (!claimed) return;
|
|
46654
46687
|
if (!claimed.leaseId) {
|
|
46655
46688
|
await deps.client.createInboxItem(projectSlug, {
|
|
46656
|
-
id: `II-${
|
|
46689
|
+
id: `II-${import_node_crypto6.default.randomUUID()}`,
|
|
46657
46690
|
kind: "handoff",
|
|
46658
46691
|
taskId: claimed.taskId,
|
|
46659
46692
|
body: `Execution run ${runId} was claimed but returned no leaseId. This indicates DB/API corruption and requires operator attention.`
|
|
@@ -47624,7 +47657,7 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
|
|
|
47624
47657
|
}
|
|
47625
47658
|
try {
|
|
47626
47659
|
await deps.client.createInboxItem(projectSlug, {
|
|
47627
|
-
id: `II-${
|
|
47660
|
+
id: `II-${import_node_crypto6.default.randomUUID()}`,
|
|
47628
47661
|
kind: "handoff",
|
|
47629
47662
|
taskId: task.id,
|
|
47630
47663
|
body: `Task ${task.id} (${task.title}) still needs operator follow-up: ${reason}. Mrrlin could not move the task back to Handoff needed automatically.`
|
|
@@ -47659,7 +47692,7 @@ async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
|
|
|
47659
47692
|
}
|
|
47660
47693
|
try {
|
|
47661
47694
|
await deps.client.createInboxItem(projectSlug, {
|
|
47662
|
-
id: `II-${
|
|
47695
|
+
id: `II-${import_node_crypto6.default.randomUUID()}`,
|
|
47663
47696
|
kind: "handoff",
|
|
47664
47697
|
taskId: task.id,
|
|
47665
47698
|
body: `Execution run ${runId} for task ${task.id} (${task.title}) needs operator attention: ${reason}`
|
|
@@ -47797,7 +47830,7 @@ async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId
|
|
|
47797
47830
|
}).catch(() => {
|
|
47798
47831
|
});
|
|
47799
47832
|
await deps.client.createInboxItem(projectSlug, {
|
|
47800
|
-
id: `II-${
|
|
47833
|
+
id: `II-${import_node_crypto6.default.randomUUID()}`,
|
|
47801
47834
|
kind: "handoff",
|
|
47802
47835
|
taskId: task.id,
|
|
47803
47836
|
body: `Deploy gate for run ${runId} (task ${task.id} \u2014 ${task.title}) needs operator attention: ${reason}`
|
|
@@ -47816,7 +47849,7 @@ function maxLeaseReclaims() {
|
|
|
47816
47849
|
}
|
|
47817
47850
|
|
|
47818
47851
|
// src/async-job-consumer.ts
|
|
47819
|
-
var
|
|
47852
|
+
var import_node_crypto8 = __toESM(require("node:crypto"), 1);
|
|
47820
47853
|
|
|
47821
47854
|
// src/async-tools/registry.ts
|
|
47822
47855
|
var registry2 = /* @__PURE__ */ new Map();
|
|
@@ -47855,7 +47888,7 @@ function redact(input) {
|
|
|
47855
47888
|
}
|
|
47856
47889
|
|
|
47857
47890
|
// src/telemetry/projector.ts
|
|
47858
|
-
var
|
|
47891
|
+
var import_node_crypto7 = require("node:crypto");
|
|
47859
47892
|
function isRecord2(x) {
|
|
47860
47893
|
return typeof x === "object" && x !== null;
|
|
47861
47894
|
}
|
|
@@ -47896,7 +47929,7 @@ function buildProjection(payload, type, ms, telemetry) {
|
|
|
47896
47929
|
if (typeof exitCode === "number") proj.exitCode = exitCode;
|
|
47897
47930
|
const status = tool.status;
|
|
47898
47931
|
if (typeof status === "string" && status.trim() !== "") {
|
|
47899
|
-
proj.statusHash = (0,
|
|
47932
|
+
proj.statusHash = (0, import_node_crypto7.createHash)("sha256").update(status.trim().toLowerCase()).digest("hex").slice(0, 8);
|
|
47900
47933
|
}
|
|
47901
47934
|
return proj;
|
|
47902
47935
|
}
|
|
@@ -48211,7 +48244,7 @@ async function driveAsyncJob(deps, projectSlug, jobId) {
|
|
|
48211
48244
|
const delivery = descriptor2.onComplete(outcome, input);
|
|
48212
48245
|
if (!delivery.suppressInbox) {
|
|
48213
48246
|
await deps.client.createInboxItem(projectSlug, {
|
|
48214
|
-
id: delivery.id ?? `II-${
|
|
48247
|
+
id: delivery.id ?? `II-${import_node_crypto8.default.randomUUID()}`,
|
|
48215
48248
|
kind: delivery.kind,
|
|
48216
48249
|
body: delivery.body,
|
|
48217
48250
|
...delivery.taskId ? { taskId: delivery.taskId } : {},
|
|
@@ -48229,13 +48262,13 @@ async function deriveRequestedHash(client, toolName, input) {
|
|
|
48229
48262
|
if (input.requestedHash) return input.requestedHash;
|
|
48230
48263
|
if (toolName === "run_spec_consensus" && input.pageId) {
|
|
48231
48264
|
const page = await client.getWikiPage(input.projectSlug, input.pageId);
|
|
48232
|
-
return page.contentHash ??
|
|
48265
|
+
return page.contentHash ?? import_node_crypto8.default.createHash("sha256").update(page.markdownBody).digest("hex");
|
|
48233
48266
|
}
|
|
48234
48267
|
if (toolName === "draft_task_spec" && input.taskId) {
|
|
48235
48268
|
const task = await client.getTask(input.projectSlug, input.taskId);
|
|
48236
|
-
return task.updatedAt ??
|
|
48269
|
+
return task.updatedAt ?? import_node_crypto8.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
|
|
48237
48270
|
}
|
|
48238
|
-
return
|
|
48271
|
+
return import_node_crypto8.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
|
|
48239
48272
|
}
|
|
48240
48273
|
async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId)) {
|
|
48241
48274
|
const projects = await deps.client.listProjects();
|
|
@@ -48716,7 +48749,7 @@ function createToolBusyClock(opts) {
|
|
|
48716
48749
|
}
|
|
48717
48750
|
|
|
48718
48751
|
// src/worker-token.ts
|
|
48719
|
-
var
|
|
48752
|
+
var import_node_crypto9 = require("node:crypto");
|
|
48720
48753
|
var import_node_fs11 = require("node:fs");
|
|
48721
48754
|
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
48722
48755
|
var import_node_path19 = __toESM(require("node:path"), 1);
|
|
@@ -48747,7 +48780,7 @@ function readOrCreateWorkerToken() {
|
|
|
48747
48780
|
if (existing) return existing;
|
|
48748
48781
|
const dir = workerDir();
|
|
48749
48782
|
(0, import_node_fs11.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
48750
|
-
const token = (0,
|
|
48783
|
+
const token = (0, import_node_crypto9.randomBytes)(32).toString("hex");
|
|
48751
48784
|
(0, import_node_fs11.writeFileSync)(workerTokenPath(), `${token}
|
|
48752
48785
|
`, { encoding: "utf8", mode: 384 });
|
|
48753
48786
|
return token;
|
|
@@ -48815,7 +48848,7 @@ function wrapConstructor(hashCons) {
|
|
|
48815
48848
|
hashC.create = () => hashCons();
|
|
48816
48849
|
return hashC;
|
|
48817
48850
|
}
|
|
48818
|
-
function
|
|
48851
|
+
function randomBytes3(bytesLength = 32) {
|
|
48819
48852
|
if (crypto5 && typeof crypto5.getRandomValues === "function") {
|
|
48820
48853
|
return crypto5.getRandomValues(new Uint8Array(bytesLength));
|
|
48821
48854
|
}
|
|
@@ -48854,10 +48887,10 @@ function encodeTranscript(channelId, ephemeralPhonePub, ephemeralAgentPub) {
|
|
|
48854
48887
|
|
|
48855
48888
|
// ../../packages/director-e2e/dist/random.js
|
|
48856
48889
|
function generateSecret() {
|
|
48857
|
-
return
|
|
48890
|
+
return randomBytes3(32);
|
|
48858
48891
|
}
|
|
48859
48892
|
function generateChannelId() {
|
|
48860
|
-
return toBase64Url(
|
|
48893
|
+
return toBase64Url(randomBytes3(16));
|
|
48861
48894
|
}
|
|
48862
48895
|
|
|
48863
48896
|
// ../../packages/director-e2e/dist/qr.js
|
|
@@ -50026,7 +50059,7 @@ function validateOpts(curve) {
|
|
|
50026
50059
|
}
|
|
50027
50060
|
function twistedEdwards(curveDef) {
|
|
50028
50061
|
const CURVE = validateOpts(curveDef);
|
|
50029
|
-
const { Fp: Fp2, n: CURVE_ORDER, prehash, hash: cHash, randomBytes:
|
|
50062
|
+
const { Fp: Fp2, n: CURVE_ORDER, prehash, hash: cHash, randomBytes: randomBytes5, nByteLength, h: cofactor } = CURVE;
|
|
50030
50063
|
const MASK = _2n3 << BigInt(nByteLength * 8) - _1n4;
|
|
50031
50064
|
const modP = Fp2.create;
|
|
50032
50065
|
const uvRatio2 = CURVE.uvRatio || ((u, v) => {
|
|
@@ -50365,7 +50398,7 @@ function twistedEdwards(curveDef) {
|
|
|
50365
50398
|
const utils = {
|
|
50366
50399
|
getExtendedPublicKey,
|
|
50367
50400
|
// ed25519 private keys are uniform 32b. No need to check for modulo bias, like in secp256k1.
|
|
50368
|
-
randomPrivateKey: () =>
|
|
50401
|
+
randomPrivateKey: () => randomBytes5(Fp2.BYTES),
|
|
50369
50402
|
/**
|
|
50370
50403
|
* We're doing scalar multiplication (used in getPublicKey etc) with precomputed BASE_POINT
|
|
50371
50404
|
* values. This slows down first getPublicKey() by milliseconds (see Speed section),
|
|
@@ -50580,7 +50613,7 @@ var ed25519Defaults = {
|
|
|
50580
50613
|
Gx: BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),
|
|
50581
50614
|
Gy: BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),
|
|
50582
50615
|
hash: sha512,
|
|
50583
|
-
randomBytes:
|
|
50616
|
+
randomBytes: randomBytes3,
|
|
50584
50617
|
adjustScalarBytes,
|
|
50585
50618
|
// dom2
|
|
50586
50619
|
// Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3.
|
|
@@ -50615,7 +50648,7 @@ var x25519 = /* @__PURE__ */ (() => montgomery({
|
|
|
50615
50648
|
return mod(pow2(pow_p_5_8, BigInt(3), P) * b2, P);
|
|
50616
50649
|
},
|
|
50617
50650
|
adjustScalarBytes,
|
|
50618
|
-
randomBytes:
|
|
50651
|
+
randomBytes: randomBytes3
|
|
50619
50652
|
}))();
|
|
50620
50653
|
function edwardsToMontgomeryPub(edwardsPub) {
|
|
50621
50654
|
const { y } = ed25519.ExtendedPoint.fromHex(edwardsPub);
|
|
@@ -53613,9 +53646,9 @@ function readCodexFallbackModels() {
|
|
|
53613
53646
|
return [...models.values()];
|
|
53614
53647
|
}
|
|
53615
53648
|
function selfUpdateInboxItemId(offeredVersion) {
|
|
53616
|
-
if (!offeredVersion) return `II-MCPUPD-${(0,
|
|
53649
|
+
if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto10.randomUUID)()}`;
|
|
53617
53650
|
if (/^[A-Za-z0-9._-]+$/.test(offeredVersion)) return `II-MCPUPD-${offeredVersion}`;
|
|
53618
|
-
const hash3 =
|
|
53651
|
+
const hash3 = import_node_crypto10.default.createHash("sha256").update(offeredVersion).digest("hex").slice(0, 10);
|
|
53619
53652
|
return `II-MCPUPD-${offeredVersion.replace(/[^A-Za-z0-9._-]/g, "-")}-${hash3}`;
|
|
53620
53653
|
}
|
|
53621
53654
|
function neutralCheckoutCwd(stateDir) {
|
|
@@ -54165,7 +54198,7 @@ function createBridgeRequestListener(opts) {
|
|
|
54165
54198
|
res.end(JSON.stringify({ ok: false, error: "Origin not allowed." }));
|
|
54166
54199
|
return;
|
|
54167
54200
|
}
|
|
54168
|
-
const nonce =
|
|
54201
|
+
const nonce = import_node_crypto10.default.randomBytes(16).toString("base64url");
|
|
54169
54202
|
res.writeHead(200, { "content-type": "application/json" });
|
|
54170
54203
|
res.end(JSON.stringify({ ok: true, wsUrl: `ws://${host}:${port}/ws`, token, nonce }));
|
|
54171
54204
|
return;
|
|
@@ -54464,7 +54497,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
54464
54497
|
}
|
|
54465
54498
|
}
|
|
54466
54499
|
socket.on("message", async (data) => {
|
|
54467
|
-
const spanId =
|
|
54500
|
+
const spanId = import_node_crypto10.default.randomUUID();
|
|
54468
54501
|
if (logCtx) {
|
|
54469
54502
|
logCtx.span.id = spanId;
|
|
54470
54503
|
logCtx.span.at = Date.now();
|
|
@@ -55042,7 +55075,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
55042
55075
|
thread.inFlight = true;
|
|
55043
55076
|
pendingTurnSessions.delete(directorSessionId);
|
|
55044
55077
|
thread.replay = createReplayBuffer({
|
|
55045
|
-
turnId: (0,
|
|
55078
|
+
turnId: (0, import_node_crypto10.randomUUID)(),
|
|
55046
55079
|
spanId,
|
|
55047
55080
|
...deps.retentionMs !== void 0 ? { retentionMs: deps.retentionMs } : {},
|
|
55048
55081
|
...deps.ackLingerMs !== void 0 ? { ackLingerMs: deps.ackLingerMs } : {}
|
|
@@ -55462,6 +55495,7 @@ function checkTelemetryDefaultProject(env, warn) {
|
|
|
55462
55495
|
}
|
|
55463
55496
|
async function startDirectorBridge() {
|
|
55464
55497
|
const config2 = parseConfig();
|
|
55498
|
+
let telemetryPipelineRunning = false;
|
|
55465
55499
|
checkTelemetryDefaultProject(process.env, (m) => console.error(m));
|
|
55466
55500
|
const turnLock = createTurnLock();
|
|
55467
55501
|
let lastTurnEndedAt = Date.now();
|
|
@@ -55689,7 +55723,7 @@ async function startDirectorBridge() {
|
|
|
55689
55723
|
};
|
|
55690
55724
|
const sessionSinks = createSessionSinkRegistry();
|
|
55691
55725
|
const tombstones = /* @__PURE__ */ new Map();
|
|
55692
|
-
const bridgeInstanceId = (0,
|
|
55726
|
+
const bridgeInstanceId = (0, import_node_crypto10.randomUUID)();
|
|
55693
55727
|
const asyncConsumerDeps = {
|
|
55694
55728
|
client,
|
|
55695
55729
|
run: wrappedTurnLock.run,
|
|
@@ -55964,7 +55998,7 @@ async function startDirectorBridge() {
|
|
|
55964
55998
|
const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
|
|
55965
55999
|
let bridgeBinShaShort = "unknown00000";
|
|
55966
56000
|
try {
|
|
55967
|
-
bridgeBinShaShort =
|
|
56001
|
+
bridgeBinShaShort = import_node_crypto10.default.createHash("sha256").update(import_node_fs17.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
|
|
55968
56002
|
} catch {
|
|
55969
56003
|
}
|
|
55970
56004
|
attachBridgeWss(server, {
|
|
@@ -56141,42 +56175,54 @@ async function startDirectorBridge() {
|
|
|
56141
56175
|
});
|
|
56142
56176
|
}
|
|
56143
56177
|
}
|
|
56144
|
-
|
|
56145
|
-
|
|
56146
|
-
|
|
56147
|
-
|
|
56148
|
-
|
|
56149
|
-
|
|
56150
|
-
|
|
56151
|
-
|
|
56152
|
-
|
|
56153
|
-
|
|
56154
|
-
|
|
56155
|
-
|
|
56156
|
-
|
|
56157
|
-
|
|
56158
|
-
|
|
56159
|
-
|
|
56160
|
-
|
|
56178
|
+
if (telemetryPipelineRunning) {
|
|
56179
|
+
bridgeLogger.logOut({
|
|
56180
|
+
spanId: "gc",
|
|
56181
|
+
sessionId: null,
|
|
56182
|
+
type: "<telemetry-pipeline-skipped>",
|
|
56183
|
+
payload: { reason: "previous run still in flight" }
|
|
56184
|
+
});
|
|
56185
|
+
} else {
|
|
56186
|
+
telemetryPipelineRunning = true;
|
|
56187
|
+
void (async () => {
|
|
56188
|
+
try {
|
|
56189
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
56190
|
+
await foldClosedDays(config2.stateDir, today);
|
|
56191
|
+
await uploadPendingDays(config2.stateDir, client, bridgeHealth, {
|
|
56192
|
+
cwd: config2.codexCwd ?? process.cwd(),
|
|
56193
|
+
codexExecutable: config2.codexExecutable,
|
|
56194
|
+
timeoutMs: readEnvInt("MRRLIN_TELEMETRY_GATE_TIMEOUT_SECONDS", 60) * 1e3
|
|
56195
|
+
});
|
|
56196
|
+
const pruneResult = await prune(config2.stateDir, {
|
|
56197
|
+
ageDays: readEnvInt("MRRLIN_LOG_RETENTION_AGE_DAYS", 30),
|
|
56198
|
+
budgetMb: readEnvInt("MRRLIN_LOG_RETENTION_BUDGET_MB", 1024),
|
|
56199
|
+
// The reconstruction window's day-files are off limits. Derived from the thread
|
|
56200
|
+
// TTL so the two numbers cannot drift apart.
|
|
56201
|
+
protectedSinceMs: Date.now() - config2.idleThreadTtlMs
|
|
56202
|
+
});
|
|
56203
|
+
if (pruneResult.budgetOvershootBytes > 0) {
|
|
56204
|
+
bridgeLogger.logOut({
|
|
56205
|
+
spanId: "gc",
|
|
56206
|
+
sessionId: null,
|
|
56207
|
+
type: "<log-budget-overshoot>",
|
|
56208
|
+
payload: {
|
|
56209
|
+
overshootBytes: pruneResult.budgetOvershootBytes,
|
|
56210
|
+
reason: "protected re-seed window not pruned"
|
|
56211
|
+
}
|
|
56212
|
+
});
|
|
56213
|
+
}
|
|
56214
|
+
} catch (error51) {
|
|
56161
56215
|
bridgeLogger.logOut({
|
|
56162
56216
|
spanId: "gc",
|
|
56163
56217
|
sessionId: null,
|
|
56164
|
-
type: "<
|
|
56165
|
-
payload: {
|
|
56166
|
-
overshootBytes: pruneResult.budgetOvershootBytes,
|
|
56167
|
-
reason: "protected re-seed window not pruned"
|
|
56168
|
-
}
|
|
56218
|
+
type: "<telemetry-pipeline-error>",
|
|
56219
|
+
payload: { error: error51 instanceof Error ? error51.message : String(error51) }
|
|
56169
56220
|
});
|
|
56221
|
+
} finally {
|
|
56222
|
+
telemetryPipelineRunning = false;
|
|
56170
56223
|
}
|
|
56171
|
-
}
|
|
56172
|
-
|
|
56173
|
-
spanId: "gc",
|
|
56174
|
-
sessionId: null,
|
|
56175
|
-
type: "<telemetry-pipeline-error>",
|
|
56176
|
-
payload: { error: error51 instanceof Error ? error51.message : String(error51) }
|
|
56177
|
-
});
|
|
56178
|
-
}
|
|
56179
|
-
})();
|
|
56224
|
+
})();
|
|
56225
|
+
}
|
|
56180
56226
|
scheduleClaimLoop();
|
|
56181
56227
|
}, claimIntervalMs());
|
|
56182
56228
|
claimTimer.unref?.();
|
|
@@ -56397,7 +56443,7 @@ function timingSafeTokenEqual(provided, expected) {
|
|
|
56397
56443
|
const a = Buffer.from(provided);
|
|
56398
56444
|
const b = Buffer.from(expected);
|
|
56399
56445
|
if (a.length !== b.length) return false;
|
|
56400
|
-
return
|
|
56446
|
+
return import_node_crypto10.default.timingSafeEqual(a, b);
|
|
56401
56447
|
}
|
|
56402
56448
|
function readDispatchBody(req) {
|
|
56403
56449
|
return new Promise((resolve, reject) => {
|
|
@@ -56426,7 +56472,7 @@ function readOrCreateBridgeToken(stateDir) {
|
|
|
56426
56472
|
} catch {
|
|
56427
56473
|
}
|
|
56428
56474
|
import_node_fs17.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
|
|
56429
|
-
const token =
|
|
56475
|
+
const token = import_node_crypto10.default.randomBytes(32).toString("base64url");
|
|
56430
56476
|
import_node_fs17.default.writeFileSync(tokenPath, `${token}
|
|
56431
56477
|
`, { mode: 384 });
|
|
56432
56478
|
return token;
|
|
@@ -59811,7 +59857,7 @@ var StdioServerTransport = class {
|
|
|
59811
59857
|
};
|
|
59812
59858
|
|
|
59813
59859
|
// src/tools.ts
|
|
59814
|
-
var
|
|
59860
|
+
var import_node_crypto13 = require("node:crypto");
|
|
59815
59861
|
var import_promises10 = require("node:fs/promises");
|
|
59816
59862
|
var import_node_path27 = __toESM(require("node:path"), 1);
|
|
59817
59863
|
var import_node_os12 = __toESM(require("node:os"), 1);
|
|
@@ -60501,7 +60547,7 @@ async function resolveActiveRunHead(input, deps) {
|
|
|
60501
60547
|
}
|
|
60502
60548
|
|
|
60503
60549
|
// src/async-tools/consensus.ts
|
|
60504
|
-
var
|
|
60550
|
+
var import_node_crypto11 = require("node:crypto");
|
|
60505
60551
|
|
|
60506
60552
|
// src/consensus/question-similarity.ts
|
|
60507
60553
|
var SUPPRESSION_SIMILARITY_THRESHOLD = 0.6;
|
|
@@ -60777,9 +60823,9 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
|
|
|
60777
60823
|
}
|
|
60778
60824
|
if (taskId) {
|
|
60779
60825
|
const scopeId = taskId;
|
|
60780
|
-
const groupId = toFile.length > 1 ? `II-${scopeId}-gate-group-${(0,
|
|
60826
|
+
const groupId = toFile.length > 1 ? `II-${scopeId}-gate-group-${(0, import_node_crypto11.createHash)("sha256").update(toFile.map((c) => c.rawQuestion).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
|
|
60781
60827
|
for (const clarification of toFile) {
|
|
60782
|
-
const id = `II-${scopeId}-gate-${(0,
|
|
60828
|
+
const id = `II-${scopeId}-gate-${(0, import_node_crypto11.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`;
|
|
60783
60829
|
try {
|
|
60784
60830
|
const questionOptions = buildGateQuestionOptions(clarification.rawQuestion, clarification.category);
|
|
60785
60831
|
await ctx.client.createInboxItem(input.projectSlug, {
|
|
@@ -60797,9 +60843,9 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
|
|
|
60797
60843
|
filedQuestionCount = toFile.length;
|
|
60798
60844
|
} else if (planId) {
|
|
60799
60845
|
const scopeId = planId;
|
|
60800
|
-
const groupId = toFile.length > 1 ? `II-${scopeId}-gate-group-${(0,
|
|
60846
|
+
const groupId = toFile.length > 1 ? `II-${scopeId}-gate-group-${(0, import_node_crypto11.createHash)("sha256").update(toFile.map((c) => c.rawQuestion).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
|
|
60801
60847
|
for (const clarification of toFile) {
|
|
60802
|
-
const id = `II-${scopeId}-gate-${(0,
|
|
60848
|
+
const id = `II-${scopeId}-gate-${(0, import_node_crypto11.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`;
|
|
60803
60849
|
try {
|
|
60804
60850
|
const questionOptions = buildGateQuestionOptions(clarification.rawQuestion, clarification.category);
|
|
60805
60851
|
await ctx.client.createInboxItem(input.projectSlug, {
|
|
@@ -60823,7 +60869,7 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
|
|
|
60823
60869
|
taskId: page.taskId ?? null
|
|
60824
60870
|
});
|
|
60825
60871
|
const reviewHash = domainScopedReviewHash2(page.contentHash, domain2);
|
|
60826
|
-
const baseBlockItemId = `II-${taskId}-gateblock-${(0,
|
|
60872
|
+
const baseBlockItemId = `II-${taskId}-gateblock-${(0, import_node_crypto11.createHash)("sha256").update(reviewHash).digest("hex").slice(0, 10)}`;
|
|
60827
60873
|
const reviewAgainAvailable = !taskInboxItems.some(
|
|
60828
60874
|
(item) => item.id === baseBlockItemId && item.status !== "pending" && item.answer === REVIEW_AGAIN_ANSWER
|
|
60829
60875
|
);
|
|
@@ -61545,7 +61591,7 @@ function createReportEvidenceDescriptor() {
|
|
|
61545
61591
|
var reportEvidenceDescriptor = createReportEvidenceDescriptor();
|
|
61546
61592
|
|
|
61547
61593
|
// src/async-tools/enqueue.ts
|
|
61548
|
-
var
|
|
61594
|
+
var import_node_crypto12 = __toESM(require("node:crypto"), 1);
|
|
61549
61595
|
async function enqueueAsyncTool(client, descriptor2, input) {
|
|
61550
61596
|
if (descriptor2.cachedResult) {
|
|
61551
61597
|
const cached2 = await descriptor2.cachedResult(client, input);
|
|
@@ -61558,7 +61604,7 @@ async function enqueueAsyncTool(client, descriptor2, input) {
|
|
|
61558
61604
|
if (active) {
|
|
61559
61605
|
return { status: "already_running", jobId: active.id, message: "Already running; will notify in inbox." };
|
|
61560
61606
|
}
|
|
61561
|
-
const jobId = `AJ-${
|
|
61607
|
+
const jobId = `AJ-${import_node_crypto12.default.randomUUID()}`;
|
|
61562
61608
|
try {
|
|
61563
61609
|
await client.createAsyncJob(input.projectSlug, {
|
|
61564
61610
|
id: jobId,
|
|
@@ -63138,7 +63184,7 @@ function createMrrlinTools(options) {
|
|
|
63138
63184
|
"PRODUCED_URL_RECORD_FAILED",
|
|
63139
63185
|
"Unable to record produced URL.",
|
|
63140
63186
|
async (c, { projectSlug, runId, url: url2, label }) => {
|
|
63141
|
-
const id = `EA-pu-${(0,
|
|
63187
|
+
const id = `EA-pu-${(0, import_node_crypto13.randomBytes)(4).toString("hex")}`;
|
|
63142
63188
|
const payload = label ? { url: url2, label } : { url: url2 };
|
|
63143
63189
|
return await c.appendExecutionArtifact(projectSlug, runId, {
|
|
63144
63190
|
id,
|