@mrrlin-dev/mcp 0.4.237 → 0.4.247
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 +1023 -77
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -17448,6 +17448,7 @@ var init_operationIds = __esm({
|
|
|
17448
17448
|
beginColdWorkV2: "beginColdWorkV2",
|
|
17449
17449
|
parkColdWork: "parkColdWork",
|
|
17450
17450
|
restartReconciledColdWork: "restartReconciledColdWork",
|
|
17451
|
+
closeParkedColdWork: "closeParkedColdWork",
|
|
17451
17452
|
registerDrainSupervision: "registerDrainSupervision",
|
|
17452
17453
|
relayDrainStatement: "relayDrainStatement",
|
|
17453
17454
|
beginColdWorkV3: "beginColdWorkV3",
|
|
@@ -19371,6 +19372,13 @@ var init_integration_connections = __esm({
|
|
|
19371
19372
|
authorizationGeneration: external_exports.number().int().min(1),
|
|
19372
19373
|
configDigest: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
19373
19374
|
bindingRevision: external_exports.number().int().min(1).default(1),
|
|
19375
|
+
publisherTarget: external_exports.object({
|
|
19376
|
+
targetId: external_exports.string().min(1).max(128),
|
|
19377
|
+
endpoint: external_exports.string().url(),
|
|
19378
|
+
publicOrigin: external_exports.string().url(),
|
|
19379
|
+
rootDirectory: external_exports.string().optional(),
|
|
19380
|
+
buildSettingsDigest: external_exports.string().regex(/^[0-9a-f]{64}$/).optional()
|
|
19381
|
+
}).strict().optional(),
|
|
19374
19382
|
ownerActor: external_exports.string().min(1),
|
|
19375
19383
|
createdAt: external_exports.string().datetime(),
|
|
19376
19384
|
updatedAt: external_exports.string().datetime()
|
|
@@ -19559,7 +19567,9 @@ var init_publisher_profiles = __esm({
|
|
|
19559
19567
|
endpoint: external_exports.string().url().refine(isHttpsOrLoopbackTestUrl, { message: "Endpoint must use https: (http: permitted only on loopback in test mode)" }),
|
|
19560
19568
|
targetId: external_exports.string().min(1).max(128),
|
|
19561
19569
|
publicOrigin: external_exports.string().url().refine(isHttpsOrLoopbackTestUrl, { message: "Public origin must use https: (http: permitted only on loopback in test mode)" }),
|
|
19562
|
-
|
|
19570
|
+
// Omit rather than send "": the target fingerprint treats "" as absent but the
|
|
19571
|
+
// dispatch fence compares the stored jsonb, so "" would drift at dispatch.
|
|
19572
|
+
rootDirectory: external_exports.string().min(1).optional(),
|
|
19563
19573
|
buildSettingsDigest: external_exports.string().regex(/^[0-9a-f]{64}$/).optional(),
|
|
19564
19574
|
configRevision: external_exports.number().int().min(1).default(1),
|
|
19565
19575
|
authorizationGeneration: external_exports.number().int().min(1).default(1),
|
|
@@ -19672,6 +19682,9 @@ var init_vercel_publishing = __esm({
|
|
|
19672
19682
|
invocationId: external_exports.string().min(1).nullable().optional(),
|
|
19673
19683
|
evidenceDigest: external_exports.string().nullable().optional(),
|
|
19674
19684
|
dispatchCount: external_exports.number().int().min(0).default(0).optional(),
|
|
19685
|
+
/** The operation id the bridge actually dispatched (sent to the publisher, stamped into the live
|
|
19686
|
+
* marker). Absent on older rows and older APIs; closure then falls back to the marker-only check. */
|
|
19687
|
+
dispatchedOperationId: external_exports.string().min(1).nullable().optional(),
|
|
19675
19688
|
createdAt: external_exports.string().datetime(),
|
|
19676
19689
|
updatedAt: external_exports.string().datetime()
|
|
19677
19690
|
});
|
|
@@ -19736,7 +19749,10 @@ var init_vercel_publishing = __esm({
|
|
|
19736
19749
|
errorMessage: external_exports.string().min(1)
|
|
19737
19750
|
});
|
|
19738
19751
|
CommitPublishDispatchRequestSchema = external_exports.object({
|
|
19739
|
-
leaseOwner: external_exports.string().min(1)
|
|
19752
|
+
leaseOwner: external_exports.string().min(1),
|
|
19753
|
+
/** The operation id this dispatch sends to the publisher. Optional so an older bridge still commits;
|
|
19754
|
+
* the row then keeps it null and closure falls back to the marker-only check. */
|
|
19755
|
+
operationId: external_exports.string().min(1).optional()
|
|
19740
19756
|
});
|
|
19741
19757
|
}
|
|
19742
19758
|
});
|
|
@@ -53116,7 +53132,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53116
53132
|
"../../node_modules/.pnpm/undici@7.30.2/node_modules/undici/lib/mock/snapshot-recorder.js"(exports2, module2) {
|
|
53117
53133
|
"use strict";
|
|
53118
53134
|
var { writeFile: writeFile7, readFile: readFile10, mkdir: mkdir4 } = require("node:fs/promises");
|
|
53119
|
-
var { dirname:
|
|
53135
|
+
var { dirname: dirname4, resolve: resolve4 } = require("node:path");
|
|
53120
53136
|
var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = require("node:timers");
|
|
53121
53137
|
var { InvalidArgumentError, UndiciError } = require_errors2();
|
|
53122
53138
|
var { hashId, isUrlExcludedFactory, normalizeHeaders: normalizeHeaders2, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -53347,7 +53363,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
53347
53363
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
53348
53364
|
}
|
|
53349
53365
|
const resolvedPath = resolve4(path42);
|
|
53350
|
-
await mkdir4(
|
|
53366
|
+
await mkdir4(dirname4(resolvedPath), { recursive: true });
|
|
53351
53367
|
const data = Array.from(this.#snapshots.entries()).map(([hash3, snapshot]) => ({
|
|
53352
53368
|
hash: hash3,
|
|
53353
53369
|
snapshot
|
|
@@ -78748,6 +78764,14 @@ function createMrrlinClient(config2) {
|
|
|
78748
78764
|
});
|
|
78749
78765
|
return body?.data?.applied === true;
|
|
78750
78766
|
},
|
|
78767
|
+
async closeParkedColdWork(projectSlug, runId, attemptId) {
|
|
78768
|
+
const body = await request(`${projectPath(projectSlug)}/execution-runs/${encodeURIComponent(runId)}/close-parked-cold-work`, {
|
|
78769
|
+
method: "POST",
|
|
78770
|
+
headers: { "content-type": "application/json" },
|
|
78771
|
+
body: JSON.stringify({ attemptId })
|
|
78772
|
+
});
|
|
78773
|
+
return body?.data?.applied === true;
|
|
78774
|
+
},
|
|
78751
78775
|
async publishExecutorThread(projectSlug, taskId, input) {
|
|
78752
78776
|
try {
|
|
78753
78777
|
const body = await request(`${projectPath(projectSlug)}/tasks/${encodeURIComponent(taskId)}/publish-executor-thread`, {
|
|
@@ -79424,6 +79448,14 @@ function createMrrlinClient(config2) {
|
|
|
79424
79448
|
});
|
|
79425
79449
|
return Boolean(body?.success ?? true);
|
|
79426
79450
|
},
|
|
79451
|
+
async enrollManagedPublisher(projectSlug, input) {
|
|
79452
|
+
const body = await request(`${projectPath(projectSlug)}/managed-publisher`, {
|
|
79453
|
+
method: "PUT",
|
|
79454
|
+
headers: { "content-type": "application/json" },
|
|
79455
|
+
body: JSON.stringify(input)
|
|
79456
|
+
});
|
|
79457
|
+
return EnrollManagedPublisherResponseSchema.parse(body);
|
|
79458
|
+
},
|
|
79427
79459
|
async listIntegrationCatalog(options = {}) {
|
|
79428
79460
|
const params = new URLSearchParams();
|
|
79429
79461
|
const q = options.query ?? options.q;
|
|
@@ -82406,6 +82438,10 @@ function computeSetupRequestDigest(action, params) {
|
|
|
82406
82438
|
const canonical = JSON.stringify(canonicalizeValue(params));
|
|
82407
82439
|
return (0, import_node_crypto6.createHash)("sha256").update(`${action}:${canonical}`).digest("hex");
|
|
82408
82440
|
}
|
|
82441
|
+
function computeToolSchemaDigest(schema) {
|
|
82442
|
+
const normalized = typeof schema === "string" ? schema : JSON.stringify(canonicalizeValue(schema));
|
|
82443
|
+
return (0, import_node_crypto6.createHash)("sha256").update(normalized).digest("hex");
|
|
82444
|
+
}
|
|
82409
82445
|
function computePreparedEnvelopeDigest(envelope) {
|
|
82410
82446
|
if ("profileId" in envelope && envelope.profileId === "publisher.mcp.v1") {
|
|
82411
82447
|
const canonical2 = {
|
|
@@ -88250,6 +88286,15 @@ async function executeHttpRequest(targetUrl, init, signal, allowLocal = false, m
|
|
|
88250
88286
|
function createSafeFetch(options) {
|
|
88251
88287
|
return (url2, init) => safeFetch(url2, init, options);
|
|
88252
88288
|
}
|
|
88289
|
+
function stampFinalUrl(response, finalUrl) {
|
|
88290
|
+
if (!response.url) {
|
|
88291
|
+
try {
|
|
88292
|
+
Object.defineProperty(response, "url", { value: finalUrl, configurable: true });
|
|
88293
|
+
} catch {
|
|
88294
|
+
}
|
|
88295
|
+
}
|
|
88296
|
+
return response;
|
|
88297
|
+
}
|
|
88253
88298
|
async function safeFetch(inputUrl, init, policy) {
|
|
88254
88299
|
const allowLocal = process.env.NODE_ENV !== "production" && (policy?.allowLocalEndpoints ?? false);
|
|
88255
88300
|
const maxRedirects = policy?.maxRedirects ?? DEFAULT_MAX_REDIRECTS;
|
|
@@ -88309,7 +88354,7 @@ async function safeFetch(inputUrl, init, policy) {
|
|
|
88309
88354
|
} else {
|
|
88310
88355
|
cleanup();
|
|
88311
88356
|
}
|
|
88312
|
-
return response;
|
|
88357
|
+
return stampFinalUrl(response, currentUrl);
|
|
88313
88358
|
}
|
|
88314
88359
|
try {
|
|
88315
88360
|
await response.body?.cancel();
|
|
@@ -88362,7 +88407,7 @@ async function safeFetch(inputUrl, init, policy) {
|
|
|
88362
88407
|
} else {
|
|
88363
88408
|
cleanup();
|
|
88364
88409
|
}
|
|
88365
|
-
return response;
|
|
88410
|
+
return stampFinalUrl(response, currentUrl);
|
|
88366
88411
|
} catch (fetchErr) {
|
|
88367
88412
|
cleanup();
|
|
88368
88413
|
throw fetchErr;
|
|
@@ -89373,12 +89418,33 @@ var LocalConnectionStore = class _LocalConnectionStore {
|
|
|
89373
89418
|
const connectionId = existing?.id ?? input.id ?? import_node_crypto7.default.randomUUID();
|
|
89374
89419
|
let configRevision = existing ? existing.configRevision : 1;
|
|
89375
89420
|
let authorizationGeneration = existing ? existing.authorizationGeneration : input.authorizationGeneration ?? 1;
|
|
89421
|
+
let publisherSecretRevisionAdvanced = false;
|
|
89376
89422
|
const inputRefs = existing?.inputRefs ? { ...existing.inputRefs } : {};
|
|
89377
89423
|
if (input.secretValues && Object.keys(input.secretValues).length > 0) {
|
|
89378
89424
|
if (!this.isVaultUnlocked()) {
|
|
89379
89425
|
throw new VaultLockedError();
|
|
89380
89426
|
}
|
|
89381
89427
|
const vaultSecrets = await this.readDecryptedSecrets();
|
|
89428
|
+
const isPublisher = (input.legacyServerId ?? existing?.legacyServerId) === "publisher.mcp.v1";
|
|
89429
|
+
const publisherSecretsChanged = existing && isPublisher && Object.entries(input.secretValues).some(([slot, value]) => {
|
|
89430
|
+
const ref = inputRefs[slot];
|
|
89431
|
+
return !ref || vaultSecrets[ref] !== value;
|
|
89432
|
+
});
|
|
89433
|
+
if (existing && publisherSecretsChanged) {
|
|
89434
|
+
configRevision += 1;
|
|
89435
|
+
authorizationGeneration += 1;
|
|
89436
|
+
publisherSecretRevisionAdvanced = true;
|
|
89437
|
+
const invalidated = ConnectionRecordSchema.parse({
|
|
89438
|
+
...existing,
|
|
89439
|
+
configRevision,
|
|
89440
|
+
authorizationGeneration,
|
|
89441
|
+
updatedAt: now
|
|
89442
|
+
});
|
|
89443
|
+
writeProtectedJsonAtomic(this.getConnectionsPath(), {
|
|
89444
|
+
version: "v1",
|
|
89445
|
+
connections: [...existingList.filter((c) => c.id !== connectionId), invalidated]
|
|
89446
|
+
}, true);
|
|
89447
|
+
}
|
|
89382
89448
|
for (const [slotName, secretValue] of Object.entries(input.secretValues)) {
|
|
89383
89449
|
let ref = inputRefs[slotName];
|
|
89384
89450
|
if (!ref) {
|
|
@@ -89398,7 +89464,7 @@ var LocalConnectionStore = class _LocalConnectionStore {
|
|
|
89398
89464
|
const existingSlotKeys = Object.keys(existing.inputRefs ?? {}).sort();
|
|
89399
89465
|
const newSlotKeys = Object.keys(inputRefs).sort();
|
|
89400
89466
|
const secretSlotsChanged = JSON.stringify(existingSlotKeys) !== JSON.stringify(newSlotKeys);
|
|
89401
|
-
if (endpointChanged || commandChanged || argsChanged || envKeysChanged || originChanged || secretSlotsChanged) {
|
|
89467
|
+
if (!publisherSecretRevisionAdvanced && (endpointChanged || commandChanged || argsChanged || envKeysChanged || originChanged || secretSlotsChanged)) {
|
|
89402
89468
|
configRevision += 1;
|
|
89403
89469
|
authorizationGeneration += 1;
|
|
89404
89470
|
}
|
|
@@ -89477,29 +89543,31 @@ var LocalConnectionStore = class _LocalConnectionStore {
|
|
|
89477
89543
|
});
|
|
89478
89544
|
}
|
|
89479
89545
|
async resolveConnection(connectionId) {
|
|
89480
|
-
|
|
89481
|
-
|
|
89482
|
-
|
|
89483
|
-
|
|
89484
|
-
if (!conn.inputRefs || Object.keys(conn.inputRefs).length === 0) {
|
|
89485
|
-
return { connection: conn, secrets: {} };
|
|
89486
|
-
}
|
|
89487
|
-
if (!this.isVaultUnlocked()) {
|
|
89488
|
-
throw new VaultLockedError();
|
|
89489
|
-
}
|
|
89490
|
-
const decryptedMap = await this.readDecryptedSecrets();
|
|
89491
|
-
const resolvedSecrets = {};
|
|
89492
|
-
for (const [slotName, ref] of Object.entries(conn.inputRefs)) {
|
|
89493
|
-
const val = decryptedMap[ref];
|
|
89494
|
-
if (val === void 0) {
|
|
89495
|
-
throw new MissingSecretError(slotName);
|
|
89546
|
+
return withStoreLock(this.integrationsDir, async () => {
|
|
89547
|
+
const conn = this.getConnection(connectionId);
|
|
89548
|
+
if (!conn) {
|
|
89549
|
+
throw new Error(`Connection not found: ${connectionId}`);
|
|
89496
89550
|
}
|
|
89497
|
-
|
|
89498
|
-
|
|
89499
|
-
|
|
89500
|
-
|
|
89501
|
-
|
|
89502
|
-
|
|
89551
|
+
if (!conn.inputRefs || Object.keys(conn.inputRefs).length === 0) {
|
|
89552
|
+
return { connection: conn, secrets: {} };
|
|
89553
|
+
}
|
|
89554
|
+
if (!this.isVaultUnlocked()) {
|
|
89555
|
+
throw new VaultLockedError();
|
|
89556
|
+
}
|
|
89557
|
+
const decryptedMap = await this.readDecryptedSecrets();
|
|
89558
|
+
const resolvedSecrets = {};
|
|
89559
|
+
for (const [slotName, ref] of Object.entries(conn.inputRefs)) {
|
|
89560
|
+
const val = decryptedMap[ref];
|
|
89561
|
+
if (val === void 0) {
|
|
89562
|
+
throw new MissingSecretError(slotName);
|
|
89563
|
+
}
|
|
89564
|
+
resolvedSecrets[slotName] = val;
|
|
89565
|
+
}
|
|
89566
|
+
return {
|
|
89567
|
+
connection: conn,
|
|
89568
|
+
secrets: resolvedSecrets
|
|
89569
|
+
};
|
|
89570
|
+
});
|
|
89503
89571
|
}
|
|
89504
89572
|
async advanceAuthorizationGeneration(connectionId) {
|
|
89505
89573
|
return withStoreLock(this.integrationsDir, async () => {
|
|
@@ -92030,7 +92098,6 @@ var VercelAdapter = class {
|
|
|
92030
92098
|
const wireToolName = "get_deployment";
|
|
92031
92099
|
const wireArguments = {
|
|
92032
92100
|
teamId: target.teamId,
|
|
92033
|
-
id: params.deploymentId,
|
|
92034
92101
|
idOrUrl: params.deploymentId
|
|
92035
92102
|
};
|
|
92036
92103
|
const canonicalToolArgumentsDigest = (0, import_node_crypto10.createHash)("sha256").update(JSON.stringify(canonicalizeValue(wireArguments))).digest("hex");
|
|
@@ -92672,6 +92739,26 @@ var HttpMcpClient = class {
|
|
|
92672
92739
|
const result = await this.rpc("tools/list", {});
|
|
92673
92740
|
return result?.tools ?? [];
|
|
92674
92741
|
}
|
|
92742
|
+
/** Read every advertised tool page for security-sensitive contract checks. */
|
|
92743
|
+
async listAllTools() {
|
|
92744
|
+
const tools = [];
|
|
92745
|
+
const seen = /* @__PURE__ */ new Set();
|
|
92746
|
+
let cursor;
|
|
92747
|
+
for (let page = 0; page < 32; page++) {
|
|
92748
|
+
const result = await this.rpc("tools/list", cursor ? { cursor } : {});
|
|
92749
|
+
if (!result || !Array.isArray(result.tools)) {
|
|
92750
|
+
throw new Error("Invalid paginated tools/list response");
|
|
92751
|
+
}
|
|
92752
|
+
tools.push(...result.tools);
|
|
92753
|
+
if (result.nextCursor === void 0) return tools;
|
|
92754
|
+
if (typeof result.nextCursor !== "string" || !result.nextCursor || seen.has(result.nextCursor)) {
|
|
92755
|
+
throw new Error("Invalid or repeated tools/list cursor");
|
|
92756
|
+
}
|
|
92757
|
+
seen.add(result.nextCursor);
|
|
92758
|
+
cursor = result.nextCursor;
|
|
92759
|
+
}
|
|
92760
|
+
throw new Error("Too many tools/list pages");
|
|
92761
|
+
}
|
|
92675
92762
|
async callTool(name, args) {
|
|
92676
92763
|
const result = await this.rpc("tools/call", { name, arguments: args });
|
|
92677
92764
|
return result;
|
|
@@ -93267,6 +93354,89 @@ function scopePublisherServer(server, toolName2) {
|
|
|
93267
93354
|
headers
|
|
93268
93355
|
};
|
|
93269
93356
|
}
|
|
93357
|
+
async function preflightPublisherServer(server) {
|
|
93358
|
+
if (server.transport !== "http" || !server.url || !server.headers || server.authProvider) {
|
|
93359
|
+
throw new PublisherContractError("Publisher requires an HTTP endpoint and two role-specific bearer tokens");
|
|
93360
|
+
}
|
|
93361
|
+
const headers = server.headers;
|
|
93362
|
+
const releaseToken = headers.releaseToken ?? headers.release_token ?? headers.RELEASE_TOKEN;
|
|
93363
|
+
const observeToken = headers.observeToken ?? headers.observe_token ?? headers.OBSERVE_TOKEN;
|
|
93364
|
+
if (!releaseToken || !observeToken) {
|
|
93365
|
+
throw new PublisherContractError("Publisher requires both release and observe bearer tokens");
|
|
93366
|
+
}
|
|
93367
|
+
validatePublisherUrl(server.url, "Target endpoint");
|
|
93368
|
+
await preflightPublisherSchemas(server.url, { releaseToken, observeToken }, {
|
|
93369
|
+
allowLocalEndpoints: process.env.NODE_ENV === "test" || process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1"
|
|
93370
|
+
});
|
|
93371
|
+
}
|
|
93372
|
+
async function preflightPublisherSchemas(endpoint, credentials, options) {
|
|
93373
|
+
if (credentials.releaseToken === credentials.observeToken) {
|
|
93374
|
+
throw new PublisherContractError("Identical token values rejected: release and observe credentials must be distinct");
|
|
93375
|
+
}
|
|
93376
|
+
const allowLocal = options?.allowLocalEndpoints ?? false;
|
|
93377
|
+
const releaseClient = new HttpMcpClient(
|
|
93378
|
+
endpoint,
|
|
93379
|
+
{ Authorization: `Bearer ${credentials.releaseToken}` },
|
|
93380
|
+
allowLocal
|
|
93381
|
+
);
|
|
93382
|
+
try {
|
|
93383
|
+
await releaseClient.initialize();
|
|
93384
|
+
const tools = await releaseClient.listAllTools();
|
|
93385
|
+
const releaseTools = tools.filter((t) => t?.name === PUBLISHER_MCP_V1_TOOLS.release);
|
|
93386
|
+
if (releaseTools.length !== 1) {
|
|
93387
|
+
throw new PublisherContractError(
|
|
93388
|
+
`Release credential must expose exactly one required tool "${PUBLISHER_MCP_V1_TOOLS.release}"`
|
|
93389
|
+
);
|
|
93390
|
+
}
|
|
93391
|
+
if (tools.some((t) => t.name === PUBLISHER_MCP_V1_TOOLS.observe)) {
|
|
93392
|
+
throw new PublisherContractError(
|
|
93393
|
+
`Role isolation violation: Release credential must not expose observe tool "${PUBLISHER_MCP_V1_TOOLS.observe}"`
|
|
93394
|
+
);
|
|
93395
|
+
}
|
|
93396
|
+
const digest = computeToolSchemaDigest(releaseTools[0]?.inputSchema);
|
|
93397
|
+
if (digest !== PUBLISHER_RELEASE_V1_SCHEMA_DIGEST) {
|
|
93398
|
+
throw new PublisherContractError(
|
|
93399
|
+
`Schema drift detected for "${PUBLISHER_MCP_V1_TOOLS.release}": expected digest "${PUBLISHER_RELEASE_V1_SCHEMA_DIGEST}", got "${digest}"`
|
|
93400
|
+
);
|
|
93401
|
+
}
|
|
93402
|
+
} finally {
|
|
93403
|
+
await releaseClient.close().catch(() => {
|
|
93404
|
+
});
|
|
93405
|
+
}
|
|
93406
|
+
const observeClient = new HttpMcpClient(
|
|
93407
|
+
endpoint,
|
|
93408
|
+
{ Authorization: `Bearer ${credentials.observeToken}` },
|
|
93409
|
+
allowLocal
|
|
93410
|
+
);
|
|
93411
|
+
try {
|
|
93412
|
+
await observeClient.initialize();
|
|
93413
|
+
const tools = await observeClient.listAllTools();
|
|
93414
|
+
const observeTools = tools.filter((t) => t?.name === PUBLISHER_MCP_V1_TOOLS.observe);
|
|
93415
|
+
if (observeTools.length !== 1) {
|
|
93416
|
+
throw new PublisherContractError(
|
|
93417
|
+
`Observe credential must expose exactly one required tool "${PUBLISHER_MCP_V1_TOOLS.observe}"`
|
|
93418
|
+
);
|
|
93419
|
+
}
|
|
93420
|
+
if (tools.some((t) => t.name === PUBLISHER_MCP_V1_TOOLS.release)) {
|
|
93421
|
+
throw new PublisherContractError(
|
|
93422
|
+
`Role isolation violation: Observe credential must not expose release tool "${PUBLISHER_MCP_V1_TOOLS.release}"`
|
|
93423
|
+
);
|
|
93424
|
+
}
|
|
93425
|
+
const digest = computeToolSchemaDigest(observeTools[0]?.inputSchema);
|
|
93426
|
+
if (digest !== PUBLISHER_OBSERVE_V1_SCHEMA_DIGEST) {
|
|
93427
|
+
throw new PublisherContractError(
|
|
93428
|
+
`Schema drift detected for "${PUBLISHER_MCP_V1_TOOLS.observe}": expected digest "${PUBLISHER_OBSERVE_V1_SCHEMA_DIGEST}", got "${digest}"`
|
|
93429
|
+
);
|
|
93430
|
+
}
|
|
93431
|
+
} finally {
|
|
93432
|
+
await observeClient.close().catch(() => {
|
|
93433
|
+
});
|
|
93434
|
+
}
|
|
93435
|
+
return {
|
|
93436
|
+
releaseDigest: PUBLISHER_RELEASE_V1_SCHEMA_DIGEST,
|
|
93437
|
+
observeDigest: PUBLISHER_OBSERVE_V1_SCHEMA_DIGEST
|
|
93438
|
+
};
|
|
93439
|
+
}
|
|
93270
93440
|
var publisherMcpAdapter = new PublisherMcpAdapter();
|
|
93271
93441
|
registerPublisherAdapter(publisherMcpAdapter);
|
|
93272
93442
|
|
|
@@ -93467,8 +93637,7 @@ function assertPublisherEndpoint(serverUrl, profileAuthority, envelope) {
|
|
|
93467
93637
|
if (profileAuthority !== "custom") throw new Error("profile mismatch");
|
|
93468
93638
|
const expected = new URL(envelope.target.endpoint);
|
|
93469
93639
|
if (actual.href !== expected.href) throw new Error("endpoint drift");
|
|
93470
|
-
|
|
93471
|
-
if (!localFixture) throw new Error("custom target enrollment cannot be verified");
|
|
93640
|
+
validatePublisherUrl(actual.href, "Publisher endpoint");
|
|
93472
93641
|
} else {
|
|
93473
93642
|
if (profileAuthority === "custom") throw new Error("profile mismatch");
|
|
93474
93643
|
const local = (actual.hostname === "127.0.0.1" || actual.hostname === "localhost") && (process.env.NODE_ENV === "test" || process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1");
|
|
@@ -93486,6 +93655,21 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
93486
93655
|
this.context = context;
|
|
93487
93656
|
}
|
|
93488
93657
|
static inFlightDispatches = /* @__PURE__ */ new Set();
|
|
93658
|
+
/** The operation id this attempt is bound to — the same one sent to the publisher and stamped
|
|
93659
|
+
* into the published marker. Read by the produced_url evidence write (S6). */
|
|
93660
|
+
get boundOperationId() {
|
|
93661
|
+
return this.context.operationId;
|
|
93662
|
+
}
|
|
93663
|
+
/** The source digest of the approved prepared envelope this attempt dispatches. */
|
|
93664
|
+
get boundSourceDigest() {
|
|
93665
|
+
return this.context.preparedEnvelope.sourceDigest;
|
|
93666
|
+
}
|
|
93667
|
+
/** Version of the digest scheme behind `boundSourceDigest`. Both V1 envelope schemas carry the
|
|
93668
|
+
* v1 manifest digest and no version field; an envelope that names its own version wins. */
|
|
93669
|
+
get boundSourceDigestVersion() {
|
|
93670
|
+
const declared = this.context.preparedEnvelope.sourceDigestVersion;
|
|
93671
|
+
return typeof declared === "string" && declared.length > 0 ? declared : "v1";
|
|
93672
|
+
}
|
|
93489
93673
|
/**
|
|
93490
93674
|
* Prepares the attempt row in the database (or retrieves existing row).
|
|
93491
93675
|
*/
|
|
@@ -93658,6 +93842,9 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
93658
93842
|
);
|
|
93659
93843
|
}
|
|
93660
93844
|
await this.verifyAuthority(server, approvedEnvelope, payload.operation, payload.profileId);
|
|
93845
|
+
if ("profileId" in approvedEnvelope && approvedEnvelope.profileId === "publisher.mcp.v1") {
|
|
93846
|
+
await preflightPublisherServer(server);
|
|
93847
|
+
}
|
|
93661
93848
|
if (current2.dispatchCount && current2.dispatchCount > 0) {
|
|
93662
93849
|
throw new PublishLeaseFencingError(
|
|
93663
93850
|
`Single-use dispatch commitment already consumed for attempt ${attemptId} (dispatchCount=${current2.dispatchCount}). Re-dispatch is prohibited; status must be reconciled.`
|
|
@@ -93669,7 +93856,8 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
93669
93856
|
);
|
|
93670
93857
|
}
|
|
93671
93858
|
const comm = await this.client.commitPublishDispatch(this.context.projectSlug, attemptId, {
|
|
93672
|
-
leaseOwner: this.context.leaseOwner
|
|
93859
|
+
leaseOwner: this.context.leaseOwner,
|
|
93860
|
+
operationId: this.context.operationId
|
|
93673
93861
|
});
|
|
93674
93862
|
if (!comm) {
|
|
93675
93863
|
throw new PublishLeaseFencingError(
|
|
@@ -93938,6 +94126,12 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
93938
94126
|
`AUTHORITY_DRIFT: Live authorization generation (${liveBinding.authorizationGeneration}) does not match approved envelope authorization generation (${approvedEnvelope.authorizationGeneration})`
|
|
93939
94127
|
);
|
|
93940
94128
|
}
|
|
94129
|
+
if ("target" in approvedEnvelope && (!liveBinding.publisherTarget || computeTargetFingerprint(liveBinding.publisherTarget) !== computeTargetFingerprint(approvedEnvelope.target))) {
|
|
94130
|
+
throw new PublishLeaseFencingError("AUTHORITY_DRIFT: Publisher target differs from owner enrollment");
|
|
94131
|
+
}
|
|
94132
|
+
if ("target" in approvedEnvelope && server.authorizationGeneration !== liveBinding.authorizationGeneration) {
|
|
94133
|
+
throw new PublishLeaseFencingError("AUTHORITY_DRIFT: Local publisher authorization generation changed");
|
|
94134
|
+
}
|
|
93941
94135
|
if (server.connectionId && liveBinding.connectionId !== server.connectionId) {
|
|
93942
94136
|
throw new PublishLeaseFencingError(
|
|
93943
94137
|
`AUTHORITY_DRIFT: Live binding connectionId (${liveBinding.connectionId}) does not match server connectionId (${server.connectionId})`
|
|
@@ -94226,10 +94420,12 @@ async function resolveDeliveryServer(serverId, opts) {
|
|
|
94226
94420
|
return null;
|
|
94227
94421
|
}
|
|
94228
94422
|
if (resolved.kind === "managed") {
|
|
94423
|
+
let managedConnection = resolved.connection;
|
|
94229
94424
|
let secrets = {};
|
|
94230
94425
|
if (resolved.connection.inputRefs && Object.keys(resolved.connection.inputRefs).length > 0 && store.isVaultUnlocked()) {
|
|
94231
94426
|
try {
|
|
94232
94427
|
const secretObj = await store.resolveConnection(resolved.connection.id);
|
|
94428
|
+
managedConnection = secretObj.connection;
|
|
94233
94429
|
secrets = secretObj.secrets;
|
|
94234
94430
|
} catch {
|
|
94235
94431
|
}
|
|
@@ -94237,11 +94433,11 @@ async function resolveDeliveryServer(serverId, opts) {
|
|
|
94237
94433
|
let authProvider;
|
|
94238
94434
|
if (store.isVaultUnlocked()) {
|
|
94239
94435
|
try {
|
|
94240
|
-
const authGen =
|
|
94241
|
-
const mapping = await store.getOAuthResourceMapping(
|
|
94242
|
-
if (mapping?.resource &&
|
|
94436
|
+
const authGen = managedConnection.authorizationGeneration ?? 1;
|
|
94437
|
+
const mapping = await store.getOAuthResourceMapping(managedConnection.id, authGen);
|
|
94438
|
+
if (mapping?.resource && managedConnection.endpoint) {
|
|
94243
94439
|
try {
|
|
94244
|
-
const endpointOrigin = new URL(
|
|
94440
|
+
const endpointOrigin = new URL(managedConnection.endpoint).origin;
|
|
94245
94441
|
const resourceOrigin = new URL(mapping.resource).origin;
|
|
94246
94442
|
if (endpointOrigin !== resourceOrigin) {
|
|
94247
94443
|
throw new AuthorizationGenerationMismatchError(
|
|
@@ -94253,15 +94449,15 @@ async function resolveDeliveryServer(serverId, opts) {
|
|
|
94253
94449
|
}
|
|
94254
94450
|
}
|
|
94255
94451
|
const tokens2 = await store.getOAuthTokens({
|
|
94256
|
-
connectionId:
|
|
94452
|
+
connectionId: managedConnection.id,
|
|
94257
94453
|
authorizationGeneration: authGen,
|
|
94258
94454
|
issuer: mapping?.issuer,
|
|
94259
94455
|
resource: mapping?.resource
|
|
94260
94456
|
});
|
|
94261
94457
|
let isServerHostLocal = false;
|
|
94262
|
-
if (
|
|
94458
|
+
if (managedConnection.endpoint) {
|
|
94263
94459
|
try {
|
|
94264
|
-
const parsedEndpoint = new URL(
|
|
94460
|
+
const parsedEndpoint = new URL(managedConnection.endpoint);
|
|
94265
94461
|
isServerHostLocal = parsedEndpoint.hostname === "localhost" || parsedEndpoint.hostname === "127.0.0.1" || parsedEndpoint.hostname === "::1" || parsedEndpoint.hostname === "[::1]";
|
|
94266
94462
|
} catch {
|
|
94267
94463
|
}
|
|
@@ -94270,7 +94466,7 @@ async function resolveDeliveryServer(serverId, opts) {
|
|
|
94270
94466
|
if (tokens2) {
|
|
94271
94467
|
authProvider = new MrrlinOAuthClientProvider({
|
|
94272
94468
|
store,
|
|
94273
|
-
connectionId:
|
|
94469
|
+
connectionId: managedConnection.id,
|
|
94274
94470
|
authorizationGeneration: authGen,
|
|
94275
94471
|
redirectUrl: "http://127.0.0.1/integrations/oauth/callback",
|
|
94276
94472
|
expectedIssuer: mapping?.issuer,
|
|
@@ -94282,35 +94478,35 @@ async function resolveDeliveryServer(serverId, opts) {
|
|
|
94282
94478
|
if (err instanceof AuthorizationGenerationMismatchError) throw err;
|
|
94283
94479
|
}
|
|
94284
94480
|
}
|
|
94285
|
-
const configDigest =
|
|
94286
|
-
transport:
|
|
94287
|
-
endpoint:
|
|
94288
|
-
command:
|
|
94289
|
-
args:
|
|
94290
|
-
envKeys:
|
|
94291
|
-
inputRefKeys: Object.keys(
|
|
94481
|
+
const configDigest = managedConnection.configDigest ?? computeConnectionConfigDigest({
|
|
94482
|
+
transport: managedConnection.transport,
|
|
94483
|
+
endpoint: managedConnection.endpoint,
|
|
94484
|
+
command: managedConnection.command,
|
|
94485
|
+
args: managedConnection.args,
|
|
94486
|
+
envKeys: managedConnection.envKeys,
|
|
94487
|
+
inputRefKeys: Object.keys(managedConnection.inputRefs ?? {})
|
|
94292
94488
|
});
|
|
94293
|
-
if (
|
|
94489
|
+
if (managedConnection.transport === "streamable_http") {
|
|
94294
94490
|
return {
|
|
94295
|
-
id:
|
|
94491
|
+
id: managedConnection.legacyServerId ?? managedConnection.id,
|
|
94296
94492
|
transport: "http",
|
|
94297
|
-
url:
|
|
94493
|
+
url: managedConnection.endpoint ?? "",
|
|
94298
94494
|
headers: secrets,
|
|
94299
94495
|
authProvider,
|
|
94300
|
-
connectionId:
|
|
94301
|
-
authorizationGeneration:
|
|
94496
|
+
connectionId: managedConnection.id,
|
|
94497
|
+
authorizationGeneration: managedConnection.authorizationGeneration,
|
|
94302
94498
|
configDigest
|
|
94303
94499
|
};
|
|
94304
94500
|
}
|
|
94305
94501
|
return {
|
|
94306
|
-
id:
|
|
94502
|
+
id: managedConnection.legacyServerId ?? managedConnection.id,
|
|
94307
94503
|
transport: "stdio",
|
|
94308
|
-
command:
|
|
94309
|
-
args:
|
|
94504
|
+
command: managedConnection.command ?? "",
|
|
94505
|
+
args: managedConnection.args ?? [],
|
|
94310
94506
|
env: secrets,
|
|
94311
94507
|
authProvider,
|
|
94312
|
-
connectionId:
|
|
94313
|
-
authorizationGeneration:
|
|
94508
|
+
connectionId: managedConnection.id,
|
|
94509
|
+
authorizationGeneration: managedConnection.authorizationGeneration,
|
|
94314
94510
|
configDigest
|
|
94315
94511
|
};
|
|
94316
94512
|
}
|
|
@@ -94923,10 +95119,15 @@ async function callDestination(client, projectSlug, route, resolvedToolName, pay
|
|
|
94923
95119
|
}
|
|
94924
95120
|
}
|
|
94925
95121
|
}
|
|
94926
|
-
|
|
95122
|
+
const delivered = await deliverToPublish(server, resolvedToolName, publishPayload, {
|
|
94927
95123
|
controller,
|
|
94928
95124
|
attemptId: attId
|
|
94929
95125
|
});
|
|
95126
|
+
await recordManagedPublishEvidence(client, projectSlug, runId, controller, attId, delivered, {
|
|
95127
|
+
operation: typeof operation === "string" ? operation : "",
|
|
95128
|
+
environment: publishPayload.environment
|
|
95129
|
+
});
|
|
95130
|
+
return delivered;
|
|
94930
95131
|
}
|
|
94931
95132
|
return deliverToPublish(server, resolvedToolName, publishPayload, {
|
|
94932
95133
|
controller: attemptController,
|
|
@@ -95159,6 +95360,38 @@ async function readPullRequestState(client, projectSlug, taskProjectSlug, pullRe
|
|
|
95159
95360
|
throw err;
|
|
95160
95361
|
}
|
|
95161
95362
|
}
|
|
95363
|
+
async function recordManagedPublishEvidence(client, projectSlug, runId, controller, attemptId, delivered, publish) {
|
|
95364
|
+
if (!runId || !controller) return;
|
|
95365
|
+
if (!isReleasePublish(publish)) return;
|
|
95366
|
+
const url2 = delivered.normalized?.url ?? null;
|
|
95367
|
+
if (delivered.normalized?.status !== "success" || !url2 || url2 !== delivered.url) return;
|
|
95368
|
+
const operationId = controller.boundOperationId;
|
|
95369
|
+
const sourceDigest = controller.boundSourceDigest;
|
|
95370
|
+
if (!operationId || !sourceDigest) return;
|
|
95371
|
+
const id = `EA-pu-m-${import_node_crypto12.default.createHash("sha256").update(`${runId}
|
|
95372
|
+
${operationId}
|
|
95373
|
+
${url2}`).digest("hex").slice(0, 16)}`;
|
|
95374
|
+
try {
|
|
95375
|
+
await client.appendExecutionArtifact(projectSlug, runId, {
|
|
95376
|
+
id,
|
|
95377
|
+
kind: "produced_url",
|
|
95378
|
+
payload: {
|
|
95379
|
+
url: url2,
|
|
95380
|
+
label: "managed_publish",
|
|
95381
|
+
operationId,
|
|
95382
|
+
sourceDigest,
|
|
95383
|
+
sourceDigestVersion: controller.boundSourceDigestVersion,
|
|
95384
|
+
...attemptId ? { publishAttemptId: attemptId } : {}
|
|
95385
|
+
}
|
|
95386
|
+
});
|
|
95387
|
+
} catch (error51) {
|
|
95388
|
+
console.error(`[mrrlin] produced_url evidence write failed for run ${runId}: ${errorMessage(error51) ?? String(error51)}`);
|
|
95389
|
+
}
|
|
95390
|
+
}
|
|
95391
|
+
function isReleasePublish(publish) {
|
|
95392
|
+
if (publish.environment !== "production") return false;
|
|
95393
|
+
return publish.operation === "release" || publish.operation === "publish_release" || publish.operation === "observe" || publish.operation === "publish_observe";
|
|
95394
|
+
}
|
|
95162
95395
|
function digestCapabilityPayload(payload) {
|
|
95163
95396
|
if (payload && typeof payload === "object" && "envelope" in payload) {
|
|
95164
95397
|
const { envelope: _env, ...rest } = payload;
|
|
@@ -96479,7 +96712,7 @@ function buildDraftSpecPrompt(task, constitution, deployTarget = null) {
|
|
|
96479
96712
|
`id: ${task.id}`,
|
|
96480
96713
|
`title: ${task.title}`,
|
|
96481
96714
|
`type: ${task.type ?? "task"}`,
|
|
96482
|
-
`domains: ${
|
|
96715
|
+
`domains: ${task.domains?.length ? task.domains.join(", ") : "none (not a code task)"}`,
|
|
96483
96716
|
`impact: ${task.impact ?? ""}`,
|
|
96484
96717
|
`category: ${task.category ?? ""} / ${task.subcategory ?? ""}`,
|
|
96485
96718
|
`tags: ${(task.tags ?? []).join(", ")}`,
|
|
@@ -99650,6 +99883,56 @@ function unfinishedRunWorktrees(runs) {
|
|
|
99650
99883
|
}
|
|
99651
99884
|
return keep;
|
|
99652
99885
|
}
|
|
99886
|
+
function gitCommonDir(checkout) {
|
|
99887
|
+
const dotGit = (0, import_node_path24.join)(checkout, ".git");
|
|
99888
|
+
try {
|
|
99889
|
+
if ((0, import_node_fs18.lstatSync)(dotGit).isDirectory()) return dotGit;
|
|
99890
|
+
const match2 = /^gitdir: (.+)$/m.exec((0, import_node_fs18.readFileSync)(dotGit, "utf8"));
|
|
99891
|
+
if (!match2?.[1]) return null;
|
|
99892
|
+
const gitdir = (0, import_node_path24.resolve)(checkout, match2[1].trim());
|
|
99893
|
+
try {
|
|
99894
|
+
return (0, import_node_path24.resolve)(gitdir, (0, import_node_fs18.readFileSync)((0, import_node_path24.join)(gitdir, "commondir"), "utf8").trim());
|
|
99895
|
+
} catch {
|
|
99896
|
+
return gitdir;
|
|
99897
|
+
}
|
|
99898
|
+
} catch {
|
|
99899
|
+
return null;
|
|
99900
|
+
}
|
|
99901
|
+
}
|
|
99902
|
+
function pruneOwnedStaleRegistrations(checkout, ownedPrefixes) {
|
|
99903
|
+
const commonDir = gitCommonDir(checkout);
|
|
99904
|
+
if (!commonDir) return [];
|
|
99905
|
+
const admin = (0, import_node_path24.join)(commonDir, "worktrees");
|
|
99906
|
+
let ids;
|
|
99907
|
+
try {
|
|
99908
|
+
ids = (0, import_node_fs18.readdirSync)(admin);
|
|
99909
|
+
} catch {
|
|
99910
|
+
return [];
|
|
99911
|
+
}
|
|
99912
|
+
const fold = (path42) => process.platform === "win32" ? (0, import_node_path24.normalize)(path42).toLowerCase() : (0, import_node_path24.normalize)(path42);
|
|
99913
|
+
const prefixes = ownedPrefixes.map(fold);
|
|
99914
|
+
const pruned = [];
|
|
99915
|
+
for (const id of ids) {
|
|
99916
|
+
const entry = (0, import_node_path24.join)(admin, id);
|
|
99917
|
+
if ((0, import_node_fs18.existsSync)((0, import_node_path24.join)(entry, "locked"))) continue;
|
|
99918
|
+
let target;
|
|
99919
|
+
try {
|
|
99920
|
+
target = (0, import_node_fs18.readFileSync)((0, import_node_path24.join)(entry, "gitdir"), "utf8").trim();
|
|
99921
|
+
} catch {
|
|
99922
|
+
continue;
|
|
99923
|
+
}
|
|
99924
|
+
if (!(0, import_node_path24.isAbsolute)(target) || (0, import_node_path24.basename)(target) !== ".git" || /[\x00-\x1f\x7f]/.test(target)) continue;
|
|
99925
|
+
const worktree = (0, import_node_path24.dirname)(target);
|
|
99926
|
+
if (!prefixes.some((prefix) => fold(worktree).startsWith(prefix))) continue;
|
|
99927
|
+
if ((0, import_node_fs18.existsSync)(target) || (0, import_node_fs18.existsSync)(worktree)) continue;
|
|
99928
|
+
try {
|
|
99929
|
+
(0, import_node_fs18.rmSync)(entry, { recursive: true, force: true });
|
|
99930
|
+
pruned.push(worktree);
|
|
99931
|
+
} catch {
|
|
99932
|
+
}
|
|
99933
|
+
}
|
|
99934
|
+
return pruned;
|
|
99935
|
+
}
|
|
99653
99936
|
async function sweepOrphanWorktrees(opts, runGit2 = git2) {
|
|
99654
99937
|
const reaped = [];
|
|
99655
99938
|
const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, `sweep:${opts.slug}`);
|
|
@@ -99707,6 +99990,8 @@ async function sweepOrphanWorktrees(opts, runGit2 = git2) {
|
|
|
99707
99990
|
}
|
|
99708
99991
|
}
|
|
99709
99992
|
}
|
|
99993
|
+
const rawPrefix = (0, import_node_path24.normalize)(opts.worktreeRoot) + import_node_path24.sep + opts.slug + import_node_path24.sep;
|
|
99994
|
+
reaped.push(...pruneOwnedStaleRegistrations(opts.checkout, [ownedPrefix, rawPrefix]));
|
|
99710
99995
|
});
|
|
99711
99996
|
});
|
|
99712
99997
|
} finally {
|
|
@@ -102504,6 +102789,12 @@ function createMrrlinTools(options) {
|
|
|
102504
102789
|
"A local_apply landing record is written only by the bridge when it lands a run. Read the landing with get_execution_run (localLanding) instead."
|
|
102505
102790
|
);
|
|
102506
102791
|
}
|
|
102792
|
+
if (input.kind === "produced_url") {
|
|
102793
|
+
throw new McpToolCodedError(
|
|
102794
|
+
"PRODUCED_URL_RESERVED",
|
|
102795
|
+
"A produced_url artifact is written only by record_produced_url. Call record_produced_url with the page's URL instead."
|
|
102796
|
+
);
|
|
102797
|
+
}
|
|
102507
102798
|
return await c.appendExecutionArtifact(projectSlug, runId, input);
|
|
102508
102799
|
}
|
|
102509
102800
|
),
|
|
@@ -106548,7 +106839,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106548
106839
|
}
|
|
106549
106840
|
|
|
106550
106841
|
// src/_generated/version.ts
|
|
106551
|
-
var PKG_VERSION = "0.4.
|
|
106842
|
+
var PKG_VERSION = "0.4.247";
|
|
106552
106843
|
|
|
106553
106844
|
// src/bridge-allowed-origins.ts
|
|
106554
106845
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -110732,7 +111023,627 @@ init_dist2();
|
|
|
110732
111023
|
init_dist();
|
|
110733
111024
|
|
|
110734
111025
|
// src/delivery/public-url-verifier.ts
|
|
111026
|
+
var DEFAULT_VERIFIER_TIMEOUT_MS = 1e4;
|
|
111027
|
+
var DEFAULT_VERIFIER_MAX_REDIRECTS = 3;
|
|
110735
111028
|
var DEFAULT_VERIFIER_MAX_BYTES = 2 * 1024 * 1024;
|
|
111029
|
+
function isProtectedStatus(status) {
|
|
111030
|
+
return status === 401 || status === 403;
|
|
111031
|
+
}
|
|
111032
|
+
function isDnsOrUnreachableError(err) {
|
|
111033
|
+
if (!err) return false;
|
|
111034
|
+
if (err?.name === "TimeoutError") return true;
|
|
111035
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
111036
|
+
const lower = msg.toLowerCase();
|
|
111037
|
+
return lower.includes("failed to resolve hostname") || lower.includes("enotfound") || lower.includes("eai_again") || lower.includes("econnrefused") || lower.includes("econnreset") || lower.includes("etimedout") || lower.includes("timed out") || lower.includes("getaddrinfo") || lower.includes("dns") || lower.includes("unresolvable") || err instanceof NetworkPolicyViolationError && lower.includes("resolve");
|
|
111038
|
+
}
|
|
111039
|
+
var LOGIN_PATH_SEGMENTS = /* @__PURE__ */ new Set([
|
|
111040
|
+
"login",
|
|
111041
|
+
"log-in",
|
|
111042
|
+
"signin",
|
|
111043
|
+
"sign-in",
|
|
111044
|
+
"auth",
|
|
111045
|
+
"sso",
|
|
111046
|
+
"oauth",
|
|
111047
|
+
"authorize"
|
|
111048
|
+
]);
|
|
111049
|
+
function looksLikeLoginPage(input) {
|
|
111050
|
+
const { requestedUrl, finalUrl, body } = input;
|
|
111051
|
+
if (finalUrl) {
|
|
111052
|
+
try {
|
|
111053
|
+
const requested = new URL(requestedUrl);
|
|
111054
|
+
const final = new URL(finalUrl);
|
|
111055
|
+
const redirected = requested.origin !== final.origin || requested.pathname !== final.pathname;
|
|
111056
|
+
if (redirected) {
|
|
111057
|
+
const path42 = final.pathname.toLowerCase();
|
|
111058
|
+
if (path42.split("/").filter(Boolean).some((segment) => LOGIN_PATH_SEGMENTS.has(segment))) return true;
|
|
111059
|
+
if (path42.includes("protection_bypass") || final.searchParams.has("protection_bypass")) return true;
|
|
111060
|
+
}
|
|
111061
|
+
} catch {
|
|
111062
|
+
}
|
|
111063
|
+
}
|
|
111064
|
+
if (body) {
|
|
111065
|
+
const asksForPassword = /<input\b[^>]*\btype\s*=\s*["']?password\b/i.test(body);
|
|
111066
|
+
const title = /<title[^>]*>([\s\S]*?)<\/title>/i.exec(body)?.[1] ?? "";
|
|
111067
|
+
const signInTitle = /\b(log[\s-]?in|sign[\s-]?in|authenticate|authentication required)\b/i.test(title);
|
|
111068
|
+
if (asksForPassword && signInTitle) return true;
|
|
111069
|
+
}
|
|
111070
|
+
return false;
|
|
111071
|
+
}
|
|
111072
|
+
function finalResponseUrl(response) {
|
|
111073
|
+
return typeof response.url === "string" ? response.url : "";
|
|
111074
|
+
}
|
|
111075
|
+
async function readBodyPrefix(response, maxBytes = 64 * 1024) {
|
|
111076
|
+
const reader = response.body?.getReader();
|
|
111077
|
+
if (!reader) return "";
|
|
111078
|
+
const chunks = [];
|
|
111079
|
+
let total = 0;
|
|
111080
|
+
try {
|
|
111081
|
+
while (total < maxBytes) {
|
|
111082
|
+
const { done, value } = await reader.read();
|
|
111083
|
+
if (done || !value) break;
|
|
111084
|
+
chunks.push(Buffer.from(value));
|
|
111085
|
+
total += value.byteLength;
|
|
111086
|
+
}
|
|
111087
|
+
} catch {
|
|
111088
|
+
} finally {
|
|
111089
|
+
await reader.cancel().catch(() => {
|
|
111090
|
+
});
|
|
111091
|
+
}
|
|
111092
|
+
return Buffer.concat(chunks).subarray(0, maxBytes).toString("utf8");
|
|
111093
|
+
}
|
|
111094
|
+
function isTransientVerificationFailure(result) {
|
|
111095
|
+
if (result.transient === true) return true;
|
|
111096
|
+
if (result.outcome === "dns_pending") return true;
|
|
111097
|
+
return typeof result.httpStatus === "number" && result.httpStatus >= 500 && (result.outcome === "marker_missing" || result.outcome === "landing_page_error" || result.outcome === "verification_failed");
|
|
111098
|
+
}
|
|
111099
|
+
function readMarkerDigestVersion(rawContent) {
|
|
111100
|
+
try {
|
|
111101
|
+
const parsed = JSON.parse(rawContent);
|
|
111102
|
+
if (parsed === null || typeof parsed !== "object") return null;
|
|
111103
|
+
const version2 = parsed.sourceDigestVersion;
|
|
111104
|
+
if (version2 === void 0) return "v1";
|
|
111105
|
+
return typeof version2 === "string" && version2.length > 0 ? version2 : null;
|
|
111106
|
+
} catch {
|
|
111107
|
+
return null;
|
|
111108
|
+
}
|
|
111109
|
+
}
|
|
111110
|
+
function cleanBaseUrl(rawUrl) {
|
|
111111
|
+
const trimmed = rawUrl.trim();
|
|
111112
|
+
const withProtocol = trimmed.startsWith("http://") || trimmed.startsWith("https://") ? trimmed : `https://${trimmed}`;
|
|
111113
|
+
return withProtocol.replace(/\/+$/, "");
|
|
111114
|
+
}
|
|
111115
|
+
async function verifyPublicUrl(options) {
|
|
111116
|
+
const {
|
|
111117
|
+
publicUrl,
|
|
111118
|
+
expectedOperationId,
|
|
111119
|
+
expectedSourceDigest,
|
|
111120
|
+
expectedSourceDigestVersion,
|
|
111121
|
+
markerPath = PUBLISH_SOURCE_LIMITS.RESERVED_MARKER_PATH,
|
|
111122
|
+
customDomain,
|
|
111123
|
+
allowLocalEndpoints = process.env.NODE_ENV === "test" && process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1",
|
|
111124
|
+
timeoutMs = DEFAULT_VERIFIER_TIMEOUT_MS,
|
|
111125
|
+
maxRedirects = DEFAULT_VERIFIER_MAX_REDIRECTS,
|
|
111126
|
+
maxResponseBytes = DEFAULT_VERIFIER_MAX_BYTES,
|
|
111127
|
+
fetchFn = safeFetch
|
|
111128
|
+
} = options;
|
|
111129
|
+
if (!publicUrl || typeof publicUrl !== "string") {
|
|
111130
|
+
return {
|
|
111131
|
+
verified: false,
|
|
111132
|
+
publicUrl: String(publicUrl),
|
|
111133
|
+
outcome: "verification_failed",
|
|
111134
|
+
reason: "Candidate public URL must be a non-empty string"
|
|
111135
|
+
};
|
|
111136
|
+
}
|
|
111137
|
+
const normalizedPublicBase = cleanBaseUrl(publicUrl);
|
|
111138
|
+
const cleanMarkerPath = markerPath.replace(/^\/+/, "");
|
|
111139
|
+
const markerUrl = `${normalizedPublicBase}/${cleanMarkerPath}`;
|
|
111140
|
+
const landingUrl = `${normalizedPublicBase}/`;
|
|
111141
|
+
const policy = {
|
|
111142
|
+
allowLocalEndpoints,
|
|
111143
|
+
timeoutMs,
|
|
111144
|
+
maxRedirects,
|
|
111145
|
+
maxResponseBytes
|
|
111146
|
+
};
|
|
111147
|
+
let markerResponse;
|
|
111148
|
+
try {
|
|
111149
|
+
markerResponse = await fetchFn(
|
|
111150
|
+
markerUrl,
|
|
111151
|
+
{
|
|
111152
|
+
method: "GET",
|
|
111153
|
+
headers: {
|
|
111154
|
+
accept: "application/json, text/plain",
|
|
111155
|
+
"user-agent": "Mrrlin-Public-Verifier/1.0"
|
|
111156
|
+
}
|
|
111157
|
+
},
|
|
111158
|
+
policy
|
|
111159
|
+
);
|
|
111160
|
+
} catch (err) {
|
|
111161
|
+
if (err instanceof NetworkPolicyViolationError) {
|
|
111162
|
+
return {
|
|
111163
|
+
verified: false,
|
|
111164
|
+
publicUrl: normalizedPublicBase,
|
|
111165
|
+
outcome: "network_policy_violation",
|
|
111166
|
+
reason: `Network policy rejected verification request: ${err.message}`,
|
|
111167
|
+
...isDnsOrUnreachableError(err) ? { transient: true } : {}
|
|
111168
|
+
};
|
|
111169
|
+
}
|
|
111170
|
+
return {
|
|
111171
|
+
verified: false,
|
|
111172
|
+
publicUrl: normalizedPublicBase,
|
|
111173
|
+
outcome: "verification_failed",
|
|
111174
|
+
reason: `Failed to reach verification marker endpoint: ${err instanceof Error ? err.message : String(err)}`,
|
|
111175
|
+
...isDnsOrUnreachableError(err) ? { transient: true } : {}
|
|
111176
|
+
};
|
|
111177
|
+
}
|
|
111178
|
+
if (isProtectedStatus(markerResponse.status)) {
|
|
111179
|
+
return {
|
|
111180
|
+
verified: false,
|
|
111181
|
+
publicUrl: normalizedPublicBase,
|
|
111182
|
+
outcome: "protected_preview",
|
|
111183
|
+
reason: `Verification marker is protected by an authentication wall (HTTP ${markerResponse.status})`,
|
|
111184
|
+
httpStatus: markerResponse.status
|
|
111185
|
+
};
|
|
111186
|
+
}
|
|
111187
|
+
if (markerResponse.status !== 200) {
|
|
111188
|
+
return {
|
|
111189
|
+
verified: false,
|
|
111190
|
+
publicUrl: normalizedPublicBase,
|
|
111191
|
+
outcome: "marker_missing",
|
|
111192
|
+
reason: `Verification marker request returned non-200 status (HTTP ${markerResponse.status})`,
|
|
111193
|
+
httpStatus: markerResponse.status
|
|
111194
|
+
};
|
|
111195
|
+
}
|
|
111196
|
+
let markerBody;
|
|
111197
|
+
try {
|
|
111198
|
+
markerBody = await readBoundedResponseBody(markerResponse, maxResponseBytes);
|
|
111199
|
+
} catch (err) {
|
|
111200
|
+
return {
|
|
111201
|
+
verified: false,
|
|
111202
|
+
publicUrl: normalizedPublicBase,
|
|
111203
|
+
outcome: "verification_failed",
|
|
111204
|
+
reason: `Failed to read marker response body within bounds: ${err instanceof Error ? err.message : String(err)}`
|
|
111205
|
+
};
|
|
111206
|
+
}
|
|
111207
|
+
if (expectedSourceDigestVersion !== void 0) {
|
|
111208
|
+
const markerVersion = readMarkerDigestVersion(markerBody);
|
|
111209
|
+
if (markerVersion !== expectedSourceDigestVersion) {
|
|
111210
|
+
return {
|
|
111211
|
+
verified: false,
|
|
111212
|
+
publicUrl: normalizedPublicBase,
|
|
111213
|
+
outcome: "digest_version_mismatch",
|
|
111214
|
+
reason: `Verification marker uses source digest version "${markerVersion ?? "unreadable"}", expected "${expectedSourceDigestVersion}"`,
|
|
111215
|
+
httpStatus: markerResponse.status
|
|
111216
|
+
};
|
|
111217
|
+
}
|
|
111218
|
+
}
|
|
111219
|
+
const markerValid = verifyPublishMarker(markerBody, {
|
|
111220
|
+
operationId: expectedOperationId,
|
|
111221
|
+
sourceDigest: expectedSourceDigest
|
|
111222
|
+
});
|
|
111223
|
+
if (!markerValid) {
|
|
111224
|
+
return {
|
|
111225
|
+
verified: false,
|
|
111226
|
+
publicUrl: normalizedPublicBase,
|
|
111227
|
+
outcome: "marker_mismatch",
|
|
111228
|
+
reason: "Verification marker content does not match expected operationId and sourceDigest (PUB-009)",
|
|
111229
|
+
httpStatus: markerResponse.status
|
|
111230
|
+
};
|
|
111231
|
+
}
|
|
111232
|
+
let landingResponse;
|
|
111233
|
+
try {
|
|
111234
|
+
landingResponse = await fetchFn(
|
|
111235
|
+
landingUrl,
|
|
111236
|
+
{
|
|
111237
|
+
method: "GET",
|
|
111238
|
+
headers: {
|
|
111239
|
+
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
111240
|
+
"user-agent": "Mrrlin-Public-Verifier/1.0"
|
|
111241
|
+
}
|
|
111242
|
+
},
|
|
111243
|
+
policy
|
|
111244
|
+
);
|
|
111245
|
+
} catch (err) {
|
|
111246
|
+
if (err instanceof NetworkPolicyViolationError) {
|
|
111247
|
+
return {
|
|
111248
|
+
verified: false,
|
|
111249
|
+
publicUrl: normalizedPublicBase,
|
|
111250
|
+
outcome: "network_policy_violation",
|
|
111251
|
+
reason: `Network policy rejected landing page request: ${err.message}`,
|
|
111252
|
+
...isDnsOrUnreachableError(err) ? { transient: true } : {}
|
|
111253
|
+
};
|
|
111254
|
+
}
|
|
111255
|
+
return {
|
|
111256
|
+
verified: false,
|
|
111257
|
+
publicUrl: normalizedPublicBase,
|
|
111258
|
+
outcome: "verification_failed",
|
|
111259
|
+
reason: `Failed to reach landing page: ${err instanceof Error ? err.message : String(err)}`,
|
|
111260
|
+
...isDnsOrUnreachableError(err) ? { transient: true } : {}
|
|
111261
|
+
};
|
|
111262
|
+
}
|
|
111263
|
+
if (isProtectedStatus(landingResponse.status)) {
|
|
111264
|
+
await landingResponse.body?.cancel().catch(() => {
|
|
111265
|
+
});
|
|
111266
|
+
return {
|
|
111267
|
+
verified: false,
|
|
111268
|
+
publicUrl: normalizedPublicBase,
|
|
111269
|
+
outcome: "protected_preview",
|
|
111270
|
+
reason: `Landing page is protected by authentication or preview gate (HTTP ${landingResponse.status})`,
|
|
111271
|
+
httpStatus: landingResponse.status
|
|
111272
|
+
};
|
|
111273
|
+
}
|
|
111274
|
+
if (landingResponse.status >= 400) {
|
|
111275
|
+
await landingResponse.body?.cancel().catch(() => {
|
|
111276
|
+
});
|
|
111277
|
+
return {
|
|
111278
|
+
verified: false,
|
|
111279
|
+
publicUrl: normalizedPublicBase,
|
|
111280
|
+
outcome: "landing_page_error",
|
|
111281
|
+
reason: `Landing page returned HTTP ${landingResponse.status}`,
|
|
111282
|
+
httpStatus: landingResponse.status
|
|
111283
|
+
};
|
|
111284
|
+
}
|
|
111285
|
+
const landingBody = await readBodyPrefix(landingResponse);
|
|
111286
|
+
if (looksLikeLoginPage({ requestedUrl: landingUrl, finalUrl: finalResponseUrl(landingResponse), body: landingBody })) {
|
|
111287
|
+
return {
|
|
111288
|
+
verified: false,
|
|
111289
|
+
publicUrl: normalizedPublicBase,
|
|
111290
|
+
outcome: "protected_preview",
|
|
111291
|
+
reason: `Landing page ends on a sign-in page${finalResponseUrl(landingResponse) ? ` (${finalResponseUrl(landingResponse)})` : ""}, so it is not public`,
|
|
111292
|
+
httpStatus: landingResponse.status
|
|
111293
|
+
};
|
|
111294
|
+
}
|
|
111295
|
+
let customDomainVerified = false;
|
|
111296
|
+
if (customDomain && customDomain.trim().length > 0) {
|
|
111297
|
+
const normalizedDomain = customDomain.trim().toLowerCase().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
111298
|
+
const customDomainMarkerUrl = `https://${normalizedDomain}/${cleanMarkerPath}`;
|
|
111299
|
+
let domainResponse;
|
|
111300
|
+
try {
|
|
111301
|
+
domainResponse = await fetchFn(
|
|
111302
|
+
customDomainMarkerUrl,
|
|
111303
|
+
{
|
|
111304
|
+
method: "GET",
|
|
111305
|
+
headers: {
|
|
111306
|
+
accept: "application/json, text/plain",
|
|
111307
|
+
"user-agent": "Mrrlin-Public-Verifier/1.0"
|
|
111308
|
+
}
|
|
111309
|
+
},
|
|
111310
|
+
policy
|
|
111311
|
+
);
|
|
111312
|
+
} catch (err) {
|
|
111313
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
111314
|
+
if (isDnsOrUnreachableError(err)) {
|
|
111315
|
+
return {
|
|
111316
|
+
verified: false,
|
|
111317
|
+
publicUrl: normalizedPublicBase,
|
|
111318
|
+
outcome: "dns_pending",
|
|
111319
|
+
reason: `Custom domain "${normalizedDomain}" DNS is propagating or unresolvable (PUB-010): ${msg}`
|
|
111320
|
+
};
|
|
111321
|
+
}
|
|
111322
|
+
return {
|
|
111323
|
+
verified: false,
|
|
111324
|
+
publicUrl: normalizedPublicBase,
|
|
111325
|
+
outcome: "verification_failed",
|
|
111326
|
+
reason: `Custom domain verification failed: ${msg}`
|
|
111327
|
+
};
|
|
111328
|
+
}
|
|
111329
|
+
if (isProtectedStatus(domainResponse.status)) {
|
|
111330
|
+
return {
|
|
111331
|
+
verified: false,
|
|
111332
|
+
publicUrl: normalizedPublicBase,
|
|
111333
|
+
outcome: "protected_preview",
|
|
111334
|
+
reason: `Custom domain "${normalizedDomain}" is protected by authentication (HTTP ${domainResponse.status})`,
|
|
111335
|
+
httpStatus: domainResponse.status
|
|
111336
|
+
};
|
|
111337
|
+
}
|
|
111338
|
+
if (domainResponse.status !== 200) {
|
|
111339
|
+
return {
|
|
111340
|
+
verified: false,
|
|
111341
|
+
publicUrl: normalizedPublicBase,
|
|
111342
|
+
outcome: "verification_failed",
|
|
111343
|
+
reason: `Custom domain "${normalizedDomain}" returned non-200 status (HTTP ${domainResponse.status})`,
|
|
111344
|
+
httpStatus: domainResponse.status
|
|
111345
|
+
};
|
|
111346
|
+
}
|
|
111347
|
+
let domainMarkerBody;
|
|
111348
|
+
try {
|
|
111349
|
+
domainMarkerBody = await readBoundedResponseBody(domainResponse, maxResponseBytes);
|
|
111350
|
+
} catch (err) {
|
|
111351
|
+
return {
|
|
111352
|
+
verified: false,
|
|
111353
|
+
publicUrl: normalizedPublicBase,
|
|
111354
|
+
outcome: "verification_failed",
|
|
111355
|
+
reason: `Failed to read custom domain marker body: ${err instanceof Error ? err.message : String(err)}`
|
|
111356
|
+
};
|
|
111357
|
+
}
|
|
111358
|
+
const domainMarkerValid = verifyPublishMarker(domainMarkerBody, {
|
|
111359
|
+
operationId: expectedOperationId,
|
|
111360
|
+
sourceDigest: expectedSourceDigest
|
|
111361
|
+
});
|
|
111362
|
+
if (!domainMarkerValid) {
|
|
111363
|
+
return {
|
|
111364
|
+
verified: false,
|
|
111365
|
+
publicUrl: normalizedPublicBase,
|
|
111366
|
+
outcome: "verification_failed",
|
|
111367
|
+
reason: `Custom domain "${normalizedDomain}" points to older or mismatched content (PUB-010)`
|
|
111368
|
+
};
|
|
111369
|
+
}
|
|
111370
|
+
customDomainVerified = true;
|
|
111371
|
+
}
|
|
111372
|
+
return {
|
|
111373
|
+
verified: true,
|
|
111374
|
+
publicUrl: normalizedPublicBase,
|
|
111375
|
+
customDomainVerified: customDomain ? customDomainVerified : void 0,
|
|
111376
|
+
marker: {
|
|
111377
|
+
operationId: expectedOperationId,
|
|
111378
|
+
sourceDigest: expectedSourceDigest
|
|
111379
|
+
},
|
|
111380
|
+
verifiedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
111381
|
+
landingPageStatusCode: landingResponse.status
|
|
111382
|
+
};
|
|
111383
|
+
}
|
|
111384
|
+
|
|
111385
|
+
// src/delivery/page-publication-evidence.ts
|
|
111386
|
+
var MANAGED_PUBLISHER_SERVER_ID = "publisher.mcp.v1";
|
|
111387
|
+
var SUPPORTED_SOURCE_DIGEST_VERSIONS = /* @__PURE__ */ new Set(["v1"]);
|
|
111388
|
+
var DEFAULT_LIVENESS_TIMEOUT_MS = 1e4;
|
|
111389
|
+
var DEFAULT_PUBLICATION_RETRY = { attempts: 3, delaysMs: [2e3, 6e3] };
|
|
111390
|
+
var DEFAULT_PUBLICATION_DEADLINE_MS = 3e4;
|
|
111391
|
+
function nonEmptyString(value) {
|
|
111392
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
111393
|
+
}
|
|
111394
|
+
function defaultAllowLocal() {
|
|
111395
|
+
return process.env.NODE_ENV === "test" && process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1";
|
|
111396
|
+
}
|
|
111397
|
+
var realSleep = (ms) => new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
111398
|
+
async function withTransientRetry(check2, retry, remainingMs) {
|
|
111399
|
+
const attempts = Math.max(1, Math.min(retry?.attempts ?? DEFAULT_PUBLICATION_RETRY.attempts, 5));
|
|
111400
|
+
const delays = retry?.delaysMs ?? DEFAULT_PUBLICATION_RETRY.delaysMs;
|
|
111401
|
+
const sleep = retry?.sleep ?? realSleep;
|
|
111402
|
+
let result = await check2();
|
|
111403
|
+
let tried = 1;
|
|
111404
|
+
for (let attempt = 2; attempt <= attempts && !result.ok && result.transient; attempt += 1) {
|
|
111405
|
+
const delay6 = delays[Math.min(attempt - 2, delays.length - 1)] ?? 0;
|
|
111406
|
+
if (delay6 >= remainingMs()) break;
|
|
111407
|
+
await sleep(delay6);
|
|
111408
|
+
result = await check2();
|
|
111409
|
+
tried += 1;
|
|
111410
|
+
}
|
|
111411
|
+
if (!result.ok && result.transient && tried > 1) {
|
|
111412
|
+
return { ...result, reason: `${result.reason} (still failing after ${tried} attempts)` };
|
|
111413
|
+
}
|
|
111414
|
+
return result;
|
|
111415
|
+
}
|
|
111416
|
+
async function withinDeadline(work, remainingMs, onTimeout) {
|
|
111417
|
+
if (remainingMs <= 0) return onTimeout();
|
|
111418
|
+
let timer;
|
|
111419
|
+
const timeout = new Promise((resolve4) => {
|
|
111420
|
+
timer = setTimeout(() => resolve4(onTimeout()), remainingMs);
|
|
111421
|
+
});
|
|
111422
|
+
try {
|
|
111423
|
+
return await Promise.race([work, timeout]);
|
|
111424
|
+
} finally {
|
|
111425
|
+
clearTimeout(timer);
|
|
111426
|
+
}
|
|
111427
|
+
}
|
|
111428
|
+
async function verifyUrlLive(url2, options = {}) {
|
|
111429
|
+
const fetchFn = options.fetchFn ?? safeFetch;
|
|
111430
|
+
let response;
|
|
111431
|
+
try {
|
|
111432
|
+
response = await fetchFn(
|
|
111433
|
+
url2,
|
|
111434
|
+
{ method: "GET", headers: { accept: "text/html,*/*;q=0.8", "user-agent": "Mrrlin-Public-Verifier/1.0" } },
|
|
111435
|
+
{
|
|
111436
|
+
allowLocalEndpoints: options.allowLocalEndpoints ?? defaultAllowLocal(),
|
|
111437
|
+
timeoutMs: options.timeoutMs ?? DEFAULT_LIVENESS_TIMEOUT_MS,
|
|
111438
|
+
maxRedirects: 3
|
|
111439
|
+
}
|
|
111440
|
+
);
|
|
111441
|
+
} catch (error51) {
|
|
111442
|
+
const transient = isDnsOrUnreachableError(error51);
|
|
111443
|
+
if (error51 instanceof NetworkPolicyViolationError) {
|
|
111444
|
+
return { live: false, reason: `network policy refused ${url2}: ${error51.message}`, transient };
|
|
111445
|
+
}
|
|
111446
|
+
return { live: false, reason: `${url2} is unreachable: ${error51 instanceof Error ? error51.message : String(error51)}`, transient };
|
|
111447
|
+
}
|
|
111448
|
+
if (response.status === 401 || response.status === 403) {
|
|
111449
|
+
await response.body?.cancel().catch(() => {
|
|
111450
|
+
});
|
|
111451
|
+
return { live: false, reason: `${url2} is behind an authentication wall (HTTP ${response.status})`, transient: false };
|
|
111452
|
+
}
|
|
111453
|
+
if (response.status >= 400) {
|
|
111454
|
+
await response.body?.cancel().catch(() => {
|
|
111455
|
+
});
|
|
111456
|
+
return { live: false, reason: `${url2} answered HTTP ${response.status}`, transient: response.status >= 500 };
|
|
111457
|
+
}
|
|
111458
|
+
const finalUrl = finalResponseUrl(response);
|
|
111459
|
+
const body = await readBodyPrefix(response);
|
|
111460
|
+
if (looksLikeLoginPage({ requestedUrl: url2, finalUrl, body })) {
|
|
111461
|
+
return {
|
|
111462
|
+
live: false,
|
|
111463
|
+
reason: `${url2} is behind an authentication wall (it ends on a sign-in page${finalUrl && finalUrl !== url2 ? `: ${finalUrl}` : ""})`,
|
|
111464
|
+
transient: false
|
|
111465
|
+
};
|
|
111466
|
+
}
|
|
111467
|
+
return { live: true };
|
|
111468
|
+
}
|
|
111469
|
+
async function checkPublishAttemptBinding(options, url2, attemptId, sourceDigest, operationId) {
|
|
111470
|
+
let attempt;
|
|
111471
|
+
try {
|
|
111472
|
+
attempt = await options.resolvePublishAttempt(attemptId);
|
|
111473
|
+
} catch (error51) {
|
|
111474
|
+
return {
|
|
111475
|
+
ok: false,
|
|
111476
|
+
transient: false,
|
|
111477
|
+
reason: `publication_evidence_missing: publish attempt ${attemptId} for ${url2} could not be read: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
111478
|
+
};
|
|
111479
|
+
}
|
|
111480
|
+
if (!attempt) {
|
|
111481
|
+
return { ok: false, transient: false, reason: `publication_evidence_unbound: ${url2} names publish attempt ${attemptId}, which does not exist in this project` };
|
|
111482
|
+
}
|
|
111483
|
+
if (attempt.projectSlug !== options.projectSlug || attempt.runId !== options.runId) {
|
|
111484
|
+
return { ok: false, transient: false, reason: `publication_evidence_unbound: publish attempt ${attemptId} belongs to another run, not ${options.runId}` };
|
|
111485
|
+
}
|
|
111486
|
+
if (attempt.status === "failed") {
|
|
111487
|
+
return { ok: false, transient: false, reason: `publication_evidence_unbound: publish attempt ${attemptId} failed, so it cannot prove ${url2}` };
|
|
111488
|
+
}
|
|
111489
|
+
if (attempt.preparedEnvelope?.sourceDigest !== sourceDigest) {
|
|
111490
|
+
return { ok: false, transient: false, reason: `publication_evidence_unbound: ${url2} claims a source digest that publish attempt ${attemptId} did not publish` };
|
|
111491
|
+
}
|
|
111492
|
+
const dispatchedOperationId = nonEmptyString(attempt.dispatchedOperationId);
|
|
111493
|
+
if (dispatchedOperationId !== null && dispatchedOperationId !== operationId) {
|
|
111494
|
+
return { ok: false, transient: false, reason: `publication_evidence_unbound: ${url2} claims operation ${operationId}, but publish attempt ${attemptId} dispatched ${dispatchedOperationId}` };
|
|
111495
|
+
}
|
|
111496
|
+
return { ok: true };
|
|
111497
|
+
}
|
|
111498
|
+
async function verifyPagePublicationEvidence(options) {
|
|
111499
|
+
const startedAt = Date.now();
|
|
111500
|
+
const deadlineMs = options.deadlineMs ?? DEFAULT_PUBLICATION_DEADLINE_MS;
|
|
111501
|
+
const remainingMs = () => deadlineMs - (Date.now() - startedAt);
|
|
111502
|
+
const produced = options.artifacts.map((artifact, index) => ({ artifact, index })).filter(({ artifact }) => artifact.kind === "produced_url").sort((a, b) => {
|
|
111503
|
+
const ac = a.artifact.createdAt ?? "";
|
|
111504
|
+
const bc = b.artifact.createdAt ?? "";
|
|
111505
|
+
return ac && bc && ac !== bc ? ac < bc ? -1 : 1 : a.index - b.index;
|
|
111506
|
+
}).map(({ artifact }) => artifact);
|
|
111507
|
+
if (produced.length === 0) {
|
|
111508
|
+
return {
|
|
111509
|
+
ok: false,
|
|
111510
|
+
reason: "publication_evidence_missing: the page outcome has no produced URL, so nothing proves the page is public"
|
|
111511
|
+
};
|
|
111512
|
+
}
|
|
111513
|
+
let publisher;
|
|
111514
|
+
try {
|
|
111515
|
+
publisher = await options.resolvePublisherTarget();
|
|
111516
|
+
} catch (error51) {
|
|
111517
|
+
return {
|
|
111518
|
+
ok: false,
|
|
111519
|
+
reason: `publication_evidence_missing: the publisher binding could not be read: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
111520
|
+
};
|
|
111521
|
+
}
|
|
111522
|
+
let publicOrigin = null;
|
|
111523
|
+
try {
|
|
111524
|
+
publicOrigin = publisher?.publicOrigin ? new URL(publisher.publicOrigin).origin : null;
|
|
111525
|
+
} catch {
|
|
111526
|
+
publicOrigin = null;
|
|
111527
|
+
}
|
|
111528
|
+
const isManaged = (artifact) => {
|
|
111529
|
+
const payload = artifact.payload ?? {};
|
|
111530
|
+
return ["operationId", "sourceDigest", "sourceDigestVersion", "publishAttemptId"].some((key) => nonEmptyString(payload[key]) !== null);
|
|
111531
|
+
};
|
|
111532
|
+
const primary = produced.find(isManaged) ?? produced[0];
|
|
111533
|
+
if (!primary) {
|
|
111534
|
+
return { ok: false, reason: "publication_evidence_missing: the page outcome has no produced URL" };
|
|
111535
|
+
}
|
|
111536
|
+
if (publisher && !isManaged(primary)) {
|
|
111537
|
+
const url2 = nonEmptyString((primary.payload ?? {}).url) ?? "(no url)";
|
|
111538
|
+
return {
|
|
111539
|
+
ok: false,
|
|
111540
|
+
reason: `publication_evidence_unmanaged: this project publishes through ${MANAGED_PUBLISHER_SERVER_ID}, so a page closes only on a managed publish; ${url2} was recorded by hand and carries no publish evidence`
|
|
111541
|
+
};
|
|
111542
|
+
}
|
|
111543
|
+
const checkOne = async (artifact, retryTransient) => {
|
|
111544
|
+
const retry = retryTransient ? options.retry : { ...options.retry, attempts: 1 };
|
|
111545
|
+
const fetchTimeoutMs = () => Math.max(1, Math.min(options.timeoutMs ?? DEFAULT_LIVENESS_TIMEOUT_MS, remainingMs()));
|
|
111546
|
+
const payload = artifact.payload ?? {};
|
|
111547
|
+
const rawUrl = nonEmptyString(payload.url);
|
|
111548
|
+
let parsedUrl = null;
|
|
111549
|
+
try {
|
|
111550
|
+
if (rawUrl && rawUrl.startsWith("/") && !rawUrl.startsWith("//")) {
|
|
111551
|
+
parsedUrl = publicOrigin ? new URL(rawUrl, publicOrigin) : null;
|
|
111552
|
+
} else {
|
|
111553
|
+
parsedUrl = rawUrl ? new URL(rawUrl) : null;
|
|
111554
|
+
}
|
|
111555
|
+
} catch {
|
|
111556
|
+
parsedUrl = null;
|
|
111557
|
+
}
|
|
111558
|
+
if (!rawUrl || !parsedUrl || parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
|
|
111559
|
+
return {
|
|
111560
|
+
ok: false,
|
|
111561
|
+
url: rawUrl ?? "(no url)",
|
|
111562
|
+
reason: `publication_evidence_missing: produced URL artifact ${artifact.id} is not an absolute http(s) URL` + (rawUrl?.startsWith("/") ? " and there is no publisher public origin to resolve it against" : "")
|
|
111563
|
+
};
|
|
111564
|
+
}
|
|
111565
|
+
const url2 = parsedUrl.toString();
|
|
111566
|
+
if (!isManaged(artifact)) {
|
|
111567
|
+
const liveness = await withTransientRetry(async () => {
|
|
111568
|
+
const live = await verifyUrlLive(url2, { ...options, timeoutMs: fetchTimeoutMs() });
|
|
111569
|
+
return live.live ? { ok: true } : { ok: false, reason: live.reason, transient: live.transient };
|
|
111570
|
+
}, retry, remainingMs);
|
|
111571
|
+
if (!liveness.ok) return { ok: false, url: url2, reason: `public_url_not_verified: ${liveness.reason}` };
|
|
111572
|
+
return { ok: true, verified: { artifactId: artifact.id, url: url2, mode: "liveness" } };
|
|
111573
|
+
}
|
|
111574
|
+
const operationId = nonEmptyString(payload.operationId);
|
|
111575
|
+
const sourceDigest = nonEmptyString(payload.sourceDigest);
|
|
111576
|
+
const sourceDigestVersion = nonEmptyString(payload.sourceDigestVersion);
|
|
111577
|
+
const publishAttemptId = nonEmptyString(payload.publishAttemptId);
|
|
111578
|
+
if (!operationId || !sourceDigest || !sourceDigestVersion || !publishAttemptId) {
|
|
111579
|
+
return {
|
|
111580
|
+
ok: false,
|
|
111581
|
+
url: url2,
|
|
111582
|
+
reason: `publication_evidence_missing: produced URL ${url2} carries incomplete publish evidence (operationId, sourceDigest, sourceDigestVersion and publishAttemptId are all required)`
|
|
111583
|
+
};
|
|
111584
|
+
}
|
|
111585
|
+
if (!SUPPORTED_SOURCE_DIGEST_VERSIONS.has(sourceDigestVersion)) {
|
|
111586
|
+
return {
|
|
111587
|
+
ok: false,
|
|
111588
|
+
url: url2,
|
|
111589
|
+
reason: `publication_evidence_missing: produced URL ${url2} uses source digest version "${sourceDigestVersion}", which this closure cannot compare`
|
|
111590
|
+
};
|
|
111591
|
+
}
|
|
111592
|
+
if (!publicOrigin) {
|
|
111593
|
+
return {
|
|
111594
|
+
ok: false,
|
|
111595
|
+
url: url2,
|
|
111596
|
+
reason: `publication_evidence_missing: no ${MANAGED_PUBLISHER_SERVER_ID} binding with a public origin to check ${url2} against`
|
|
111597
|
+
};
|
|
111598
|
+
}
|
|
111599
|
+
if (parsedUrl.origin !== publicOrigin) {
|
|
111600
|
+
return {
|
|
111601
|
+
ok: false,
|
|
111602
|
+
url: url2,
|
|
111603
|
+
reason: `public_url_outside_origin: ${url2} is not inside the publisher's public origin ${publicOrigin}`
|
|
111604
|
+
};
|
|
111605
|
+
}
|
|
111606
|
+
const binding = await checkPublishAttemptBinding(options, url2, publishAttemptId, sourceDigest, operationId);
|
|
111607
|
+
if (!binding.ok) return { ok: false, url: url2, reason: binding.reason };
|
|
111608
|
+
const result = await withTransientRetry(async () => {
|
|
111609
|
+
const verified2 = await verifyPublicUrl({
|
|
111610
|
+
publicUrl: url2,
|
|
111611
|
+
expectedOperationId: operationId,
|
|
111612
|
+
expectedSourceDigest: sourceDigest,
|
|
111613
|
+
expectedSourceDigestVersion: sourceDigestVersion,
|
|
111614
|
+
allowLocalEndpoints: options.allowLocalEndpoints,
|
|
111615
|
+
...options.fetchFn ? { fetchFn: options.fetchFn } : {},
|
|
111616
|
+
timeoutMs: fetchTimeoutMs()
|
|
111617
|
+
});
|
|
111618
|
+
if (verified2.verified) return { ok: true };
|
|
111619
|
+
const reason = verified2.outcome === "digest_version_mismatch" ? `publication_evidence_missing: ${verified2.reason}` : `public_url_not_verified: ${verified2.outcome}: ${verified2.reason}`;
|
|
111620
|
+
return { ok: false, reason, transient: isTransientVerificationFailure(verified2) };
|
|
111621
|
+
}, retry, remainingMs);
|
|
111622
|
+
if (!result.ok) return { ok: false, url: url2, reason: result.reason };
|
|
111623
|
+
return { ok: true, verified: { artifactId: artifact.id, url: url2, mode: "managed" } };
|
|
111624
|
+
};
|
|
111625
|
+
const deadlineReason = `public_url_not_verified: the publication check ran out of its ${Math.round(deadlineMs / 1e3)}s budget`;
|
|
111626
|
+
const primaryResult = await withinDeadline(checkOne(primary, true), remainingMs(), () => ({
|
|
111627
|
+
ok: false,
|
|
111628
|
+
url: "",
|
|
111629
|
+
reason: deadlineReason
|
|
111630
|
+
}));
|
|
111631
|
+
if (!primaryResult.ok) return { ok: false, reason: primaryResult.reason };
|
|
111632
|
+
const verified = [primaryResult.verified];
|
|
111633
|
+
const secondaryFailures = [];
|
|
111634
|
+
for (const artifact of produced) {
|
|
111635
|
+
if (artifact === primary) continue;
|
|
111636
|
+
const rawUrl = nonEmptyString((artifact.payload ?? {}).url) ?? "(no url)";
|
|
111637
|
+
const secondary = await withinDeadline(checkOne(artifact, false), remainingMs(), () => ({
|
|
111638
|
+
ok: false,
|
|
111639
|
+
url: rawUrl,
|
|
111640
|
+
reason: `${deadlineReason}; not checked in time`
|
|
111641
|
+
}));
|
|
111642
|
+
if (secondary.ok) verified.push(secondary.verified);
|
|
111643
|
+
else secondaryFailures.push({ artifactId: artifact.id, url: secondary.url, reason: secondary.reason });
|
|
111644
|
+
}
|
|
111645
|
+
return { ok: true, primary: primaryResult.verified, verified, secondaryFailures };
|
|
111646
|
+
}
|
|
110736
111647
|
|
|
110737
111648
|
// src/prompts/task-notes-contract.ts
|
|
110738
111649
|
init_dist();
|
|
@@ -113003,7 +113914,7 @@ async function driveClaimedRun(deps, projectSlug, runId, claimed, leaseId) {
|
|
|
113003
113914
|
);
|
|
113004
113915
|
return;
|
|
113005
113916
|
}
|
|
113006
|
-
const runDomains = Array.isArray(task.domains) ? task.domains : [
|
|
113917
|
+
const runDomains = Array.isArray(task.domains) ? task.domains : [];
|
|
113007
113918
|
const hasCodeDomain = runDomains.some((d) => typeof d === "string" && d.trim().toLowerCase() === "code");
|
|
113008
113919
|
const isPureCode = runDomains.length === 1 && hasCodeDomain;
|
|
113009
113920
|
const requires = task.declaredOutcome?.requires ?? [];
|
|
@@ -113035,11 +113946,12 @@ async function driveClaimedRun(deps, projectSlug, runId, claimed, leaseId) {
|
|
|
113035
113946
|
const isCodeRun = isPureCode || hasCodeDomain && needsCodeChange && claimed.codeExecution === true && claimed.executionRouteIntent === "code" && !!runApproval;
|
|
113036
113947
|
const verifyLegacyPureScope = async () => {
|
|
113037
113948
|
const current2 = await deps.client.getTask(projectSlug, task.id);
|
|
113038
|
-
const domains = current2.domains ?? [
|
|
113949
|
+
const domains = current2.domains ?? [];
|
|
113039
113950
|
return current2.codeScopeApprovalRequired !== true && domains.length === 1 && domains[0] === "code";
|
|
113040
113951
|
};
|
|
113041
113952
|
if (!isCodeRun) {
|
|
113042
|
-
const runDomain = runDomains.find((d) => typeof d === "string" && d.trim().toLowerCase() !== "code") ?? runDomains[0] ??
|
|
113953
|
+
const runDomain = runDomains.find((d) => typeof d === "string" && d.trim().toLowerCase() !== "code") ?? runDomains[0] ?? // No domain: author the result with the general content producer.
|
|
113954
|
+
"content";
|
|
113043
113955
|
let providerId = claimed.agentSeat;
|
|
113044
113956
|
if (providerId == null) {
|
|
113045
113957
|
const seat = await mintResolvedSeat(resolveProvider(process.env, getSelectedProvider()));
|
|
@@ -114426,7 +115338,7 @@ function buildDeliverableAuthorPrompt(task, specMarkdown, project, journalMarkdo
|
|
|
114426
115338
|
`--- TASK ---`,
|
|
114427
115339
|
`id: ${task.id}`,
|
|
114428
115340
|
`title: ${task.title}`,
|
|
114429
|
-
`domains: ${
|
|
115341
|
+
`domains: ${task.domains?.length ? task.domains.join(", ") : "none (not a code task)"}`,
|
|
114430
115342
|
``,
|
|
114431
115343
|
`notes:`,
|
|
114432
115344
|
task.notes ?? "(none)",
|
|
@@ -114757,22 +115669,56 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2,
|
|
|
114757
115669
|
}
|
|
114758
115670
|
const awaitsResultConfirmation = rawProject.awaitsResultConfirmation === true;
|
|
114759
115671
|
const isPageOutcome = task.declaredOutcome?.requires?.includes("page") === true;
|
|
114760
|
-
const
|
|
114761
|
-
|
|
114762
|
-
|
|
114763
|
-
deps,
|
|
115672
|
+
const verifyPagePublication = async (artifacts) => {
|
|
115673
|
+
const evidence = await verifyPagePublicationEvidence({
|
|
115674
|
+
artifacts,
|
|
114764
115675
|
projectSlug,
|
|
114765
|
-
task,
|
|
114766
115676
|
runId,
|
|
114767
|
-
|
|
114768
|
-
|
|
114769
|
-
|
|
114770
|
-
|
|
114771
|
-
|
|
115677
|
+
resolvePublisherTarget: async () => {
|
|
115678
|
+
const target = (await deps.client.getIntegrationBinding(projectSlug, MANAGED_PUBLISHER_SERVER_ID))?.publisherTarget;
|
|
115679
|
+
return target ? { publicOrigin: target.publicOrigin ?? null } : null;
|
|
115680
|
+
},
|
|
115681
|
+
// Read-only: binds managed evidence to this run's own publish attempt (anti-forgery).
|
|
115682
|
+
resolvePublishAttempt: (attemptId) => deps.client.getPublishAttempt(projectSlug, attemptId),
|
|
115683
|
+
...deps.publicationFetch ? { fetchFn: deps.publicationFetch } : {},
|
|
115684
|
+
...deps.publicationRetrySleep ? { retry: { sleep: deps.publicationRetrySleep } } : {}
|
|
115685
|
+
});
|
|
115686
|
+
if (evidence.ok && evidence.secondaryFailures.length > 0) {
|
|
115687
|
+
const lines2 = evidence.secondaryFailures.map((failure) => `- ${failure.url}: ${failure.reason}`).join("\n");
|
|
115688
|
+
console.error(`[mrrlin] run ${runId}: ${evidence.secondaryFailures.length} secondary produced URL(s) failed the public check`);
|
|
115689
|
+
try {
|
|
115690
|
+
await deps.client.appendTaskEvent(projectSlug, task.id, {
|
|
115691
|
+
kind: "note",
|
|
115692
|
+
body: `The page's main link ${evidence.primary.url} is live, but ${evidence.secondaryFailures.length === 1 ? "another link this run recorded is" : "other links this run recorded are"} not:
|
|
115693
|
+
${lines2}`
|
|
115694
|
+
});
|
|
115695
|
+
} catch {
|
|
115696
|
+
}
|
|
115697
|
+
}
|
|
115698
|
+
return evidence;
|
|
115699
|
+
};
|
|
115700
|
+
if (isPageOutcome && parsedResult.outcome === "completed" && !awaitsResultConfirmation && !deps.signingProvider) {
|
|
115701
|
+
const artifacts = await deps.client.listExecutionArtifacts(projectSlug, runId).catch(() => []);
|
|
115702
|
+
if (artifacts.some((artifact) => artifact.kind === "produced_url")) {
|
|
115703
|
+
const evidence = await verifyPagePublication(artifacts);
|
|
115704
|
+
deps.activeLease?.progress();
|
|
115705
|
+
if (!evidence.ok) {
|
|
115706
|
+
await failRun(deps, projectSlug, task, runId, leaseId, evidence.reason);
|
|
115707
|
+
return;
|
|
115708
|
+
}
|
|
115709
|
+
}
|
|
114772
115710
|
}
|
|
114773
115711
|
if (deps.signingProvider && (parsedResult.outcome === "negative_result" || parsedResult.outcome === "completed" && !awaitsResultConfirmation)) {
|
|
115712
|
+
const existingArtifacts = isPageOutcome ? await deps.client.listExecutionArtifacts(projectSlug, runId).catch(() => []) : [];
|
|
115713
|
+
if (isPageOutcome && parsedResult.outcome === "completed") {
|
|
115714
|
+
const evidence = await verifyPagePublication(existingArtifacts);
|
|
115715
|
+
deps.activeLease?.progress();
|
|
115716
|
+
if (!evidence.ok) {
|
|
115717
|
+
await failRun(deps, projectSlug, task, runId, leaseId, evidence.reason);
|
|
115718
|
+
return;
|
|
115719
|
+
}
|
|
115720
|
+
}
|
|
114774
115721
|
try {
|
|
114775
|
-
const existingArtifacts = isPageOutcome ? await deps.client.listExecutionArtifacts(projectSlug, runId).catch(() => []) : [];
|
|
114776
115722
|
const urlArtifacts = existingArtifacts.filter((a) => a.kind === "produced_url").map((a) => ({
|
|
114777
115723
|
artifactId: a.id,
|
|
114778
115724
|
storageVersion: "1",
|
|
@@ -124424,7 +125370,7 @@ function buildThreadStartParams(msg, config2, desiredModel) {
|
|
|
124424
125370
|
"- Apply this format ONLY to Specs/{id} pages; do not retro-fit it onto other wiki page types.",
|
|
124425
125371
|
"- With each spec, set the task's `declaredOutcome` via `update_task` yourself; approval needs it.",
|
|
124426
125372
|
'- Spec consensus runs ASYNCHRONOUSLY. Call `run_spec_consensus` for a `Specs/{id}` page; it returns IMMEDIATELY. On `already_converged`, the spec is already marked ready \u2014 proceed straight to `create_execution_run`; do NOT call `mark_spec_ready` and do NOT re-run consensus. On `queued` or `already_running`, tell the user it was launched and END your turn \u2014 do NOT poll or call it again; the result arrives in the inbox (an `info` item on CONVERGED, a `handoff` item if it was blocked/failed). When a `handoff` says it was blocked, address the recorded issues in the spec (any edit re-arms the gate) and call `run_spec_consensus` once more. For a NON-code task (domain seo/marketing/content, ADR 0020): the low-risk lanes `seo`, `marketing`, and `content` proceed to `create_execution_run` after consensus converges, using the same flow as code tasks. When the review agrees, tell the operator "the reviewers agreed on the spec" and proceed to create_execution_run. When it does not, tell them the reviewers could not agree and that there is a decision question in the inbox. Never say "consensus", "converged", or "CONVERGED" to the operator; those are internal words.',
|
|
124427
|
-
"-
|
|
125373
|
+
"- Classify every task you create via `domains`: `['code']` for software changes, else `['seo']`, `['marketing']` or `['content']` (a `parentTaskId` follow-up inherits its parent's). Code is never the default. Reclassify as you learn: when a task turns out to need code changes, update_task its `domains` to include `code`; when it does not, switch them to the fitting non-code domain.",
|
|
124428
125374
|
'- When a task needs a browser (login flows, UI verification/clicks, scraping), pass `prerequisites:[{mcp:"mrrlin-browser",reason:"..."}]` to `create_execution_run`. If that run later fails into a handoff, the operator gets a one-click "Launch browser & resume" that brings up the dedicated browser as the turn starts.',
|
|
124429
125375
|
"- When you actually drive a browser (calling `browser_navigate`, `browser_click`, `browser_snapshot`, `browser_type`, etc.), invoke those tools from the **`mrrlin-browser`** MCP server ONLY. Do NOT use tools from any other browser MCP (`playwright`, `chrome-devtools`, `puppeteer`, etc.) even if they are also connected on this operator's box \u2014 those use a shared/default Playwright profile that is fragile across runs. Only `mrrlin-browser` uses this project's dedicated Chromium + persistent operator profile (`~/.mrrlin/browser/profile`). If your host exposes multiple browser MCPs with overlapping tool names, prefer the `mrrlin-browser` server unconditionally.",
|
|
124430
125376
|
"- One browser session is shared by every concurrent chat on this operator's box (a code run drives its task's own copy) \u2014 a deliberate tradeoff, so a second user is expected, not exceptional. If a `mrrlin-browser` call fails with `Browser is already in use for ...`, that means another one of the operator's own chats or tasks is driving the browser RIGHT NOW. Do not present this as a broken tool or a mysterious error: tell the operator plainly that the browser is busy with another task, ask them to wait for it to finish (or close it), and offer to retry shortly. Never retry-loop this silently.",
|