@mrrlin-dev/mcp 0.4.237 → 0.4.248
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 +1043 -81
- 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 () => {
|
|
@@ -91866,6 +91934,12 @@ function validateCandidateUrl(rawUrl) {
|
|
|
91866
91934
|
}
|
|
91867
91935
|
return parsed.toString().replace(/\/$/, "");
|
|
91868
91936
|
}
|
|
91937
|
+
function parseGitHubRepository(value) {
|
|
91938
|
+
if (!value) return null;
|
|
91939
|
+
const match2 = /^([A-Za-z0-9](?:[A-Za-z0-9-]{0,38}))\/([A-Za-z0-9_.-]{1,100})$/.exec(value);
|
|
91940
|
+
if (!match2 || !match2[1] || !match2[2] || match2[2] === "." || match2[2] === "..") return null;
|
|
91941
|
+
return { org: match2[1], repo: match2[2] };
|
|
91942
|
+
}
|
|
91869
91943
|
var VercelAdapter = class {
|
|
91870
91944
|
profileId = "vercel.v1";
|
|
91871
91945
|
adapterVersion = "1.0.0";
|
|
@@ -91906,6 +91980,12 @@ var VercelAdapter = class {
|
|
|
91906
91980
|
if (!manifest.gitCommitSha || !/^[0-9a-f]{40}$/.test(manifest.gitCommitSha)) {
|
|
91907
91981
|
return { eligible: false, reason: "Git source mode requires a 40-character commit SHA" };
|
|
91908
91982
|
}
|
|
91983
|
+
if (!parseGitHubRepository(manifest.gitRepository)) {
|
|
91984
|
+
return { eligible: false, reason: "Git source mode requires a GitHub repository in owner/repo format" };
|
|
91985
|
+
}
|
|
91986
|
+
if (computeSourceManifestDigest({ mode: "git_commit", gitCommitSha: manifest.gitCommitSha }) !== manifest.sourceDigest) {
|
|
91987
|
+
return { eligible: false, reason: "Git source digest does not match the requested commit" };
|
|
91988
|
+
}
|
|
91909
91989
|
return { eligible: true };
|
|
91910
91990
|
}
|
|
91911
91991
|
if (manifest.mode === "inline_manifest") {
|
|
@@ -91929,15 +92009,15 @@ var VercelAdapter = class {
|
|
|
91929
92009
|
throw new VercelContractError(targetValidation.reason);
|
|
91930
92010
|
}
|
|
91931
92011
|
const target = targetValidation.target;
|
|
91932
|
-
const sourceEligibility = this.isSourceEligible(params.sourceManifest);
|
|
91933
|
-
if (!sourceEligibility.eligible) {
|
|
91934
|
-
throw new VercelContractError(sourceEligibility.reason);
|
|
91935
|
-
}
|
|
91936
92012
|
if (!params.operationId || typeof params.operationId !== "string") {
|
|
91937
92013
|
throw new VercelContractError("PrepareRequestParams must specify non-empty operationId");
|
|
91938
92014
|
}
|
|
91939
92015
|
const op = normalizePublisherOperation(params.operation);
|
|
91940
92016
|
if (op === "publish_release" || op === "publish_preview") {
|
|
92017
|
+
const sourceEligibility = this.isSourceEligible(params.sourceManifest);
|
|
92018
|
+
if (!sourceEligibility.eligible) {
|
|
92019
|
+
throw new VercelContractError(sourceEligibility.reason);
|
|
92020
|
+
}
|
|
91941
92021
|
if (op === "publish_release") {
|
|
91942
92022
|
if (params.environment !== "production") {
|
|
91943
92023
|
throw new VercelContractError(
|
|
@@ -92007,8 +92087,12 @@ var VercelAdapter = class {
|
|
|
92007
92087
|
if (params.sourceManifest.mode === "inline_manifest") {
|
|
92008
92088
|
requestBody.files = filesPayload;
|
|
92009
92089
|
} else if (params.sourceManifest.mode === "git_commit") {
|
|
92090
|
+
const repository = parseGitHubRepository(params.sourceManifest.gitRepository);
|
|
92091
|
+
if (!repository) throw new VercelContractError("GitHub repository is missing or invalid");
|
|
92010
92092
|
requestBody.gitSource = {
|
|
92011
92093
|
type: "github",
|
|
92094
|
+
org: repository.org,
|
|
92095
|
+
repo: repository.repo,
|
|
92012
92096
|
sha: params.sourceManifest.gitCommitSha
|
|
92013
92097
|
};
|
|
92014
92098
|
}
|
|
@@ -92030,7 +92114,6 @@ var VercelAdapter = class {
|
|
|
92030
92114
|
const wireToolName = "get_deployment";
|
|
92031
92115
|
const wireArguments = {
|
|
92032
92116
|
teamId: target.teamId,
|
|
92033
|
-
id: params.deploymentId,
|
|
92034
92117
|
idOrUrl: params.deploymentId
|
|
92035
92118
|
};
|
|
92036
92119
|
const canonicalToolArgumentsDigest = (0, import_node_crypto10.createHash)("sha256").update(JSON.stringify(canonicalizeValue(wireArguments))).digest("hex");
|
|
@@ -92672,6 +92755,26 @@ var HttpMcpClient = class {
|
|
|
92672
92755
|
const result = await this.rpc("tools/list", {});
|
|
92673
92756
|
return result?.tools ?? [];
|
|
92674
92757
|
}
|
|
92758
|
+
/** Read every advertised tool page for security-sensitive contract checks. */
|
|
92759
|
+
async listAllTools() {
|
|
92760
|
+
const tools = [];
|
|
92761
|
+
const seen = /* @__PURE__ */ new Set();
|
|
92762
|
+
let cursor;
|
|
92763
|
+
for (let page = 0; page < 32; page++) {
|
|
92764
|
+
const result = await this.rpc("tools/list", cursor ? { cursor } : {});
|
|
92765
|
+
if (!result || !Array.isArray(result.tools)) {
|
|
92766
|
+
throw new Error("Invalid paginated tools/list response");
|
|
92767
|
+
}
|
|
92768
|
+
tools.push(...result.tools);
|
|
92769
|
+
if (result.nextCursor === void 0) return tools;
|
|
92770
|
+
if (typeof result.nextCursor !== "string" || !result.nextCursor || seen.has(result.nextCursor)) {
|
|
92771
|
+
throw new Error("Invalid or repeated tools/list cursor");
|
|
92772
|
+
}
|
|
92773
|
+
seen.add(result.nextCursor);
|
|
92774
|
+
cursor = result.nextCursor;
|
|
92775
|
+
}
|
|
92776
|
+
throw new Error("Too many tools/list pages");
|
|
92777
|
+
}
|
|
92675
92778
|
async callTool(name, args) {
|
|
92676
92779
|
const result = await this.rpc("tools/call", { name, arguments: args });
|
|
92677
92780
|
return result;
|
|
@@ -93267,6 +93370,89 @@ function scopePublisherServer(server, toolName2) {
|
|
|
93267
93370
|
headers
|
|
93268
93371
|
};
|
|
93269
93372
|
}
|
|
93373
|
+
async function preflightPublisherServer(server) {
|
|
93374
|
+
if (server.transport !== "http" || !server.url || !server.headers || server.authProvider) {
|
|
93375
|
+
throw new PublisherContractError("Publisher requires an HTTP endpoint and two role-specific bearer tokens");
|
|
93376
|
+
}
|
|
93377
|
+
const headers = server.headers;
|
|
93378
|
+
const releaseToken = headers.releaseToken ?? headers.release_token ?? headers.RELEASE_TOKEN;
|
|
93379
|
+
const observeToken = headers.observeToken ?? headers.observe_token ?? headers.OBSERVE_TOKEN;
|
|
93380
|
+
if (!releaseToken || !observeToken) {
|
|
93381
|
+
throw new PublisherContractError("Publisher requires both release and observe bearer tokens");
|
|
93382
|
+
}
|
|
93383
|
+
validatePublisherUrl(server.url, "Target endpoint");
|
|
93384
|
+
await preflightPublisherSchemas(server.url, { releaseToken, observeToken }, {
|
|
93385
|
+
allowLocalEndpoints: process.env.NODE_ENV === "test" || process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1"
|
|
93386
|
+
});
|
|
93387
|
+
}
|
|
93388
|
+
async function preflightPublisherSchemas(endpoint, credentials, options) {
|
|
93389
|
+
if (credentials.releaseToken === credentials.observeToken) {
|
|
93390
|
+
throw new PublisherContractError("Identical token values rejected: release and observe credentials must be distinct");
|
|
93391
|
+
}
|
|
93392
|
+
const allowLocal = options?.allowLocalEndpoints ?? false;
|
|
93393
|
+
const releaseClient = new HttpMcpClient(
|
|
93394
|
+
endpoint,
|
|
93395
|
+
{ Authorization: `Bearer ${credentials.releaseToken}` },
|
|
93396
|
+
allowLocal
|
|
93397
|
+
);
|
|
93398
|
+
try {
|
|
93399
|
+
await releaseClient.initialize();
|
|
93400
|
+
const tools = await releaseClient.listAllTools();
|
|
93401
|
+
const releaseTools = tools.filter((t) => t?.name === PUBLISHER_MCP_V1_TOOLS.release);
|
|
93402
|
+
if (releaseTools.length !== 1) {
|
|
93403
|
+
throw new PublisherContractError(
|
|
93404
|
+
`Release credential must expose exactly one required tool "${PUBLISHER_MCP_V1_TOOLS.release}"`
|
|
93405
|
+
);
|
|
93406
|
+
}
|
|
93407
|
+
if (tools.some((t) => t.name === PUBLISHER_MCP_V1_TOOLS.observe)) {
|
|
93408
|
+
throw new PublisherContractError(
|
|
93409
|
+
`Role isolation violation: Release credential must not expose observe tool "${PUBLISHER_MCP_V1_TOOLS.observe}"`
|
|
93410
|
+
);
|
|
93411
|
+
}
|
|
93412
|
+
const digest = computeToolSchemaDigest(releaseTools[0]?.inputSchema);
|
|
93413
|
+
if (digest !== PUBLISHER_RELEASE_V1_SCHEMA_DIGEST) {
|
|
93414
|
+
throw new PublisherContractError(
|
|
93415
|
+
`Schema drift detected for "${PUBLISHER_MCP_V1_TOOLS.release}": expected digest "${PUBLISHER_RELEASE_V1_SCHEMA_DIGEST}", got "${digest}"`
|
|
93416
|
+
);
|
|
93417
|
+
}
|
|
93418
|
+
} finally {
|
|
93419
|
+
await releaseClient.close().catch(() => {
|
|
93420
|
+
});
|
|
93421
|
+
}
|
|
93422
|
+
const observeClient = new HttpMcpClient(
|
|
93423
|
+
endpoint,
|
|
93424
|
+
{ Authorization: `Bearer ${credentials.observeToken}` },
|
|
93425
|
+
allowLocal
|
|
93426
|
+
);
|
|
93427
|
+
try {
|
|
93428
|
+
await observeClient.initialize();
|
|
93429
|
+
const tools = await observeClient.listAllTools();
|
|
93430
|
+
const observeTools = tools.filter((t) => t?.name === PUBLISHER_MCP_V1_TOOLS.observe);
|
|
93431
|
+
if (observeTools.length !== 1) {
|
|
93432
|
+
throw new PublisherContractError(
|
|
93433
|
+
`Observe credential must expose exactly one required tool "${PUBLISHER_MCP_V1_TOOLS.observe}"`
|
|
93434
|
+
);
|
|
93435
|
+
}
|
|
93436
|
+
if (tools.some((t) => t.name === PUBLISHER_MCP_V1_TOOLS.release)) {
|
|
93437
|
+
throw new PublisherContractError(
|
|
93438
|
+
`Role isolation violation: Observe credential must not expose release tool "${PUBLISHER_MCP_V1_TOOLS.release}"`
|
|
93439
|
+
);
|
|
93440
|
+
}
|
|
93441
|
+
const digest = computeToolSchemaDigest(observeTools[0]?.inputSchema);
|
|
93442
|
+
if (digest !== PUBLISHER_OBSERVE_V1_SCHEMA_DIGEST) {
|
|
93443
|
+
throw new PublisherContractError(
|
|
93444
|
+
`Schema drift detected for "${PUBLISHER_MCP_V1_TOOLS.observe}": expected digest "${PUBLISHER_OBSERVE_V1_SCHEMA_DIGEST}", got "${digest}"`
|
|
93445
|
+
);
|
|
93446
|
+
}
|
|
93447
|
+
} finally {
|
|
93448
|
+
await observeClient.close().catch(() => {
|
|
93449
|
+
});
|
|
93450
|
+
}
|
|
93451
|
+
return {
|
|
93452
|
+
releaseDigest: PUBLISHER_RELEASE_V1_SCHEMA_DIGEST,
|
|
93453
|
+
observeDigest: PUBLISHER_OBSERVE_V1_SCHEMA_DIGEST
|
|
93454
|
+
};
|
|
93455
|
+
}
|
|
93270
93456
|
var publisherMcpAdapter = new PublisherMcpAdapter();
|
|
93271
93457
|
registerPublisherAdapter(publisherMcpAdapter);
|
|
93272
93458
|
|
|
@@ -93467,8 +93653,7 @@ function assertPublisherEndpoint(serverUrl, profileAuthority, envelope) {
|
|
|
93467
93653
|
if (profileAuthority !== "custom") throw new Error("profile mismatch");
|
|
93468
93654
|
const expected = new URL(envelope.target.endpoint);
|
|
93469
93655
|
if (actual.href !== expected.href) throw new Error("endpoint drift");
|
|
93470
|
-
|
|
93471
|
-
if (!localFixture) throw new Error("custom target enrollment cannot be verified");
|
|
93656
|
+
validatePublisherUrl(actual.href, "Publisher endpoint");
|
|
93472
93657
|
} else {
|
|
93473
93658
|
if (profileAuthority === "custom") throw new Error("profile mismatch");
|
|
93474
93659
|
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 +93671,21 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
93486
93671
|
this.context = context;
|
|
93487
93672
|
}
|
|
93488
93673
|
static inFlightDispatches = /* @__PURE__ */ new Set();
|
|
93674
|
+
/** The operation id this attempt is bound to — the same one sent to the publisher and stamped
|
|
93675
|
+
* into the published marker. Read by the produced_url evidence write (S6). */
|
|
93676
|
+
get boundOperationId() {
|
|
93677
|
+
return this.context.operationId;
|
|
93678
|
+
}
|
|
93679
|
+
/** The source digest of the approved prepared envelope this attempt dispatches. */
|
|
93680
|
+
get boundSourceDigest() {
|
|
93681
|
+
return this.context.preparedEnvelope.sourceDigest;
|
|
93682
|
+
}
|
|
93683
|
+
/** Version of the digest scheme behind `boundSourceDigest`. Both V1 envelope schemas carry the
|
|
93684
|
+
* v1 manifest digest and no version field; an envelope that names its own version wins. */
|
|
93685
|
+
get boundSourceDigestVersion() {
|
|
93686
|
+
const declared = this.context.preparedEnvelope.sourceDigestVersion;
|
|
93687
|
+
return typeof declared === "string" && declared.length > 0 ? declared : "v1";
|
|
93688
|
+
}
|
|
93489
93689
|
/**
|
|
93490
93690
|
* Prepares the attempt row in the database (or retrieves existing row).
|
|
93491
93691
|
*/
|
|
@@ -93658,6 +93858,9 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
93658
93858
|
);
|
|
93659
93859
|
}
|
|
93660
93860
|
await this.verifyAuthority(server, approvedEnvelope, payload.operation, payload.profileId);
|
|
93861
|
+
if ("profileId" in approvedEnvelope && approvedEnvelope.profileId === "publisher.mcp.v1") {
|
|
93862
|
+
await preflightPublisherServer(server);
|
|
93863
|
+
}
|
|
93661
93864
|
if (current2.dispatchCount && current2.dispatchCount > 0) {
|
|
93662
93865
|
throw new PublishLeaseFencingError(
|
|
93663
93866
|
`Single-use dispatch commitment already consumed for attempt ${attemptId} (dispatchCount=${current2.dispatchCount}). Re-dispatch is prohibited; status must be reconciled.`
|
|
@@ -93669,7 +93872,8 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
93669
93872
|
);
|
|
93670
93873
|
}
|
|
93671
93874
|
const comm = await this.client.commitPublishDispatch(this.context.projectSlug, attemptId, {
|
|
93672
|
-
leaseOwner: this.context.leaseOwner
|
|
93875
|
+
leaseOwner: this.context.leaseOwner,
|
|
93876
|
+
operationId: this.context.operationId
|
|
93673
93877
|
});
|
|
93674
93878
|
if (!comm) {
|
|
93675
93879
|
throw new PublishLeaseFencingError(
|
|
@@ -93938,6 +94142,12 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
93938
94142
|
`AUTHORITY_DRIFT: Live authorization generation (${liveBinding.authorizationGeneration}) does not match approved envelope authorization generation (${approvedEnvelope.authorizationGeneration})`
|
|
93939
94143
|
);
|
|
93940
94144
|
}
|
|
94145
|
+
if ("target" in approvedEnvelope && (!liveBinding.publisherTarget || computeTargetFingerprint(liveBinding.publisherTarget) !== computeTargetFingerprint(approvedEnvelope.target))) {
|
|
94146
|
+
throw new PublishLeaseFencingError("AUTHORITY_DRIFT: Publisher target differs from owner enrollment");
|
|
94147
|
+
}
|
|
94148
|
+
if ("target" in approvedEnvelope && server.authorizationGeneration !== liveBinding.authorizationGeneration) {
|
|
94149
|
+
throw new PublishLeaseFencingError("AUTHORITY_DRIFT: Local publisher authorization generation changed");
|
|
94150
|
+
}
|
|
93941
94151
|
if (server.connectionId && liveBinding.connectionId !== server.connectionId) {
|
|
93942
94152
|
throw new PublishLeaseFencingError(
|
|
93943
94153
|
`AUTHORITY_DRIFT: Live binding connectionId (${liveBinding.connectionId}) does not match server connectionId (${server.connectionId})`
|
|
@@ -94226,10 +94436,12 @@ async function resolveDeliveryServer(serverId, opts) {
|
|
|
94226
94436
|
return null;
|
|
94227
94437
|
}
|
|
94228
94438
|
if (resolved.kind === "managed") {
|
|
94439
|
+
let managedConnection = resolved.connection;
|
|
94229
94440
|
let secrets = {};
|
|
94230
94441
|
if (resolved.connection.inputRefs && Object.keys(resolved.connection.inputRefs).length > 0 && store.isVaultUnlocked()) {
|
|
94231
94442
|
try {
|
|
94232
94443
|
const secretObj = await store.resolveConnection(resolved.connection.id);
|
|
94444
|
+
managedConnection = secretObj.connection;
|
|
94233
94445
|
secrets = secretObj.secrets;
|
|
94234
94446
|
} catch {
|
|
94235
94447
|
}
|
|
@@ -94237,11 +94449,11 @@ async function resolveDeliveryServer(serverId, opts) {
|
|
|
94237
94449
|
let authProvider;
|
|
94238
94450
|
if (store.isVaultUnlocked()) {
|
|
94239
94451
|
try {
|
|
94240
|
-
const authGen =
|
|
94241
|
-
const mapping = await store.getOAuthResourceMapping(
|
|
94242
|
-
if (mapping?.resource &&
|
|
94452
|
+
const authGen = managedConnection.authorizationGeneration ?? 1;
|
|
94453
|
+
const mapping = await store.getOAuthResourceMapping(managedConnection.id, authGen);
|
|
94454
|
+
if (mapping?.resource && managedConnection.endpoint) {
|
|
94243
94455
|
try {
|
|
94244
|
-
const endpointOrigin = new URL(
|
|
94456
|
+
const endpointOrigin = new URL(managedConnection.endpoint).origin;
|
|
94245
94457
|
const resourceOrigin = new URL(mapping.resource).origin;
|
|
94246
94458
|
if (endpointOrigin !== resourceOrigin) {
|
|
94247
94459
|
throw new AuthorizationGenerationMismatchError(
|
|
@@ -94253,15 +94465,15 @@ async function resolveDeliveryServer(serverId, opts) {
|
|
|
94253
94465
|
}
|
|
94254
94466
|
}
|
|
94255
94467
|
const tokens2 = await store.getOAuthTokens({
|
|
94256
|
-
connectionId:
|
|
94468
|
+
connectionId: managedConnection.id,
|
|
94257
94469
|
authorizationGeneration: authGen,
|
|
94258
94470
|
issuer: mapping?.issuer,
|
|
94259
94471
|
resource: mapping?.resource
|
|
94260
94472
|
});
|
|
94261
94473
|
let isServerHostLocal = false;
|
|
94262
|
-
if (
|
|
94474
|
+
if (managedConnection.endpoint) {
|
|
94263
94475
|
try {
|
|
94264
|
-
const parsedEndpoint = new URL(
|
|
94476
|
+
const parsedEndpoint = new URL(managedConnection.endpoint);
|
|
94265
94477
|
isServerHostLocal = parsedEndpoint.hostname === "localhost" || parsedEndpoint.hostname === "127.0.0.1" || parsedEndpoint.hostname === "::1" || parsedEndpoint.hostname === "[::1]";
|
|
94266
94478
|
} catch {
|
|
94267
94479
|
}
|
|
@@ -94270,7 +94482,7 @@ async function resolveDeliveryServer(serverId, opts) {
|
|
|
94270
94482
|
if (tokens2) {
|
|
94271
94483
|
authProvider = new MrrlinOAuthClientProvider({
|
|
94272
94484
|
store,
|
|
94273
|
-
connectionId:
|
|
94485
|
+
connectionId: managedConnection.id,
|
|
94274
94486
|
authorizationGeneration: authGen,
|
|
94275
94487
|
redirectUrl: "http://127.0.0.1/integrations/oauth/callback",
|
|
94276
94488
|
expectedIssuer: mapping?.issuer,
|
|
@@ -94282,35 +94494,35 @@ async function resolveDeliveryServer(serverId, opts) {
|
|
|
94282
94494
|
if (err instanceof AuthorizationGenerationMismatchError) throw err;
|
|
94283
94495
|
}
|
|
94284
94496
|
}
|
|
94285
|
-
const configDigest =
|
|
94286
|
-
transport:
|
|
94287
|
-
endpoint:
|
|
94288
|
-
command:
|
|
94289
|
-
args:
|
|
94290
|
-
envKeys:
|
|
94291
|
-
inputRefKeys: Object.keys(
|
|
94497
|
+
const configDigest = managedConnection.configDigest ?? computeConnectionConfigDigest({
|
|
94498
|
+
transport: managedConnection.transport,
|
|
94499
|
+
endpoint: managedConnection.endpoint,
|
|
94500
|
+
command: managedConnection.command,
|
|
94501
|
+
args: managedConnection.args,
|
|
94502
|
+
envKeys: managedConnection.envKeys,
|
|
94503
|
+
inputRefKeys: Object.keys(managedConnection.inputRefs ?? {})
|
|
94292
94504
|
});
|
|
94293
|
-
if (
|
|
94505
|
+
if (managedConnection.transport === "streamable_http") {
|
|
94294
94506
|
return {
|
|
94295
|
-
id:
|
|
94507
|
+
id: managedConnection.legacyServerId ?? managedConnection.id,
|
|
94296
94508
|
transport: "http",
|
|
94297
|
-
url:
|
|
94509
|
+
url: managedConnection.endpoint ?? "",
|
|
94298
94510
|
headers: secrets,
|
|
94299
94511
|
authProvider,
|
|
94300
|
-
connectionId:
|
|
94301
|
-
authorizationGeneration:
|
|
94512
|
+
connectionId: managedConnection.id,
|
|
94513
|
+
authorizationGeneration: managedConnection.authorizationGeneration,
|
|
94302
94514
|
configDigest
|
|
94303
94515
|
};
|
|
94304
94516
|
}
|
|
94305
94517
|
return {
|
|
94306
|
-
id:
|
|
94518
|
+
id: managedConnection.legacyServerId ?? managedConnection.id,
|
|
94307
94519
|
transport: "stdio",
|
|
94308
|
-
command:
|
|
94309
|
-
args:
|
|
94520
|
+
command: managedConnection.command ?? "",
|
|
94521
|
+
args: managedConnection.args ?? [],
|
|
94310
94522
|
env: secrets,
|
|
94311
94523
|
authProvider,
|
|
94312
|
-
connectionId:
|
|
94313
|
-
authorizationGeneration:
|
|
94524
|
+
connectionId: managedConnection.id,
|
|
94525
|
+
authorizationGeneration: managedConnection.authorizationGeneration,
|
|
94314
94526
|
configDigest
|
|
94315
94527
|
};
|
|
94316
94528
|
}
|
|
@@ -94923,10 +95135,15 @@ async function callDestination(client, projectSlug, route, resolvedToolName, pay
|
|
|
94923
95135
|
}
|
|
94924
95136
|
}
|
|
94925
95137
|
}
|
|
94926
|
-
|
|
95138
|
+
const delivered = await deliverToPublish(server, resolvedToolName, publishPayload, {
|
|
94927
95139
|
controller,
|
|
94928
95140
|
attemptId: attId
|
|
94929
95141
|
});
|
|
95142
|
+
await recordManagedPublishEvidence(client, projectSlug, runId, controller, attId, delivered, {
|
|
95143
|
+
operation: typeof operation === "string" ? operation : "",
|
|
95144
|
+
environment: publishPayload.environment
|
|
95145
|
+
});
|
|
95146
|
+
return delivered;
|
|
94930
95147
|
}
|
|
94931
95148
|
return deliverToPublish(server, resolvedToolName, publishPayload, {
|
|
94932
95149
|
controller: attemptController,
|
|
@@ -95159,6 +95376,38 @@ async function readPullRequestState(client, projectSlug, taskProjectSlug, pullRe
|
|
|
95159
95376
|
throw err;
|
|
95160
95377
|
}
|
|
95161
95378
|
}
|
|
95379
|
+
async function recordManagedPublishEvidence(client, projectSlug, runId, controller, attemptId, delivered, publish) {
|
|
95380
|
+
if (!runId || !controller) return;
|
|
95381
|
+
if (!isReleasePublish(publish)) return;
|
|
95382
|
+
const url2 = delivered.normalized?.url ?? null;
|
|
95383
|
+
if (delivered.normalized?.status !== "success" || !url2 || url2 !== delivered.url) return;
|
|
95384
|
+
const operationId = controller.boundOperationId;
|
|
95385
|
+
const sourceDigest = controller.boundSourceDigest;
|
|
95386
|
+
if (!operationId || !sourceDigest) return;
|
|
95387
|
+
const id = `EA-pu-m-${import_node_crypto12.default.createHash("sha256").update(`${runId}
|
|
95388
|
+
${operationId}
|
|
95389
|
+
${url2}`).digest("hex").slice(0, 16)}`;
|
|
95390
|
+
try {
|
|
95391
|
+
await client.appendExecutionArtifact(projectSlug, runId, {
|
|
95392
|
+
id,
|
|
95393
|
+
kind: "produced_url",
|
|
95394
|
+
payload: {
|
|
95395
|
+
url: url2,
|
|
95396
|
+
label: "managed_publish",
|
|
95397
|
+
operationId,
|
|
95398
|
+
sourceDigest,
|
|
95399
|
+
sourceDigestVersion: controller.boundSourceDigestVersion,
|
|
95400
|
+
...attemptId ? { publishAttemptId: attemptId } : {}
|
|
95401
|
+
}
|
|
95402
|
+
});
|
|
95403
|
+
} catch (error51) {
|
|
95404
|
+
console.error(`[mrrlin] produced_url evidence write failed for run ${runId}: ${errorMessage(error51) ?? String(error51)}`);
|
|
95405
|
+
}
|
|
95406
|
+
}
|
|
95407
|
+
function isReleasePublish(publish) {
|
|
95408
|
+
if (publish.environment !== "production") return false;
|
|
95409
|
+
return publish.operation === "release" || publish.operation === "publish_release" || publish.operation === "observe" || publish.operation === "publish_observe";
|
|
95410
|
+
}
|
|
95162
95411
|
function digestCapabilityPayload(payload) {
|
|
95163
95412
|
if (payload && typeof payload === "object" && "envelope" in payload) {
|
|
95164
95413
|
const { envelope: _env, ...rest } = payload;
|
|
@@ -96479,7 +96728,7 @@ function buildDraftSpecPrompt(task, constitution, deployTarget = null) {
|
|
|
96479
96728
|
`id: ${task.id}`,
|
|
96480
96729
|
`title: ${task.title}`,
|
|
96481
96730
|
`type: ${task.type ?? "task"}`,
|
|
96482
|
-
`domains: ${
|
|
96731
|
+
`domains: ${task.domains?.length ? task.domains.join(", ") : "none (not a code task)"}`,
|
|
96483
96732
|
`impact: ${task.impact ?? ""}`,
|
|
96484
96733
|
`category: ${task.category ?? ""} / ${task.subcategory ?? ""}`,
|
|
96485
96734
|
`tags: ${(task.tags ?? []).join(", ")}`,
|
|
@@ -99650,6 +99899,56 @@ function unfinishedRunWorktrees(runs) {
|
|
|
99650
99899
|
}
|
|
99651
99900
|
return keep;
|
|
99652
99901
|
}
|
|
99902
|
+
function gitCommonDir(checkout) {
|
|
99903
|
+
const dotGit = (0, import_node_path24.join)(checkout, ".git");
|
|
99904
|
+
try {
|
|
99905
|
+
if ((0, import_node_fs18.lstatSync)(dotGit).isDirectory()) return dotGit;
|
|
99906
|
+
const match2 = /^gitdir: (.+)$/m.exec((0, import_node_fs18.readFileSync)(dotGit, "utf8"));
|
|
99907
|
+
if (!match2?.[1]) return null;
|
|
99908
|
+
const gitdir = (0, import_node_path24.resolve)(checkout, match2[1].trim());
|
|
99909
|
+
try {
|
|
99910
|
+
return (0, import_node_path24.resolve)(gitdir, (0, import_node_fs18.readFileSync)((0, import_node_path24.join)(gitdir, "commondir"), "utf8").trim());
|
|
99911
|
+
} catch {
|
|
99912
|
+
return gitdir;
|
|
99913
|
+
}
|
|
99914
|
+
} catch {
|
|
99915
|
+
return null;
|
|
99916
|
+
}
|
|
99917
|
+
}
|
|
99918
|
+
function pruneOwnedStaleRegistrations(checkout, ownedPrefixes) {
|
|
99919
|
+
const commonDir = gitCommonDir(checkout);
|
|
99920
|
+
if (!commonDir) return [];
|
|
99921
|
+
const admin = (0, import_node_path24.join)(commonDir, "worktrees");
|
|
99922
|
+
let ids;
|
|
99923
|
+
try {
|
|
99924
|
+
ids = (0, import_node_fs18.readdirSync)(admin);
|
|
99925
|
+
} catch {
|
|
99926
|
+
return [];
|
|
99927
|
+
}
|
|
99928
|
+
const fold = (path42) => process.platform === "win32" ? (0, import_node_path24.normalize)(path42).toLowerCase() : (0, import_node_path24.normalize)(path42);
|
|
99929
|
+
const prefixes = ownedPrefixes.map(fold);
|
|
99930
|
+
const pruned = [];
|
|
99931
|
+
for (const id of ids) {
|
|
99932
|
+
const entry = (0, import_node_path24.join)(admin, id);
|
|
99933
|
+
if ((0, import_node_fs18.existsSync)((0, import_node_path24.join)(entry, "locked"))) continue;
|
|
99934
|
+
let target;
|
|
99935
|
+
try {
|
|
99936
|
+
target = (0, import_node_fs18.readFileSync)((0, import_node_path24.join)(entry, "gitdir"), "utf8").trim();
|
|
99937
|
+
} catch {
|
|
99938
|
+
continue;
|
|
99939
|
+
}
|
|
99940
|
+
if (!(0, import_node_path24.isAbsolute)(target) || (0, import_node_path24.basename)(target) !== ".git" || /[\x00-\x1f\x7f]/.test(target)) continue;
|
|
99941
|
+
const worktree = (0, import_node_path24.dirname)(target);
|
|
99942
|
+
if (!prefixes.some((prefix) => fold(worktree).startsWith(prefix))) continue;
|
|
99943
|
+
if ((0, import_node_fs18.existsSync)(target) || (0, import_node_fs18.existsSync)(worktree)) continue;
|
|
99944
|
+
try {
|
|
99945
|
+
(0, import_node_fs18.rmSync)(entry, { recursive: true, force: true });
|
|
99946
|
+
pruned.push(worktree);
|
|
99947
|
+
} catch {
|
|
99948
|
+
}
|
|
99949
|
+
}
|
|
99950
|
+
return pruned;
|
|
99951
|
+
}
|
|
99653
99952
|
async function sweepOrphanWorktrees(opts, runGit2 = git2) {
|
|
99654
99953
|
const reaped = [];
|
|
99655
99954
|
const hooksDir = prepareDisabledGitHooksDir(opts.locksDir, `sweep:${opts.slug}`);
|
|
@@ -99707,6 +100006,8 @@ async function sweepOrphanWorktrees(opts, runGit2 = git2) {
|
|
|
99707
100006
|
}
|
|
99708
100007
|
}
|
|
99709
100008
|
}
|
|
100009
|
+
const rawPrefix = (0, import_node_path24.normalize)(opts.worktreeRoot) + import_node_path24.sep + opts.slug + import_node_path24.sep;
|
|
100010
|
+
reaped.push(...pruneOwnedStaleRegistrations(opts.checkout, [ownedPrefix, rawPrefix]));
|
|
99710
100011
|
});
|
|
99711
100012
|
});
|
|
99712
100013
|
} finally {
|
|
@@ -102504,6 +102805,12 @@ function createMrrlinTools(options) {
|
|
|
102504
102805
|
"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
102806
|
);
|
|
102506
102807
|
}
|
|
102808
|
+
if (input.kind === "produced_url") {
|
|
102809
|
+
throw new McpToolCodedError(
|
|
102810
|
+
"PRODUCED_URL_RESERVED",
|
|
102811
|
+
"A produced_url artifact is written only by record_produced_url. Call record_produced_url with the page's URL instead."
|
|
102812
|
+
);
|
|
102813
|
+
}
|
|
102507
102814
|
return await c.appendExecutionArtifact(projectSlug, runId, input);
|
|
102508
102815
|
}
|
|
102509
102816
|
),
|
|
@@ -106548,7 +106855,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
106548
106855
|
}
|
|
106549
106856
|
|
|
106550
106857
|
// src/_generated/version.ts
|
|
106551
|
-
var PKG_VERSION = "0.4.
|
|
106858
|
+
var PKG_VERSION = "0.4.248";
|
|
106552
106859
|
|
|
106553
106860
|
// src/bridge-allowed-origins.ts
|
|
106554
106861
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -110732,7 +111039,627 @@ init_dist2();
|
|
|
110732
111039
|
init_dist();
|
|
110733
111040
|
|
|
110734
111041
|
// src/delivery/public-url-verifier.ts
|
|
111042
|
+
var DEFAULT_VERIFIER_TIMEOUT_MS = 1e4;
|
|
111043
|
+
var DEFAULT_VERIFIER_MAX_REDIRECTS = 3;
|
|
110735
111044
|
var DEFAULT_VERIFIER_MAX_BYTES = 2 * 1024 * 1024;
|
|
111045
|
+
function isProtectedStatus(status) {
|
|
111046
|
+
return status === 401 || status === 403;
|
|
111047
|
+
}
|
|
111048
|
+
function isDnsOrUnreachableError(err) {
|
|
111049
|
+
if (!err) return false;
|
|
111050
|
+
if (err?.name === "TimeoutError") return true;
|
|
111051
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
111052
|
+
const lower = msg.toLowerCase();
|
|
111053
|
+
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");
|
|
111054
|
+
}
|
|
111055
|
+
var LOGIN_PATH_SEGMENTS = /* @__PURE__ */ new Set([
|
|
111056
|
+
"login",
|
|
111057
|
+
"log-in",
|
|
111058
|
+
"signin",
|
|
111059
|
+
"sign-in",
|
|
111060
|
+
"auth",
|
|
111061
|
+
"sso",
|
|
111062
|
+
"oauth",
|
|
111063
|
+
"authorize"
|
|
111064
|
+
]);
|
|
111065
|
+
function looksLikeLoginPage(input) {
|
|
111066
|
+
const { requestedUrl, finalUrl, body } = input;
|
|
111067
|
+
if (finalUrl) {
|
|
111068
|
+
try {
|
|
111069
|
+
const requested = new URL(requestedUrl);
|
|
111070
|
+
const final = new URL(finalUrl);
|
|
111071
|
+
const redirected = requested.origin !== final.origin || requested.pathname !== final.pathname;
|
|
111072
|
+
if (redirected) {
|
|
111073
|
+
const path42 = final.pathname.toLowerCase();
|
|
111074
|
+
if (path42.split("/").filter(Boolean).some((segment) => LOGIN_PATH_SEGMENTS.has(segment))) return true;
|
|
111075
|
+
if (path42.includes("protection_bypass") || final.searchParams.has("protection_bypass")) return true;
|
|
111076
|
+
}
|
|
111077
|
+
} catch {
|
|
111078
|
+
}
|
|
111079
|
+
}
|
|
111080
|
+
if (body) {
|
|
111081
|
+
const asksForPassword = /<input\b[^>]*\btype\s*=\s*["']?password\b/i.test(body);
|
|
111082
|
+
const title = /<title[^>]*>([\s\S]*?)<\/title>/i.exec(body)?.[1] ?? "";
|
|
111083
|
+
const signInTitle = /\b(log[\s-]?in|sign[\s-]?in|authenticate|authentication required)\b/i.test(title);
|
|
111084
|
+
if (asksForPassword && signInTitle) return true;
|
|
111085
|
+
}
|
|
111086
|
+
return false;
|
|
111087
|
+
}
|
|
111088
|
+
function finalResponseUrl(response) {
|
|
111089
|
+
return typeof response.url === "string" ? response.url : "";
|
|
111090
|
+
}
|
|
111091
|
+
async function readBodyPrefix(response, maxBytes = 64 * 1024) {
|
|
111092
|
+
const reader = response.body?.getReader();
|
|
111093
|
+
if (!reader) return "";
|
|
111094
|
+
const chunks = [];
|
|
111095
|
+
let total = 0;
|
|
111096
|
+
try {
|
|
111097
|
+
while (total < maxBytes) {
|
|
111098
|
+
const { done, value } = await reader.read();
|
|
111099
|
+
if (done || !value) break;
|
|
111100
|
+
chunks.push(Buffer.from(value));
|
|
111101
|
+
total += value.byteLength;
|
|
111102
|
+
}
|
|
111103
|
+
} catch {
|
|
111104
|
+
} finally {
|
|
111105
|
+
await reader.cancel().catch(() => {
|
|
111106
|
+
});
|
|
111107
|
+
}
|
|
111108
|
+
return Buffer.concat(chunks).subarray(0, maxBytes).toString("utf8");
|
|
111109
|
+
}
|
|
111110
|
+
function isTransientVerificationFailure(result) {
|
|
111111
|
+
if (result.transient === true) return true;
|
|
111112
|
+
if (result.outcome === "dns_pending") return true;
|
|
111113
|
+
return typeof result.httpStatus === "number" && result.httpStatus >= 500 && (result.outcome === "marker_missing" || result.outcome === "landing_page_error" || result.outcome === "verification_failed");
|
|
111114
|
+
}
|
|
111115
|
+
function readMarkerDigestVersion(rawContent) {
|
|
111116
|
+
try {
|
|
111117
|
+
const parsed = JSON.parse(rawContent);
|
|
111118
|
+
if (parsed === null || typeof parsed !== "object") return null;
|
|
111119
|
+
const version2 = parsed.sourceDigestVersion;
|
|
111120
|
+
if (version2 === void 0) return "v1";
|
|
111121
|
+
return typeof version2 === "string" && version2.length > 0 ? version2 : null;
|
|
111122
|
+
} catch {
|
|
111123
|
+
return null;
|
|
111124
|
+
}
|
|
111125
|
+
}
|
|
111126
|
+
function cleanBaseUrl(rawUrl) {
|
|
111127
|
+
const trimmed = rawUrl.trim();
|
|
111128
|
+
const withProtocol = trimmed.startsWith("http://") || trimmed.startsWith("https://") ? trimmed : `https://${trimmed}`;
|
|
111129
|
+
return withProtocol.replace(/\/+$/, "");
|
|
111130
|
+
}
|
|
111131
|
+
async function verifyPublicUrl(options) {
|
|
111132
|
+
const {
|
|
111133
|
+
publicUrl,
|
|
111134
|
+
expectedOperationId,
|
|
111135
|
+
expectedSourceDigest,
|
|
111136
|
+
expectedSourceDigestVersion,
|
|
111137
|
+
markerPath = PUBLISH_SOURCE_LIMITS.RESERVED_MARKER_PATH,
|
|
111138
|
+
customDomain,
|
|
111139
|
+
allowLocalEndpoints = process.env.NODE_ENV === "test" && process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1",
|
|
111140
|
+
timeoutMs = DEFAULT_VERIFIER_TIMEOUT_MS,
|
|
111141
|
+
maxRedirects = DEFAULT_VERIFIER_MAX_REDIRECTS,
|
|
111142
|
+
maxResponseBytes = DEFAULT_VERIFIER_MAX_BYTES,
|
|
111143
|
+
fetchFn = safeFetch
|
|
111144
|
+
} = options;
|
|
111145
|
+
if (!publicUrl || typeof publicUrl !== "string") {
|
|
111146
|
+
return {
|
|
111147
|
+
verified: false,
|
|
111148
|
+
publicUrl: String(publicUrl),
|
|
111149
|
+
outcome: "verification_failed",
|
|
111150
|
+
reason: "Candidate public URL must be a non-empty string"
|
|
111151
|
+
};
|
|
111152
|
+
}
|
|
111153
|
+
const normalizedPublicBase = cleanBaseUrl(publicUrl);
|
|
111154
|
+
const cleanMarkerPath = markerPath.replace(/^\/+/, "");
|
|
111155
|
+
const markerUrl = `${normalizedPublicBase}/${cleanMarkerPath}`;
|
|
111156
|
+
const landingUrl = `${normalizedPublicBase}/`;
|
|
111157
|
+
const policy = {
|
|
111158
|
+
allowLocalEndpoints,
|
|
111159
|
+
timeoutMs,
|
|
111160
|
+
maxRedirects,
|
|
111161
|
+
maxResponseBytes
|
|
111162
|
+
};
|
|
111163
|
+
let markerResponse;
|
|
111164
|
+
try {
|
|
111165
|
+
markerResponse = await fetchFn(
|
|
111166
|
+
markerUrl,
|
|
111167
|
+
{
|
|
111168
|
+
method: "GET",
|
|
111169
|
+
headers: {
|
|
111170
|
+
accept: "application/json, text/plain",
|
|
111171
|
+
"user-agent": "Mrrlin-Public-Verifier/1.0"
|
|
111172
|
+
}
|
|
111173
|
+
},
|
|
111174
|
+
policy
|
|
111175
|
+
);
|
|
111176
|
+
} catch (err) {
|
|
111177
|
+
if (err instanceof NetworkPolicyViolationError) {
|
|
111178
|
+
return {
|
|
111179
|
+
verified: false,
|
|
111180
|
+
publicUrl: normalizedPublicBase,
|
|
111181
|
+
outcome: "network_policy_violation",
|
|
111182
|
+
reason: `Network policy rejected verification request: ${err.message}`,
|
|
111183
|
+
...isDnsOrUnreachableError(err) ? { transient: true } : {}
|
|
111184
|
+
};
|
|
111185
|
+
}
|
|
111186
|
+
return {
|
|
111187
|
+
verified: false,
|
|
111188
|
+
publicUrl: normalizedPublicBase,
|
|
111189
|
+
outcome: "verification_failed",
|
|
111190
|
+
reason: `Failed to reach verification marker endpoint: ${err instanceof Error ? err.message : String(err)}`,
|
|
111191
|
+
...isDnsOrUnreachableError(err) ? { transient: true } : {}
|
|
111192
|
+
};
|
|
111193
|
+
}
|
|
111194
|
+
if (isProtectedStatus(markerResponse.status)) {
|
|
111195
|
+
return {
|
|
111196
|
+
verified: false,
|
|
111197
|
+
publicUrl: normalizedPublicBase,
|
|
111198
|
+
outcome: "protected_preview",
|
|
111199
|
+
reason: `Verification marker is protected by an authentication wall (HTTP ${markerResponse.status})`,
|
|
111200
|
+
httpStatus: markerResponse.status
|
|
111201
|
+
};
|
|
111202
|
+
}
|
|
111203
|
+
if (markerResponse.status !== 200) {
|
|
111204
|
+
return {
|
|
111205
|
+
verified: false,
|
|
111206
|
+
publicUrl: normalizedPublicBase,
|
|
111207
|
+
outcome: "marker_missing",
|
|
111208
|
+
reason: `Verification marker request returned non-200 status (HTTP ${markerResponse.status})`,
|
|
111209
|
+
httpStatus: markerResponse.status
|
|
111210
|
+
};
|
|
111211
|
+
}
|
|
111212
|
+
let markerBody;
|
|
111213
|
+
try {
|
|
111214
|
+
markerBody = await readBoundedResponseBody(markerResponse, maxResponseBytes);
|
|
111215
|
+
} catch (err) {
|
|
111216
|
+
return {
|
|
111217
|
+
verified: false,
|
|
111218
|
+
publicUrl: normalizedPublicBase,
|
|
111219
|
+
outcome: "verification_failed",
|
|
111220
|
+
reason: `Failed to read marker response body within bounds: ${err instanceof Error ? err.message : String(err)}`
|
|
111221
|
+
};
|
|
111222
|
+
}
|
|
111223
|
+
if (expectedSourceDigestVersion !== void 0) {
|
|
111224
|
+
const markerVersion = readMarkerDigestVersion(markerBody);
|
|
111225
|
+
if (markerVersion !== expectedSourceDigestVersion) {
|
|
111226
|
+
return {
|
|
111227
|
+
verified: false,
|
|
111228
|
+
publicUrl: normalizedPublicBase,
|
|
111229
|
+
outcome: "digest_version_mismatch",
|
|
111230
|
+
reason: `Verification marker uses source digest version "${markerVersion ?? "unreadable"}", expected "${expectedSourceDigestVersion}"`,
|
|
111231
|
+
httpStatus: markerResponse.status
|
|
111232
|
+
};
|
|
111233
|
+
}
|
|
111234
|
+
}
|
|
111235
|
+
const markerValid = verifyPublishMarker(markerBody, {
|
|
111236
|
+
operationId: expectedOperationId,
|
|
111237
|
+
sourceDigest: expectedSourceDigest
|
|
111238
|
+
});
|
|
111239
|
+
if (!markerValid) {
|
|
111240
|
+
return {
|
|
111241
|
+
verified: false,
|
|
111242
|
+
publicUrl: normalizedPublicBase,
|
|
111243
|
+
outcome: "marker_mismatch",
|
|
111244
|
+
reason: "Verification marker content does not match expected operationId and sourceDigest (PUB-009)",
|
|
111245
|
+
httpStatus: markerResponse.status
|
|
111246
|
+
};
|
|
111247
|
+
}
|
|
111248
|
+
let landingResponse;
|
|
111249
|
+
try {
|
|
111250
|
+
landingResponse = await fetchFn(
|
|
111251
|
+
landingUrl,
|
|
111252
|
+
{
|
|
111253
|
+
method: "GET",
|
|
111254
|
+
headers: {
|
|
111255
|
+
accept: "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
|
111256
|
+
"user-agent": "Mrrlin-Public-Verifier/1.0"
|
|
111257
|
+
}
|
|
111258
|
+
},
|
|
111259
|
+
policy
|
|
111260
|
+
);
|
|
111261
|
+
} catch (err) {
|
|
111262
|
+
if (err instanceof NetworkPolicyViolationError) {
|
|
111263
|
+
return {
|
|
111264
|
+
verified: false,
|
|
111265
|
+
publicUrl: normalizedPublicBase,
|
|
111266
|
+
outcome: "network_policy_violation",
|
|
111267
|
+
reason: `Network policy rejected landing page request: ${err.message}`,
|
|
111268
|
+
...isDnsOrUnreachableError(err) ? { transient: true } : {}
|
|
111269
|
+
};
|
|
111270
|
+
}
|
|
111271
|
+
return {
|
|
111272
|
+
verified: false,
|
|
111273
|
+
publicUrl: normalizedPublicBase,
|
|
111274
|
+
outcome: "verification_failed",
|
|
111275
|
+
reason: `Failed to reach landing page: ${err instanceof Error ? err.message : String(err)}`,
|
|
111276
|
+
...isDnsOrUnreachableError(err) ? { transient: true } : {}
|
|
111277
|
+
};
|
|
111278
|
+
}
|
|
111279
|
+
if (isProtectedStatus(landingResponse.status)) {
|
|
111280
|
+
await landingResponse.body?.cancel().catch(() => {
|
|
111281
|
+
});
|
|
111282
|
+
return {
|
|
111283
|
+
verified: false,
|
|
111284
|
+
publicUrl: normalizedPublicBase,
|
|
111285
|
+
outcome: "protected_preview",
|
|
111286
|
+
reason: `Landing page is protected by authentication or preview gate (HTTP ${landingResponse.status})`,
|
|
111287
|
+
httpStatus: landingResponse.status
|
|
111288
|
+
};
|
|
111289
|
+
}
|
|
111290
|
+
if (landingResponse.status >= 400) {
|
|
111291
|
+
await landingResponse.body?.cancel().catch(() => {
|
|
111292
|
+
});
|
|
111293
|
+
return {
|
|
111294
|
+
verified: false,
|
|
111295
|
+
publicUrl: normalizedPublicBase,
|
|
111296
|
+
outcome: "landing_page_error",
|
|
111297
|
+
reason: `Landing page returned HTTP ${landingResponse.status}`,
|
|
111298
|
+
httpStatus: landingResponse.status
|
|
111299
|
+
};
|
|
111300
|
+
}
|
|
111301
|
+
const landingBody = await readBodyPrefix(landingResponse);
|
|
111302
|
+
if (looksLikeLoginPage({ requestedUrl: landingUrl, finalUrl: finalResponseUrl(landingResponse), body: landingBody })) {
|
|
111303
|
+
return {
|
|
111304
|
+
verified: false,
|
|
111305
|
+
publicUrl: normalizedPublicBase,
|
|
111306
|
+
outcome: "protected_preview",
|
|
111307
|
+
reason: `Landing page ends on a sign-in page${finalResponseUrl(landingResponse) ? ` (${finalResponseUrl(landingResponse)})` : ""}, so it is not public`,
|
|
111308
|
+
httpStatus: landingResponse.status
|
|
111309
|
+
};
|
|
111310
|
+
}
|
|
111311
|
+
let customDomainVerified = false;
|
|
111312
|
+
if (customDomain && customDomain.trim().length > 0) {
|
|
111313
|
+
const normalizedDomain = customDomain.trim().toLowerCase().replace(/^https?:\/\//, "").replace(/\/+$/, "");
|
|
111314
|
+
const customDomainMarkerUrl = `https://${normalizedDomain}/${cleanMarkerPath}`;
|
|
111315
|
+
let domainResponse;
|
|
111316
|
+
try {
|
|
111317
|
+
domainResponse = await fetchFn(
|
|
111318
|
+
customDomainMarkerUrl,
|
|
111319
|
+
{
|
|
111320
|
+
method: "GET",
|
|
111321
|
+
headers: {
|
|
111322
|
+
accept: "application/json, text/plain",
|
|
111323
|
+
"user-agent": "Mrrlin-Public-Verifier/1.0"
|
|
111324
|
+
}
|
|
111325
|
+
},
|
|
111326
|
+
policy
|
|
111327
|
+
);
|
|
111328
|
+
} catch (err) {
|
|
111329
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
111330
|
+
if (isDnsOrUnreachableError(err)) {
|
|
111331
|
+
return {
|
|
111332
|
+
verified: false,
|
|
111333
|
+
publicUrl: normalizedPublicBase,
|
|
111334
|
+
outcome: "dns_pending",
|
|
111335
|
+
reason: `Custom domain "${normalizedDomain}" DNS is propagating or unresolvable (PUB-010): ${msg}`
|
|
111336
|
+
};
|
|
111337
|
+
}
|
|
111338
|
+
return {
|
|
111339
|
+
verified: false,
|
|
111340
|
+
publicUrl: normalizedPublicBase,
|
|
111341
|
+
outcome: "verification_failed",
|
|
111342
|
+
reason: `Custom domain verification failed: ${msg}`
|
|
111343
|
+
};
|
|
111344
|
+
}
|
|
111345
|
+
if (isProtectedStatus(domainResponse.status)) {
|
|
111346
|
+
return {
|
|
111347
|
+
verified: false,
|
|
111348
|
+
publicUrl: normalizedPublicBase,
|
|
111349
|
+
outcome: "protected_preview",
|
|
111350
|
+
reason: `Custom domain "${normalizedDomain}" is protected by authentication (HTTP ${domainResponse.status})`,
|
|
111351
|
+
httpStatus: domainResponse.status
|
|
111352
|
+
};
|
|
111353
|
+
}
|
|
111354
|
+
if (domainResponse.status !== 200) {
|
|
111355
|
+
return {
|
|
111356
|
+
verified: false,
|
|
111357
|
+
publicUrl: normalizedPublicBase,
|
|
111358
|
+
outcome: "verification_failed",
|
|
111359
|
+
reason: `Custom domain "${normalizedDomain}" returned non-200 status (HTTP ${domainResponse.status})`,
|
|
111360
|
+
httpStatus: domainResponse.status
|
|
111361
|
+
};
|
|
111362
|
+
}
|
|
111363
|
+
let domainMarkerBody;
|
|
111364
|
+
try {
|
|
111365
|
+
domainMarkerBody = await readBoundedResponseBody(domainResponse, maxResponseBytes);
|
|
111366
|
+
} catch (err) {
|
|
111367
|
+
return {
|
|
111368
|
+
verified: false,
|
|
111369
|
+
publicUrl: normalizedPublicBase,
|
|
111370
|
+
outcome: "verification_failed",
|
|
111371
|
+
reason: `Failed to read custom domain marker body: ${err instanceof Error ? err.message : String(err)}`
|
|
111372
|
+
};
|
|
111373
|
+
}
|
|
111374
|
+
const domainMarkerValid = verifyPublishMarker(domainMarkerBody, {
|
|
111375
|
+
operationId: expectedOperationId,
|
|
111376
|
+
sourceDigest: expectedSourceDigest
|
|
111377
|
+
});
|
|
111378
|
+
if (!domainMarkerValid) {
|
|
111379
|
+
return {
|
|
111380
|
+
verified: false,
|
|
111381
|
+
publicUrl: normalizedPublicBase,
|
|
111382
|
+
outcome: "verification_failed",
|
|
111383
|
+
reason: `Custom domain "${normalizedDomain}" points to older or mismatched content (PUB-010)`
|
|
111384
|
+
};
|
|
111385
|
+
}
|
|
111386
|
+
customDomainVerified = true;
|
|
111387
|
+
}
|
|
111388
|
+
return {
|
|
111389
|
+
verified: true,
|
|
111390
|
+
publicUrl: normalizedPublicBase,
|
|
111391
|
+
customDomainVerified: customDomain ? customDomainVerified : void 0,
|
|
111392
|
+
marker: {
|
|
111393
|
+
operationId: expectedOperationId,
|
|
111394
|
+
sourceDigest: expectedSourceDigest
|
|
111395
|
+
},
|
|
111396
|
+
verifiedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
111397
|
+
landingPageStatusCode: landingResponse.status
|
|
111398
|
+
};
|
|
111399
|
+
}
|
|
111400
|
+
|
|
111401
|
+
// src/delivery/page-publication-evidence.ts
|
|
111402
|
+
var MANAGED_PUBLISHER_SERVER_ID = "publisher.mcp.v1";
|
|
111403
|
+
var SUPPORTED_SOURCE_DIGEST_VERSIONS = /* @__PURE__ */ new Set(["v1"]);
|
|
111404
|
+
var DEFAULT_LIVENESS_TIMEOUT_MS = 1e4;
|
|
111405
|
+
var DEFAULT_PUBLICATION_RETRY = { attempts: 3, delaysMs: [2e3, 6e3] };
|
|
111406
|
+
var DEFAULT_PUBLICATION_DEADLINE_MS = 3e4;
|
|
111407
|
+
function nonEmptyString(value) {
|
|
111408
|
+
return typeof value === "string" && value.length > 0 ? value : null;
|
|
111409
|
+
}
|
|
111410
|
+
function defaultAllowLocal() {
|
|
111411
|
+
return process.env.NODE_ENV === "test" && process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1";
|
|
111412
|
+
}
|
|
111413
|
+
var realSleep = (ms) => new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
111414
|
+
async function withTransientRetry(check2, retry, remainingMs) {
|
|
111415
|
+
const attempts = Math.max(1, Math.min(retry?.attempts ?? DEFAULT_PUBLICATION_RETRY.attempts, 5));
|
|
111416
|
+
const delays = retry?.delaysMs ?? DEFAULT_PUBLICATION_RETRY.delaysMs;
|
|
111417
|
+
const sleep = retry?.sleep ?? realSleep;
|
|
111418
|
+
let result = await check2();
|
|
111419
|
+
let tried = 1;
|
|
111420
|
+
for (let attempt = 2; attempt <= attempts && !result.ok && result.transient; attempt += 1) {
|
|
111421
|
+
const delay6 = delays[Math.min(attempt - 2, delays.length - 1)] ?? 0;
|
|
111422
|
+
if (delay6 >= remainingMs()) break;
|
|
111423
|
+
await sleep(delay6);
|
|
111424
|
+
result = await check2();
|
|
111425
|
+
tried += 1;
|
|
111426
|
+
}
|
|
111427
|
+
if (!result.ok && result.transient && tried > 1) {
|
|
111428
|
+
return { ...result, reason: `${result.reason} (still failing after ${tried} attempts)` };
|
|
111429
|
+
}
|
|
111430
|
+
return result;
|
|
111431
|
+
}
|
|
111432
|
+
async function withinDeadline(work, remainingMs, onTimeout) {
|
|
111433
|
+
if (remainingMs <= 0) return onTimeout();
|
|
111434
|
+
let timer;
|
|
111435
|
+
const timeout = new Promise((resolve4) => {
|
|
111436
|
+
timer = setTimeout(() => resolve4(onTimeout()), remainingMs);
|
|
111437
|
+
});
|
|
111438
|
+
try {
|
|
111439
|
+
return await Promise.race([work, timeout]);
|
|
111440
|
+
} finally {
|
|
111441
|
+
clearTimeout(timer);
|
|
111442
|
+
}
|
|
111443
|
+
}
|
|
111444
|
+
async function verifyUrlLive(url2, options = {}) {
|
|
111445
|
+
const fetchFn = options.fetchFn ?? safeFetch;
|
|
111446
|
+
let response;
|
|
111447
|
+
try {
|
|
111448
|
+
response = await fetchFn(
|
|
111449
|
+
url2,
|
|
111450
|
+
{ method: "GET", headers: { accept: "text/html,*/*;q=0.8", "user-agent": "Mrrlin-Public-Verifier/1.0" } },
|
|
111451
|
+
{
|
|
111452
|
+
allowLocalEndpoints: options.allowLocalEndpoints ?? defaultAllowLocal(),
|
|
111453
|
+
timeoutMs: options.timeoutMs ?? DEFAULT_LIVENESS_TIMEOUT_MS,
|
|
111454
|
+
maxRedirects: 3
|
|
111455
|
+
}
|
|
111456
|
+
);
|
|
111457
|
+
} catch (error51) {
|
|
111458
|
+
const transient = isDnsOrUnreachableError(error51);
|
|
111459
|
+
if (error51 instanceof NetworkPolicyViolationError) {
|
|
111460
|
+
return { live: false, reason: `network policy refused ${url2}: ${error51.message}`, transient };
|
|
111461
|
+
}
|
|
111462
|
+
return { live: false, reason: `${url2} is unreachable: ${error51 instanceof Error ? error51.message : String(error51)}`, transient };
|
|
111463
|
+
}
|
|
111464
|
+
if (response.status === 401 || response.status === 403) {
|
|
111465
|
+
await response.body?.cancel().catch(() => {
|
|
111466
|
+
});
|
|
111467
|
+
return { live: false, reason: `${url2} is behind an authentication wall (HTTP ${response.status})`, transient: false };
|
|
111468
|
+
}
|
|
111469
|
+
if (response.status >= 400) {
|
|
111470
|
+
await response.body?.cancel().catch(() => {
|
|
111471
|
+
});
|
|
111472
|
+
return { live: false, reason: `${url2} answered HTTP ${response.status}`, transient: response.status >= 500 };
|
|
111473
|
+
}
|
|
111474
|
+
const finalUrl = finalResponseUrl(response);
|
|
111475
|
+
const body = await readBodyPrefix(response);
|
|
111476
|
+
if (looksLikeLoginPage({ requestedUrl: url2, finalUrl, body })) {
|
|
111477
|
+
return {
|
|
111478
|
+
live: false,
|
|
111479
|
+
reason: `${url2} is behind an authentication wall (it ends on a sign-in page${finalUrl && finalUrl !== url2 ? `: ${finalUrl}` : ""})`,
|
|
111480
|
+
transient: false
|
|
111481
|
+
};
|
|
111482
|
+
}
|
|
111483
|
+
return { live: true };
|
|
111484
|
+
}
|
|
111485
|
+
async function checkPublishAttemptBinding(options, url2, attemptId, sourceDigest, operationId) {
|
|
111486
|
+
let attempt;
|
|
111487
|
+
try {
|
|
111488
|
+
attempt = await options.resolvePublishAttempt(attemptId);
|
|
111489
|
+
} catch (error51) {
|
|
111490
|
+
return {
|
|
111491
|
+
ok: false,
|
|
111492
|
+
transient: false,
|
|
111493
|
+
reason: `publication_evidence_missing: publish attempt ${attemptId} for ${url2} could not be read: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
111494
|
+
};
|
|
111495
|
+
}
|
|
111496
|
+
if (!attempt) {
|
|
111497
|
+
return { ok: false, transient: false, reason: `publication_evidence_unbound: ${url2} names publish attempt ${attemptId}, which does not exist in this project` };
|
|
111498
|
+
}
|
|
111499
|
+
if (attempt.projectSlug !== options.projectSlug || attempt.runId !== options.runId) {
|
|
111500
|
+
return { ok: false, transient: false, reason: `publication_evidence_unbound: publish attempt ${attemptId} belongs to another run, not ${options.runId}` };
|
|
111501
|
+
}
|
|
111502
|
+
if (attempt.status === "failed") {
|
|
111503
|
+
return { ok: false, transient: false, reason: `publication_evidence_unbound: publish attempt ${attemptId} failed, so it cannot prove ${url2}` };
|
|
111504
|
+
}
|
|
111505
|
+
if (attempt.preparedEnvelope?.sourceDigest !== sourceDigest) {
|
|
111506
|
+
return { ok: false, transient: false, reason: `publication_evidence_unbound: ${url2} claims a source digest that publish attempt ${attemptId} did not publish` };
|
|
111507
|
+
}
|
|
111508
|
+
const dispatchedOperationId = nonEmptyString(attempt.dispatchedOperationId);
|
|
111509
|
+
if (dispatchedOperationId !== null && dispatchedOperationId !== operationId) {
|
|
111510
|
+
return { ok: false, transient: false, reason: `publication_evidence_unbound: ${url2} claims operation ${operationId}, but publish attempt ${attemptId} dispatched ${dispatchedOperationId}` };
|
|
111511
|
+
}
|
|
111512
|
+
return { ok: true };
|
|
111513
|
+
}
|
|
111514
|
+
async function verifyPagePublicationEvidence(options) {
|
|
111515
|
+
const startedAt = Date.now();
|
|
111516
|
+
const deadlineMs = options.deadlineMs ?? DEFAULT_PUBLICATION_DEADLINE_MS;
|
|
111517
|
+
const remainingMs = () => deadlineMs - (Date.now() - startedAt);
|
|
111518
|
+
const produced = options.artifacts.map((artifact, index) => ({ artifact, index })).filter(({ artifact }) => artifact.kind === "produced_url").sort((a, b) => {
|
|
111519
|
+
const ac = a.artifact.createdAt ?? "";
|
|
111520
|
+
const bc = b.artifact.createdAt ?? "";
|
|
111521
|
+
return ac && bc && ac !== bc ? ac < bc ? -1 : 1 : a.index - b.index;
|
|
111522
|
+
}).map(({ artifact }) => artifact);
|
|
111523
|
+
if (produced.length === 0) {
|
|
111524
|
+
return {
|
|
111525
|
+
ok: false,
|
|
111526
|
+
reason: "publication_evidence_missing: the page outcome has no produced URL, so nothing proves the page is public"
|
|
111527
|
+
};
|
|
111528
|
+
}
|
|
111529
|
+
let publisher;
|
|
111530
|
+
try {
|
|
111531
|
+
publisher = await options.resolvePublisherTarget();
|
|
111532
|
+
} catch (error51) {
|
|
111533
|
+
return {
|
|
111534
|
+
ok: false,
|
|
111535
|
+
reason: `publication_evidence_missing: the publisher binding could not be read: ${error51 instanceof Error ? error51.message : String(error51)}`
|
|
111536
|
+
};
|
|
111537
|
+
}
|
|
111538
|
+
let publicOrigin = null;
|
|
111539
|
+
try {
|
|
111540
|
+
publicOrigin = publisher?.publicOrigin ? new URL(publisher.publicOrigin).origin : null;
|
|
111541
|
+
} catch {
|
|
111542
|
+
publicOrigin = null;
|
|
111543
|
+
}
|
|
111544
|
+
const isManaged = (artifact) => {
|
|
111545
|
+
const payload = artifact.payload ?? {};
|
|
111546
|
+
return ["operationId", "sourceDigest", "sourceDigestVersion", "publishAttemptId"].some((key) => nonEmptyString(payload[key]) !== null);
|
|
111547
|
+
};
|
|
111548
|
+
const primary = produced.find(isManaged) ?? produced[0];
|
|
111549
|
+
if (!primary) {
|
|
111550
|
+
return { ok: false, reason: "publication_evidence_missing: the page outcome has no produced URL" };
|
|
111551
|
+
}
|
|
111552
|
+
if (publisher && !isManaged(primary)) {
|
|
111553
|
+
const url2 = nonEmptyString((primary.payload ?? {}).url) ?? "(no url)";
|
|
111554
|
+
return {
|
|
111555
|
+
ok: false,
|
|
111556
|
+
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`
|
|
111557
|
+
};
|
|
111558
|
+
}
|
|
111559
|
+
const checkOne = async (artifact, retryTransient) => {
|
|
111560
|
+
const retry = retryTransient ? options.retry : { ...options.retry, attempts: 1 };
|
|
111561
|
+
const fetchTimeoutMs = () => Math.max(1, Math.min(options.timeoutMs ?? DEFAULT_LIVENESS_TIMEOUT_MS, remainingMs()));
|
|
111562
|
+
const payload = artifact.payload ?? {};
|
|
111563
|
+
const rawUrl = nonEmptyString(payload.url);
|
|
111564
|
+
let parsedUrl = null;
|
|
111565
|
+
try {
|
|
111566
|
+
if (rawUrl && rawUrl.startsWith("/") && !rawUrl.startsWith("//")) {
|
|
111567
|
+
parsedUrl = publicOrigin ? new URL(rawUrl, publicOrigin) : null;
|
|
111568
|
+
} else {
|
|
111569
|
+
parsedUrl = rawUrl ? new URL(rawUrl) : null;
|
|
111570
|
+
}
|
|
111571
|
+
} catch {
|
|
111572
|
+
parsedUrl = null;
|
|
111573
|
+
}
|
|
111574
|
+
if (!rawUrl || !parsedUrl || parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
|
|
111575
|
+
return {
|
|
111576
|
+
ok: false,
|
|
111577
|
+
url: rawUrl ?? "(no url)",
|
|
111578
|
+
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" : "")
|
|
111579
|
+
};
|
|
111580
|
+
}
|
|
111581
|
+
const url2 = parsedUrl.toString();
|
|
111582
|
+
if (!isManaged(artifact)) {
|
|
111583
|
+
const liveness = await withTransientRetry(async () => {
|
|
111584
|
+
const live = await verifyUrlLive(url2, { ...options, timeoutMs: fetchTimeoutMs() });
|
|
111585
|
+
return live.live ? { ok: true } : { ok: false, reason: live.reason, transient: live.transient };
|
|
111586
|
+
}, retry, remainingMs);
|
|
111587
|
+
if (!liveness.ok) return { ok: false, url: url2, reason: `public_url_not_verified: ${liveness.reason}` };
|
|
111588
|
+
return { ok: true, verified: { artifactId: artifact.id, url: url2, mode: "liveness" } };
|
|
111589
|
+
}
|
|
111590
|
+
const operationId = nonEmptyString(payload.operationId);
|
|
111591
|
+
const sourceDigest = nonEmptyString(payload.sourceDigest);
|
|
111592
|
+
const sourceDigestVersion = nonEmptyString(payload.sourceDigestVersion);
|
|
111593
|
+
const publishAttemptId = nonEmptyString(payload.publishAttemptId);
|
|
111594
|
+
if (!operationId || !sourceDigest || !sourceDigestVersion || !publishAttemptId) {
|
|
111595
|
+
return {
|
|
111596
|
+
ok: false,
|
|
111597
|
+
url: url2,
|
|
111598
|
+
reason: `publication_evidence_missing: produced URL ${url2} carries incomplete publish evidence (operationId, sourceDigest, sourceDigestVersion and publishAttemptId are all required)`
|
|
111599
|
+
};
|
|
111600
|
+
}
|
|
111601
|
+
if (!SUPPORTED_SOURCE_DIGEST_VERSIONS.has(sourceDigestVersion)) {
|
|
111602
|
+
return {
|
|
111603
|
+
ok: false,
|
|
111604
|
+
url: url2,
|
|
111605
|
+
reason: `publication_evidence_missing: produced URL ${url2} uses source digest version "${sourceDigestVersion}", which this closure cannot compare`
|
|
111606
|
+
};
|
|
111607
|
+
}
|
|
111608
|
+
if (!publicOrigin) {
|
|
111609
|
+
return {
|
|
111610
|
+
ok: false,
|
|
111611
|
+
url: url2,
|
|
111612
|
+
reason: `publication_evidence_missing: no ${MANAGED_PUBLISHER_SERVER_ID} binding with a public origin to check ${url2} against`
|
|
111613
|
+
};
|
|
111614
|
+
}
|
|
111615
|
+
if (parsedUrl.origin !== publicOrigin) {
|
|
111616
|
+
return {
|
|
111617
|
+
ok: false,
|
|
111618
|
+
url: url2,
|
|
111619
|
+
reason: `public_url_outside_origin: ${url2} is not inside the publisher's public origin ${publicOrigin}`
|
|
111620
|
+
};
|
|
111621
|
+
}
|
|
111622
|
+
const binding = await checkPublishAttemptBinding(options, url2, publishAttemptId, sourceDigest, operationId);
|
|
111623
|
+
if (!binding.ok) return { ok: false, url: url2, reason: binding.reason };
|
|
111624
|
+
const result = await withTransientRetry(async () => {
|
|
111625
|
+
const verified2 = await verifyPublicUrl({
|
|
111626
|
+
publicUrl: url2,
|
|
111627
|
+
expectedOperationId: operationId,
|
|
111628
|
+
expectedSourceDigest: sourceDigest,
|
|
111629
|
+
expectedSourceDigestVersion: sourceDigestVersion,
|
|
111630
|
+
allowLocalEndpoints: options.allowLocalEndpoints,
|
|
111631
|
+
...options.fetchFn ? { fetchFn: options.fetchFn } : {},
|
|
111632
|
+
timeoutMs: fetchTimeoutMs()
|
|
111633
|
+
});
|
|
111634
|
+
if (verified2.verified) return { ok: true };
|
|
111635
|
+
const reason = verified2.outcome === "digest_version_mismatch" ? `publication_evidence_missing: ${verified2.reason}` : `public_url_not_verified: ${verified2.outcome}: ${verified2.reason}`;
|
|
111636
|
+
return { ok: false, reason, transient: isTransientVerificationFailure(verified2) };
|
|
111637
|
+
}, retry, remainingMs);
|
|
111638
|
+
if (!result.ok) return { ok: false, url: url2, reason: result.reason };
|
|
111639
|
+
return { ok: true, verified: { artifactId: artifact.id, url: url2, mode: "managed" } };
|
|
111640
|
+
};
|
|
111641
|
+
const deadlineReason = `public_url_not_verified: the publication check ran out of its ${Math.round(deadlineMs / 1e3)}s budget`;
|
|
111642
|
+
const primaryResult = await withinDeadline(checkOne(primary, true), remainingMs(), () => ({
|
|
111643
|
+
ok: false,
|
|
111644
|
+
url: "",
|
|
111645
|
+
reason: deadlineReason
|
|
111646
|
+
}));
|
|
111647
|
+
if (!primaryResult.ok) return { ok: false, reason: primaryResult.reason };
|
|
111648
|
+
const verified = [primaryResult.verified];
|
|
111649
|
+
const secondaryFailures = [];
|
|
111650
|
+
for (const artifact of produced) {
|
|
111651
|
+
if (artifact === primary) continue;
|
|
111652
|
+
const rawUrl = nonEmptyString((artifact.payload ?? {}).url) ?? "(no url)";
|
|
111653
|
+
const secondary = await withinDeadline(checkOne(artifact, false), remainingMs(), () => ({
|
|
111654
|
+
ok: false,
|
|
111655
|
+
url: rawUrl,
|
|
111656
|
+
reason: `${deadlineReason}; not checked in time`
|
|
111657
|
+
}));
|
|
111658
|
+
if (secondary.ok) verified.push(secondary.verified);
|
|
111659
|
+
else secondaryFailures.push({ artifactId: artifact.id, url: secondary.url, reason: secondary.reason });
|
|
111660
|
+
}
|
|
111661
|
+
return { ok: true, primary: primaryResult.verified, verified, secondaryFailures };
|
|
111662
|
+
}
|
|
110736
111663
|
|
|
110737
111664
|
// src/prompts/task-notes-contract.ts
|
|
110738
111665
|
init_dist();
|
|
@@ -113003,7 +113930,7 @@ async function driveClaimedRun(deps, projectSlug, runId, claimed, leaseId) {
|
|
|
113003
113930
|
);
|
|
113004
113931
|
return;
|
|
113005
113932
|
}
|
|
113006
|
-
const runDomains = Array.isArray(task.domains) ? task.domains : [
|
|
113933
|
+
const runDomains = Array.isArray(task.domains) ? task.domains : [];
|
|
113007
113934
|
const hasCodeDomain = runDomains.some((d) => typeof d === "string" && d.trim().toLowerCase() === "code");
|
|
113008
113935
|
const isPureCode = runDomains.length === 1 && hasCodeDomain;
|
|
113009
113936
|
const requires = task.declaredOutcome?.requires ?? [];
|
|
@@ -113035,11 +113962,12 @@ async function driveClaimedRun(deps, projectSlug, runId, claimed, leaseId) {
|
|
|
113035
113962
|
const isCodeRun = isPureCode || hasCodeDomain && needsCodeChange && claimed.codeExecution === true && claimed.executionRouteIntent === "code" && !!runApproval;
|
|
113036
113963
|
const verifyLegacyPureScope = async () => {
|
|
113037
113964
|
const current2 = await deps.client.getTask(projectSlug, task.id);
|
|
113038
|
-
const domains = current2.domains ?? [
|
|
113965
|
+
const domains = current2.domains ?? [];
|
|
113039
113966
|
return current2.codeScopeApprovalRequired !== true && domains.length === 1 && domains[0] === "code";
|
|
113040
113967
|
};
|
|
113041
113968
|
if (!isCodeRun) {
|
|
113042
|
-
const runDomain = runDomains.find((d) => typeof d === "string" && d.trim().toLowerCase() !== "code") ?? runDomains[0] ??
|
|
113969
|
+
const runDomain = runDomains.find((d) => typeof d === "string" && d.trim().toLowerCase() !== "code") ?? runDomains[0] ?? // No domain: author the result with the general content producer.
|
|
113970
|
+
"content";
|
|
113043
113971
|
let providerId = claimed.agentSeat;
|
|
113044
113972
|
if (providerId == null) {
|
|
113045
113973
|
const seat = await mintResolvedSeat(resolveProvider(process.env, getSelectedProvider()));
|
|
@@ -114426,7 +115354,7 @@ function buildDeliverableAuthorPrompt(task, specMarkdown, project, journalMarkdo
|
|
|
114426
115354
|
`--- TASK ---`,
|
|
114427
115355
|
`id: ${task.id}`,
|
|
114428
115356
|
`title: ${task.title}`,
|
|
114429
|
-
`domains: ${
|
|
115357
|
+
`domains: ${task.domains?.length ? task.domains.join(", ") : "none (not a code task)"}`,
|
|
114430
115358
|
``,
|
|
114431
115359
|
`notes:`,
|
|
114432
115360
|
task.notes ?? "(none)",
|
|
@@ -114757,22 +115685,56 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2,
|
|
|
114757
115685
|
}
|
|
114758
115686
|
const awaitsResultConfirmation = rawProject.awaitsResultConfirmation === true;
|
|
114759
115687
|
const isPageOutcome = task.declaredOutcome?.requires?.includes("page") === true;
|
|
114760
|
-
const
|
|
114761
|
-
|
|
114762
|
-
|
|
114763
|
-
deps,
|
|
115688
|
+
const verifyPagePublication = async (artifacts) => {
|
|
115689
|
+
const evidence = await verifyPagePublicationEvidence({
|
|
115690
|
+
artifacts,
|
|
114764
115691
|
projectSlug,
|
|
114765
|
-
task,
|
|
114766
115692
|
runId,
|
|
114767
|
-
|
|
114768
|
-
|
|
114769
|
-
|
|
114770
|
-
|
|
114771
|
-
|
|
115693
|
+
resolvePublisherTarget: async () => {
|
|
115694
|
+
const target = (await deps.client.getIntegrationBinding(projectSlug, MANAGED_PUBLISHER_SERVER_ID))?.publisherTarget;
|
|
115695
|
+
return target ? { publicOrigin: target.publicOrigin ?? null } : null;
|
|
115696
|
+
},
|
|
115697
|
+
// Read-only: binds managed evidence to this run's own publish attempt (anti-forgery).
|
|
115698
|
+
resolvePublishAttempt: (attemptId) => deps.client.getPublishAttempt(projectSlug, attemptId),
|
|
115699
|
+
...deps.publicationFetch ? { fetchFn: deps.publicationFetch } : {},
|
|
115700
|
+
...deps.publicationRetrySleep ? { retry: { sleep: deps.publicationRetrySleep } } : {}
|
|
115701
|
+
});
|
|
115702
|
+
if (evidence.ok && evidence.secondaryFailures.length > 0) {
|
|
115703
|
+
const lines2 = evidence.secondaryFailures.map((failure) => `- ${failure.url}: ${failure.reason}`).join("\n");
|
|
115704
|
+
console.error(`[mrrlin] run ${runId}: ${evidence.secondaryFailures.length} secondary produced URL(s) failed the public check`);
|
|
115705
|
+
try {
|
|
115706
|
+
await deps.client.appendTaskEvent(projectSlug, task.id, {
|
|
115707
|
+
kind: "note",
|
|
115708
|
+
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:
|
|
115709
|
+
${lines2}`
|
|
115710
|
+
});
|
|
115711
|
+
} catch {
|
|
115712
|
+
}
|
|
115713
|
+
}
|
|
115714
|
+
return evidence;
|
|
115715
|
+
};
|
|
115716
|
+
if (isPageOutcome && parsedResult.outcome === "completed" && !awaitsResultConfirmation && !deps.signingProvider) {
|
|
115717
|
+
const artifacts = await deps.client.listExecutionArtifacts(projectSlug, runId).catch(() => []);
|
|
115718
|
+
if (artifacts.some((artifact) => artifact.kind === "produced_url")) {
|
|
115719
|
+
const evidence = await verifyPagePublication(artifacts);
|
|
115720
|
+
deps.activeLease?.progress();
|
|
115721
|
+
if (!evidence.ok) {
|
|
115722
|
+
await failRun(deps, projectSlug, task, runId, leaseId, evidence.reason);
|
|
115723
|
+
return;
|
|
115724
|
+
}
|
|
115725
|
+
}
|
|
114772
115726
|
}
|
|
114773
115727
|
if (deps.signingProvider && (parsedResult.outcome === "negative_result" || parsedResult.outcome === "completed" && !awaitsResultConfirmation)) {
|
|
115728
|
+
const existingArtifacts = isPageOutcome ? await deps.client.listExecutionArtifacts(projectSlug, runId).catch(() => []) : [];
|
|
115729
|
+
if (isPageOutcome && parsedResult.outcome === "completed") {
|
|
115730
|
+
const evidence = await verifyPagePublication(existingArtifacts);
|
|
115731
|
+
deps.activeLease?.progress();
|
|
115732
|
+
if (!evidence.ok) {
|
|
115733
|
+
await failRun(deps, projectSlug, task, runId, leaseId, evidence.reason);
|
|
115734
|
+
return;
|
|
115735
|
+
}
|
|
115736
|
+
}
|
|
114774
115737
|
try {
|
|
114775
|
-
const existingArtifacts = isPageOutcome ? await deps.client.listExecutionArtifacts(projectSlug, runId).catch(() => []) : [];
|
|
114776
115738
|
const urlArtifacts = existingArtifacts.filter((a) => a.kind === "produced_url").map((a) => ({
|
|
114777
115739
|
artifactId: a.id,
|
|
114778
115740
|
storageVersion: "1",
|
|
@@ -124424,7 +125386,7 @@ function buildThreadStartParams(msg, config2, desiredModel) {
|
|
|
124424
125386
|
"- Apply this format ONLY to Specs/{id} pages; do not retro-fit it onto other wiki page types.",
|
|
124425
125387
|
"- With each spec, set the task's `declaredOutcome` via `update_task` yourself; approval needs it.",
|
|
124426
125388
|
'- 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
|
-
"-
|
|
125389
|
+
"- 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
125390
|
'- 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
125391
|
"- 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
125392
|
"- 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.",
|