@mrrlin-dev/mcp 0.4.221 → 0.4.223
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 +1348 -578
- package/package.json +1 -1
package/dist/bin.cjs
CHANGED
|
@@ -14343,7 +14343,7 @@ var require_util2 = __commonJS({
|
|
|
14343
14343
|
var { kDestroyed, kBodyUsed, kListeners, kBody } = require_symbols();
|
|
14344
14344
|
var { IncomingMessage } = require("node:http");
|
|
14345
14345
|
var stream = require("node:stream");
|
|
14346
|
-
var
|
|
14346
|
+
var net7 = require("node:net");
|
|
14347
14347
|
var { stringify } = require("node:querystring");
|
|
14348
14348
|
var { EventEmitter: EE } = require("node:events");
|
|
14349
14349
|
var timers = require_timers();
|
|
@@ -14492,7 +14492,7 @@ var require_util2 = __commonJS({
|
|
|
14492
14492
|
}
|
|
14493
14493
|
assert2(typeof host === "string");
|
|
14494
14494
|
const servername = getHostname(host);
|
|
14495
|
-
if (
|
|
14495
|
+
if (net7.isIP(servername)) {
|
|
14496
14496
|
return "";
|
|
14497
14497
|
}
|
|
14498
14498
|
return servername;
|
|
@@ -16197,7 +16197,7 @@ var require_dispatcher_base = __commonJS({
|
|
|
16197
16197
|
var require_connect = __commonJS({
|
|
16198
16198
|
"../../node_modules/.pnpm/undici@7.30.2/node_modules/undici/lib/core/connect.js"(exports2, module2) {
|
|
16199
16199
|
"use strict";
|
|
16200
|
-
var
|
|
16200
|
+
var net7 = require("node:net");
|
|
16201
16201
|
var assert2 = require("node:assert");
|
|
16202
16202
|
var util = require_util2();
|
|
16203
16203
|
var { InvalidArgumentError } = require_errors2();
|
|
@@ -16284,7 +16284,7 @@ var require_connect = __commonJS({
|
|
|
16284
16284
|
} else {
|
|
16285
16285
|
assert2(!httpSocket, "httpSocket can only be sent on TLS update");
|
|
16286
16286
|
port = port || 80;
|
|
16287
|
-
socket =
|
|
16287
|
+
socket = net7.connect({
|
|
16288
16288
|
highWaterMark: 64 * 1024,
|
|
16289
16289
|
// Same as nodejs fs streams.
|
|
16290
16290
|
...options,
|
|
@@ -21997,7 +21997,7 @@ var require_client = __commonJS({
|
|
|
21997
21997
|
"../../node_modules/.pnpm/undici@7.30.2/node_modules/undici/lib/dispatcher/client.js"(exports2, module2) {
|
|
21998
21998
|
"use strict";
|
|
21999
21999
|
var assert2 = require("node:assert");
|
|
22000
|
-
var
|
|
22000
|
+
var net7 = require("node:net");
|
|
22001
22001
|
var http6 = require("node:http");
|
|
22002
22002
|
var util = require_util2();
|
|
22003
22003
|
var { ClientStats } = require_stats();
|
|
@@ -22153,7 +22153,7 @@ var require_client = __commonJS({
|
|
|
22153
22153
|
if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) {
|
|
22154
22154
|
throw new InvalidArgumentError("maxRequestsPerClient must be a positive number");
|
|
22155
22155
|
}
|
|
22156
|
-
if (localAddress != null && (typeof localAddress !== "string" ||
|
|
22156
|
+
if (localAddress != null && (typeof localAddress !== "string" || net7.isIP(localAddress) === 0)) {
|
|
22157
22157
|
throw new InvalidArgumentError("localAddress must be valid string IP address");
|
|
22158
22158
|
}
|
|
22159
22159
|
if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) {
|
|
@@ -22333,7 +22333,7 @@ var require_client = __commonJS({
|
|
|
22333
22333
|
const idx = hostname3.indexOf("]");
|
|
22334
22334
|
assert2(idx !== -1);
|
|
22335
22335
|
const ip = hostname3.substring(1, idx);
|
|
22336
|
-
assert2(
|
|
22336
|
+
assert2(net7.isIPv6(ip));
|
|
22337
22337
|
hostname3 = ip;
|
|
22338
22338
|
}
|
|
22339
22339
|
client[kConnecting] = true;
|
|
@@ -23281,10 +23281,10 @@ var require_socks5_utils = __commonJS({
|
|
|
23281
23281
|
"../../node_modules/.pnpm/undici@7.30.2/node_modules/undici/lib/core/socks5-utils.js"(exports2, module2) {
|
|
23282
23282
|
"use strict";
|
|
23283
23283
|
var { Buffer: Buffer2 } = require("node:buffer");
|
|
23284
|
-
var
|
|
23284
|
+
var net7 = require("node:net");
|
|
23285
23285
|
var { InvalidArgumentError } = require_errors2();
|
|
23286
23286
|
function parseAddress(address) {
|
|
23287
|
-
if (
|
|
23287
|
+
if (net7.isIPv4(address)) {
|
|
23288
23288
|
const parts = address.split(".").map(Number);
|
|
23289
23289
|
return {
|
|
23290
23290
|
type: 1,
|
|
@@ -23292,7 +23292,7 @@ var require_socks5_utils = __commonJS({
|
|
|
23292
23292
|
buffer: Buffer2.from(parts)
|
|
23293
23293
|
};
|
|
23294
23294
|
}
|
|
23295
|
-
if (
|
|
23295
|
+
if (net7.isIPv6(address)) {
|
|
23296
23296
|
return {
|
|
23297
23297
|
type: 4,
|
|
23298
23298
|
// IPv6
|
|
@@ -23315,7 +23315,7 @@ var require_socks5_utils = __commonJS({
|
|
|
23315
23315
|
if (address.includes(".")) {
|
|
23316
23316
|
const lastColonIndex = address.lastIndexOf(":");
|
|
23317
23317
|
const ipv4Part = address.slice(lastColonIndex + 1);
|
|
23318
|
-
if (
|
|
23318
|
+
if (net7.isIPv4(ipv4Part)) {
|
|
23319
23319
|
const octets = ipv4Part.split(".").map(Number);
|
|
23320
23320
|
const high = (octets[0] << 8 | octets[1]).toString(16);
|
|
23321
23321
|
const low = (octets[2] << 8 | octets[3]).toString(16);
|
|
@@ -42225,9 +42225,9 @@ var require_websocket2 = __commonJS({
|
|
|
42225
42225
|
var EventEmitter3 = require("events");
|
|
42226
42226
|
var https4 = require("https");
|
|
42227
42227
|
var http6 = require("http");
|
|
42228
|
-
var
|
|
42228
|
+
var net7 = require("net");
|
|
42229
42229
|
var tls2 = require("tls");
|
|
42230
|
-
var { randomBytes: randomBytes6, createHash:
|
|
42230
|
+
var { randomBytes: randomBytes6, createHash: createHash14 } = require("crypto");
|
|
42231
42231
|
var { Duplex, Readable: Readable2 } = require("stream");
|
|
42232
42232
|
var { URL: URL2 } = require("url");
|
|
42233
42233
|
var PerMessageDeflate2 = require_permessage_deflate2();
|
|
@@ -42895,7 +42895,7 @@ var require_websocket2 = __commonJS({
|
|
|
42895
42895
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
42896
42896
|
return;
|
|
42897
42897
|
}
|
|
42898
|
-
const digest =
|
|
42898
|
+
const digest = createHash14("sha1").update(key + GUID).digest("base64");
|
|
42899
42899
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
42900
42900
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
42901
42901
|
return;
|
|
@@ -42969,12 +42969,12 @@ var require_websocket2 = __commonJS({
|
|
|
42969
42969
|
}
|
|
42970
42970
|
function netConnect(options) {
|
|
42971
42971
|
options.path = options.socketPath;
|
|
42972
|
-
return
|
|
42972
|
+
return net7.connect(options);
|
|
42973
42973
|
}
|
|
42974
42974
|
function tlsConnect(options) {
|
|
42975
42975
|
options.path = void 0;
|
|
42976
42976
|
if (!options.servername && options.servername !== "") {
|
|
42977
|
-
options.servername =
|
|
42977
|
+
options.servername = net7.isIP(options.host) ? "" : options.host;
|
|
42978
42978
|
}
|
|
42979
42979
|
return tls2.connect(options);
|
|
42980
42980
|
}
|
|
@@ -43264,7 +43264,7 @@ var require_websocket_server = __commonJS({
|
|
|
43264
43264
|
var EventEmitter3 = require("events");
|
|
43265
43265
|
var http6 = require("http");
|
|
43266
43266
|
var { Duplex } = require("stream");
|
|
43267
|
-
var { createHash:
|
|
43267
|
+
var { createHash: createHash14 } = require("crypto");
|
|
43268
43268
|
var extension2 = require_extension();
|
|
43269
43269
|
var PerMessageDeflate2 = require_permessage_deflate2();
|
|
43270
43270
|
var subprotocol2 = require_subprotocol();
|
|
@@ -43571,7 +43571,7 @@ var require_websocket_server = __commonJS({
|
|
|
43571
43571
|
);
|
|
43572
43572
|
}
|
|
43573
43573
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
43574
|
-
const digest =
|
|
43574
|
+
const digest = createHash14("sha1").update(key + GUID).digest("base64");
|
|
43575
43575
|
const headers = [
|
|
43576
43576
|
"HTTP/1.1 101 Switching Protocols",
|
|
43577
43577
|
"Upgrade: websocket",
|
|
@@ -49603,7 +49603,7 @@ var import_node_os16 = __toESM(require("node:os"), 1);
|
|
|
49603
49603
|
var import_node_path29 = __toESM(require("node:path"), 1);
|
|
49604
49604
|
|
|
49605
49605
|
// src/tools.ts
|
|
49606
|
-
var
|
|
49606
|
+
var import_node_crypto23 = require("node:crypto");
|
|
49607
49607
|
var import_promises12 = require("node:fs/promises");
|
|
49608
49608
|
var import_node_path28 = __toESM(require("node:path"), 1);
|
|
49609
49609
|
var import_node_os15 = __toESM(require("node:os"), 1);
|
|
@@ -64453,6 +64453,7 @@ var openApiOperationIds = {
|
|
|
64453
64453
|
renewPublishLease: "renewPublishLease",
|
|
64454
64454
|
recordPublishSubmission: "recordPublishSubmission",
|
|
64455
64455
|
finalizePublishAttempt: "finalizePublishAttempt",
|
|
64456
|
+
enrollManagedPublisher: "enrollManagedPublisher",
|
|
64456
64457
|
listIntegrationCatalog: "listIntegrationCatalog",
|
|
64457
64458
|
getIntegrationCatalogItem: "getIntegrationCatalogItem"
|
|
64458
64459
|
};
|
|
@@ -66199,6 +66200,123 @@ function detectSecretExposureInEndpoint(endpoint, secretValues) {
|
|
|
66199
66200
|
return null;
|
|
66200
66201
|
}
|
|
66201
66202
|
|
|
66203
|
+
// ../../packages/schemas/dist/publisher-profiles.js
|
|
66204
|
+
var PUBLISHER_MCP_V1_PROFILE_ID = "publisher.mcp.v1";
|
|
66205
|
+
var PUBLISHER_MCP_V1_ADAPTER_VERSION = "1.0.0";
|
|
66206
|
+
var PUBLISHER_MCP_V1_TOOLS = {
|
|
66207
|
+
release: "mrrlin_publish_release_v1",
|
|
66208
|
+
observe: "mrrlin_publish_observe_v1"
|
|
66209
|
+
};
|
|
66210
|
+
var isHttpsOrLoopbackTestUrl = (val) => {
|
|
66211
|
+
if (val.startsWith("https://"))
|
|
66212
|
+
return true;
|
|
66213
|
+
if (process.env.NODE_ENV === "test" || process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1") {
|
|
66214
|
+
return val.startsWith("http://127.0.0.1") || val.startsWith("http://localhost") || val.startsWith("http://[::1]");
|
|
66215
|
+
}
|
|
66216
|
+
return false;
|
|
66217
|
+
};
|
|
66218
|
+
var PublisherStatusSchema = external_exports.enum([
|
|
66219
|
+
"queued",
|
|
66220
|
+
"in_progress",
|
|
66221
|
+
"success",
|
|
66222
|
+
"failure"
|
|
66223
|
+
]);
|
|
66224
|
+
var PublisherReleaseRequestV1Schema = external_exports.object({
|
|
66225
|
+
targetId: external_exports.string().min(1).max(128),
|
|
66226
|
+
operationId: external_exports.string().min(1).max(128),
|
|
66227
|
+
sourceDigest: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
66228
|
+
archiveSha256: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
66229
|
+
archiveBase64: external_exports.string().min(1).max(5592408).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)
|
|
66230
|
+
}).strict();
|
|
66231
|
+
var PublisherObserveRequestV1Schema = external_exports.object({
|
|
66232
|
+
targetId: external_exports.string().min(1).max(128),
|
|
66233
|
+
operationId: external_exports.string().min(1).max(128),
|
|
66234
|
+
deploymentId: external_exports.string().min(1).max(128).optional()
|
|
66235
|
+
}).strict();
|
|
66236
|
+
var PublisherDeploymentResultV1Schema = external_exports.object({
|
|
66237
|
+
targetId: external_exports.string().min(1).max(128),
|
|
66238
|
+
operationId: external_exports.string().min(1).max(128),
|
|
66239
|
+
deploymentId: external_exports.string().min(1).max(128),
|
|
66240
|
+
sourceDigest: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
66241
|
+
status: PublisherStatusSchema,
|
|
66242
|
+
publicUrl: external_exports.string().url().refine(isHttpsOrLoopbackTestUrl, { message: "URL must use https: (http: permitted only on loopback in test mode)" }).optional()
|
|
66243
|
+
}).strict().refine((data) => {
|
|
66244
|
+
if (data.status === "success") {
|
|
66245
|
+
return typeof data.publicUrl === "string" && data.publicUrl.length > 0;
|
|
66246
|
+
}
|
|
66247
|
+
return data.publicUrl === void 0;
|
|
66248
|
+
}, {
|
|
66249
|
+
message: "Success status requires candidate HTTPS publicUrl; other states must omit it"
|
|
66250
|
+
});
|
|
66251
|
+
var PublisherObserveNotFoundResultV1Schema = external_exports.object({
|
|
66252
|
+
targetId: external_exports.string().min(1).max(128),
|
|
66253
|
+
operationId: external_exports.string().min(1).max(128),
|
|
66254
|
+
status: external_exports.literal("not_found")
|
|
66255
|
+
}).strict();
|
|
66256
|
+
var PublisherObserveResultV1Schema = external_exports.union([
|
|
66257
|
+
PublisherDeploymentResultV1Schema,
|
|
66258
|
+
PublisherObserveNotFoundResultV1Schema
|
|
66259
|
+
]);
|
|
66260
|
+
var PublisherTargetRefV1Schema = external_exports.object({
|
|
66261
|
+
targetId: external_exports.string().min(1).max(128),
|
|
66262
|
+
endpoint: external_exports.string().url().refine(isHttpsOrLoopbackTestUrl, { message: "Endpoint must use https: (http: permitted only on loopback in test mode)" }),
|
|
66263
|
+
publicOrigin: external_exports.string().url().refine(isHttpsOrLoopbackTestUrl, { message: "Public origin must use https: (http: permitted only on loopback in test mode)" }),
|
|
66264
|
+
rootDirectory: external_exports.string().optional(),
|
|
66265
|
+
buildSettingsDigest: external_exports.string().regex(/^[0-9a-f]{64}$/).optional()
|
|
66266
|
+
}).strict();
|
|
66267
|
+
var PublisherPreparedEnvelopeV1Schema = external_exports.object({
|
|
66268
|
+
schemaVersion: external_exports.literal("1.0.0"),
|
|
66269
|
+
profileId: external_exports.literal("publisher.mcp.v1"),
|
|
66270
|
+
adapterVersion: external_exports.literal("1.0.0"),
|
|
66271
|
+
project: external_exports.string().min(1),
|
|
66272
|
+
task: external_exports.string().min(1),
|
|
66273
|
+
run: external_exports.string().min(1),
|
|
66274
|
+
environment: external_exports.literal("production"),
|
|
66275
|
+
logicalOperationId: external_exports.enum(["publish_release", "publish_observe"]),
|
|
66276
|
+
target: PublisherTargetRefV1Schema,
|
|
66277
|
+
sourceDigest: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
66278
|
+
archiveSha256: external_exports.string().regex(/^[0-9a-f]{64}$/).optional(),
|
|
66279
|
+
canonicalToolArgumentsDigest: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
66280
|
+
payloadDigest: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
66281
|
+
toolSchemaDigest: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
66282
|
+
connectionBindingRevision: external_exports.number().int().min(1),
|
|
66283
|
+
authorizationGeneration: external_exports.number().int().min(1)
|
|
66284
|
+
}).strict();
|
|
66285
|
+
var PUBLISHER_RELEASE_V1_SCHEMA_DIGEST = "cbbdf5fb7ae6a1ddcc15ab7ea36936af049c2b4fb79153758f1771c138bac594";
|
|
66286
|
+
var PUBLISHER_OBSERVE_V1_SCHEMA_DIGEST = "2bc9642371190b562b0c2179b5fd25e172d47e975275a37fc6dd02e1e6661ad7";
|
|
66287
|
+
var EnrollManagedPublisherRequestSchema = external_exports.object({
|
|
66288
|
+
connectionId: external_exports.string().uuid(),
|
|
66289
|
+
bridgeInstallationId: external_exports.string().min(1),
|
|
66290
|
+
endpoint: external_exports.string().url().refine(isHttpsOrLoopbackTestUrl, { message: "Endpoint must use https: (http: permitted only on loopback in test mode)" }),
|
|
66291
|
+
targetId: external_exports.string().min(1).max(128),
|
|
66292
|
+
publicOrigin: external_exports.string().url().refine(isHttpsOrLoopbackTestUrl, { message: "Public origin must use https: (http: permitted only on loopback in test mode)" }),
|
|
66293
|
+
rootDirectory: external_exports.string().optional(),
|
|
66294
|
+
buildSettingsDigest: external_exports.string().regex(/^[0-9a-f]{64}$/).optional(),
|
|
66295
|
+
configRevision: external_exports.number().int().min(1).default(1),
|
|
66296
|
+
authorizationGeneration: external_exports.number().int().min(1).default(1),
|
|
66297
|
+
configDigest: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
66298
|
+
expectedBindingRevision: external_exports.number().int().min(1).optional(),
|
|
66299
|
+
replaceExisting: external_exports.boolean().default(false)
|
|
66300
|
+
}).strict().refine((data) => {
|
|
66301
|
+
try {
|
|
66302
|
+
const u = new URL(data.endpoint);
|
|
66303
|
+
return !u.username && !u.password && !u.search && !u.hash;
|
|
66304
|
+
} catch {
|
|
66305
|
+
return false;
|
|
66306
|
+
}
|
|
66307
|
+
}, { message: "Endpoint must not contain credentials, query, or fragment" }).refine((data) => {
|
|
66308
|
+
try {
|
|
66309
|
+
const u = new URL(data.publicOrigin);
|
|
66310
|
+
return !u.username && !u.password && !u.search && !u.hash;
|
|
66311
|
+
} catch {
|
|
66312
|
+
return false;
|
|
66313
|
+
}
|
|
66314
|
+
}, { message: "Public origin must not contain credentials, query, or fragment" });
|
|
66315
|
+
var EnrollManagedPublisherResponseSchema = external_exports.object({
|
|
66316
|
+
binding: IntegrationConnectionBindingSchema,
|
|
66317
|
+
target: PublisherTargetRefV1Schema
|
|
66318
|
+
}).strict();
|
|
66319
|
+
|
|
66202
66320
|
// ../../packages/schemas/dist/vercel-publishing.js
|
|
66203
66321
|
var VercelEnvironmentSchema = external_exports.enum(["preview", "production"]);
|
|
66204
66322
|
var VercelSourceModeSchema = external_exports.enum(["git_commit", "inline_manifest"]);
|
|
@@ -66266,7 +66384,7 @@ var PublishAttemptRecordV1Schema = external_exports.object({
|
|
|
66266
66384
|
logicalOperationId: external_exports.string().min(1),
|
|
66267
66385
|
attemptNumber: external_exports.number().int().min(1),
|
|
66268
66386
|
preparedEnvelopeDigest: external_exports.string().regex(/^[0-9a-f]{64}$/),
|
|
66269
|
-
preparedEnvelope: VercelPreparedEnvelopeV1Schema,
|
|
66387
|
+
preparedEnvelope: external_exports.union([VercelPreparedEnvelopeV1Schema, PublisherPreparedEnvelopeV1Schema]),
|
|
66270
66388
|
status: PublishAttemptStatusSchema,
|
|
66271
66389
|
leaseOwner: external_exports.string().nullable().optional(),
|
|
66272
66390
|
leaseExpiresAt: external_exports.string().datetime().nullable().optional(),
|
|
@@ -66296,7 +66414,7 @@ var PreparePublishAttemptRequestSchema = external_exports.object({
|
|
|
66296
66414
|
runId: external_exports.string().min(1),
|
|
66297
66415
|
environment: VercelEnvironmentSchema,
|
|
66298
66416
|
logicalOperationId: external_exports.string().min(1),
|
|
66299
|
-
preparedEnvelope: VercelPreparedEnvelopeV1Schema
|
|
66417
|
+
preparedEnvelope: external_exports.union([VercelPreparedEnvelopeV1Schema, PublisherPreparedEnvelopeV1Schema])
|
|
66300
66418
|
});
|
|
66301
66419
|
var ClaimPublishDispatchRequestSchema = external_exports.object({
|
|
66302
66420
|
runId: external_exports.string().min(1),
|
|
@@ -66404,8 +66522,46 @@ var VERCEL_V1_PROFILE = {
|
|
|
66404
66522
|
allowedPathPrefix: "/",
|
|
66405
66523
|
operations: VERCEL_V1_OPERATIONS
|
|
66406
66524
|
};
|
|
66525
|
+
var PUBLISHER_MCP_V1_OPERATIONS = {
|
|
66526
|
+
publish_release: {
|
|
66527
|
+
logicalOperationId: "publish_release",
|
|
66528
|
+
wireToolName: PUBLISHER_MCP_V1_TOOLS.release,
|
|
66529
|
+
operationClass: "mutation",
|
|
66530
|
+
canonicalSchemaDigest: PUBLISHER_RELEASE_V1_SCHEMA_DIGEST,
|
|
66531
|
+
description: "Publish static files to enrolled production target (PUB-013, PUB-015)"
|
|
66532
|
+
},
|
|
66533
|
+
publish_observe: {
|
|
66534
|
+
logicalOperationId: "publish_observe",
|
|
66535
|
+
wireToolName: PUBLISHER_MCP_V1_TOOLS.observe,
|
|
66536
|
+
operationClass: "read",
|
|
66537
|
+
canonicalSchemaDigest: PUBLISHER_OBSERVE_V1_SCHEMA_DIGEST,
|
|
66538
|
+
description: "Inspect deployment status and public URLs on enrolled custom publisher (PUB-013, PUB-015)"
|
|
66539
|
+
},
|
|
66540
|
+
mrrlin_publish_release_v1: {
|
|
66541
|
+
logicalOperationId: "publish_release",
|
|
66542
|
+
wireToolName: PUBLISHER_MCP_V1_TOOLS.release,
|
|
66543
|
+
operationClass: "mutation",
|
|
66544
|
+
canonicalSchemaDigest: PUBLISHER_RELEASE_V1_SCHEMA_DIGEST,
|
|
66545
|
+
description: "Direct wire release tool mapping"
|
|
66546
|
+
},
|
|
66547
|
+
mrrlin_publish_observe_v1: {
|
|
66548
|
+
logicalOperationId: "publish_observe",
|
|
66549
|
+
wireToolName: PUBLISHER_MCP_V1_TOOLS.observe,
|
|
66550
|
+
operationClass: "read",
|
|
66551
|
+
canonicalSchemaDigest: PUBLISHER_OBSERVE_V1_SCHEMA_DIGEST,
|
|
66552
|
+
description: "Direct wire observe tool mapping"
|
|
66553
|
+
}
|
|
66554
|
+
};
|
|
66555
|
+
var PUBLISHER_MCP_V1_PROFILE = {
|
|
66556
|
+
profileId: PUBLISHER_MCP_V1_PROFILE_ID,
|
|
66557
|
+
adapterVersion: PUBLISHER_MCP_V1_ADAPTER_VERSION,
|
|
66558
|
+
endpointAuthority: "custom",
|
|
66559
|
+
allowedPathPrefix: "/",
|
|
66560
|
+
operations: PUBLISHER_MCP_V1_OPERATIONS
|
|
66561
|
+
};
|
|
66407
66562
|
var INTEGRATION_TOOL_PROFILES = {
|
|
66408
|
-
"vercel.v1": VERCEL_V1_PROFILE
|
|
66563
|
+
"vercel.v1": VERCEL_V1_PROFILE,
|
|
66564
|
+
"publisher.mcp.v1": PUBLISHER_MCP_V1_PROFILE
|
|
66409
66565
|
};
|
|
66410
66566
|
function getIntegrationToolProfile(profileId) {
|
|
66411
66567
|
return INTEGRATION_TOOL_PROFILES[profileId] ?? null;
|
|
@@ -66736,6 +66892,8 @@ var mrrlinRunBlockingReasonCodeSchema = external_exports.enum([
|
|
|
66736
66892
|
"publish_address_ambiguous",
|
|
66737
66893
|
// workspace-context-isolation (OQ-091): project boundary profile cannot be resolved fail-closed
|
|
66738
66894
|
"workspace_boundary_unresolvable",
|
|
66895
|
+
// PUB-011: public proof collected but closure signing is unavailable
|
|
66896
|
+
"receipt_signing_unavailable",
|
|
66739
66897
|
"unknown"
|
|
66740
66898
|
]);
|
|
66741
66899
|
var KNOWN_RUN_BLOCKING_REASON_CODES = new Set(mrrlinRunBlockingReasonCodeSchema.options);
|
|
@@ -78779,7 +78937,7 @@ function resolveStateDir(env = process.env) {
|
|
|
78779
78937
|
|
|
78780
78938
|
// src/delivery/index.ts
|
|
78781
78939
|
var import_node_os10 = __toESM(require("node:os"), 1);
|
|
78782
|
-
var
|
|
78940
|
+
var import_node_crypto12 = __toESM(require("node:crypto"), 1);
|
|
78783
78941
|
var import_promises8 = require("node:timers/promises");
|
|
78784
78942
|
|
|
78785
78943
|
// ../../packages/schemas/dist/integration-crypto.js
|
|
@@ -78820,52 +78978,84 @@ function computeSetupRequestDigest(action, params) {
|
|
|
78820
78978
|
return (0, import_node_crypto6.createHash)("sha256").update(`${action}:${canonical}`).digest("hex");
|
|
78821
78979
|
}
|
|
78822
78980
|
function computePreparedEnvelopeDigest(envelope) {
|
|
78823
|
-
if (
|
|
78824
|
-
const
|
|
78981
|
+
if ("profileId" in envelope && envelope.profileId === "publisher.mcp.v1") {
|
|
78982
|
+
const canonical2 = {
|
|
78983
|
+
schemaVersion: envelope.schemaVersion,
|
|
78984
|
+
profileId: envelope.profileId,
|
|
78985
|
+
adapterVersion: envelope.adapterVersion,
|
|
78825
78986
|
project: envelope.project,
|
|
78826
78987
|
task: envelope.task,
|
|
78827
78988
|
run: envelope.run,
|
|
78828
|
-
logicalOperationId: envelope.logicalOperationId,
|
|
78829
|
-
operation: envelope.operation,
|
|
78830
|
-
connectionBindingRevision: envelope.connectionBindingRevision,
|
|
78831
|
-
authorizationGeneration: envelope.authorizationGeneration,
|
|
78832
|
-
routeRevision: envelope.routeRevision,
|
|
78833
|
-
toolName: envelope.toolName,
|
|
78834
|
-
toolSchemaDigest: envelope.toolSchemaDigest,
|
|
78835
|
-
adapterVersion: envelope.adapterVersion,
|
|
78836
|
-
teamId: envelope.teamId,
|
|
78837
|
-
projectId: envelope.projectId,
|
|
78838
78989
|
environment: envelope.environment,
|
|
78839
|
-
|
|
78990
|
+
logicalOperationId: envelope.logicalOperationId,
|
|
78991
|
+
target: envelope.target,
|
|
78840
78992
|
sourceDigest: envelope.sourceDigest,
|
|
78841
|
-
|
|
78993
|
+
archiveSha256: envelope.archiveSha256,
|
|
78994
|
+
canonicalToolArgumentsDigest: envelope.canonicalToolArgumentsDigest,
|
|
78995
|
+
payloadDigest: envelope.payloadDigest,
|
|
78996
|
+
toolSchemaDigest: envelope.toolSchemaDigest,
|
|
78997
|
+
connectionBindingRevision: envelope.connectionBindingRevision,
|
|
78998
|
+
authorizationGeneration: envelope.authorizationGeneration
|
|
78999
|
+
};
|
|
79000
|
+
return (0, import_node_crypto6.createHash)("sha256").update(JSON.stringify(canonical2)).digest("hex");
|
|
79001
|
+
}
|
|
79002
|
+
const vercelEnv = envelope;
|
|
79003
|
+
if (!vercelEnv.payloadDigest) {
|
|
79004
|
+
const legacyCanonical = {
|
|
79005
|
+
project: vercelEnv.project,
|
|
79006
|
+
task: vercelEnv.task,
|
|
79007
|
+
run: vercelEnv.run,
|
|
79008
|
+
logicalOperationId: vercelEnv.logicalOperationId,
|
|
79009
|
+
operation: vercelEnv.operation,
|
|
79010
|
+
connectionBindingRevision: vercelEnv.connectionBindingRevision,
|
|
79011
|
+
authorizationGeneration: vercelEnv.authorizationGeneration,
|
|
79012
|
+
routeRevision: vercelEnv.routeRevision,
|
|
79013
|
+
toolName: vercelEnv.toolName,
|
|
79014
|
+
toolSchemaDigest: vercelEnv.toolSchemaDigest,
|
|
79015
|
+
adapterVersion: vercelEnv.adapterVersion,
|
|
79016
|
+
teamId: vercelEnv.teamId,
|
|
79017
|
+
projectId: vercelEnv.projectId,
|
|
79018
|
+
environment: vercelEnv.environment,
|
|
79019
|
+
targetFingerprint: vercelEnv.targetFingerprint,
|
|
79020
|
+
sourceDigest: vercelEnv.sourceDigest,
|
|
79021
|
+
canonicalToolArgumentsDigest: vercelEnv.canonicalToolArgumentsDigest
|
|
78842
79022
|
};
|
|
78843
79023
|
return (0, import_node_crypto6.createHash)("sha256").update(JSON.stringify(legacyCanonical)).digest("hex");
|
|
78844
79024
|
}
|
|
78845
79025
|
const canonical = {
|
|
78846
|
-
project:
|
|
78847
|
-
task:
|
|
78848
|
-
run:
|
|
78849
|
-
logicalOperationId:
|
|
78850
|
-
operation:
|
|
78851
|
-
serverId:
|
|
78852
|
-
connectionBindingRevision:
|
|
78853
|
-
authorizationGeneration:
|
|
78854
|
-
routeRevision:
|
|
78855
|
-
toolName:
|
|
78856
|
-
toolSchemaDigest:
|
|
78857
|
-
adapterVersion:
|
|
78858
|
-
teamId:
|
|
78859
|
-
projectId:
|
|
78860
|
-
environment:
|
|
78861
|
-
targetFingerprint:
|
|
78862
|
-
sourceDigest:
|
|
78863
|
-
canonicalToolArgumentsDigest:
|
|
78864
|
-
payloadDigest:
|
|
79026
|
+
project: vercelEnv.project,
|
|
79027
|
+
task: vercelEnv.task,
|
|
79028
|
+
run: vercelEnv.run,
|
|
79029
|
+
logicalOperationId: vercelEnv.logicalOperationId,
|
|
79030
|
+
operation: vercelEnv.operation,
|
|
79031
|
+
serverId: vercelEnv.serverId ?? "vercel",
|
|
79032
|
+
connectionBindingRevision: vercelEnv.connectionBindingRevision,
|
|
79033
|
+
authorizationGeneration: vercelEnv.authorizationGeneration,
|
|
79034
|
+
routeRevision: vercelEnv.routeRevision,
|
|
79035
|
+
toolName: vercelEnv.toolName,
|
|
79036
|
+
toolSchemaDigest: vercelEnv.toolSchemaDigest,
|
|
79037
|
+
adapterVersion: vercelEnv.adapterVersion,
|
|
79038
|
+
teamId: vercelEnv.teamId,
|
|
79039
|
+
projectId: vercelEnv.projectId,
|
|
79040
|
+
environment: vercelEnv.environment,
|
|
79041
|
+
targetFingerprint: vercelEnv.targetFingerprint,
|
|
79042
|
+
sourceDigest: vercelEnv.sourceDigest,
|
|
79043
|
+
canonicalToolArgumentsDigest: vercelEnv.canonicalToolArgumentsDigest,
|
|
79044
|
+
payloadDigest: vercelEnv.payloadDigest
|
|
78865
79045
|
};
|
|
78866
79046
|
return (0, import_node_crypto6.createHash)("sha256").update(JSON.stringify(canonical)).digest("hex");
|
|
78867
79047
|
}
|
|
78868
79048
|
function computeTargetFingerprint(target) {
|
|
79049
|
+
if ("endpoint" in target && "publicOrigin" in target) {
|
|
79050
|
+
const canonical2 = {
|
|
79051
|
+
targetId: target.targetId,
|
|
79052
|
+
endpoint: target.endpoint,
|
|
79053
|
+
publicOrigin: target.publicOrigin,
|
|
79054
|
+
rootDirectory: target.rootDirectory ?? "",
|
|
79055
|
+
buildSettingsDigest: target.buildSettingsDigest ?? ""
|
|
79056
|
+
};
|
|
79057
|
+
return (0, import_node_crypto6.createHash)("sha256").update(JSON.stringify(canonical2)).digest("hex");
|
|
79058
|
+
}
|
|
78869
79059
|
const canonical = {
|
|
78870
79060
|
provider: target.provider,
|
|
78871
79061
|
profileVersion: target.profileVersion,
|
|
@@ -87758,12 +87948,15 @@ var import_node_net4 = __toESM(require("node:net"), 1);
|
|
|
87758
87948
|
|
|
87759
87949
|
// src/delivery/publish-source.ts
|
|
87760
87950
|
var import_node_crypto9 = require("node:crypto");
|
|
87951
|
+
var import_node_zlib = require("node:zlib");
|
|
87761
87952
|
var PUBLISH_SOURCE_LIMITS = {
|
|
87762
87953
|
MAX_FILES: 300,
|
|
87763
87954
|
MAX_FILE_BYTES: 3 * 1024 * 1024,
|
|
87764
87955
|
// 3 MiB per file
|
|
87765
87956
|
MAX_TOTAL_BYTES: 4 * 1024 * 1024,
|
|
87766
87957
|
// 4 MiB total expanded data
|
|
87958
|
+
MAX_ZIP_BYTES: 4 * 1024 * 1024,
|
|
87959
|
+
// 4 MiB ZIP bytes (PUB-013, PUB-015)
|
|
87767
87960
|
RESERVED_MARKER_PATH: ".well-known/mrrlin-publish.json",
|
|
87768
87961
|
PROHIBITED_CONTROL_FILES: /* @__PURE__ */ new Set([
|
|
87769
87962
|
"netlify.toml",
|
|
@@ -87866,6 +88059,7 @@ function createPublishMarker(params) {
|
|
|
87866
88059
|
};
|
|
87867
88060
|
}
|
|
87868
88061
|
function verifyPublishMarker(rawContent, expected) {
|
|
88062
|
+
if (!rawContent || typeof rawContent !== "string") return false;
|
|
87869
88063
|
try {
|
|
87870
88064
|
const parsed = JSON.parse(rawContent);
|
|
87871
88065
|
return parsed.operationId === expected.operationId && parsed.sourceDigest === expected.sourceDigest;
|
|
@@ -87970,6 +88164,112 @@ function verifyStagedSource(files, expected) {
|
|
|
87970
88164
|
}
|
|
87971
88165
|
return staged;
|
|
87972
88166
|
}
|
|
88167
|
+
function buildStaticZipArchive(stagedFiles, marker) {
|
|
88168
|
+
if (!stagedFiles || stagedFiles.length === 0) {
|
|
88169
|
+
throw new SourceMissingError("No source files provided for zip archive");
|
|
88170
|
+
}
|
|
88171
|
+
const hasIndexHtml = stagedFiles.some((f) => f.path === "index.html");
|
|
88172
|
+
if (!hasIndexHtml) {
|
|
88173
|
+
throw new SourceMissingError('Publisher MCP v1 static archive requires an "index.html" at root');
|
|
88174
|
+
}
|
|
88175
|
+
const allEntries = stagedFiles.map((sf) => ({
|
|
88176
|
+
path: sf.path,
|
|
88177
|
+
content: sf.content
|
|
88178
|
+
}));
|
|
88179
|
+
const markerContentBuf = Buffer.from(marker.content, "utf8");
|
|
88180
|
+
allEntries.push({
|
|
88181
|
+
path: marker.path.replace(/^\/+/, ""),
|
|
88182
|
+
content: markerContentBuf
|
|
88183
|
+
});
|
|
88184
|
+
if (allEntries.length > PUBLISH_SOURCE_LIMITS.MAX_FILES) {
|
|
88185
|
+
throw new SourceLimitExceededError(
|
|
88186
|
+
`File count ${allEntries.length} exceeds maximum limit of ${PUBLISH_SOURCE_LIMITS.MAX_FILES} files`
|
|
88187
|
+
);
|
|
88188
|
+
}
|
|
88189
|
+
allEntries.sort((a, b) => a.path.localeCompare(b.path));
|
|
88190
|
+
let totalExpandedBytes = 0;
|
|
88191
|
+
for (const e of allEntries) {
|
|
88192
|
+
totalExpandedBytes += e.content.length;
|
|
88193
|
+
}
|
|
88194
|
+
if (totalExpandedBytes > PUBLISH_SOURCE_LIMITS.MAX_TOTAL_BYTES) {
|
|
88195
|
+
throw new SourceLimitExceededError(
|
|
88196
|
+
`Total expanded archive size (${totalExpandedBytes} bytes) exceeds maximum limit of ${PUBLISH_SOURCE_LIMITS.MAX_TOTAL_BYTES} bytes (4 MiB)`
|
|
88197
|
+
);
|
|
88198
|
+
}
|
|
88199
|
+
const localHeaders = [];
|
|
88200
|
+
const centralHeaders = [];
|
|
88201
|
+
let offset = 0;
|
|
88202
|
+
for (const entry of allEntries) {
|
|
88203
|
+
const filenameBuf = Buffer.from(entry.path, "utf8");
|
|
88204
|
+
const contentBuf = entry.content;
|
|
88205
|
+
const crc = (0, import_node_zlib.crc32)(contentBuf);
|
|
88206
|
+
const compressed = (0, import_node_zlib.deflateRawSync)(contentBuf);
|
|
88207
|
+
const useDeflate = compressed.length < contentBuf.length;
|
|
88208
|
+
const method = useDeflate ? 8 : 0;
|
|
88209
|
+
const data = useDeflate ? compressed : contentBuf;
|
|
88210
|
+
const localHeader = Buffer.alloc(30 + filenameBuf.length);
|
|
88211
|
+
localHeader.writeUInt32LE(67324752, 0);
|
|
88212
|
+
localHeader.writeUInt16LE(20, 4);
|
|
88213
|
+
localHeader.writeUInt16LE(0, 6);
|
|
88214
|
+
localHeader.writeUInt16LE(method, 8);
|
|
88215
|
+
localHeader.writeUInt16LE(0, 10);
|
|
88216
|
+
localHeader.writeUInt16LE(33, 12);
|
|
88217
|
+
localHeader.writeUInt32LE(crc, 14);
|
|
88218
|
+
localHeader.writeUInt32LE(data.length, 18);
|
|
88219
|
+
localHeader.writeUInt32LE(contentBuf.length, 22);
|
|
88220
|
+
localHeader.writeUInt16LE(filenameBuf.length, 26);
|
|
88221
|
+
localHeader.writeUInt16LE(0, 28);
|
|
88222
|
+
filenameBuf.copy(localHeader, 30);
|
|
88223
|
+
const centralHeader = Buffer.alloc(46 + filenameBuf.length);
|
|
88224
|
+
centralHeader.writeUInt32LE(33639248, 0);
|
|
88225
|
+
centralHeader.writeUInt16LE(20, 4);
|
|
88226
|
+
centralHeader.writeUInt16LE(20, 6);
|
|
88227
|
+
centralHeader.writeUInt16LE(0, 8);
|
|
88228
|
+
centralHeader.writeUInt16LE(method, 10);
|
|
88229
|
+
centralHeader.writeUInt16LE(0, 12);
|
|
88230
|
+
centralHeader.writeUInt16LE(33, 14);
|
|
88231
|
+
centralHeader.writeUInt32LE(crc, 16);
|
|
88232
|
+
centralHeader.writeUInt32LE(data.length, 20);
|
|
88233
|
+
centralHeader.writeUInt32LE(contentBuf.length, 24);
|
|
88234
|
+
centralHeader.writeUInt16LE(filenameBuf.length, 28);
|
|
88235
|
+
centralHeader.writeUInt16LE(0, 30);
|
|
88236
|
+
centralHeader.writeUInt16LE(0, 32);
|
|
88237
|
+
centralHeader.writeUInt16LE(0, 34);
|
|
88238
|
+
centralHeader.writeUInt16LE(0, 36);
|
|
88239
|
+
centralHeader.writeUInt32LE(0, 38);
|
|
88240
|
+
centralHeader.writeUInt32LE(offset, 42);
|
|
88241
|
+
filenameBuf.copy(centralHeader, 46);
|
|
88242
|
+
localHeaders.push(localHeader, data);
|
|
88243
|
+
centralHeaders.push(centralHeader);
|
|
88244
|
+
offset += localHeader.length + data.length;
|
|
88245
|
+
}
|
|
88246
|
+
const centralDirOffset = offset;
|
|
88247
|
+
const centralDirSize = centralHeaders.reduce((sum, h) => sum + h.length, 0);
|
|
88248
|
+
const eocd = Buffer.alloc(22);
|
|
88249
|
+
eocd.writeUInt32LE(101010256, 0);
|
|
88250
|
+
eocd.writeUInt16LE(0, 4);
|
|
88251
|
+
eocd.writeUInt16LE(0, 6);
|
|
88252
|
+
eocd.writeUInt16LE(allEntries.length, 8);
|
|
88253
|
+
eocd.writeUInt16LE(allEntries.length, 10);
|
|
88254
|
+
eocd.writeUInt32LE(centralDirSize, 12);
|
|
88255
|
+
eocd.writeUInt32LE(centralDirOffset, 16);
|
|
88256
|
+
eocd.writeUInt16LE(0, 20);
|
|
88257
|
+
const zipBuffer = Buffer.concat([...localHeaders, ...centralHeaders, eocd]);
|
|
88258
|
+
if (zipBuffer.length > PUBLISH_SOURCE_LIMITS.MAX_ZIP_BYTES) {
|
|
88259
|
+
throw new SourceLimitExceededError(
|
|
88260
|
+
`Compressed ZIP archive size (${zipBuffer.length} bytes) exceeds maximum limit of ${PUBLISH_SOURCE_LIMITS.MAX_ZIP_BYTES} bytes (4 MiB)`
|
|
88261
|
+
);
|
|
88262
|
+
}
|
|
88263
|
+
const archiveSha256 = (0, import_node_crypto9.createHash)("sha256").update(zipBuffer).digest("hex");
|
|
88264
|
+
const archiveBase64 = zipBuffer.toString("base64");
|
|
88265
|
+
return {
|
|
88266
|
+
zipBuffer,
|
|
88267
|
+
archiveSha256,
|
|
88268
|
+
archiveBase64,
|
|
88269
|
+
entryCount: allEntries.length,
|
|
88270
|
+
totalExpandedBytes
|
|
88271
|
+
};
|
|
88272
|
+
}
|
|
87973
88273
|
|
|
87974
88274
|
// src/delivery/adapters/vercel.ts
|
|
87975
88275
|
var VercelContractError = class extends Error {
|
|
@@ -88441,6 +88741,7 @@ var VercelAdapter = class {
|
|
|
88441
88741
|
if (structuredMatches.length === 1 && contentMatches.length === 1) {
|
|
88442
88742
|
const s = structuredMatches[0];
|
|
88443
88743
|
const c = contentMatches[0];
|
|
88744
|
+
if (!s || !c) return null;
|
|
88444
88745
|
const sId = s.id ?? s.deploymentId;
|
|
88445
88746
|
const cId = c.id ?? c.deploymentId;
|
|
88446
88747
|
if (sId && cId && sId !== cId) {
|
|
@@ -88484,9 +88785,9 @@ var VercelAdapter = class {
|
|
|
88484
88785
|
}
|
|
88485
88786
|
match = s;
|
|
88486
88787
|
} else if (structuredMatches.length === 1) {
|
|
88487
|
-
match = structuredMatches[0];
|
|
88788
|
+
match = structuredMatches[0] ?? null;
|
|
88488
88789
|
} else if (contentMatches.length === 1) {
|
|
88489
|
-
match = contentMatches[0];
|
|
88790
|
+
match = contentMatches[0] ?? null;
|
|
88490
88791
|
}
|
|
88491
88792
|
if (!match) return null;
|
|
88492
88793
|
return this.parseResponse({
|
|
@@ -88701,6 +89002,742 @@ function normalizeVercelStatus(status) {
|
|
|
88701
89002
|
var vercelAdapter = new VercelAdapter();
|
|
88702
89003
|
registerPublisherAdapter(vercelAdapter);
|
|
88703
89004
|
|
|
89005
|
+
// src/delivery/adapters/publisher-mcp.ts
|
|
89006
|
+
var import_node_crypto11 = require("node:crypto");
|
|
89007
|
+
var import_node_net5 = __toESM(require("node:net"), 1);
|
|
89008
|
+
|
|
89009
|
+
// src/connections/client.ts
|
|
89010
|
+
var import_node_child_process13 = require("node:child_process");
|
|
89011
|
+
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
89012
|
+
var HttpMcpClient = class {
|
|
89013
|
+
endpoint;
|
|
89014
|
+
headers;
|
|
89015
|
+
allowLocal;
|
|
89016
|
+
authProvider;
|
|
89017
|
+
messageId = 1;
|
|
89018
|
+
constructor(endpoint, headers = {}, allowLocal = false, authProvider) {
|
|
89019
|
+
this.endpoint = endpoint;
|
|
89020
|
+
this.headers = headers;
|
|
89021
|
+
this.allowLocal = allowLocal;
|
|
89022
|
+
this.authProvider = authProvider;
|
|
89023
|
+
}
|
|
89024
|
+
async rpc(method, params) {
|
|
89025
|
+
const id = this.messageId++;
|
|
89026
|
+
const body = JSON.stringify({
|
|
89027
|
+
jsonrpc: "2.0",
|
|
89028
|
+
id,
|
|
89029
|
+
method,
|
|
89030
|
+
params: params ?? {}
|
|
89031
|
+
});
|
|
89032
|
+
if (this.authProvider) {
|
|
89033
|
+
try {
|
|
89034
|
+
const token = await this.authProvider.getValidAccessToken();
|
|
89035
|
+
if (token) {
|
|
89036
|
+
this.headers["authorization"] = `Bearer ${token}`;
|
|
89037
|
+
}
|
|
89038
|
+
} catch (err) {
|
|
89039
|
+
if (err instanceof OAuthReauthorizationRequiredError) {
|
|
89040
|
+
const authErr = new Error(err.message);
|
|
89041
|
+
authErr.code = "UNAUTHORIZED";
|
|
89042
|
+
throw authErr;
|
|
89043
|
+
}
|
|
89044
|
+
throw err;
|
|
89045
|
+
}
|
|
89046
|
+
}
|
|
89047
|
+
let res = await safeFetch(
|
|
89048
|
+
this.endpoint,
|
|
89049
|
+
{
|
|
89050
|
+
method: "POST",
|
|
89051
|
+
headers: {
|
|
89052
|
+
"content-type": "application/json",
|
|
89053
|
+
...this.headers
|
|
89054
|
+
},
|
|
89055
|
+
body
|
|
89056
|
+
},
|
|
89057
|
+
{ allowLocalEndpoints: this.allowLocal, timeoutMs: 1e4 }
|
|
89058
|
+
);
|
|
89059
|
+
if (res.status === 401 && this.authProvider) {
|
|
89060
|
+
try {
|
|
89061
|
+
const failedAuth = this.headers["authorization"];
|
|
89062
|
+
const failedToken = failedAuth?.startsWith("Bearer ") ? failedAuth.slice(7) : void 0;
|
|
89063
|
+
const currentTokens = await this.authProvider.tokens();
|
|
89064
|
+
let newAccessToken;
|
|
89065
|
+
if (failedToken && currentTokens?.access_token && currentTokens.access_token !== failedToken) {
|
|
89066
|
+
newAccessToken = currentTokens.access_token;
|
|
89067
|
+
} else {
|
|
89068
|
+
const refreshed = await this.authProvider.refreshAccessToken(
|
|
89069
|
+
this.authProvider.expectedIssuer ?? this.endpoint,
|
|
89070
|
+
void 0,
|
|
89071
|
+
failedToken
|
|
89072
|
+
);
|
|
89073
|
+
newAccessToken = refreshed.access_token;
|
|
89074
|
+
}
|
|
89075
|
+
this.headers["authorization"] = `Bearer ${newAccessToken}`;
|
|
89076
|
+
res = await safeFetch(
|
|
89077
|
+
this.endpoint,
|
|
89078
|
+
{
|
|
89079
|
+
method: "POST",
|
|
89080
|
+
headers: {
|
|
89081
|
+
"content-type": "application/json",
|
|
89082
|
+
...this.headers
|
|
89083
|
+
},
|
|
89084
|
+
body
|
|
89085
|
+
},
|
|
89086
|
+
{ allowLocalEndpoints: this.allowLocal, timeoutMs: 1e4 }
|
|
89087
|
+
);
|
|
89088
|
+
} catch (refreshErr) {
|
|
89089
|
+
const authErr = new Error(
|
|
89090
|
+
refreshErr instanceof Error ? refreshErr.message : "Reauthorization required"
|
|
89091
|
+
);
|
|
89092
|
+
authErr.code = "UNAUTHORIZED";
|
|
89093
|
+
throw authErr;
|
|
89094
|
+
}
|
|
89095
|
+
}
|
|
89096
|
+
if (res.status === 401 || res.status === 403) {
|
|
89097
|
+
const err = new Error(`Authentication failure: HTTP ${res.status}`);
|
|
89098
|
+
err.code = "UNAUTHORIZED";
|
|
89099
|
+
throw err;
|
|
89100
|
+
}
|
|
89101
|
+
if (!res.ok) {
|
|
89102
|
+
const errorText = await readBoundedResponseBody(res, 64 * 1024);
|
|
89103
|
+
throw new Error(`HTTP ${res.status}: ${errorText}`);
|
|
89104
|
+
}
|
|
89105
|
+
const rawBody = await readBoundedResponseBody(res, 2 * 1024 * 1024);
|
|
89106
|
+
const json2 = JSON.parse(rawBody);
|
|
89107
|
+
if (json2.error) {
|
|
89108
|
+
throw new Error(`MCP Error ${json2.error.code}: ${json2.error.message}`);
|
|
89109
|
+
}
|
|
89110
|
+
return json2.result;
|
|
89111
|
+
}
|
|
89112
|
+
async initialize() {
|
|
89113
|
+
const result = await this.rpc("initialize", {
|
|
89114
|
+
protocolVersion: "2024-11-05",
|
|
89115
|
+
clientInfo: { name: "mrrlin", version: "1.0.0" },
|
|
89116
|
+
capabilities: {}
|
|
89117
|
+
});
|
|
89118
|
+
try {
|
|
89119
|
+
await safeFetch(
|
|
89120
|
+
this.endpoint,
|
|
89121
|
+
{
|
|
89122
|
+
method: "POST",
|
|
89123
|
+
headers: {
|
|
89124
|
+
"content-type": "application/json",
|
|
89125
|
+
...this.headers
|
|
89126
|
+
},
|
|
89127
|
+
body: JSON.stringify({
|
|
89128
|
+
jsonrpc: "2.0",
|
|
89129
|
+
method: "notifications/initialized",
|
|
89130
|
+
params: {}
|
|
89131
|
+
})
|
|
89132
|
+
},
|
|
89133
|
+
{ allowLocalEndpoints: this.allowLocal }
|
|
89134
|
+
);
|
|
89135
|
+
} catch {
|
|
89136
|
+
}
|
|
89137
|
+
return result;
|
|
89138
|
+
}
|
|
89139
|
+
async listTools() {
|
|
89140
|
+
const result = await this.rpc("tools/list", {});
|
|
89141
|
+
return result?.tools ?? [];
|
|
89142
|
+
}
|
|
89143
|
+
async callTool(name, args) {
|
|
89144
|
+
const result = await this.rpc("tools/call", { name, arguments: args });
|
|
89145
|
+
return result;
|
|
89146
|
+
}
|
|
89147
|
+
async close() {
|
|
89148
|
+
}
|
|
89149
|
+
};
|
|
89150
|
+
var StdioMcpClient = class {
|
|
89151
|
+
command;
|
|
89152
|
+
args;
|
|
89153
|
+
env;
|
|
89154
|
+
process = null;
|
|
89155
|
+
messageId = 1;
|
|
89156
|
+
pending = /* @__PURE__ */ new Map();
|
|
89157
|
+
rl = null;
|
|
89158
|
+
constructor(command, args = [], env = {}) {
|
|
89159
|
+
this.command = command;
|
|
89160
|
+
this.args = args;
|
|
89161
|
+
this.env = env;
|
|
89162
|
+
}
|
|
89163
|
+
ensureProcess() {
|
|
89164
|
+
if (this.process && this.process.exitCode === null) {
|
|
89165
|
+
return this.process;
|
|
89166
|
+
}
|
|
89167
|
+
const mergedEnv = {
|
|
89168
|
+
...process.env,
|
|
89169
|
+
...this.env
|
|
89170
|
+
};
|
|
89171
|
+
const child = (0, import_node_child_process13.spawn)(this.command, this.args, {
|
|
89172
|
+
env: mergedEnv,
|
|
89173
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
89174
|
+
});
|
|
89175
|
+
child.on("error", (err) => {
|
|
89176
|
+
for (const handler of this.pending.values()) {
|
|
89177
|
+
handler.reject(err);
|
|
89178
|
+
}
|
|
89179
|
+
this.pending.clear();
|
|
89180
|
+
});
|
|
89181
|
+
child.on("exit", (code) => {
|
|
89182
|
+
const err = new Error(`Process exited with code ${code}`);
|
|
89183
|
+
for (const handler of this.pending.values()) {
|
|
89184
|
+
handler.reject(err);
|
|
89185
|
+
}
|
|
89186
|
+
this.pending.clear();
|
|
89187
|
+
});
|
|
89188
|
+
if (child.stdout) {
|
|
89189
|
+
this.rl = import_node_readline.default.createInterface({ input: child.stdout });
|
|
89190
|
+
this.rl.on("line", (line) => {
|
|
89191
|
+
const trimmed = line.trim();
|
|
89192
|
+
if (!trimmed || !trimmed.startsWith("{")) return;
|
|
89193
|
+
try {
|
|
89194
|
+
const json2 = JSON.parse(trimmed);
|
|
89195
|
+
const handler = json2.id !== void 0 ? this.pending.get(json2.id) : void 0;
|
|
89196
|
+
if (handler) {
|
|
89197
|
+
this.pending.delete(json2.id);
|
|
89198
|
+
if (json2.error) {
|
|
89199
|
+
handler.reject(new Error(`MCP Error ${json2.error.code}: ${json2.error.message}`));
|
|
89200
|
+
} else {
|
|
89201
|
+
handler.resolve(json2.result);
|
|
89202
|
+
}
|
|
89203
|
+
}
|
|
89204
|
+
} catch {
|
|
89205
|
+
}
|
|
89206
|
+
});
|
|
89207
|
+
}
|
|
89208
|
+
this.process = child;
|
|
89209
|
+
return child;
|
|
89210
|
+
}
|
|
89211
|
+
async rpc(method, params) {
|
|
89212
|
+
const child = this.ensureProcess();
|
|
89213
|
+
const id = this.messageId++;
|
|
89214
|
+
const payload = JSON.stringify({
|
|
89215
|
+
jsonrpc: "2.0",
|
|
89216
|
+
id,
|
|
89217
|
+
method,
|
|
89218
|
+
params: params ?? {}
|
|
89219
|
+
});
|
|
89220
|
+
return new Promise((resolve3, reject) => {
|
|
89221
|
+
this.pending.set(id, { resolve: resolve3, reject });
|
|
89222
|
+
child.stdin?.write(`${payload}
|
|
89223
|
+
`);
|
|
89224
|
+
});
|
|
89225
|
+
}
|
|
89226
|
+
async initialize() {
|
|
89227
|
+
const result = await this.rpc("initialize", {
|
|
89228
|
+
protocolVersion: "2024-11-05",
|
|
89229
|
+
clientInfo: { name: "mrrlin", version: "1.0.0" },
|
|
89230
|
+
capabilities: {}
|
|
89231
|
+
});
|
|
89232
|
+
const child = this.ensureProcess();
|
|
89233
|
+
child.stdin?.write(
|
|
89234
|
+
`${JSON.stringify({
|
|
89235
|
+
jsonrpc: "2.0",
|
|
89236
|
+
method: "notifications/initialized",
|
|
89237
|
+
params: {}
|
|
89238
|
+
})}
|
|
89239
|
+
`
|
|
89240
|
+
);
|
|
89241
|
+
return result;
|
|
89242
|
+
}
|
|
89243
|
+
async listTools() {
|
|
89244
|
+
const result = await this.rpc("tools/list", {});
|
|
89245
|
+
return result?.tools ?? [];
|
|
89246
|
+
}
|
|
89247
|
+
async callTool(name, args) {
|
|
89248
|
+
const result = await this.rpc("tools/call", { name, arguments: args });
|
|
89249
|
+
return result;
|
|
89250
|
+
}
|
|
89251
|
+
async close() {
|
|
89252
|
+
if (this.rl) {
|
|
89253
|
+
this.rl.close();
|
|
89254
|
+
this.rl = null;
|
|
89255
|
+
}
|
|
89256
|
+
if (this.process && this.process.exitCode === null) {
|
|
89257
|
+
this.process.kill("SIGTERM");
|
|
89258
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
89259
|
+
if (this.process.exitCode === null) {
|
|
89260
|
+
this.process.kill("SIGKILL");
|
|
89261
|
+
}
|
|
89262
|
+
this.process = null;
|
|
89263
|
+
}
|
|
89264
|
+
}
|
|
89265
|
+
};
|
|
89266
|
+
async function createMcpClientForTarget(target, options) {
|
|
89267
|
+
if (target.kind === "managed") {
|
|
89268
|
+
const conn = target.connection;
|
|
89269
|
+
let resolvedSecrets = {};
|
|
89270
|
+
if (conn.inputRefs && Object.keys(conn.inputRefs).length > 0 && target.store) {
|
|
89271
|
+
const resolved = await target.store.resolveConnection(conn.id);
|
|
89272
|
+
resolvedSecrets = resolved.secrets;
|
|
89273
|
+
}
|
|
89274
|
+
if (conn.transport === "streamable_http") {
|
|
89275
|
+
if (!conn.endpoint) throw new Error("Missing endpoint for http connection");
|
|
89276
|
+
let isServerHostLocal = false;
|
|
89277
|
+
try {
|
|
89278
|
+
const parsedEndpoint = new URL(conn.endpoint);
|
|
89279
|
+
isServerHostLocal = parsedEndpoint.hostname === "localhost" || parsedEndpoint.hostname === "127.0.0.1" || parsedEndpoint.hostname === "::1" || parsedEndpoint.hostname === "[::1]";
|
|
89280
|
+
} catch {
|
|
89281
|
+
}
|
|
89282
|
+
const effectiveAllowLocal = Boolean(options?.allowLocalEndpoints) && isServerHostLocal && (process.env.NODE_ENV !== "production" || process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1");
|
|
89283
|
+
let authProvider;
|
|
89284
|
+
if (target.store && target.store.isVaultUnlocked()) {
|
|
89285
|
+
try {
|
|
89286
|
+
const authGen = conn.authorizationGeneration ?? 1;
|
|
89287
|
+
const mapping = await target.store.getOAuthResourceMapping(conn.id, authGen).catch(() => void 0);
|
|
89288
|
+
const queryResource = mapping?.resource ?? conn.endpoint;
|
|
89289
|
+
const existingTokens = await target.store.getOAuthTokens({
|
|
89290
|
+
connectionId: conn.id,
|
|
89291
|
+
authorizationGeneration: authGen,
|
|
89292
|
+
resource: queryResource,
|
|
89293
|
+
issuer: mapping?.issuer
|
|
89294
|
+
});
|
|
89295
|
+
if (existingTokens) {
|
|
89296
|
+
const expectedResource = existingTokens.resource ?? mapping?.resource ?? conn.endpoint;
|
|
89297
|
+
const tokenOrigin = new URL(expectedResource).origin;
|
|
89298
|
+
const connOrigin = new URL(conn.endpoint).origin;
|
|
89299
|
+
if (tokenOrigin === connOrigin) {
|
|
89300
|
+
authProvider = new MrrlinOAuthClientProvider({
|
|
89301
|
+
store: target.store,
|
|
89302
|
+
connectionId: conn.id,
|
|
89303
|
+
authorizationGeneration: authGen,
|
|
89304
|
+
expectedIssuer: existingTokens.issuer ?? mapping?.issuer,
|
|
89305
|
+
expectedResource,
|
|
89306
|
+
allowLocalEndpoints: effectiveAllowLocal
|
|
89307
|
+
});
|
|
89308
|
+
}
|
|
89309
|
+
}
|
|
89310
|
+
} catch {
|
|
89311
|
+
}
|
|
89312
|
+
}
|
|
89313
|
+
return new HttpMcpClient(
|
|
89314
|
+
conn.endpoint,
|
|
89315
|
+
resolvedSecrets,
|
|
89316
|
+
effectiveAllowLocal,
|
|
89317
|
+
authProvider
|
|
89318
|
+
);
|
|
89319
|
+
}
|
|
89320
|
+
if (conn.transport === "stdio") {
|
|
89321
|
+
if (!conn.command) throw new Error("Missing command for stdio connection");
|
|
89322
|
+
return new StdioMcpClient(conn.command, conn.args ?? [], resolvedSecrets);
|
|
89323
|
+
}
|
|
89324
|
+
throw new Error(`Unsupported transport: ${conn.transport}`);
|
|
89325
|
+
}
|
|
89326
|
+
const srv = target.server;
|
|
89327
|
+
if (srv.transport === "http") {
|
|
89328
|
+
return new HttpMcpClient(srv.url, srv.headers ?? {}, options?.allowLocalEndpoints ?? false);
|
|
89329
|
+
}
|
|
89330
|
+
if (srv.transport === "stdio") {
|
|
89331
|
+
return new StdioMcpClient(srv.command, srv.args ?? [], srv.env ?? {});
|
|
89332
|
+
}
|
|
89333
|
+
throw new Error(`Unsupported legacy server transport: ${srv.transport}`);
|
|
89334
|
+
}
|
|
89335
|
+
async function probeConnection(client, timeoutMs = 1e4) {
|
|
89336
|
+
const startTime = Date.now();
|
|
89337
|
+
const timer = setTimeout(() => {
|
|
89338
|
+
client.close().catch(() => {
|
|
89339
|
+
});
|
|
89340
|
+
}, timeoutMs);
|
|
89341
|
+
try {
|
|
89342
|
+
const init = await client.initialize();
|
|
89343
|
+
const tools = await client.listTools();
|
|
89344
|
+
const latencyMs = Date.now() - startTime;
|
|
89345
|
+
return {
|
|
89346
|
+
ok: true,
|
|
89347
|
+
state: "ready",
|
|
89348
|
+
serverInfo: init.serverInfo,
|
|
89349
|
+
tools,
|
|
89350
|
+
latencyMs
|
|
89351
|
+
};
|
|
89352
|
+
} catch (err) {
|
|
89353
|
+
const code = err?.code ?? "PROBE_FAILED";
|
|
89354
|
+
const msg = err?.message ?? String(err);
|
|
89355
|
+
const state = code === "UNAUTHORIZED" ? "needs_auth" : "probe_failed";
|
|
89356
|
+
return {
|
|
89357
|
+
ok: false,
|
|
89358
|
+
state,
|
|
89359
|
+
error: {
|
|
89360
|
+
code,
|
|
89361
|
+
message: msg
|
|
89362
|
+
}
|
|
89363
|
+
};
|
|
89364
|
+
} finally {
|
|
89365
|
+
clearTimeout(timer);
|
|
89366
|
+
await client.close().catch(() => {
|
|
89367
|
+
});
|
|
89368
|
+
}
|
|
89369
|
+
}
|
|
89370
|
+
|
|
89371
|
+
// src/delivery/adapters/publisher-mcp.ts
|
|
89372
|
+
var PublisherContractError = class extends Error {
|
|
89373
|
+
code = "contract_mismatch";
|
|
89374
|
+
constructor(message) {
|
|
89375
|
+
super(message);
|
|
89376
|
+
this.name = "PublisherContractError";
|
|
89377
|
+
}
|
|
89378
|
+
};
|
|
89379
|
+
function extractPayloadObject(result) {
|
|
89380
|
+
if (!result) return null;
|
|
89381
|
+
if (Array.isArray(result)) {
|
|
89382
|
+
for (const item of result) {
|
|
89383
|
+
if (item && typeof item === "object") {
|
|
89384
|
+
const textObj = item;
|
|
89385
|
+
if (typeof textObj.text === "string") {
|
|
89386
|
+
try {
|
|
89387
|
+
return JSON.parse(textObj.text);
|
|
89388
|
+
} catch {
|
|
89389
|
+
}
|
|
89390
|
+
}
|
|
89391
|
+
}
|
|
89392
|
+
}
|
|
89393
|
+
return null;
|
|
89394
|
+
}
|
|
89395
|
+
if (typeof result === "object") {
|
|
89396
|
+
const rec = result;
|
|
89397
|
+
if (rec.structuredContent && typeof rec.structuredContent === "object") {
|
|
89398
|
+
return rec.structuredContent;
|
|
89399
|
+
}
|
|
89400
|
+
if (Array.isArray(rec.content)) {
|
|
89401
|
+
for (const item of rec.content) {
|
|
89402
|
+
if (item && typeof item === "object") {
|
|
89403
|
+
const textObj = item;
|
|
89404
|
+
if (typeof textObj.text === "string") {
|
|
89405
|
+
try {
|
|
89406
|
+
return JSON.parse(textObj.text);
|
|
89407
|
+
} catch {
|
|
89408
|
+
}
|
|
89409
|
+
}
|
|
89410
|
+
}
|
|
89411
|
+
}
|
|
89412
|
+
}
|
|
89413
|
+
return rec;
|
|
89414
|
+
}
|
|
89415
|
+
if (typeof result === "string") {
|
|
89416
|
+
try {
|
|
89417
|
+
return JSON.parse(result);
|
|
89418
|
+
} catch {
|
|
89419
|
+
return null;
|
|
89420
|
+
}
|
|
89421
|
+
}
|
|
89422
|
+
return null;
|
|
89423
|
+
}
|
|
89424
|
+
function validatePublisherUrl(rawUrl, label) {
|
|
89425
|
+
if (!rawUrl || typeof rawUrl !== "string") {
|
|
89426
|
+
throw new PublisherContractError(`${label} URL must be a non-empty string`);
|
|
89427
|
+
}
|
|
89428
|
+
let parsed;
|
|
89429
|
+
try {
|
|
89430
|
+
parsed = new URL(rawUrl);
|
|
89431
|
+
} catch {
|
|
89432
|
+
throw new PublisherContractError(`Malformed ${label} URL: "${rawUrl}"`);
|
|
89433
|
+
}
|
|
89434
|
+
const isLocalTest = (process.env.NODE_ENV === "test" || process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1") && (parsed.hostname === "127.0.0.1" || parsed.hostname === "localhost" || parsed.hostname === "::1");
|
|
89435
|
+
if (parsed.protocol !== "https:" && !isLocalTest) {
|
|
89436
|
+
throw new PublisherContractError(`Insecure ${label} URL: protocol must be https:, got "${parsed.protocol}"`);
|
|
89437
|
+
}
|
|
89438
|
+
if (parsed.username || parsed.password) {
|
|
89439
|
+
throw new PublisherContractError(`${label} URL must not contain credentials (user/password)`);
|
|
89440
|
+
}
|
|
89441
|
+
if (parsed.search) {
|
|
89442
|
+
throw new PublisherContractError(`${label} URL must not contain query parameters`);
|
|
89443
|
+
}
|
|
89444
|
+
if (parsed.hash) {
|
|
89445
|
+
throw new PublisherContractError(`${label} URL must not contain URL fragments`);
|
|
89446
|
+
}
|
|
89447
|
+
if (!isLocalTest) {
|
|
89448
|
+
if (parsed.hostname === "localhost" || isPrivateIp(parsed.hostname) || import_node_net5.default.isIP(parsed.hostname) !== 0 || !parsed.hostname.includes(".") || parsed.hostname.endsWith(".internal") || parsed.hostname.endsWith(".local")) {
|
|
89449
|
+
throw new PublisherContractError(`${label} URL points to invalid or private destination: "${parsed.hostname}"`);
|
|
89450
|
+
}
|
|
89451
|
+
}
|
|
89452
|
+
return parsed;
|
|
89453
|
+
}
|
|
89454
|
+
var PublisherMcpAdapter = class {
|
|
89455
|
+
profileId = PUBLISHER_MCP_V1_PROFILE_ID;
|
|
89456
|
+
adapterVersion = PUBLISHER_MCP_V1_ADAPTER_VERSION;
|
|
89457
|
+
supportedSourceModes = ["inline_manifest"];
|
|
89458
|
+
supportsPreview = false;
|
|
89459
|
+
validateTarget(target) {
|
|
89460
|
+
if (!target || typeof target !== "object") {
|
|
89461
|
+
return { valid: false, reason: "Target must be a non-null object" };
|
|
89462
|
+
}
|
|
89463
|
+
const parseResult = PublisherTargetRefV1Schema.safeParse(target);
|
|
89464
|
+
if (!parseResult.success) {
|
|
89465
|
+
return {
|
|
89466
|
+
valid: false,
|
|
89467
|
+
reason: `Target validation failed: ${parseResult.error.message}`
|
|
89468
|
+
};
|
|
89469
|
+
}
|
|
89470
|
+
const validated = parseResult.data;
|
|
89471
|
+
try {
|
|
89472
|
+
validatePublisherUrl(validated.endpoint, "Target endpoint");
|
|
89473
|
+
validatePublisherUrl(validated.publicOrigin, "Target public origin");
|
|
89474
|
+
} catch (err) {
|
|
89475
|
+
return {
|
|
89476
|
+
valid: false,
|
|
89477
|
+
reason: err instanceof Error ? err.message : String(err)
|
|
89478
|
+
};
|
|
89479
|
+
}
|
|
89480
|
+
return { valid: true, target: validated };
|
|
89481
|
+
}
|
|
89482
|
+
isSourceEligible(manifest) {
|
|
89483
|
+
if (!manifest) {
|
|
89484
|
+
return { eligible: false, reason: "Missing source manifest" };
|
|
89485
|
+
}
|
|
89486
|
+
if (manifest.mode === "git_commit") {
|
|
89487
|
+
return { eligible: false, reason: "Publisher MCP v1 only supports static inline manifests (git_commit not supported)" };
|
|
89488
|
+
}
|
|
89489
|
+
if (manifest.mode === "inline_manifest") {
|
|
89490
|
+
if (!manifest.files || manifest.files.length === 0) {
|
|
89491
|
+
return { eligible: false, reason: "Inline manifest contains no files" };
|
|
89492
|
+
}
|
|
89493
|
+
if (manifest.files.length > PUBLISH_SOURCE_LIMITS.MAX_FILES) {
|
|
89494
|
+
return {
|
|
89495
|
+
eligible: false,
|
|
89496
|
+
reason: `Inline source exceeds maximum file count limit of ${PUBLISH_SOURCE_LIMITS.MAX_FILES} files`
|
|
89497
|
+
};
|
|
89498
|
+
}
|
|
89499
|
+
if (manifest.totalBytes > PUBLISH_SOURCE_LIMITS.MAX_TOTAL_BYTES) {
|
|
89500
|
+
return {
|
|
89501
|
+
eligible: false,
|
|
89502
|
+
reason: `Inline source exceeds maximum size limit of ${PUBLISH_SOURCE_LIMITS.MAX_TOTAL_BYTES} bytes (4 MiB)`
|
|
89503
|
+
};
|
|
89504
|
+
}
|
|
89505
|
+
for (const f of manifest.files) {
|
|
89506
|
+
if (f.size > PUBLISH_SOURCE_LIMITS.MAX_FILE_BYTES) {
|
|
89507
|
+
return {
|
|
89508
|
+
eligible: false,
|
|
89509
|
+
reason: `File "${f.path}" size (${f.size} bytes) exceeds maximum file limit of ${PUBLISH_SOURCE_LIMITS.MAX_FILE_BYTES} bytes (3 MiB)`
|
|
89510
|
+
};
|
|
89511
|
+
}
|
|
89512
|
+
}
|
|
89513
|
+
const hasIndex = manifest.files.some((f) => f.path === "index.html");
|
|
89514
|
+
if (!hasIndex) {
|
|
89515
|
+
return { eligible: false, reason: 'Publisher MCP v1 requires an "index.html" at root of static archive' };
|
|
89516
|
+
}
|
|
89517
|
+
return { eligible: true };
|
|
89518
|
+
}
|
|
89519
|
+
const mode = manifest.mode;
|
|
89520
|
+
return { eligible: false, reason: `Unsupported source mode: "${mode}"` };
|
|
89521
|
+
}
|
|
89522
|
+
prepareRequest(params) {
|
|
89523
|
+
if (params.operation === "publish_preview" || params.environment === "preview") {
|
|
89524
|
+
throw new PublisherContractError("Preview is not supported for publisher.mcp.v1");
|
|
89525
|
+
}
|
|
89526
|
+
const targetValidation = this.validateTarget(params.target);
|
|
89527
|
+
if (!targetValidation.valid) {
|
|
89528
|
+
throw new PublisherContractError(targetValidation.reason);
|
|
89529
|
+
}
|
|
89530
|
+
const target = targetValidation.target;
|
|
89531
|
+
const sourceEligibility = this.isSourceEligible(params.sourceManifest);
|
|
89532
|
+
if (!sourceEligibility.eligible) {
|
|
89533
|
+
throw new PublisherContractError(sourceEligibility.reason);
|
|
89534
|
+
}
|
|
89535
|
+
if (!params.operationId || typeof params.operationId !== "string") {
|
|
89536
|
+
throw new PublisherContractError("PrepareRequestParams must specify non-empty operationId");
|
|
89537
|
+
}
|
|
89538
|
+
if (params.operation === "publish_release") {
|
|
89539
|
+
if (params.environment !== "production") {
|
|
89540
|
+
throw new PublisherContractError(
|
|
89541
|
+
`publish_release requires environment="production", got "${params.environment}"`
|
|
89542
|
+
);
|
|
89543
|
+
}
|
|
89544
|
+
if (!params.stagedFiles || params.stagedFiles.length === 0) {
|
|
89545
|
+
throw new PublisherContractError("Inline manifest source mode requires non-empty stagedFiles");
|
|
89546
|
+
}
|
|
89547
|
+
const verified = verifyStagedSource(params.stagedFiles, {
|
|
89548
|
+
sourceDigest: params.sourceManifest.sourceDigest,
|
|
89549
|
+
operationId: params.operationId,
|
|
89550
|
+
marker: params.marker
|
|
89551
|
+
});
|
|
89552
|
+
const zip = buildStaticZipArchive(verified.stagedFiles, verified.marker);
|
|
89553
|
+
const toolArguments = {
|
|
89554
|
+
targetId: target.targetId,
|
|
89555
|
+
operationId: params.operationId,
|
|
89556
|
+
sourceDigest: params.sourceManifest.sourceDigest,
|
|
89557
|
+
archiveSha256: zip.archiveSha256,
|
|
89558
|
+
archiveBase64: zip.archiveBase64
|
|
89559
|
+
};
|
|
89560
|
+
PublisherReleaseRequestV1Schema.parse(toolArguments);
|
|
89561
|
+
const canonicalToolArgumentsDigest = (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify(canonicalizeValue(toolArguments))).digest("hex");
|
|
89562
|
+
return {
|
|
89563
|
+
toolName: PUBLISHER_MCP_V1_TOOLS.release,
|
|
89564
|
+
arguments: toolArguments,
|
|
89565
|
+
canonicalToolArgumentsDigest
|
|
89566
|
+
};
|
|
89567
|
+
}
|
|
89568
|
+
if (params.operation === "publish_observe") {
|
|
89569
|
+
const toolArguments = {
|
|
89570
|
+
targetId: target.targetId,
|
|
89571
|
+
operationId: params.operationId,
|
|
89572
|
+
...params.deploymentId ? { deploymentId: params.deploymentId } : {}
|
|
89573
|
+
};
|
|
89574
|
+
PublisherObserveRequestV1Schema.parse(toolArguments);
|
|
89575
|
+
const canonicalToolArgumentsDigest = (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify(canonicalizeValue(toolArguments))).digest("hex");
|
|
89576
|
+
return {
|
|
89577
|
+
toolName: PUBLISHER_MCP_V1_TOOLS.observe,
|
|
89578
|
+
arguments: toolArguments,
|
|
89579
|
+
canonicalToolArgumentsDigest
|
|
89580
|
+
};
|
|
89581
|
+
}
|
|
89582
|
+
throw new PublisherContractError(`Unsupported publisher operation: "${params.operation}"`);
|
|
89583
|
+
}
|
|
89584
|
+
parseResponse(params) {
|
|
89585
|
+
const rawPayload = extractPayloadObject(params.rawResult);
|
|
89586
|
+
if (!rawPayload || typeof rawPayload !== "object") {
|
|
89587
|
+
throw new PublisherContractError("Empty or unparseable publisher response payload");
|
|
89588
|
+
}
|
|
89589
|
+
const targetValidation = this.validateTarget(params.target);
|
|
89590
|
+
if (!targetValidation.valid) {
|
|
89591
|
+
throw new PublisherContractError(targetValidation.reason);
|
|
89592
|
+
}
|
|
89593
|
+
const target = targetValidation.target;
|
|
89594
|
+
if (rawPayload.status === "not_found") {
|
|
89595
|
+
const notFoundParsed = PublisherObserveNotFoundResultV1Schema.safeParse(rawPayload);
|
|
89596
|
+
if (!notFoundParsed.success) {
|
|
89597
|
+
throw new PublisherContractError(`Invalid not_found observe result: ${notFoundParsed.error.message}`);
|
|
89598
|
+
}
|
|
89599
|
+
if (notFoundParsed.data.targetId !== target.targetId) {
|
|
89600
|
+
throw new PublisherContractError(
|
|
89601
|
+
`Target mismatch in not_found response: expected "${target.targetId}", got "${notFoundParsed.data.targetId}"`
|
|
89602
|
+
);
|
|
89603
|
+
}
|
|
89604
|
+
if (params.expectedOperationId && notFoundParsed.data.operationId !== params.expectedOperationId) {
|
|
89605
|
+
throw new PublisherContractError(
|
|
89606
|
+
`Operation ID mismatch in not_found response: expected "${params.expectedOperationId}", got "${notFoundParsed.data.operationId}"`
|
|
89607
|
+
);
|
|
89608
|
+
}
|
|
89609
|
+
return {
|
|
89610
|
+
deploymentId: "",
|
|
89611
|
+
status: "failure",
|
|
89612
|
+
url: null,
|
|
89613
|
+
targetId: notFoundParsed.data.targetId,
|
|
89614
|
+
raw: rawPayload,
|
|
89615
|
+
error: {
|
|
89616
|
+
code: "not_found",
|
|
89617
|
+
message: `Deployment record not found for operation "${params.expectedOperationId}" and target "${target.targetId}"`
|
|
89618
|
+
}
|
|
89619
|
+
};
|
|
89620
|
+
}
|
|
89621
|
+
const parseRes = PublisherDeploymentResultV1Schema.safeParse(rawPayload);
|
|
89622
|
+
if (!parseRes.success) {
|
|
89623
|
+
throw new PublisherContractError(`Response contract validation failed: ${parseRes.error.message}`);
|
|
89624
|
+
}
|
|
89625
|
+
const dep = parseRes.data;
|
|
89626
|
+
if (dep.targetId !== target.targetId) {
|
|
89627
|
+
throw new PublisherContractError(
|
|
89628
|
+
`Target ID mismatch in publisher response: expected "${target.targetId}", got "${dep.targetId}"`
|
|
89629
|
+
);
|
|
89630
|
+
}
|
|
89631
|
+
if (params.expectedOperationId && dep.operationId !== params.expectedOperationId) {
|
|
89632
|
+
throw new PublisherContractError(
|
|
89633
|
+
`Operation ID mismatch in publisher response: expected "${params.expectedOperationId}", got "${dep.operationId}"`
|
|
89634
|
+
);
|
|
89635
|
+
}
|
|
89636
|
+
if (params.expectedDeploymentId && dep.deploymentId !== params.expectedDeploymentId) {
|
|
89637
|
+
throw new PublisherContractError(
|
|
89638
|
+
`Deployment ID mismatch in publisher response: expected "${params.expectedDeploymentId}", got "${dep.deploymentId}"`
|
|
89639
|
+
);
|
|
89640
|
+
}
|
|
89641
|
+
if (params.expectedSourceDigest && dep.sourceDigest !== params.expectedSourceDigest) {
|
|
89642
|
+
throw new PublisherContractError(
|
|
89643
|
+
`Source digest mismatch in publisher response: expected "${params.expectedSourceDigest}", got "${dep.sourceDigest}"`
|
|
89644
|
+
);
|
|
89645
|
+
}
|
|
89646
|
+
let authoritativeUrl = null;
|
|
89647
|
+
if (dep.status === "success") {
|
|
89648
|
+
if (!dep.publicUrl) {
|
|
89649
|
+
throw new PublisherContractError('Successful deployment response missing required "publicUrl"');
|
|
89650
|
+
}
|
|
89651
|
+
const parsedPublicUrl = validatePublisherUrl(dep.publicUrl, "Public deployment");
|
|
89652
|
+
const expectedOrigin = new URL(target.publicOrigin).origin;
|
|
89653
|
+
if (parsedPublicUrl.origin !== expectedOrigin) {
|
|
89654
|
+
throw new PublisherContractError(
|
|
89655
|
+
`Public URL origin mismatch: expected origin "${expectedOrigin}", got "${parsedPublicUrl.origin}"`
|
|
89656
|
+
);
|
|
89657
|
+
}
|
|
89658
|
+
if (!dep.publicUrl.endsWith("/")) {
|
|
89659
|
+
throw new PublisherContractError(
|
|
89660
|
+
`Deployment public URL must end with trailing slash: "${dep.publicUrl}"`
|
|
89661
|
+
);
|
|
89662
|
+
}
|
|
89663
|
+
authoritativeUrl = dep.publicUrl;
|
|
89664
|
+
}
|
|
89665
|
+
return {
|
|
89666
|
+
deploymentId: dep.deploymentId,
|
|
89667
|
+
status: dep.status,
|
|
89668
|
+
url: authoritativeUrl,
|
|
89669
|
+
targetId: dep.targetId,
|
|
89670
|
+
candidateDomain: authoritativeUrl ? new URL(authoritativeUrl).hostname : void 0,
|
|
89671
|
+
raw: rawPayload
|
|
89672
|
+
};
|
|
89673
|
+
}
|
|
89674
|
+
prepareReconcileQuery(params) {
|
|
89675
|
+
const targetValidation = this.validateTarget(params.target);
|
|
89676
|
+
if (!targetValidation.valid) {
|
|
89677
|
+
throw new PublisherContractError(targetValidation.reason);
|
|
89678
|
+
}
|
|
89679
|
+
const target = targetValidation.target;
|
|
89680
|
+
const queryArgs = {
|
|
89681
|
+
targetId: target.targetId,
|
|
89682
|
+
operationId: params.operationId ?? "",
|
|
89683
|
+
...params.deploymentId ? { deploymentId: params.deploymentId } : {}
|
|
89684
|
+
};
|
|
89685
|
+
PublisherObserveRequestV1Schema.parse(queryArgs);
|
|
89686
|
+
return {
|
|
89687
|
+
toolName: PUBLISHER_MCP_V1_TOOLS.observe,
|
|
89688
|
+
arguments: queryArgs
|
|
89689
|
+
};
|
|
89690
|
+
}
|
|
89691
|
+
parseReconcileResponse(params) {
|
|
89692
|
+
return this.parseResponse({
|
|
89693
|
+
operation: "publish_observe",
|
|
89694
|
+
rawResult: params.rawResult,
|
|
89695
|
+
target: params.target,
|
|
89696
|
+
expectedOperationId: params.operationId,
|
|
89697
|
+
expectedDeploymentId: params.deploymentId,
|
|
89698
|
+
expectedSourceDigest: params.sourceDigest
|
|
89699
|
+
});
|
|
89700
|
+
}
|
|
89701
|
+
};
|
|
89702
|
+
function scopePublisherServer(server, toolName2) {
|
|
89703
|
+
if (server.transport !== "http" || !server.headers) {
|
|
89704
|
+
return server;
|
|
89705
|
+
}
|
|
89706
|
+
const headers = { ...server.headers };
|
|
89707
|
+
const relToken = headers.releaseToken ?? headers.release_token ?? headers.RELEASE_TOKEN;
|
|
89708
|
+
const obsToken = headers.observeToken ?? headers.observe_token ?? headers.OBSERVE_TOKEN;
|
|
89709
|
+
if (relToken && obsToken && relToken === obsToken) {
|
|
89710
|
+
throw new PublisherContractError(
|
|
89711
|
+
"Identical token values rejected: release and observe credentials must be distinct bearer tokens"
|
|
89712
|
+
);
|
|
89713
|
+
}
|
|
89714
|
+
delete headers.releaseToken;
|
|
89715
|
+
delete headers.release_token;
|
|
89716
|
+
delete headers.RELEASE_TOKEN;
|
|
89717
|
+
delete headers.observeToken;
|
|
89718
|
+
delete headers.observe_token;
|
|
89719
|
+
delete headers.OBSERVE_TOKEN;
|
|
89720
|
+
if (toolName2 === PUBLISHER_MCP_V1_TOOLS.release) {
|
|
89721
|
+
if (!relToken) {
|
|
89722
|
+
throw new PublisherContractError("Missing required release bearer token for release operation");
|
|
89723
|
+
}
|
|
89724
|
+
headers.Authorization = `Bearer ${relToken}`;
|
|
89725
|
+
delete headers.authorization;
|
|
89726
|
+
} else if (toolName2 === PUBLISHER_MCP_V1_TOOLS.observe) {
|
|
89727
|
+
if (!obsToken) {
|
|
89728
|
+
throw new PublisherContractError("Missing required observe bearer token for observe operation");
|
|
89729
|
+
}
|
|
89730
|
+
headers.Authorization = `Bearer ${obsToken}`;
|
|
89731
|
+
delete headers.authorization;
|
|
89732
|
+
}
|
|
89733
|
+
return {
|
|
89734
|
+
...server,
|
|
89735
|
+
headers
|
|
89736
|
+
};
|
|
89737
|
+
}
|
|
89738
|
+
var publisherMcpAdapter = new PublisherMcpAdapter();
|
|
89739
|
+
registerPublisherAdapter(publisherMcpAdapter);
|
|
89740
|
+
|
|
88704
89741
|
// src/delivery/publish.ts
|
|
88705
89742
|
function normalizePublisherOperation(op) {
|
|
88706
89743
|
if (op === "release" || op === "publish_release") return "publish_release";
|
|
@@ -88743,7 +89780,8 @@ async function deliverManagedPublish(server, payload) {
|
|
|
88743
89780
|
marker: payload.marker,
|
|
88744
89781
|
deploymentId: payload.deploymentId
|
|
88745
89782
|
});
|
|
88746
|
-
const
|
|
89783
|
+
const invokableServer = scopePublisherServer(server, prepared.toolName);
|
|
89784
|
+
const invocation = await invokeCapability(invokableServer, prepared.toolName, prepared.arguments);
|
|
88747
89785
|
const parsed = adapter.parseResponse({
|
|
88748
89786
|
operation: normalizedOp,
|
|
88749
89787
|
rawResult: invocation,
|
|
@@ -88769,7 +89807,8 @@ async function reconcileManagedPublish(server, params) {
|
|
|
88769
89807
|
operationId: params.operationId,
|
|
88770
89808
|
deploymentId: params.deploymentId
|
|
88771
89809
|
});
|
|
88772
|
-
const
|
|
89810
|
+
const invokableServer = scopePublisherServer(server, query.toolName);
|
|
89811
|
+
const invocation = await invokeCapability(invokableServer, query.toolName, query.arguments);
|
|
88773
89812
|
return adapter.parseReconcileResponse({
|
|
88774
89813
|
rawResult: invocation,
|
|
88775
89814
|
target: params.target,
|
|
@@ -89023,9 +90062,10 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
89023
90062
|
marker: payload.marker,
|
|
89024
90063
|
deploymentId: payload.deploymentId
|
|
89025
90064
|
});
|
|
89026
|
-
|
|
90065
|
+
const expectedToolName = "toolName" in approvedEnvelope ? approvedEnvelope.toolName : prepared.toolName;
|
|
90066
|
+
if (prepared.toolName !== expectedToolName) {
|
|
89027
90067
|
throw new PublishLeaseFencingError(
|
|
89028
|
-
`ENVELOPE_TOOL_MISMATCH: Computed tool name "${prepared.toolName}" does not match approved envelope tool name "${
|
|
90068
|
+
`ENVELOPE_TOOL_MISMATCH: Computed tool name "${prepared.toolName}" does not match approved envelope tool name "${expectedToolName}"`
|
|
89029
90069
|
);
|
|
89030
90070
|
}
|
|
89031
90071
|
if (payload.adapterVersion !== approvedEnvelope.adapterVersion) {
|
|
@@ -89036,9 +90076,10 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
89036
90076
|
const computedTargetFingerprint = computeTargetFingerprint(
|
|
89037
90077
|
payload.target
|
|
89038
90078
|
);
|
|
89039
|
-
|
|
90079
|
+
const expectedTargetFingerprint = "targetFingerprint" in approvedEnvelope ? approvedEnvelope.targetFingerprint : computeTargetFingerprint(approvedEnvelope.target);
|
|
90080
|
+
if (computedTargetFingerprint !== expectedTargetFingerprint) {
|
|
89040
90081
|
throw new PublishLeaseFencingError(
|
|
89041
|
-
`ENVELOPE_TARGET_MISMATCH: Target fingerprint "${computedTargetFingerprint}" does not match approved envelope target fingerprint "${
|
|
90082
|
+
`ENVELOPE_TARGET_MISMATCH: Target fingerprint "${computedTargetFingerprint}" does not match approved envelope target fingerprint "${expectedTargetFingerprint}"`
|
|
89042
90083
|
);
|
|
89043
90084
|
}
|
|
89044
90085
|
const targetRec = payload.target;
|
|
@@ -89084,7 +90125,8 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
89084
90125
|
let invocation;
|
|
89085
90126
|
let parsed;
|
|
89086
90127
|
try {
|
|
89087
|
-
|
|
90128
|
+
const invokableServer = scopePublisherServer(server, prepared.toolName);
|
|
90129
|
+
invocation = await invokeCapability(invokableServer, prepared.toolName, prepared.arguments);
|
|
89088
90130
|
parsed = adapter.parseResponse({
|
|
89089
90131
|
operation: normalizedOp,
|
|
89090
90132
|
rawResult: invocation,
|
|
@@ -89217,9 +90259,10 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
89217
90259
|
const computedTargetFingerprint = computeTargetFingerprint(
|
|
89218
90260
|
payload.target
|
|
89219
90261
|
);
|
|
89220
|
-
|
|
90262
|
+
const expectedTargetFingerprint = "targetFingerprint" in approvedEnvelope ? approvedEnvelope.targetFingerprint : computeTargetFingerprint(approvedEnvelope.target);
|
|
90263
|
+
if (computedTargetFingerprint !== expectedTargetFingerprint) {
|
|
89221
90264
|
throw new PublishLeaseFencingError(
|
|
89222
|
-
`Observation target fingerprint mismatch: payload has "${computedTargetFingerprint}", stored attempt has "${
|
|
90265
|
+
`Observation target fingerprint mismatch: payload has "${computedTargetFingerprint}", stored attempt has "${expectedTargetFingerprint}"`
|
|
89223
90266
|
);
|
|
89224
90267
|
}
|
|
89225
90268
|
if (payload.environment !== approvedEnvelope.environment) {
|
|
@@ -89252,7 +90295,8 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
89252
90295
|
operationId: this.context.operationId,
|
|
89253
90296
|
deploymentId
|
|
89254
90297
|
});
|
|
89255
|
-
const
|
|
90298
|
+
const invokableServer = scopePublisherServer(server, prepared.toolName);
|
|
90299
|
+
const invocation = await invokeCapability(invokableServer, prepared.toolName, prepared.arguments);
|
|
89256
90300
|
const parsed = adapter.parseResponse({
|
|
89257
90301
|
operation: "publish_observe",
|
|
89258
90302
|
rawResult: invocation,
|
|
@@ -89320,7 +90364,7 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
89320
90364
|
if (!this.client.getIntegrationBinding) {
|
|
89321
90365
|
throw new PublishLeaseFencingError("AUTHORITY_MISSING: getIntegrationBinding client method is required");
|
|
89322
90366
|
}
|
|
89323
|
-
const serverId = server.id ?? "
|
|
90367
|
+
const serverId = server.id ?? ("serverId" in approvedEnvelope ? approvedEnvelope.serverId : "publisher.mcp.v1");
|
|
89324
90368
|
const liveBinding = await this.client.getIntegrationBinding(
|
|
89325
90369
|
this.context.projectSlug,
|
|
89326
90370
|
serverId
|
|
@@ -89356,9 +90400,10 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
89356
90400
|
if (!routeRes.ok) {
|
|
89357
90401
|
throw new PublishLeaseFencingError("AUTHORITY_MISSING: Live capability route resolution failed");
|
|
89358
90402
|
}
|
|
89359
|
-
|
|
90403
|
+
const expectedRouteRev = "routeRevision" in approvedEnvelope ? approvedEnvelope.routeRevision : void 0;
|
|
90404
|
+
if (expectedRouteRev !== void 0 && routeRes.route.revision !== void 0 && routeRes.route.revision !== expectedRouteRev) {
|
|
89360
90405
|
throw new PublishLeaseFencingError(
|
|
89361
|
-
`AUTHORITY_DRIFT: Live route revision (${routeRes.route.revision}) does not match approved envelope route revision (${
|
|
90406
|
+
`AUTHORITY_DRIFT: Live route revision (${routeRes.route.revision}) does not match approved envelope route revision (${expectedRouteRev})`
|
|
89362
90407
|
);
|
|
89363
90408
|
}
|
|
89364
90409
|
const profile = getIntegrationToolProfile(profileId);
|
|
@@ -89377,8 +90422,9 @@ var PublishAttemptController = class _PublishAttemptController {
|
|
|
89377
90422
|
throw new PublishLeaseFencingError(`AUTHORITY_DRIFT: Invalid server URL "${server.url}"`);
|
|
89378
90423
|
}
|
|
89379
90424
|
}
|
|
89380
|
-
const
|
|
89381
|
-
const
|
|
90425
|
+
const rawOp = "operation" in approvedEnvelope ? approvedEnvelope.operation : approvedEnvelope.logicalOperationId;
|
|
90426
|
+
const envelopeOp = normalizePublisherOperation(rawOp);
|
|
90427
|
+
const profileDispatchOp = profile.operations[envelopeOp] ?? profile.operations[rawOp];
|
|
89382
90428
|
if (profileDispatchOp && approvedEnvelope.toolSchemaDigest !== profileDispatchOp.canonicalSchemaDigest) {
|
|
89383
90429
|
throw new PublishLeaseFencingError(
|
|
89384
90430
|
`AUTHORITY_DRIFT: Approved toolSchemaDigest "${approvedEnvelope.toolSchemaDigest}" does not match reviewed canonical schema digest "${profileDispatchOp.canonicalSchemaDigest}"`
|
|
@@ -89405,7 +90451,7 @@ async function deliverThroughCapability(client, rawInput) {
|
|
|
89405
90451
|
if (rawInput.artifactKind === "file_set" && isRecord3(payload) && payload.bytes instanceof Uint8Array) {
|
|
89406
90452
|
snapshotArtifactBytes = Uint8Array.from(payload.bytes);
|
|
89407
90453
|
payload = { ...payload, bytes: {
|
|
89408
|
-
sha256:
|
|
90454
|
+
sha256: import_node_crypto12.default.createHash("sha256").update(snapshotArtifactBytes).digest("hex"),
|
|
89409
90455
|
sizeBytes: snapshotArtifactBytes.byteLength
|
|
89410
90456
|
} };
|
|
89411
90457
|
}
|
|
@@ -89508,7 +90554,23 @@ async function deliverThroughCapability(client, rawInput) {
|
|
|
89508
90554
|
const profile = getIntegrationToolProfile(pub.profileId);
|
|
89509
90555
|
const profileOp = profile?.operations[normalizedOp] ?? profile?.operations[pub.operation];
|
|
89510
90556
|
const toolSchemaDigest = profileOp?.canonicalSchemaDigest ?? "4a974b7688fa5ba98db253fc3610931215b02660126588dbf3da97e88b64a66a";
|
|
89511
|
-
const envelope = {
|
|
90557
|
+
const envelope = pub.profileId === "publisher.mcp.v1" ? {
|
|
90558
|
+
schemaVersion: "1.0.0",
|
|
90559
|
+
profileId: "publisher.mcp.v1",
|
|
90560
|
+
adapterVersion: "1.0.0",
|
|
90561
|
+
project: input.taskProjectSlug,
|
|
90562
|
+
task: effectiveTaskId,
|
|
90563
|
+
run: effectiveRunId,
|
|
90564
|
+
environment: "production",
|
|
90565
|
+
logicalOperationId: normalizedOp,
|
|
90566
|
+
target: pub.target,
|
|
90567
|
+
sourceDigest: pub.sourceManifest?.sourceDigest ?? "",
|
|
90568
|
+
canonicalToolArgumentsDigest: prepared.canonicalToolArgumentsDigest,
|
|
90569
|
+
payloadDigest: "",
|
|
90570
|
+
toolSchemaDigest,
|
|
90571
|
+
connectionBindingRevision: typeof targetRef.bindingRevision === "number" ? targetRef.bindingRevision : liveBindingRev,
|
|
90572
|
+
authorizationGeneration: liveBindingAuthGen
|
|
90573
|
+
} : {
|
|
89512
90574
|
project: input.taskProjectSlug,
|
|
89513
90575
|
task: effectiveTaskId,
|
|
89514
90576
|
run: effectiveRunId,
|
|
@@ -90146,7 +91208,7 @@ async function callDestination(client, projectSlug, route, resolvedToolName, pay
|
|
|
90146
91208
|
throw new Error(`callDestination: payload.operation "${String(operation)}" is not valid for artifacts`);
|
|
90147
91209
|
}
|
|
90148
91210
|
const byteRecord = isRecord3(payload) ? payload.bytes : void 0;
|
|
90149
|
-
if (!isRecord3(byteRecord) || !snapshotArtifactBytes || snapshotArtifactBytes.byteLength > 5 * 1024 * 1024 || byteRecord.sizeBytes !== snapshotArtifactBytes.byteLength || byteRecord.sha256 !==
|
|
91211
|
+
if (!isRecord3(byteRecord) || !snapshotArtifactBytes || snapshotArtifactBytes.byteLength > 5 * 1024 * 1024 || byteRecord.sizeBytes !== snapshotArtifactBytes.byteLength || byteRecord.sha256 !== import_node_crypto12.default.createHash("sha256").update(snapshotArtifactBytes).digest("hex")) {
|
|
90150
91212
|
throw new Error("Invalid artifact bytes");
|
|
90151
91213
|
}
|
|
90152
91214
|
return deliverToArtifacts(
|
|
@@ -90206,7 +91268,7 @@ async function callDestination(client, projectSlug, route, resolvedToolName, pay
|
|
|
90206
91268
|
const effectiveTaskId = taskId ?? `task-${Date.now()}`;
|
|
90207
91269
|
const logicalOperationId = `op-${taskId ?? runId ?? Date.now()}-${publishPayload.operation}`;
|
|
90208
91270
|
const operationId = publishPayload.operationId ?? logicalOperationId;
|
|
90209
|
-
const leaseOwner = `${import_node_os10.default.hostname()}:${process.pid}:${
|
|
91271
|
+
const leaseOwner = `${import_node_os10.default.hostname()}:${process.pid}:${import_node_crypto12.default.randomUUID()}`;
|
|
90210
91272
|
const prepared = adapter.prepareRequest({
|
|
90211
91273
|
operation: normalizedOp,
|
|
90212
91274
|
target: publishPayload.target,
|
|
@@ -90221,7 +91283,23 @@ async function callDestination(client, projectSlug, route, resolvedToolName, pay
|
|
|
90221
91283
|
const profileOp = profile?.operations[normalizedOp] ?? profile?.operations[publishPayload.operation];
|
|
90222
91284
|
const toolSchemaDigest = profileOp?.canonicalSchemaDigest ?? "4a974b7688fa5ba98db253fc3610931215b02660126588dbf3da97e88b64a66a";
|
|
90223
91285
|
const targetRef = publishPayload.target;
|
|
90224
|
-
const preparedEnvelope = publishPayload.envelope ?? {
|
|
91286
|
+
const preparedEnvelope = publishPayload.envelope ?? (publishPayload.profileId === "publisher.mcp.v1" ? {
|
|
91287
|
+
schemaVersion: "1.0.0",
|
|
91288
|
+
profileId: "publisher.mcp.v1",
|
|
91289
|
+
adapterVersion: "1.0.0",
|
|
91290
|
+
project: projectSlug,
|
|
91291
|
+
task: effectiveTaskId,
|
|
91292
|
+
run: effectiveRunId,
|
|
91293
|
+
environment: "production",
|
|
91294
|
+
logicalOperationId: normalizedOp,
|
|
91295
|
+
target: publishPayload.target,
|
|
91296
|
+
sourceDigest: publishPayload.sourceManifest?.sourceDigest ?? "",
|
|
91297
|
+
canonicalToolArgumentsDigest: prepared.canonicalToolArgumentsDigest,
|
|
91298
|
+
payloadDigest: digestCapabilityPayload(publishPayload),
|
|
91299
|
+
toolSchemaDigest,
|
|
91300
|
+
connectionBindingRevision: typeof targetRef.bindingRevision === "number" ? targetRef.bindingRevision : 1,
|
|
91301
|
+
authorizationGeneration: server.authorizationGeneration ?? 1
|
|
91302
|
+
} : {
|
|
90225
91303
|
project: projectSlug,
|
|
90226
91304
|
task: effectiveTaskId,
|
|
90227
91305
|
run: effectiveRunId,
|
|
@@ -90241,7 +91319,7 @@ async function callDestination(client, projectSlug, route, resolvedToolName, pay
|
|
|
90241
91319
|
sourceDigest: publishPayload.sourceManifest?.sourceDigest ?? "",
|
|
90242
91320
|
canonicalToolArgumentsDigest: prepared.canonicalToolArgumentsDigest,
|
|
90243
91321
|
payloadDigest: digestCapabilityPayload(publishPayload)
|
|
90244
|
-
};
|
|
91322
|
+
});
|
|
90245
91323
|
const preparedEnvelopeDigest = computePreparedEnvelopeDigest(preparedEnvelope);
|
|
90246
91324
|
controller = new PublishAttemptController(client, {
|
|
90247
91325
|
projectSlug,
|
|
@@ -90543,9 +91621,9 @@ async function readPullRequestState(client, projectSlug, taskProjectSlug, pullRe
|
|
|
90543
91621
|
function digestCapabilityPayload(payload) {
|
|
90544
91622
|
if (payload && typeof payload === "object" && "envelope" in payload) {
|
|
90545
91623
|
const { envelope: _env, ...rest } = payload;
|
|
90546
|
-
return
|
|
91624
|
+
return import_node_crypto12.default.createHash("sha256").update(canonicalJson(rest)).digest("hex");
|
|
90547
91625
|
}
|
|
90548
|
-
return
|
|
91626
|
+
return import_node_crypto12.default.createHash("sha256").update(canonicalJson(payload)).digest("hex");
|
|
90549
91627
|
}
|
|
90550
91628
|
function isRecord3(value) {
|
|
90551
91629
|
return typeof value === "object" && value !== null;
|
|
@@ -90704,7 +91782,7 @@ function getAsyncToolDescriptor(toolName2) {
|
|
|
90704
91782
|
}
|
|
90705
91783
|
|
|
90706
91784
|
// src/async-tools/consensus.ts
|
|
90707
|
-
var
|
|
91785
|
+
var import_node_crypto13 = require("node:crypto");
|
|
90708
91786
|
|
|
90709
91787
|
// src/consensus/question-similarity.ts
|
|
90710
91788
|
var SUPPRESSION_SIMILARITY_THRESHOLD = 0.6;
|
|
@@ -91100,9 +92178,9 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
|
|
|
91100
92178
|
if (toFile.length > 0 && scopeId) {
|
|
91101
92179
|
const clarificationKey = taskId ? result.evaluatedClarificationKey : void 0;
|
|
91102
92180
|
const prefix = clarificationKey ? mixedCodeClarificationIdPrefix(scopeId, clarificationKey) : `II-${scopeId}-gate-`;
|
|
91103
|
-
const groupId = toFile.length > 1 ? `${prefix}group-${(0,
|
|
92181
|
+
const groupId = toFile.length > 1 ? `${prefix}group-${(0, import_node_crypto13.createHash)("sha256").update(toFile.map((c) => c.rawQuestion).sort().join("\n")).digest("hex").slice(0, 10)}` : void 0;
|
|
91104
92182
|
const questions = toFile.map((clarification) => ({
|
|
91105
|
-
id: `${prefix}${(0,
|
|
92183
|
+
id: `${prefix}${(0, import_node_crypto13.createHash)("sha256").update(clarification.rawQuestion).digest("hex").slice(0, 10)}`,
|
|
91106
92184
|
kind: "question",
|
|
91107
92185
|
...taskId ? { taskId } : { planId: scopeId },
|
|
91108
92186
|
body: humanizeClarificationBody(clarification),
|
|
@@ -91153,7 +92231,7 @@ async function handleConsensusBlocked(result, ctx, input, resolvedTaskId) {
|
|
|
91153
92231
|
taskId: page.taskId ?? null
|
|
91154
92232
|
});
|
|
91155
92233
|
const reviewHash = result.evaluatedReviewHash ?? domainScopedReviewHash2(page.contentHash, domain2);
|
|
91156
|
-
const baseBlockItemId = `II-${taskId}-gateblock-${(0,
|
|
92234
|
+
const baseBlockItemId = `II-${taskId}-gateblock-${(0, import_node_crypto13.createHash)("sha256").update(reviewHash).digest("hex").slice(0, 10)}`;
|
|
91157
92235
|
const reviewAgainAvailable = !taskInboxItems.some(
|
|
91158
92236
|
(item) => item.id === baseBlockItemId && item.status !== "pending" && item.answer === REVIEW_AGAIN_ANSWER
|
|
91159
92237
|
);
|
|
@@ -91425,7 +92503,7 @@ ${findings.map((f) => `\u2022 ${f}`).join("\n")}` : "";
|
|
|
91425
92503
|
}
|
|
91426
92504
|
const handoffTaskRef = taskRef ? ` (${taskRef})` : "";
|
|
91427
92505
|
const incompleteDelivery = outcome.kind === "failed" && (outcome.clarificationDeliveryIncomplete || outcome.gateBlockQuestionAvailable === false);
|
|
91428
|
-
const handoffSuffix = incompleteDelivery && context ? `job-${(0,
|
|
92506
|
+
const handoffSuffix = incompleteDelivery && context ? `job-${(0, import_node_crypto13.createHash)("sha256").update(JSON.stringify([context.projectSlug, context.jobId, context.createdAt])).digest("hex").slice(0, 32)}` : "finalReviewedHash" in outcome && outcome.finalReviewedHash ? outcome.finalReviewedHash.slice(0, 8) : "init";
|
|
91429
92507
|
return {
|
|
91430
92508
|
kind: "handoff",
|
|
91431
92509
|
id: `II-SPEC-STOPPED-${input.pageId}-${handoffSuffix}`,
|
|
@@ -91665,7 +92743,7 @@ var deliverableConsensusDescriptor = {
|
|
|
91665
92743
|
};
|
|
91666
92744
|
|
|
91667
92745
|
// src/async-tools/draft-spec.ts
|
|
91668
|
-
var
|
|
92746
|
+
var import_node_crypto14 = require("node:crypto");
|
|
91669
92747
|
var DRAFT_SPEC_TOOL_NAME = "draft_task_spec";
|
|
91670
92748
|
var SPECS_FOLDER = "Specs";
|
|
91671
92749
|
var DRAFT_SPEC_TLDR_MAX_CHARS = 300;
|
|
@@ -92240,7 +93318,7 @@ function onComplete3(outcome, input) {
|
|
|
92240
93318
|
};
|
|
92241
93319
|
}
|
|
92242
93320
|
const summary = outcome.error;
|
|
92243
|
-
const hash3 = (0,
|
|
93321
|
+
const hash3 = (0, import_node_crypto14.createHash)("sha256").update(summary).digest("hex").slice(0, 10);
|
|
92244
93322
|
return {
|
|
92245
93323
|
kind: "info",
|
|
92246
93324
|
id: `II-sched-draft-failed-${input.taskId}-${hash3}`,
|
|
@@ -92475,7 +93553,7 @@ function redact(input) {
|
|
|
92475
93553
|
}
|
|
92476
93554
|
|
|
92477
93555
|
// src/telemetry/projector.ts
|
|
92478
|
-
var
|
|
93556
|
+
var import_node_crypto15 = require("node:crypto");
|
|
92479
93557
|
function isRecord4(x) {
|
|
92480
93558
|
return typeof x === "object" && x !== null;
|
|
92481
93559
|
}
|
|
@@ -92516,7 +93594,7 @@ function buildProjection(payload, type, ms, telemetry) {
|
|
|
92516
93594
|
if (typeof exitCode === "number") proj.exitCode = exitCode;
|
|
92517
93595
|
const status = tool.status;
|
|
92518
93596
|
if (typeof status === "string" && status.trim() !== "") {
|
|
92519
|
-
proj.statusHash = (0,
|
|
93597
|
+
proj.statusHash = (0, import_node_crypto15.createHash)("sha256").update(status.trim().toLowerCase()).digest("hex").slice(0, 8);
|
|
92520
93598
|
}
|
|
92521
93599
|
return proj;
|
|
92522
93600
|
}
|
|
@@ -93173,7 +94251,7 @@ function createReportEvidenceDescriptor() {
|
|
|
93173
94251
|
var reportEvidenceDescriptor = createReportEvidenceDescriptor();
|
|
93174
94252
|
|
|
93175
94253
|
// src/async-tools/enqueue.ts
|
|
93176
|
-
var
|
|
94254
|
+
var import_node_crypto16 = __toESM(require("node:crypto"), 1);
|
|
93177
94255
|
async function enqueueAsyncTool(client, descriptor2, input) {
|
|
93178
94256
|
if (descriptor2.cachedResult) {
|
|
93179
94257
|
const cached2 = await descriptor2.cachedResult(client, input);
|
|
@@ -93186,7 +94264,7 @@ async function enqueueAsyncTool(client, descriptor2, input) {
|
|
|
93186
94264
|
if (active) {
|
|
93187
94265
|
return { status: "already_running", jobId: active.id, message: "Already running; will notify in inbox." };
|
|
93188
94266
|
}
|
|
93189
|
-
const jobId = `AJ-${
|
|
94267
|
+
const jobId = `AJ-${import_node_crypto16.default.randomUUID()}`;
|
|
93190
94268
|
try {
|
|
93191
94269
|
await client.createAsyncJob(input.projectSlug, {
|
|
93192
94270
|
id: jobId,
|
|
@@ -93267,7 +94345,7 @@ var CheckoutRegistry = class {
|
|
|
93267
94345
|
};
|
|
93268
94346
|
|
|
93269
94347
|
// src/checkout-handlers.ts
|
|
93270
|
-
var
|
|
94348
|
+
var import_node_child_process14 = require("node:child_process");
|
|
93271
94349
|
var import_node_fs13 = require("node:fs");
|
|
93272
94350
|
var import_node_path19 = __toESM(require("node:path"), 1);
|
|
93273
94351
|
|
|
@@ -93314,7 +94392,7 @@ function validateCheckoutPath(checkoutPath, repo) {
|
|
|
93314
94392
|
}
|
|
93315
94393
|
let remoteUrl;
|
|
93316
94394
|
try {
|
|
93317
|
-
remoteUrl = (0,
|
|
94395
|
+
remoteUrl = (0, import_node_child_process14.execFileSync)("git", ["-C", resolvedPath, "remote", "get-url", "origin"], {
|
|
93318
94396
|
encoding: "utf8",
|
|
93319
94397
|
stdio: ["ignore", "pipe", "ignore"],
|
|
93320
94398
|
timeout: 15e3,
|
|
@@ -93365,7 +94443,7 @@ function checkoutStateData(projectSlug, entry, machineLabel) {
|
|
|
93365
94443
|
}
|
|
93366
94444
|
|
|
93367
94445
|
// src/local-checkout.ts
|
|
93368
|
-
var
|
|
94446
|
+
var import_node_child_process15 = require("node:child_process");
|
|
93369
94447
|
var import_node_fs14 = require("node:fs");
|
|
93370
94448
|
var import_node_os11 = require("node:os");
|
|
93371
94449
|
var import_node_path20 = __toESM(require("node:path"), 1);
|
|
@@ -93481,7 +94559,7 @@ function checkLocalPathRules(input, options = {}) {
|
|
|
93481
94559
|
}
|
|
93482
94560
|
function gitTopLevel(realPath) {
|
|
93483
94561
|
try {
|
|
93484
|
-
return (0,
|
|
94562
|
+
return (0, import_node_child_process15.execFileSync)("git", ["-C", realPath, "rev-parse", "--show-toplevel"], {
|
|
93485
94563
|
encoding: "utf8",
|
|
93486
94564
|
stdio: ["ignore", "pipe", "ignore"],
|
|
93487
94565
|
timeout: 15e3,
|
|
@@ -93523,7 +94601,7 @@ function registerLocalOnlyCheckout(registry3, input, machineLabel, options = {},
|
|
|
93523
94601
|
}
|
|
93524
94602
|
var DEFAULT_GITIGNORE = ["node_modules/", "dist/", "build/", ".DS_Store", ".env", ".env.*", "*.log", ""].join("\n");
|
|
93525
94603
|
function runGit(realPath, args) {
|
|
93526
|
-
return (0,
|
|
94604
|
+
return (0, import_node_child_process15.execFileSync)("git", ["-C", realPath, ...args], {
|
|
93527
94605
|
encoding: "utf8",
|
|
93528
94606
|
stdio: ["ignore", "pipe", "pipe"],
|
|
93529
94607
|
timeout: 6e4,
|
|
@@ -93642,13 +94720,13 @@ function provisionNewProjectFolder(registry3, projectSlug, machineLabel, options
|
|
|
93642
94720
|
}
|
|
93643
94721
|
|
|
93644
94722
|
// src/local-apply.ts
|
|
93645
|
-
var
|
|
93646
|
-
var
|
|
94723
|
+
var import_node_child_process19 = require("node:child_process");
|
|
94724
|
+
var import_node_crypto21 = __toESM(require("node:crypto"), 1);
|
|
93647
94725
|
var import_node_fs19 = require("node:fs");
|
|
93648
94726
|
var import_node_path25 = __toESM(require("node:path"), 1);
|
|
93649
94727
|
|
|
93650
94728
|
// src/checkout-lock.ts
|
|
93651
|
-
var
|
|
94729
|
+
var import_node_crypto17 = require("node:crypto");
|
|
93652
94730
|
var import_node_fs15 = require("node:fs");
|
|
93653
94731
|
var import_node_path21 = require("node:path");
|
|
93654
94732
|
var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
|
|
@@ -93658,7 +94736,7 @@ var DELIVERY_LOCK_MAX_WAIT_MS = 36e5;
|
|
|
93658
94736
|
function deliveryLockKey(checkoutPath) {
|
|
93659
94737
|
const absolute = (0, import_node_path21.resolve)(checkoutPath);
|
|
93660
94738
|
const canonical = (0, import_node_fs15.existsSync)(absolute) ? (0, import_node_fs15.realpathSync)(absolute) : absolute;
|
|
93661
|
-
return `checkout-${(0,
|
|
94739
|
+
return `checkout-${(0, import_node_crypto17.createHash)("sha256").update(canonical).digest("hex").slice(0, 24)}`;
|
|
93662
94740
|
}
|
|
93663
94741
|
var LOCK_RETRY_INTERVAL_MS = 100;
|
|
93664
94742
|
var DEFAULT_LOCK_MAX_WAIT_MS = 6e4;
|
|
@@ -93702,8 +94780,8 @@ function isDeliveryLockHeld(locksDir, key) {
|
|
|
93702
94780
|
}
|
|
93703
94781
|
|
|
93704
94782
|
// src/delivery/local-git.ts
|
|
93705
|
-
var
|
|
93706
|
-
var
|
|
94783
|
+
var import_node_child_process16 = require("node:child_process");
|
|
94784
|
+
var import_node_crypto18 = require("node:crypto");
|
|
93707
94785
|
var import_node_fs16 = require("node:fs");
|
|
93708
94786
|
var import_node_os12 = __toESM(require("node:os"), 1);
|
|
93709
94787
|
var import_node_path22 = __toESM(require("node:path"), 1);
|
|
@@ -93812,7 +94890,7 @@ function diagnoseGpgError(rawError) {
|
|
|
93812
94890
|
return rawError;
|
|
93813
94891
|
}
|
|
93814
94892
|
function git(repo, args) {
|
|
93815
|
-
return (0,
|
|
94893
|
+
return (0, import_node_child_process16.execFileSync)("git", gitArgs(repo, args), {
|
|
93816
94894
|
encoding: "utf8",
|
|
93817
94895
|
timeout: 3e4,
|
|
93818
94896
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -93820,7 +94898,7 @@ function git(repo, args) {
|
|
|
93820
94898
|
}).trim();
|
|
93821
94899
|
}
|
|
93822
94900
|
function gitRaw(repo, args) {
|
|
93823
|
-
return (0,
|
|
94901
|
+
return (0, import_node_child_process16.execFileSync)("git", gitArgs(repo, args), {
|
|
93824
94902
|
encoding: "utf8",
|
|
93825
94903
|
timeout: 3e4,
|
|
93826
94904
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -93828,7 +94906,7 @@ function gitRaw(repo, args) {
|
|
|
93828
94906
|
});
|
|
93829
94907
|
}
|
|
93830
94908
|
function gitTx(repo, args, stdin) {
|
|
93831
|
-
const result = (0,
|
|
94909
|
+
const result = (0, import_node_child_process16.spawnSync)("git", gitArgs(repo, args), {
|
|
93832
94910
|
encoding: "utf8",
|
|
93833
94911
|
timeout: 3e4,
|
|
93834
94912
|
input: stdin,
|
|
@@ -93843,7 +94921,7 @@ ${result.error.message}` : ""}`.trim()
|
|
|
93843
94921
|
};
|
|
93844
94922
|
}
|
|
93845
94923
|
function gitTry(repo, args) {
|
|
93846
|
-
const result = (0,
|
|
94924
|
+
const result = (0, import_node_child_process16.spawnSync)("git", gitArgs(repo, args), {
|
|
93847
94925
|
encoding: "utf8",
|
|
93848
94926
|
timeout: 3e4,
|
|
93849
94927
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -93927,7 +95005,7 @@ function createStepRunner(options = {}) {
|
|
|
93927
95005
|
let timedOut = false;
|
|
93928
95006
|
let killTimer = null;
|
|
93929
95007
|
const [file2, args] = contained ? ownedExecutionCommand(command.file, command.args) : [command.file, command.args];
|
|
93930
|
-
const child = (0,
|
|
95008
|
+
const child = (0, import_node_child_process16.spawn)(file2, args, {
|
|
93931
95009
|
cwd,
|
|
93932
95010
|
env: { ...buildLocalStepEnv(), CI: "1", GIT_TERMINAL_PROMPT: "0" },
|
|
93933
95011
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -93985,7 +95063,7 @@ step timed out after ${timeoutMs} ms`);
|
|
|
93985
95063
|
}
|
|
93986
95064
|
var defaultStepRunner = createStepRunner();
|
|
93987
95065
|
function sha256(text) {
|
|
93988
|
-
return (0,
|
|
95066
|
+
return (0, import_node_crypto18.createHash)("sha256").update(text).digest("hex");
|
|
93989
95067
|
}
|
|
93990
95068
|
function commitUncommittedWork(input) {
|
|
93991
95069
|
if (git(input.worktreePath, ["status", "--porcelain", "--untracked-files=normal"]).length === 0) return false;
|
|
@@ -94457,7 +95535,7 @@ function worktreesWithBranch(repo, branch) {
|
|
|
94457
95535
|
// src/delivery/settlement-journal.ts
|
|
94458
95536
|
var import_node_fs17 = require("node:fs");
|
|
94459
95537
|
var import_node_path23 = __toESM(require("node:path"), 1);
|
|
94460
|
-
var
|
|
95538
|
+
var import_node_crypto19 = __toESM(require("node:crypto"), 1);
|
|
94461
95539
|
function settlementJournalDir(stateDir, projectSlug, runId) {
|
|
94462
95540
|
return import_node_path23.default.join(stateDir, "settlements", projectSlug, runId);
|
|
94463
95541
|
}
|
|
@@ -94468,7 +95546,7 @@ function writeSettlementJournalSync(stateDir, journal) {
|
|
|
94468
95546
|
const dir = settlementJournalDir(stateDir, journal.projectSlug, journal.runId);
|
|
94469
95547
|
(0, import_node_fs17.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
94470
95548
|
const finalPath = import_node_path23.default.join(dir, `${journal.idempotencyKey}.json`);
|
|
94471
|
-
const tempPath = import_node_path23.default.join(dir, `${journal.idempotencyKey}.tmp.${process.pid}.${Date.now()}.${
|
|
95549
|
+
const tempPath = import_node_path23.default.join(dir, `${journal.idempotencyKey}.tmp.${process.pid}.${Date.now()}.${import_node_crypto19.default.randomBytes(4).toString("hex")}`);
|
|
94472
95550
|
const content = JSON.stringify(journal, null, 2);
|
|
94473
95551
|
const fd = (0, import_node_fs17.openSync)(tempPath, "w", 384);
|
|
94474
95552
|
try {
|
|
@@ -94521,7 +95599,7 @@ function findSettlementJournalsSync(stateDir, projectSlug, runId) {
|
|
|
94521
95599
|
}
|
|
94522
95600
|
function createSettlementJournal(params) {
|
|
94523
95601
|
const stateDir = params.stateDir ?? resolveStateDir();
|
|
94524
|
-
const idempotencyKey = params.idempotencyKey ??
|
|
95602
|
+
const idempotencyKey = params.idempotencyKey ?? import_node_crypto19.default.randomUUID();
|
|
94525
95603
|
const journal = {
|
|
94526
95604
|
version: 1,
|
|
94527
95605
|
projectSlug: params.projectSlug,
|
|
@@ -94577,8 +95655,8 @@ function listPendingSettlementJournalsSync(stateDir, projectSlug) {
|
|
|
94577
95655
|
}
|
|
94578
95656
|
|
|
94579
95657
|
// src/worktree.ts
|
|
94580
|
-
var
|
|
94581
|
-
var
|
|
95658
|
+
var import_node_child_process17 = require("node:child_process");
|
|
95659
|
+
var import_node_crypto20 = require("node:crypto");
|
|
94582
95660
|
var import_node_fs18 = require("node:fs");
|
|
94583
95661
|
var import_node_path24 = require("node:path");
|
|
94584
95662
|
var import_node_util4 = require("node:util");
|
|
@@ -94601,10 +95679,10 @@ function canSweepColdWorkRoot(worktreeRoot) {
|
|
|
94601
95679
|
function worktreeBranch(runId) {
|
|
94602
95680
|
return `mrrlin/run-${runId}`;
|
|
94603
95681
|
}
|
|
94604
|
-
var defaultGitExec = (args, env) => (0,
|
|
94605
|
-
var execGitPush = (0, import_node_util4.promisify)(
|
|
95682
|
+
var defaultGitExec = (args, env) => (0, import_node_child_process17.execFileSync)("git", args, { encoding: "utf8", timeout: 3e4, env });
|
|
95683
|
+
var execGitPush = (0, import_node_util4.promisify)(import_node_child_process17.execFile);
|
|
94606
95684
|
function disabledGitHooksPath(locksDir, scope) {
|
|
94607
|
-
const scopeKey = (0,
|
|
95685
|
+
const scopeKey = (0, import_node_crypto20.createHash)("sha256").update(scope).digest("hex").slice(0, 32);
|
|
94608
95686
|
return (0, import_node_path24.resolve)(locksDir, "..", "disabled-git-hooks", scopeKey);
|
|
94609
95687
|
}
|
|
94610
95688
|
function prepareDisabledGitHooksDir(locksDir, scope) {
|
|
@@ -94639,7 +95717,7 @@ function withDisabledGitHooksEnv(env, hooksDir) {
|
|
|
94639
95717
|
};
|
|
94640
95718
|
}
|
|
94641
95719
|
function git2(checkout, args, hooksDir, baseEnv = process.env) {
|
|
94642
|
-
return (0,
|
|
95720
|
+
return (0, import_node_child_process17.execFileSync)("git", ["-C", checkout, "-c", `core.hooksPath=${hooksDir}`, ...args], {
|
|
94643
95721
|
encoding: "utf8",
|
|
94644
95722
|
timeout: 3e4,
|
|
94645
95723
|
env: { ...baseEnv, GIT_TERMINAL_PROMPT: "0" }
|
|
@@ -94753,6 +95831,7 @@ async function removeRunWorktree(opts) {
|
|
|
94753
95831
|
throw new Error("run_worktree_invalid: expected one exact Git worktree registration");
|
|
94754
95832
|
}
|
|
94755
95833
|
const match = matches[0];
|
|
95834
|
+
if (!match) throw new Error("run_worktree_invalid: expected one Git worktree registration match");
|
|
94756
95835
|
if (!match.locked) git2(opts.checkout, ["worktree", "remove", "--force", "--", match.registered], hooksDir);
|
|
94757
95836
|
}
|
|
94758
95837
|
removeDisabledGitHooksDir(opts.locksDir, (0, import_node_path24.basename)(opts.worktreePath));
|
|
@@ -94952,7 +96031,7 @@ async function sweepOrphanWorktrees(opts, runGit2 = git2) {
|
|
|
94952
96031
|
}
|
|
94953
96032
|
|
|
94954
96033
|
// src/unlanded-work.ts
|
|
94955
|
-
var
|
|
96034
|
+
var import_node_child_process18 = require("node:child_process");
|
|
94956
96035
|
var import_node_util5 = require("node:util");
|
|
94957
96036
|
var RUN_BRANCH_PREFIX = "mrrlin/run-";
|
|
94958
96037
|
var DEFAULT_LIMIT = 8;
|
|
@@ -94963,7 +96042,7 @@ var SAFE_BASE = /^(?:refs\/heads\/|origin\/)?[A-Za-z0-9._][A-Za-z0-9._/-]{0,199}
|
|
|
94963
96042
|
function isSafeBaseRef(base) {
|
|
94964
96043
|
return SAFE_BASE.test(base) && !base.includes("..");
|
|
94965
96044
|
}
|
|
94966
|
-
var execFileAsync2 = (0, import_node_util5.promisify)(
|
|
96045
|
+
var execFileAsync2 = (0, import_node_util5.promisify)(import_node_child_process18.execFile);
|
|
94967
96046
|
var defaultGitRead = async (cwd, args) => {
|
|
94968
96047
|
const { stdout } = await execFileAsync2("git", ["-C", cwd, ...args], {
|
|
94969
96048
|
timeout: 3e4,
|
|
@@ -95083,8 +96162,8 @@ function verifyReceiptSignature(payload, signatureBase64, publicKeyBase64) {
|
|
|
95083
96162
|
if (keyBuffer.length === 32) {
|
|
95084
96163
|
keyBuffer = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), keyBuffer]);
|
|
95085
96164
|
}
|
|
95086
|
-
const pubKey =
|
|
95087
|
-
return
|
|
96165
|
+
const pubKey = import_node_crypto21.default.createPublicKey({ key: keyBuffer, format: "der", type: "spki" });
|
|
96166
|
+
return import_node_crypto21.default.verify(null, bytes3, pubKey, sigBuffer);
|
|
95088
96167
|
} catch {
|
|
95089
96168
|
return false;
|
|
95090
96169
|
}
|
|
@@ -95102,7 +96181,7 @@ function gitEnv() {
|
|
|
95102
96181
|
}
|
|
95103
96182
|
function gitRead(cwd, args) {
|
|
95104
96183
|
try {
|
|
95105
|
-
return (0,
|
|
96184
|
+
return (0, import_node_child_process19.execFileSync)("git", ["-C", cwd, ...args], {
|
|
95106
96185
|
encoding: "utf8",
|
|
95107
96186
|
stdio: ["ignore", "pipe", "pipe"],
|
|
95108
96187
|
timeout: 3e4,
|
|
@@ -95162,7 +96241,7 @@ async function fileLocalLandingNote(client, projectSlug, outcome, ctx) {
|
|
|
95162
96241
|
);
|
|
95163
96242
|
await client.createInboxItem(projectSlug, { id: note.id, kind: "info", taskId: ctx.taskId, body: note.body }).catch(logFailure("inbox_note"));
|
|
95164
96243
|
await client.appendExecutionArtifact(projectSlug, ctx.runId, {
|
|
95165
|
-
id: `EA-${
|
|
96244
|
+
id: `EA-${import_node_crypto21.default.randomUUID()}`,
|
|
95166
96245
|
kind: "checkpoint",
|
|
95167
96246
|
payload: {
|
|
95168
96247
|
event: "local_apply",
|
|
@@ -95377,12 +96456,12 @@ async function applyLocalRunForTool(deps, input) {
|
|
|
95377
96456
|
return { outcome: "conflict", previousSha: null, headSha: delivered.headSha, detail: integration.files.join(", ") };
|
|
95378
96457
|
}
|
|
95379
96458
|
const build = await runDetectedBuild({ worktreePath, runStep: deps.runStep });
|
|
95380
|
-
const headSha = (0,
|
|
96459
|
+
const headSha = (0, import_node_child_process19.execFileSync)("git", ["-C", worktreePath, "rev-parse", "HEAD"], { encoding: "utf8", env: gitEnv() }).trim();
|
|
95381
96460
|
if (build.failed) {
|
|
95382
96461
|
record2({ integration, applied: false, reason: "build_failed", headSha, steps: build.steps, logs: build.logs });
|
|
95383
96462
|
return { outcome: "build_failed", previousSha: null, headSha, detail: build.failed.command };
|
|
95384
96463
|
}
|
|
95385
|
-
const changedByBuild = (0,
|
|
96464
|
+
const changedByBuild = (0, import_node_child_process19.execFileSync)("git", ["-C", worktreePath, "status", "--porcelain", "--untracked-files=no"], {
|
|
95386
96465
|
encoding: "utf8",
|
|
95387
96466
|
stdio: ["ignore", "pipe", "pipe"],
|
|
95388
96467
|
timeout: 3e4,
|
|
@@ -95404,7 +96483,7 @@ async function applyLocalRunForTool(deps, input) {
|
|
|
95404
96483
|
if (lockfilesChanged.length > 0) {
|
|
95405
96484
|
for (const lf of lockfilesChanged) {
|
|
95406
96485
|
try {
|
|
95407
|
-
(0,
|
|
96486
|
+
(0, import_node_child_process19.execFileSync)("git", ["-C", worktreePath, "add", lf], {
|
|
95408
96487
|
encoding: "utf8",
|
|
95409
96488
|
stdio: ["ignore", "pipe", "pipe"],
|
|
95410
96489
|
env: gitEnv()
|
|
@@ -95559,7 +96638,7 @@ async function applyLocalRunForTool(deps, input) {
|
|
|
95559
96638
|
if (git3.run_ref !== expectedRunRef) {
|
|
95560
96639
|
return { outcome: "build_failed", previousSha: null, headSha: delivered.headSha, detail: `Run ref ${expectedRunRef} does not match receipt run_ref ${git3.run_ref}` };
|
|
95561
96640
|
}
|
|
95562
|
-
const currentCheckoutDigest =
|
|
96641
|
+
const currentCheckoutDigest = import_node_crypto21.default.createHash("sha256").update(checkout).digest("hex");
|
|
95563
96642
|
if (git3.checkout_digest && git3.checkout_digest !== currentCheckoutDigest) {
|
|
95564
96643
|
return { outcome: "build_failed", previousSha: null, headSha: delivered.headSha, detail: `Checkout digest ${currentCheckoutDigest} does not match receipt checkout_digest ${git3.checkout_digest}` };
|
|
95565
96644
|
}
|
|
@@ -95628,12 +96707,12 @@ async function applyLocalRunForTool(deps, input) {
|
|
|
95628
96707
|
};
|
|
95629
96708
|
}
|
|
95630
96709
|
if (!runBranchStillSigned()) return branchChanged();
|
|
95631
|
-
(0,
|
|
96710
|
+
(0, import_node_child_process19.execFileSync)("git", ["-C", worktreePath, "clean", "-q", "-f", "-d"], {
|
|
95632
96711
|
stdio: ["ignore", "pipe", "pipe"],
|
|
95633
96712
|
timeout: 3e4,
|
|
95634
96713
|
env: gitEnv()
|
|
95635
96714
|
});
|
|
95636
|
-
(0,
|
|
96715
|
+
(0, import_node_child_process19.execFileSync)("git", ["-C", worktreePath, "-c", `core.hooksPath=${hooksDir}`, "checkout", "-q", "-f", "--detach", delivered.headSha], {
|
|
95637
96716
|
stdio: ["ignore", "pipe", "pipe"],
|
|
95638
96717
|
timeout: 3e4,
|
|
95639
96718
|
env: gitEnv()
|
|
@@ -95643,12 +96722,12 @@ async function applyLocalRunForTool(deps, input) {
|
|
|
95643
96722
|
} finally {
|
|
95644
96723
|
abortIntegration({ worktreePath });
|
|
95645
96724
|
if (runBranchStillSigned()) {
|
|
95646
|
-
(0,
|
|
96725
|
+
(0, import_node_child_process19.execFileSync)("git", ["-C", worktreePath, "-c", `core.hooksPath=${hooksDir}`, "checkout", "-q", "-f", runBranch], {
|
|
95647
96726
|
stdio: ["ignore", "pipe", "pipe"],
|
|
95648
96727
|
timeout: 3e4,
|
|
95649
96728
|
env: gitEnv()
|
|
95650
96729
|
});
|
|
95651
|
-
(0,
|
|
96730
|
+
(0, import_node_child_process19.execFileSync)("git", ["-C", worktreePath, "clean", "-q", "-f", "-d"], {
|
|
95652
96731
|
stdio: ["ignore", "pipe", "pipe"],
|
|
95653
96732
|
timeout: 3e4,
|
|
95654
96733
|
env: gitEnv()
|
|
@@ -95746,7 +96825,7 @@ function readAgentSecret() {
|
|
|
95746
96825
|
}
|
|
95747
96826
|
|
|
95748
96827
|
// src/worker-token.ts
|
|
95749
|
-
var
|
|
96828
|
+
var import_node_crypto22 = require("node:crypto");
|
|
95750
96829
|
var import_node_fs21 = require("node:fs");
|
|
95751
96830
|
var import_node_os14 = __toESM(require("node:os"), 1);
|
|
95752
96831
|
var import_node_path27 = __toESM(require("node:path"), 1);
|
|
@@ -95777,7 +96856,7 @@ function readOrCreateWorkerToken() {
|
|
|
95777
96856
|
if (existing) return existing;
|
|
95778
96857
|
const dir = workerDir();
|
|
95779
96858
|
(0, import_node_fs21.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
95780
|
-
const token = (0,
|
|
96859
|
+
const token = (0, import_node_crypto22.randomBytes)(32).toString("hex");
|
|
95781
96860
|
(0, import_node_fs21.writeFileSync)(workerTokenPath(), `${token}
|
|
95782
96861
|
`, { encoding: "utf8", mode: 384 });
|
|
95783
96862
|
return token;
|
|
@@ -97756,7 +98835,7 @@ function createMrrlinTools(options) {
|
|
|
97756
98835
|
"Unable to record produced URL.",
|
|
97757
98836
|
async (c, { projectSlug, runId, url: url2, label }) => {
|
|
97758
98837
|
await checkTenantBoundary(projectSlug, "produced url");
|
|
97759
|
-
const id = `EA-pu-${(0,
|
|
98838
|
+
const id = `EA-pu-${(0, import_node_crypto23.randomBytes)(4).toString("hex")}`;
|
|
97760
98839
|
const payload = label ? { url: url2, label } : { url: url2 };
|
|
97761
98840
|
return await c.appendExecutionArtifact(projectSlug, runId, {
|
|
97762
98841
|
id,
|
|
@@ -98356,7 +99435,7 @@ var import_semver2 = __toESM(require_semver2(), 1);
|
|
|
98356
99435
|
var toml3 = __toESM(require_toml(), 1);
|
|
98357
99436
|
|
|
98358
99437
|
// src/agent-version.ts
|
|
98359
|
-
var
|
|
99438
|
+
var import_node_child_process20 = require("node:child_process");
|
|
98360
99439
|
var import_semver = __toESM(require_semver2(), 1);
|
|
98361
99440
|
var SEMVER_RE = /\b\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?\b/;
|
|
98362
99441
|
var CODEX_PACKAGE = process.env.MRRLIN_CODEX_PACKAGE?.trim() || "@openai/codex";
|
|
@@ -98366,7 +99445,7 @@ function parseCodexVersion(raw) {
|
|
|
98366
99445
|
return m ? m[0] : null;
|
|
98367
99446
|
}
|
|
98368
99447
|
var defaultRun = (args) => {
|
|
98369
|
-
const r = (0,
|
|
99448
|
+
const r = (0, import_node_child_process20.spawnSync)("codex", args, { encoding: "utf8", timeout: 8e3, shell: true });
|
|
98370
99449
|
return { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
98371
99450
|
};
|
|
98372
99451
|
function getInstalledAgentVersion(provider, run4) {
|
|
@@ -98578,8 +99657,8 @@ async function verifyProviderReadiness(provider, run4, opts = {}) {
|
|
|
98578
99657
|
|
|
98579
99658
|
// src/browser-interceptor.ts
|
|
98580
99659
|
var import_node_os18 = __toESM(require("node:os"), 1);
|
|
98581
|
-
var
|
|
98582
|
-
var
|
|
99660
|
+
var import_node_readline2 = __toESM(require("node:readline"), 1);
|
|
99661
|
+
var import_node_child_process21 = require("node:child_process");
|
|
98583
99662
|
var INTERNAL_HOST_PATTERNS = [
|
|
98584
99663
|
/^(?:.*\.)?mrrlin\.(?:com|internal|local)$/i,
|
|
98585
99664
|
/^(?:localhost|127\.0\.0\.1)(?::\d+)?$/i
|
|
@@ -98705,12 +99784,12 @@ function wireBrowserServeProxy(streams) {
|
|
|
98705
99784
|
const { input, output: output3, childIn, childOut } = streams;
|
|
98706
99785
|
childIn.on("error", () => {
|
|
98707
99786
|
});
|
|
98708
|
-
const rl =
|
|
99787
|
+
const rl = import_node_readline2.default.createInterface({
|
|
98709
99788
|
input,
|
|
98710
99789
|
crlfDelay: Infinity,
|
|
98711
99790
|
terminal: false
|
|
98712
99791
|
});
|
|
98713
|
-
const childRl =
|
|
99792
|
+
const childRl = import_node_readline2.default.createInterface({
|
|
98714
99793
|
input: childOut,
|
|
98715
99794
|
crlfDelay: Infinity,
|
|
98716
99795
|
terminal: false
|
|
@@ -98760,7 +99839,7 @@ function signalToExitCode(signal) {
|
|
|
98760
99839
|
async function runBrowserServeProxy(opts) {
|
|
98761
99840
|
const input = opts.input ?? process.stdin;
|
|
98762
99841
|
const output3 = opts.output ?? process.stdout;
|
|
98763
|
-
const child = (0,
|
|
99842
|
+
const child = (0, import_node_child_process21.spawn)(opts.command, opts.args, {
|
|
98764
99843
|
stdio: ["pipe", "pipe", "inherit"],
|
|
98765
99844
|
env: { ...process.env, ...opts.env }
|
|
98766
99845
|
});
|
|
@@ -98967,7 +100046,7 @@ function failureLogLine(label, error51, suppressed, note) {
|
|
|
98967
100046
|
var import_undici2 = __toESM(require_undici(), 1);
|
|
98968
100047
|
|
|
98969
100048
|
// src/bridge-owned-connector.ts
|
|
98970
|
-
var
|
|
100049
|
+
var import_node_net6 = require("node:net");
|
|
98971
100050
|
var import_undici = __toESM(require_undici(), 1);
|
|
98972
100051
|
var OwnedBridgeConnector = class {
|
|
98973
100052
|
constructor(limit) {
|
|
@@ -99036,7 +100115,7 @@ var OwnedBridgeConnector = class {
|
|
|
99036
100115
|
try {
|
|
99037
100116
|
const raw = this.native(options, (error51, socket) => complete(error51, socket ?? null));
|
|
99038
100117
|
returned = true;
|
|
99039
|
-
if (!(raw instanceof
|
|
100118
|
+
if (!(raw instanceof import_node_net6.Socket)) {
|
|
99040
100119
|
this.uncertain = 1;
|
|
99041
100120
|
this.retired = true;
|
|
99042
100121
|
this.entries.delete(entry);
|
|
@@ -100498,7 +101577,9 @@ function createScopedHeartbeatFetch(options, mode = "full") {
|
|
|
100498
101577
|
}
|
|
100499
101578
|
};
|
|
100500
101579
|
const rawPath = typeof input === "string" ? /^https?:\/\/[^/?#\\]+(\/[^?#]*)$/iu.exec(input)?.[1] : void 0;
|
|
100501
|
-
|
|
101580
|
+
const seg1 = path42 ? path42[1] : void 0;
|
|
101581
|
+
const seg2 = path42 ? path42[2] : void 0;
|
|
101582
|
+
if (url2.origin !== origin || url2.username || url2.password || url2.search || url2.hash || !path42 || mode === "compact" && (rawPath !== url2.pathname || !seg1 || !seg2 || !safeSegment(seg1) || !safeSegment(seg2)) || init?.method !== "POST" || typeof init.body !== "string" || Buffer.byteLength(init.body) > 8192) {
|
|
100502
101583
|
throw new Error("BRIDGE_HEARTBEAT_UNSUPPORTED_REQUEST");
|
|
100503
101584
|
}
|
|
100504
101585
|
const result = await request(init.signal ?? void 0, { url: url2.href, body: init.body });
|
|
@@ -100589,11 +101670,11 @@ function bindScopedRunRead(client, read) {
|
|
|
100589
101670
|
var import_node_fs35 = __toESM(require("node:fs"), 1);
|
|
100590
101671
|
|
|
100591
101672
|
// src/executor-thread-instructions.ts
|
|
100592
|
-
var
|
|
101673
|
+
var import_node_crypto24 = require("node:crypto");
|
|
100593
101674
|
var import_node_fs23 = require("node:fs");
|
|
100594
101675
|
var import_node_path31 = require("node:path");
|
|
100595
101676
|
function instructionHash(instructions) {
|
|
100596
|
-
return (0,
|
|
101677
|
+
return (0, import_node_crypto24.createHash)("sha256").update(instructions ?? "").digest("hex").slice(0, 16);
|
|
100597
101678
|
}
|
|
100598
101679
|
var MAX_ENTRIES = 1e4;
|
|
100599
101680
|
function createExecutorThreadInstructionStore(path42, warn = (message) => process.stderr.write(`${message}
|
|
@@ -100651,7 +101732,7 @@ var import_node_http5 = __toESM(require("node:http"), 1);
|
|
|
100651
101732
|
var import_node_os26 = __toESM(require("node:os"), 1);
|
|
100652
101733
|
var import_node_path50 = __toESM(require("node:path"), 1);
|
|
100653
101734
|
var import_node_child_process28 = require("node:child_process");
|
|
100654
|
-
var
|
|
101735
|
+
var import_node_crypto33 = __toESM(require("node:crypto"), 1);
|
|
100655
101736
|
|
|
100656
101737
|
// src/turn-replay-buffer.ts
|
|
100657
101738
|
var DEFAULT_MAX_EVENTS = 2e3;
|
|
@@ -101131,14 +102212,14 @@ function createTurnLock() {
|
|
|
101131
102212
|
}
|
|
101132
102213
|
|
|
101133
102214
|
// src/self-update.ts
|
|
101134
|
-
var
|
|
101135
|
-
var
|
|
102215
|
+
var import_node_child_process23 = require("node:child_process");
|
|
102216
|
+
var import_node_crypto25 = require("node:crypto");
|
|
101136
102217
|
var import_node_fs25 = require("node:fs");
|
|
101137
102218
|
var import_node_path33 = __toESM(require("node:path"), 1);
|
|
101138
102219
|
var import_semver3 = __toESM(require_semver2(), 1);
|
|
101139
102220
|
|
|
101140
102221
|
// src/codex-auth-preflight.ts
|
|
101141
|
-
var
|
|
102222
|
+
var import_node_child_process22 = require("node:child_process");
|
|
101142
102223
|
var import_node_fs24 = require("node:fs");
|
|
101143
102224
|
var import_node_os19 = __toESM(require("node:os"), 1);
|
|
101144
102225
|
var import_node_path32 = __toESM(require("node:path"), 1);
|
|
@@ -101232,7 +102313,7 @@ function runCodexAuthRefreshSmokeForBridgeUpdate(opts = {}) {
|
|
|
101232
102313
|
CODEX_AUTH_SMOKE_PROMPT
|
|
101233
102314
|
];
|
|
101234
102315
|
const command = commandForSmoke(executable, model);
|
|
101235
|
-
const execFileSync8 = opts.execFileSyncImpl ??
|
|
102316
|
+
const execFileSync8 = opts.execFileSyncImpl ?? import_node_child_process22.execFileSync;
|
|
101236
102317
|
try {
|
|
101237
102318
|
execFileSync8(executable, args, {
|
|
101238
102319
|
cwd,
|
|
@@ -101400,7 +102481,7 @@ function resolveBinPath(opts) {
|
|
|
101400
102481
|
}
|
|
101401
102482
|
const whichSync = opts.whichSync ?? ((name) => {
|
|
101402
102483
|
try {
|
|
101403
|
-
return (0,
|
|
102484
|
+
return (0, import_node_child_process23.execFileSync)("which", [name], { encoding: "utf8", timeout: 3e3 }).trim() || null;
|
|
101404
102485
|
} catch {
|
|
101405
102486
|
return null;
|
|
101406
102487
|
}
|
|
@@ -101440,7 +102521,7 @@ function readIntervalEnv(name, fallback) {
|
|
|
101440
102521
|
return Number.isFinite(n) && n > 0 ? n : fallback;
|
|
101441
102522
|
}
|
|
101442
102523
|
function sha2562(buf) {
|
|
101443
|
-
return (0,
|
|
102524
|
+
return (0, import_node_crypto25.createHash)("sha256").update(buf).digest("hex");
|
|
101444
102525
|
}
|
|
101445
102526
|
function startSelfUpdate(deps) {
|
|
101446
102527
|
const log2 = deps.log ?? (() => {
|
|
@@ -101736,7 +102817,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
|
|
|
101736
102817
|
}
|
|
101737
102818
|
|
|
101738
102819
|
// src/_generated/version.ts
|
|
101739
|
-
var PKG_VERSION = "0.4.
|
|
102820
|
+
var PKG_VERSION = "0.4.223";
|
|
101740
102821
|
|
|
101741
102822
|
// src/bridge-allowed-origins.ts
|
|
101742
102823
|
var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
|
|
@@ -101765,7 +102846,7 @@ function readDirectorBridgeAllowedOrigins(env = process.env) {
|
|
|
101765
102846
|
}
|
|
101766
102847
|
|
|
101767
102848
|
// src/receipt-signing.ts
|
|
101768
|
-
var
|
|
102849
|
+
var import_node_crypto26 = __toESM(require("node:crypto"), 1);
|
|
101769
102850
|
var FIXTURE_SIGNING_KEY_ID = "ed25519:fixture:default";
|
|
101770
102851
|
var FIXTURE_PRIVATE_KEY_BASE64 = "MC4CAQAwBQYDK2VwBCIEIFnZBWdVAlsGODDrzXF2wQxO4mBVB/AEos6tYJzg/C/+";
|
|
101771
102852
|
function canonicalizeJson2(obj) {
|
|
@@ -101786,7 +102867,7 @@ function canonicalBytes(obj) {
|
|
|
101786
102867
|
return Buffer.from(canonicalizeJson2(obj), "utf8");
|
|
101787
102868
|
}
|
|
101788
102869
|
function sha256Hex(data) {
|
|
101789
|
-
return
|
|
102870
|
+
return import_node_crypto26.default.createHash("sha256").update(data).digest("hex");
|
|
101790
102871
|
}
|
|
101791
102872
|
var LocalEd25519SigningProvider = class {
|
|
101792
102873
|
keyId;
|
|
@@ -101799,9 +102880,9 @@ var LocalEd25519SigningProvider = class {
|
|
|
101799
102880
|
if (options.privateKey) {
|
|
101800
102881
|
if (typeof options.privateKey === "string") {
|
|
101801
102882
|
if (options.privateKey.includes("-----BEGIN")) {
|
|
101802
|
-
this.privateKey =
|
|
102883
|
+
this.privateKey = import_node_crypto26.default.createPrivateKey(options.privateKey);
|
|
101803
102884
|
} else {
|
|
101804
|
-
this.privateKey =
|
|
102885
|
+
this.privateKey = import_node_crypto26.default.createPrivateKey({
|
|
101805
102886
|
key: Buffer.from(options.privateKey, "base64"),
|
|
101806
102887
|
format: "der",
|
|
101807
102888
|
type: "pkcs8"
|
|
@@ -101810,10 +102891,10 @@ var LocalEd25519SigningProvider = class {
|
|
|
101810
102891
|
} else {
|
|
101811
102892
|
this.privateKey = options.privateKey;
|
|
101812
102893
|
}
|
|
101813
|
-
const pub =
|
|
102894
|
+
const pub = import_node_crypto26.default.createPublicKey(this.privateKey);
|
|
101814
102895
|
this.publicKeyBase64 = pub.export({ type: "spki", format: "der" }).toString("base64");
|
|
101815
102896
|
} else {
|
|
101816
|
-
const pair =
|
|
102897
|
+
const pair = import_node_crypto26.default.generateKeyPairSync("ed25519");
|
|
101817
102898
|
this.privateKey = pair.privateKey;
|
|
101818
102899
|
this.publicKeyBase64 = pair.publicKey.export({ type: "spki", format: "der" }).toString("base64");
|
|
101819
102900
|
}
|
|
@@ -101836,7 +102917,7 @@ var LocalEd25519SigningProvider = class {
|
|
|
101836
102917
|
throw new Error(`KEY_COMPROMISED: signing key ${this.keyId} is compromised: ${this.compromiseReason}`);
|
|
101837
102918
|
}
|
|
101838
102919
|
const bytes3 = canonicalBytes(payload);
|
|
101839
|
-
const signature =
|
|
102920
|
+
const signature = import_node_crypto26.default.sign(null, bytes3, this.privateKey).toString("base64");
|
|
101840
102921
|
return {
|
|
101841
102922
|
keyId: this.keyId,
|
|
101842
102923
|
signature,
|
|
@@ -101847,8 +102928,8 @@ var LocalEd25519SigningProvider = class {
|
|
|
101847
102928
|
try {
|
|
101848
102929
|
const bytes3 = canonicalBytes(payload);
|
|
101849
102930
|
const sigBuffer = Buffer.from(signature, "base64");
|
|
101850
|
-
const pubKey = publicKeySpkiBase64 ?
|
|
101851
|
-
return
|
|
102931
|
+
const pubKey = publicKeySpkiBase64 ? import_node_crypto26.default.createPublicKey({ key: Buffer.from(publicKeySpkiBase64, "base64"), format: "der", type: "spki" }) : import_node_crypto26.default.createPublicKey(this.privateKey);
|
|
102932
|
+
return import_node_crypto26.default.verify(null, bytes3, pubKey, sigBuffer);
|
|
101852
102933
|
} catch {
|
|
101853
102934
|
return false;
|
|
101854
102935
|
}
|
|
@@ -101862,8 +102943,8 @@ function verifySettlementReceiptV2(receipt, publicKeyBase64) {
|
|
|
101862
102943
|
if (keyBuffer.length === 32) {
|
|
101863
102944
|
keyBuffer = Buffer.concat([Buffer.from("302a300506032b6570032100", "hex"), keyBuffer]);
|
|
101864
102945
|
}
|
|
101865
|
-
const pubKey =
|
|
101866
|
-
return
|
|
102946
|
+
const pubKey = import_node_crypto26.default.createPublicKey({ key: keyBuffer, format: "der", type: "spki" });
|
|
102947
|
+
return import_node_crypto26.default.verify(null, bytes3, pubKey, sigBuffer);
|
|
101867
102948
|
} catch {
|
|
101868
102949
|
return false;
|
|
101869
102950
|
}
|
|
@@ -104297,7 +105378,7 @@ async function emitPruneLog(stateDir, daysRemoved, reasonByDay, bytesRemoved, ol
|
|
|
104297
105378
|
}
|
|
104298
105379
|
|
|
104299
105380
|
// src/telemetry/turn-aggregator.ts
|
|
104300
|
-
var
|
|
105381
|
+
var import_node_crypto27 = require("node:crypto");
|
|
104301
105382
|
var import_promises16 = require("node:fs/promises");
|
|
104302
105383
|
var import_node_path38 = require("node:path");
|
|
104303
105384
|
var BRIDGE_FILE_RE = /^bridge-(\d{4}-\d{2}-\d{2})\.jsonl$/;
|
|
@@ -104455,7 +105536,7 @@ async function foldClosedDays(stateDir, today) {
|
|
|
104455
105536
|
await (0, import_promises16.mkdir)(telemetryDir, { recursive: true });
|
|
104456
105537
|
for (const [slug, rows] of rowsByProject) {
|
|
104457
105538
|
const finalPath = (0, import_node_path38.join)(telemetryDir, `rows-${slug}-${day}.jsonl`);
|
|
104458
|
-
const tmpPath = `${finalPath}.tmp-${process.pid}-${(0,
|
|
105539
|
+
const tmpPath = `${finalPath}.tmp-${process.pid}-${(0, import_node_crypto27.randomBytes)(6).toString("hex")}`;
|
|
104459
105540
|
try {
|
|
104460
105541
|
await (0, import_promises16.writeFile)(tmpPath, rows.map((r) => JSON.stringify(r)).join("\n") + "\n", "utf8");
|
|
104461
105542
|
await (0, import_promises16.rename)(tmpPath, finalPath);
|
|
@@ -104472,7 +105553,7 @@ var import_promises17 = require("node:fs/promises");
|
|
|
104472
105553
|
var import_node_path40 = require("node:path");
|
|
104473
105554
|
|
|
104474
105555
|
// src/telemetry/installation-id.ts
|
|
104475
|
-
var
|
|
105556
|
+
var import_node_crypto28 = require("node:crypto");
|
|
104476
105557
|
var import_node_fs28 = require("node:fs");
|
|
104477
105558
|
var import_node_path39 = require("node:path");
|
|
104478
105559
|
var FILE_NAME = "installation-id";
|
|
@@ -104487,7 +105568,7 @@ function resolveInstallationId(stateDir) {
|
|
|
104487
105568
|
id = (0, import_node_fs28.readFileSync)(path42, "utf8").trim();
|
|
104488
105569
|
if (!UUID.test(id)) throw new Error("unusable");
|
|
104489
105570
|
} catch {
|
|
104490
|
-
id = (0,
|
|
105571
|
+
id = (0, import_node_crypto28.randomUUID)();
|
|
104491
105572
|
(0, import_node_fs28.mkdirSync)((0, import_node_path39.dirname)(path42), { recursive: true });
|
|
104492
105573
|
(0, import_node_fs28.writeFileSync)(path42, `${id}
|
|
104493
105574
|
`, "utf8");
|
|
@@ -104673,11 +105754,11 @@ async function uploadPendingDays(stateDir, client, bridgeHealth, gateCtx) {
|
|
|
104673
105754
|
}
|
|
104674
105755
|
|
|
104675
105756
|
// src/spawn-command.ts
|
|
104676
|
-
var
|
|
105757
|
+
var import_node_child_process24 = require("node:child_process");
|
|
104677
105758
|
var SAFE_FIXED_ARG_RE = /^[A-Za-z0-9@._:/=-]+$/;
|
|
104678
105759
|
function spawnSyncCommand(command, args, options, deps = {}) {
|
|
104679
105760
|
const { shellFallback, shell: _ignoredShell, ...spawnOptions } = options;
|
|
104680
|
-
const run4 = deps.spawnSyncImpl ??
|
|
105761
|
+
const run4 = deps.spawnSyncImpl ?? import_node_child_process24.spawnSync;
|
|
104681
105762
|
const platform = deps.platform ?? process.platform;
|
|
104682
105763
|
const target = resolveSpawnTarget(command, args, { ...deps, env: deps.env ?? spawnOptions.env ?? process.env });
|
|
104683
105764
|
if (platform === "win32" && shellFallback === true && target.command === command && [command, ...args].every((a) => SAFE_FIXED_ARG_RE.test(a))) {
|
|
@@ -104746,8 +105827,8 @@ function setSelectedProvider(value) {
|
|
|
104746
105827
|
|
|
104747
105828
|
// src/execution-consumer.ts
|
|
104748
105829
|
var import_node_perf_hooks = require("node:perf_hooks");
|
|
104749
|
-
var
|
|
104750
|
-
var
|
|
105830
|
+
var import_node_child_process26 = require("node:child_process");
|
|
105831
|
+
var import_node_crypto29 = __toESM(require("node:crypto"), 1);
|
|
104751
105832
|
var import_promises19 = require("node:fs/promises");
|
|
104752
105833
|
var import_node_os21 = require("node:os");
|
|
104753
105834
|
var import_node_path42 = __toESM(require("node:path"), 1);
|
|
@@ -105760,6 +106841,9 @@ function isDeployGateRunStatus(status) {
|
|
|
105760
106841
|
return status === "dev_deploy" || status === "prod_deploy";
|
|
105761
106842
|
}
|
|
105762
106843
|
|
|
106844
|
+
// src/delivery/public-url-verifier.ts
|
|
106845
|
+
var DEFAULT_VERIFIER_MAX_BYTES = 2 * 1024 * 1024;
|
|
106846
|
+
|
|
105763
106847
|
// src/prompts/task-notes-contract.ts
|
|
105764
106848
|
function renderTaskNotesContractLines(journalWriter = false) {
|
|
105765
106849
|
const brief = TASK_NOTES_BRIEF_SECTIONS.map((s) => ` ## ${s.heading} \u2014 ${s.description}`);
|
|
@@ -106359,7 +107443,7 @@ async function checkExecutorBackgroundGate(input) {
|
|
|
106359
107443
|
}
|
|
106360
107444
|
|
|
106361
107445
|
// src/executor-git-status.ts
|
|
106362
|
-
var
|
|
107446
|
+
var import_node_child_process25 = require("node:child_process");
|
|
106363
107447
|
var import_promises18 = require("node:fs/promises");
|
|
106364
107448
|
var import_node_path41 = require("node:path");
|
|
106365
107449
|
async function probeExecutorGitStatus(worktree, options) {
|
|
@@ -106377,7 +107461,7 @@ async function probeExecutorGitStatus(worktree, options) {
|
|
|
106377
107461
|
const timeout = Math.floor(deadline - performance.now());
|
|
106378
107462
|
if (timeout < 1 || options.signal?.aborted) return "unknown";
|
|
106379
107463
|
return new Promise((resolve3) => {
|
|
106380
|
-
(0,
|
|
107464
|
+
(0, import_node_child_process25.execFile)(
|
|
106381
107465
|
"git",
|
|
106382
107466
|
[
|
|
106383
107467
|
"--no-optional-locks",
|
|
@@ -106836,13 +107920,13 @@ function isBridgeGeneratedArtifact(artifact) {
|
|
|
106836
107920
|
return typeof payload === "object" && payload !== null && "event" in payload;
|
|
106837
107921
|
}
|
|
106838
107922
|
function newArtifactId() {
|
|
106839
|
-
return `EA-${
|
|
107923
|
+
return `EA-${import_node_crypto29.default.randomUUID()}`;
|
|
106840
107924
|
}
|
|
106841
107925
|
var BLAST_RADIUS_FLOOR_PATTERNS = [/^supabase\/migrations\//, /^packages\/db\/src\/schema\.ts$/];
|
|
106842
107926
|
function isBlastRadiusFloorPath(path42) {
|
|
106843
107927
|
return BLAST_RADIUS_FLOOR_PATTERNS.some((re) => re.test(path42));
|
|
106844
107928
|
}
|
|
106845
|
-
var execFileAsync3 = (0, import_node_util6.promisify)(
|
|
107929
|
+
var execFileAsync3 = (0, import_node_util6.promisify)(import_node_child_process26.execFile);
|
|
106846
107930
|
async function restrictExecutorBearerDirectory(directory) {
|
|
106847
107931
|
if (process.platform !== "win32") return;
|
|
106848
107932
|
const systemDirectory = process.env.SystemRoot;
|
|
@@ -107147,7 +108231,7 @@ async function readApprovedMixedCodeSpec(client, projectSlug, runId, runApproval
|
|
|
107147
108231
|
if (!matches(task)) throw changed();
|
|
107148
108232
|
const read = async () => {
|
|
107149
108233
|
const page = await client.getWikiPage(projectSlug, runApproval.specPageId);
|
|
107150
|
-
if (page.id !== runApproval.specPageId || page.folder !== "Specs" || page.taskId !== task.id || page.specReady !== true ||
|
|
108234
|
+
if (page.id !== runApproval.specPageId || page.folder !== "Specs" || page.taskId !== task.id || page.specReady !== true || import_node_crypto29.default.createHash("sha256").update(page.markdownBody, "utf8").digest("hex") !== runApproval.specContentHash) {
|
|
107151
108235
|
throw changed();
|
|
107152
108236
|
}
|
|
107153
108237
|
const current2 = await client.getTask(projectSlug, task.id);
|
|
@@ -107376,7 +108460,7 @@ async function driveRun(deps, projectSlug, runId, shutdown) {
|
|
|
107376
108460
|
return;
|
|
107377
108461
|
}
|
|
107378
108462
|
await deps.client.createInboxItem(projectSlug, {
|
|
107379
|
-
id: `II-${
|
|
108463
|
+
id: `II-${import_node_crypto29.default.randomUUID()}`,
|
|
107380
108464
|
kind: "handoff",
|
|
107381
108465
|
taskId: claimed.taskId,
|
|
107382
108466
|
body: `Execution run ${runId} was claimed but returned no leaseId. This indicates DB/API corruption and requires operator attention.`
|
|
@@ -109014,7 +110098,7 @@ ${coldClosureInstruction}` : workInstruction;
|
|
|
109014
110098
|
taskId: task.id,
|
|
109015
110099
|
runId,
|
|
109016
110100
|
outcome: "completed",
|
|
109017
|
-
nonce:
|
|
110101
|
+
nonce: import_node_crypto29.default.randomUUID(),
|
|
109018
110102
|
artifacts: []
|
|
109019
110103
|
}
|
|
109020
110104
|
);
|
|
@@ -109518,8 +110602,29 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2,
|
|
|
109518
110602
|
}
|
|
109519
110603
|
}
|
|
109520
110604
|
const awaitsResultConfirmation = rawProject.awaitsResultConfirmation === true;
|
|
110605
|
+
const isPageOutcome = task.declaredOutcome?.requires?.includes("page") === true;
|
|
110606
|
+
const hasPublicationEvidence = isPageOutcome && parsedResult.outcome === "completed" && !awaitsResultConfirmation && !deps.signingProvider && (await deps.client.listExecutionArtifacts(projectSlug, runId).catch(() => [])).some((artifact) => artifact.kind === "produced_url");
|
|
110607
|
+
if (hasPublicationEvidence) {
|
|
110608
|
+
await failRun(
|
|
110609
|
+
deps,
|
|
110610
|
+
projectSlug,
|
|
110611
|
+
task,
|
|
110612
|
+
runId,
|
|
110613
|
+
leaseId,
|
|
110614
|
+
`receipt_signing_unavailable: task ${task.id} produced publication evidence, but closure signing provider is unavailable (PUB-011)`,
|
|
110615
|
+
"receipt_signing_unavailable"
|
|
110616
|
+
);
|
|
110617
|
+
return;
|
|
110618
|
+
}
|
|
109521
110619
|
if (deps.signingProvider && (parsedResult.outcome === "negative_result" || parsedResult.outcome === "completed" && !awaitsResultConfirmation)) {
|
|
109522
110620
|
try {
|
|
110621
|
+
const existingArtifacts = isPageOutcome ? await deps.client.listExecutionArtifacts(projectSlug, runId).catch(() => []) : [];
|
|
110622
|
+
const urlArtifacts = existingArtifacts.filter((a) => a.kind === "produced_url").map((a) => ({
|
|
110623
|
+
artifactId: a.id,
|
|
110624
|
+
storageVersion: "1",
|
|
110625
|
+
contentHash: String(a.payload?.contentHash ?? sha256Hex(canonicalizeJson2(a.payload ?? {}))),
|
|
110626
|
+
kind: "produced_url"
|
|
110627
|
+
}));
|
|
109523
110628
|
await orchestrateSettlementClosure(
|
|
109524
110629
|
{
|
|
109525
110630
|
prepareSettlementCandidate: (slug, params) => deps.client.prepareSettlementCandidate(slug, params),
|
|
@@ -109531,14 +110636,15 @@ async function driveNonCodeRun(deps, projectSlug, runId, leaseId, task, domain2,
|
|
|
109531
110636
|
taskId: task.id,
|
|
109532
110637
|
runId,
|
|
109533
110638
|
outcome: parsedResult.outcome,
|
|
109534
|
-
nonce:
|
|
110639
|
+
nonce: import_node_crypto29.default.randomUUID(),
|
|
109535
110640
|
artifacts: [
|
|
109536
110641
|
{
|
|
109537
110642
|
artifactId: pageId,
|
|
109538
110643
|
storageVersion: "1",
|
|
109539
110644
|
contentHash,
|
|
109540
110645
|
kind: "deliverable_page"
|
|
109541
|
-
}
|
|
110646
|
+
},
|
|
110647
|
+
...urlArtifacts
|
|
109542
110648
|
]
|
|
109543
110649
|
}
|
|
109544
110650
|
);
|
|
@@ -109960,7 +111066,7 @@ async function deliverLocalRun(deps, input) {
|
|
|
109960
111066
|
projectSlug,
|
|
109961
111067
|
taskId: task.id,
|
|
109962
111068
|
runId,
|
|
109963
|
-
idempotencyKey:
|
|
111069
|
+
idempotencyKey: import_node_crypto29.default.randomUUID(),
|
|
109964
111070
|
artifactId: artifact?.id ?? artifactId,
|
|
109965
111071
|
leaseId
|
|
109966
111072
|
});
|
|
@@ -110021,7 +111127,7 @@ async function deliverLocalRun(deps, input) {
|
|
|
110021
111127
|
taskId: task.id,
|
|
110022
111128
|
runId,
|
|
110023
111129
|
outcome: "completed",
|
|
110024
|
-
nonce:
|
|
111130
|
+
nonce: import_node_crypto29.default.randomUUID(),
|
|
110025
111131
|
artifacts: [{ artifactId: artifact?.id ?? artifactId, storageVersion: "1", contentHash, kind: "verification" }]
|
|
110026
111132
|
}
|
|
110027
111133
|
);
|
|
@@ -110393,7 +111499,7 @@ async function reconcileTaskAwaitingMerge(deps, projectSlug, task, runId, reason
|
|
|
110393
111499
|
}
|
|
110394
111500
|
try {
|
|
110395
111501
|
await deps.client.createInboxItem(projectSlug, {
|
|
110396
|
-
id: `II-${
|
|
111502
|
+
id: `II-${import_node_crypto29.default.randomUUID()}`,
|
|
110397
111503
|
kind: "handoff",
|
|
110398
111504
|
taskId: task.id,
|
|
110399
111505
|
body: `Task ${task.id} (${task.title}) still needs operator follow-up: ${reason}. Mrrlin could not move the task back to Handoff needed automatically.`
|
|
@@ -110428,7 +111534,7 @@ async function notifyOperatorHandoff(deps, projectSlug, task, runId, reason) {
|
|
|
110428
111534
|
}
|
|
110429
111535
|
try {
|
|
110430
111536
|
await deps.client.createInboxItem(projectSlug, {
|
|
110431
|
-
id: `II-${
|
|
111537
|
+
id: `II-${import_node_crypto29.default.randomUUID()}`,
|
|
110432
111538
|
kind: "handoff",
|
|
110433
111539
|
taskId: task.id,
|
|
110434
111540
|
body: `Execution run ${runId} for task ${task.id} (${task.title}) needs operator attention: ${reason}`
|
|
@@ -110617,7 +111723,7 @@ async function deployGateHandoff(deps, projectSlug, task, runId, reason, leaseId
|
|
|
110617
111723
|
});
|
|
110618
111724
|
if (isRollbackReconciliation) return;
|
|
110619
111725
|
await deps.client.createInboxItem(projectSlug, {
|
|
110620
|
-
id: `II-${
|
|
111726
|
+
id: `II-${import_node_crypto29.default.randomUUID()}`,
|
|
110621
111727
|
kind: "handoff",
|
|
110622
111728
|
taskId: task.id,
|
|
110623
111729
|
body: `Deploy gate for run ${runId} (task ${task.id} \u2014 ${task.title}) needs operator attention: ${reason}`
|
|
@@ -110636,7 +111742,7 @@ function maxLeaseReclaims() {
|
|
|
110636
111742
|
}
|
|
110637
111743
|
|
|
110638
111744
|
// src/async-job-consumer.ts
|
|
110639
|
-
var
|
|
111745
|
+
var import_node_crypto30 = __toESM(require("node:crypto"), 1);
|
|
110640
111746
|
var import_promises20 = require("node:timers/promises");
|
|
110641
111747
|
var ASYNC_JOB_MAX_ATTEMPTS = 2;
|
|
110642
111748
|
function ASYNC_UNOWNED_TTL_DAYS() {
|
|
@@ -110746,10 +111852,11 @@ async function driveClaimableAsyncJob(deps, projectSlug, jobId, preClaimJob, sec
|
|
|
110746
111852
|
if (reportAction && reportClaim) {
|
|
110747
111853
|
const requestedAt = elapsed();
|
|
110748
111854
|
const claim = await reportAction({ ...reportClaim, action: "claim-aged" });
|
|
110749
|
-
|
|
111855
|
+
const leaseRemainingMs = claim?.leaseRemainingMs ?? 0;
|
|
111856
|
+
if (claim?.leaseId && leaseRemainingMs > 0) await retryReport(
|
|
110750
111857
|
{ action: "finish-aged", leaseId: claim.leaseId, incarnation: reportClaim.incarnation },
|
|
110751
|
-
() => !shutdown?.aborted && elapsed() - requestedAt <
|
|
110752
|
-
() => requestedAt +
|
|
111858
|
+
() => !shutdown?.aborted && elapsed() - requestedAt < leaseRemainingMs,
|
|
111859
|
+
() => requestedAt + leaseRemainingMs - elapsed(),
|
|
110753
111860
|
shutdown
|
|
110754
111861
|
);
|
|
110755
111862
|
return;
|
|
@@ -110936,7 +112043,7 @@ async function driveClaimableAsyncJob(deps, projectSlug, jobId, preClaimJob, sec
|
|
|
110936
112043
|
if (heartbeatPending) await heartbeatPending;
|
|
110937
112044
|
if (!checkOwnership()) return;
|
|
110938
112045
|
const requestedAt = elapsed();
|
|
110939
|
-
beginRequestId = reportAction ?
|
|
112046
|
+
beginRequestId = reportAction ? import_node_crypto30.default.randomUUID() : void 0;
|
|
110940
112047
|
const begun = reportAction && beginRequestId ? await retryReport({
|
|
110941
112048
|
action: "begin",
|
|
110942
112049
|
requestId: beginRequestId,
|
|
@@ -111047,7 +112154,7 @@ async function driveClaimableAsyncJob(deps, projectSlug, jobId, preClaimJob, sec
|
|
|
111047
112154
|
const delivery = descriptor2.onComplete(outcome, input, completionContext);
|
|
111048
112155
|
if (!delivery.suppressInbox) {
|
|
111049
112156
|
await deps.client.createInboxItem(projectSlug, {
|
|
111050
|
-
id: delivery.id ?? `II-${
|
|
112157
|
+
id: delivery.id ?? `II-${import_node_crypto30.default.randomUUID()}`,
|
|
111051
112158
|
kind: delivery.kind,
|
|
111052
112159
|
body: delivery.body,
|
|
111053
112160
|
...delivery.taskId ? { taskId: delivery.taskId } : {},
|
|
@@ -111065,13 +112172,13 @@ async function deriveRequestedHash(client, toolName2, input) {
|
|
|
111065
112172
|
if (input.requestedHash) return input.requestedHash;
|
|
111066
112173
|
if (toolName2 === "run_spec_consensus" && input.pageId) {
|
|
111067
112174
|
const page = await client.getWikiPage(input.projectSlug, input.pageId);
|
|
111068
|
-
return page.contentHash ??
|
|
112175
|
+
return page.contentHash ?? import_node_crypto30.default.createHash("sha256").update(page.markdownBody).digest("hex");
|
|
111069
112176
|
}
|
|
111070
112177
|
if (toolName2 === "draft_task_spec" && input.taskId) {
|
|
111071
112178
|
const task = await client.getTask(input.projectSlug, input.taskId);
|
|
111072
|
-
return task.updatedAt ??
|
|
112179
|
+
return task.updatedAt ?? import_node_crypto30.default.createHash("sha256").update(JSON.stringify(task)).digest("hex");
|
|
111073
112180
|
}
|
|
111074
|
-
return
|
|
112181
|
+
return import_node_crypto30.default.createHash("sha256").update(JSON.stringify(input)).digest("hex");
|
|
111075
112182
|
}
|
|
111076
112183
|
async function runAsyncBackstopSweep(deps, drive = (slug, jobId) => driveAsyncJob(deps, slug, jobId), shutdown) {
|
|
111077
112184
|
if (shutdown?.aborted) return;
|
|
@@ -111420,368 +112527,6 @@ function agentIdleMs(provider) {
|
|
|
111420
112527
|
return seconds * 1e3;
|
|
111421
112528
|
}
|
|
111422
112529
|
|
|
111423
|
-
// src/connections/client.ts
|
|
111424
|
-
var import_node_child_process26 = require("node:child_process");
|
|
111425
|
-
var import_node_readline2 = __toESM(require("node:readline"), 1);
|
|
111426
|
-
var HttpMcpClient = class {
|
|
111427
|
-
endpoint;
|
|
111428
|
-
headers;
|
|
111429
|
-
allowLocal;
|
|
111430
|
-
authProvider;
|
|
111431
|
-
messageId = 1;
|
|
111432
|
-
constructor(endpoint, headers = {}, allowLocal = false, authProvider) {
|
|
111433
|
-
this.endpoint = endpoint;
|
|
111434
|
-
this.headers = headers;
|
|
111435
|
-
this.allowLocal = allowLocal;
|
|
111436
|
-
this.authProvider = authProvider;
|
|
111437
|
-
}
|
|
111438
|
-
async rpc(method, params) {
|
|
111439
|
-
const id = this.messageId++;
|
|
111440
|
-
const body = JSON.stringify({
|
|
111441
|
-
jsonrpc: "2.0",
|
|
111442
|
-
id,
|
|
111443
|
-
method,
|
|
111444
|
-
params: params ?? {}
|
|
111445
|
-
});
|
|
111446
|
-
if (this.authProvider) {
|
|
111447
|
-
try {
|
|
111448
|
-
const token = await this.authProvider.getValidAccessToken();
|
|
111449
|
-
if (token) {
|
|
111450
|
-
this.headers["authorization"] = `Bearer ${token}`;
|
|
111451
|
-
}
|
|
111452
|
-
} catch (err) {
|
|
111453
|
-
if (err instanceof OAuthReauthorizationRequiredError) {
|
|
111454
|
-
const authErr = new Error(err.message);
|
|
111455
|
-
authErr.code = "UNAUTHORIZED";
|
|
111456
|
-
throw authErr;
|
|
111457
|
-
}
|
|
111458
|
-
throw err;
|
|
111459
|
-
}
|
|
111460
|
-
}
|
|
111461
|
-
let res = await safeFetch(
|
|
111462
|
-
this.endpoint,
|
|
111463
|
-
{
|
|
111464
|
-
method: "POST",
|
|
111465
|
-
headers: {
|
|
111466
|
-
"content-type": "application/json",
|
|
111467
|
-
...this.headers
|
|
111468
|
-
},
|
|
111469
|
-
body
|
|
111470
|
-
},
|
|
111471
|
-
{ allowLocalEndpoints: this.allowLocal, timeoutMs: 1e4 }
|
|
111472
|
-
);
|
|
111473
|
-
if (res.status === 401 && this.authProvider) {
|
|
111474
|
-
try {
|
|
111475
|
-
const failedAuth = this.headers["authorization"];
|
|
111476
|
-
const failedToken = failedAuth?.startsWith("Bearer ") ? failedAuth.slice(7) : void 0;
|
|
111477
|
-
const currentTokens = await this.authProvider.tokens();
|
|
111478
|
-
let newAccessToken;
|
|
111479
|
-
if (failedToken && currentTokens?.access_token && currentTokens.access_token !== failedToken) {
|
|
111480
|
-
newAccessToken = currentTokens.access_token;
|
|
111481
|
-
} else {
|
|
111482
|
-
const refreshed = await this.authProvider.refreshAccessToken(
|
|
111483
|
-
this.authProvider.expectedIssuer ?? this.endpoint,
|
|
111484
|
-
void 0,
|
|
111485
|
-
failedToken
|
|
111486
|
-
);
|
|
111487
|
-
newAccessToken = refreshed.access_token;
|
|
111488
|
-
}
|
|
111489
|
-
this.headers["authorization"] = `Bearer ${newAccessToken}`;
|
|
111490
|
-
res = await safeFetch(
|
|
111491
|
-
this.endpoint,
|
|
111492
|
-
{
|
|
111493
|
-
method: "POST",
|
|
111494
|
-
headers: {
|
|
111495
|
-
"content-type": "application/json",
|
|
111496
|
-
...this.headers
|
|
111497
|
-
},
|
|
111498
|
-
body
|
|
111499
|
-
},
|
|
111500
|
-
{ allowLocalEndpoints: this.allowLocal, timeoutMs: 1e4 }
|
|
111501
|
-
);
|
|
111502
|
-
} catch (refreshErr) {
|
|
111503
|
-
const authErr = new Error(
|
|
111504
|
-
refreshErr instanceof Error ? refreshErr.message : "Reauthorization required"
|
|
111505
|
-
);
|
|
111506
|
-
authErr.code = "UNAUTHORIZED";
|
|
111507
|
-
throw authErr;
|
|
111508
|
-
}
|
|
111509
|
-
}
|
|
111510
|
-
if (res.status === 401 || res.status === 403) {
|
|
111511
|
-
const err = new Error(`Authentication failure: HTTP ${res.status}`);
|
|
111512
|
-
err.code = "UNAUTHORIZED";
|
|
111513
|
-
throw err;
|
|
111514
|
-
}
|
|
111515
|
-
if (!res.ok) {
|
|
111516
|
-
const errorText = await readBoundedResponseBody(res, 64 * 1024);
|
|
111517
|
-
throw new Error(`HTTP ${res.status}: ${errorText}`);
|
|
111518
|
-
}
|
|
111519
|
-
const rawBody = await readBoundedResponseBody(res, 2 * 1024 * 1024);
|
|
111520
|
-
const json2 = JSON.parse(rawBody);
|
|
111521
|
-
if (json2.error) {
|
|
111522
|
-
throw new Error(`MCP Error ${json2.error.code}: ${json2.error.message}`);
|
|
111523
|
-
}
|
|
111524
|
-
return json2.result;
|
|
111525
|
-
}
|
|
111526
|
-
async initialize() {
|
|
111527
|
-
const result = await this.rpc("initialize", {
|
|
111528
|
-
protocolVersion: "2024-11-05",
|
|
111529
|
-
clientInfo: { name: "mrrlin", version: "1.0.0" },
|
|
111530
|
-
capabilities: {}
|
|
111531
|
-
});
|
|
111532
|
-
try {
|
|
111533
|
-
await safeFetch(
|
|
111534
|
-
this.endpoint,
|
|
111535
|
-
{
|
|
111536
|
-
method: "POST",
|
|
111537
|
-
headers: {
|
|
111538
|
-
"content-type": "application/json",
|
|
111539
|
-
...this.headers
|
|
111540
|
-
},
|
|
111541
|
-
body: JSON.stringify({
|
|
111542
|
-
jsonrpc: "2.0",
|
|
111543
|
-
method: "notifications/initialized",
|
|
111544
|
-
params: {}
|
|
111545
|
-
})
|
|
111546
|
-
},
|
|
111547
|
-
{ allowLocalEndpoints: this.allowLocal }
|
|
111548
|
-
);
|
|
111549
|
-
} catch {
|
|
111550
|
-
}
|
|
111551
|
-
return result;
|
|
111552
|
-
}
|
|
111553
|
-
async listTools() {
|
|
111554
|
-
const result = await this.rpc("tools/list", {});
|
|
111555
|
-
return result?.tools ?? [];
|
|
111556
|
-
}
|
|
111557
|
-
async callTool(name, args) {
|
|
111558
|
-
const result = await this.rpc("tools/call", { name, arguments: args });
|
|
111559
|
-
return result;
|
|
111560
|
-
}
|
|
111561
|
-
async close() {
|
|
111562
|
-
}
|
|
111563
|
-
};
|
|
111564
|
-
var StdioMcpClient = class {
|
|
111565
|
-
command;
|
|
111566
|
-
args;
|
|
111567
|
-
env;
|
|
111568
|
-
process = null;
|
|
111569
|
-
messageId = 1;
|
|
111570
|
-
pending = /* @__PURE__ */ new Map();
|
|
111571
|
-
rl = null;
|
|
111572
|
-
constructor(command, args = [], env = {}) {
|
|
111573
|
-
this.command = command;
|
|
111574
|
-
this.args = args;
|
|
111575
|
-
this.env = env;
|
|
111576
|
-
}
|
|
111577
|
-
ensureProcess() {
|
|
111578
|
-
if (this.process && this.process.exitCode === null) {
|
|
111579
|
-
return this.process;
|
|
111580
|
-
}
|
|
111581
|
-
const mergedEnv = {
|
|
111582
|
-
...process.env,
|
|
111583
|
-
...this.env
|
|
111584
|
-
};
|
|
111585
|
-
const child = (0, import_node_child_process26.spawn)(this.command, this.args, {
|
|
111586
|
-
env: mergedEnv,
|
|
111587
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
111588
|
-
});
|
|
111589
|
-
child.on("error", (err) => {
|
|
111590
|
-
for (const handler of this.pending.values()) {
|
|
111591
|
-
handler.reject(err);
|
|
111592
|
-
}
|
|
111593
|
-
this.pending.clear();
|
|
111594
|
-
});
|
|
111595
|
-
child.on("exit", (code) => {
|
|
111596
|
-
const err = new Error(`Process exited with code ${code}`);
|
|
111597
|
-
for (const handler of this.pending.values()) {
|
|
111598
|
-
handler.reject(err);
|
|
111599
|
-
}
|
|
111600
|
-
this.pending.clear();
|
|
111601
|
-
});
|
|
111602
|
-
if (child.stdout) {
|
|
111603
|
-
this.rl = import_node_readline2.default.createInterface({ input: child.stdout });
|
|
111604
|
-
this.rl.on("line", (line) => {
|
|
111605
|
-
const trimmed = line.trim();
|
|
111606
|
-
if (!trimmed || !trimmed.startsWith("{")) return;
|
|
111607
|
-
try {
|
|
111608
|
-
const json2 = JSON.parse(trimmed);
|
|
111609
|
-
const handler = json2.id !== void 0 ? this.pending.get(json2.id) : void 0;
|
|
111610
|
-
if (handler) {
|
|
111611
|
-
this.pending.delete(json2.id);
|
|
111612
|
-
if (json2.error) {
|
|
111613
|
-
handler.reject(new Error(`MCP Error ${json2.error.code}: ${json2.error.message}`));
|
|
111614
|
-
} else {
|
|
111615
|
-
handler.resolve(json2.result);
|
|
111616
|
-
}
|
|
111617
|
-
}
|
|
111618
|
-
} catch {
|
|
111619
|
-
}
|
|
111620
|
-
});
|
|
111621
|
-
}
|
|
111622
|
-
this.process = child;
|
|
111623
|
-
return child;
|
|
111624
|
-
}
|
|
111625
|
-
async rpc(method, params) {
|
|
111626
|
-
const child = this.ensureProcess();
|
|
111627
|
-
const id = this.messageId++;
|
|
111628
|
-
const payload = JSON.stringify({
|
|
111629
|
-
jsonrpc: "2.0",
|
|
111630
|
-
id,
|
|
111631
|
-
method,
|
|
111632
|
-
params: params ?? {}
|
|
111633
|
-
});
|
|
111634
|
-
return new Promise((resolve3, reject) => {
|
|
111635
|
-
this.pending.set(id, { resolve: resolve3, reject });
|
|
111636
|
-
child.stdin?.write(`${payload}
|
|
111637
|
-
`);
|
|
111638
|
-
});
|
|
111639
|
-
}
|
|
111640
|
-
async initialize() {
|
|
111641
|
-
const result = await this.rpc("initialize", {
|
|
111642
|
-
protocolVersion: "2024-11-05",
|
|
111643
|
-
clientInfo: { name: "mrrlin", version: "1.0.0" },
|
|
111644
|
-
capabilities: {}
|
|
111645
|
-
});
|
|
111646
|
-
const child = this.ensureProcess();
|
|
111647
|
-
child.stdin?.write(
|
|
111648
|
-
`${JSON.stringify({
|
|
111649
|
-
jsonrpc: "2.0",
|
|
111650
|
-
method: "notifications/initialized",
|
|
111651
|
-
params: {}
|
|
111652
|
-
})}
|
|
111653
|
-
`
|
|
111654
|
-
);
|
|
111655
|
-
return result;
|
|
111656
|
-
}
|
|
111657
|
-
async listTools() {
|
|
111658
|
-
const result = await this.rpc("tools/list", {});
|
|
111659
|
-
return result?.tools ?? [];
|
|
111660
|
-
}
|
|
111661
|
-
async callTool(name, args) {
|
|
111662
|
-
const result = await this.rpc("tools/call", { name, arguments: args });
|
|
111663
|
-
return result;
|
|
111664
|
-
}
|
|
111665
|
-
async close() {
|
|
111666
|
-
if (this.rl) {
|
|
111667
|
-
this.rl.close();
|
|
111668
|
-
this.rl = null;
|
|
111669
|
-
}
|
|
111670
|
-
if (this.process && this.process.exitCode === null) {
|
|
111671
|
-
this.process.kill("SIGTERM");
|
|
111672
|
-
await new Promise((r) => setTimeout(r, 100));
|
|
111673
|
-
if (this.process.exitCode === null) {
|
|
111674
|
-
this.process.kill("SIGKILL");
|
|
111675
|
-
}
|
|
111676
|
-
this.process = null;
|
|
111677
|
-
}
|
|
111678
|
-
}
|
|
111679
|
-
};
|
|
111680
|
-
async function createMcpClientForTarget(target, options) {
|
|
111681
|
-
if (target.kind === "managed") {
|
|
111682
|
-
const conn = target.connection;
|
|
111683
|
-
let resolvedSecrets = {};
|
|
111684
|
-
if (conn.inputRefs && Object.keys(conn.inputRefs).length > 0 && target.store) {
|
|
111685
|
-
const resolved = await target.store.resolveConnection(conn.id);
|
|
111686
|
-
resolvedSecrets = resolved.secrets;
|
|
111687
|
-
}
|
|
111688
|
-
if (conn.transport === "streamable_http") {
|
|
111689
|
-
if (!conn.endpoint) throw new Error("Missing endpoint for http connection");
|
|
111690
|
-
let isServerHostLocal = false;
|
|
111691
|
-
try {
|
|
111692
|
-
const parsedEndpoint = new URL(conn.endpoint);
|
|
111693
|
-
isServerHostLocal = parsedEndpoint.hostname === "localhost" || parsedEndpoint.hostname === "127.0.0.1" || parsedEndpoint.hostname === "::1" || parsedEndpoint.hostname === "[::1]";
|
|
111694
|
-
} catch {
|
|
111695
|
-
}
|
|
111696
|
-
const effectiveAllowLocal = Boolean(options?.allowLocalEndpoints) && isServerHostLocal && (process.env.NODE_ENV !== "production" || process.env.MRRLIN_ALLOW_LOCAL_ENDPOINTS === "1");
|
|
111697
|
-
let authProvider;
|
|
111698
|
-
if (target.store && target.store.isVaultUnlocked()) {
|
|
111699
|
-
try {
|
|
111700
|
-
const authGen = conn.authorizationGeneration ?? 1;
|
|
111701
|
-
const mapping = await target.store.getOAuthResourceMapping(conn.id, authGen).catch(() => void 0);
|
|
111702
|
-
const queryResource = mapping?.resource ?? conn.endpoint;
|
|
111703
|
-
const existingTokens = await target.store.getOAuthTokens({
|
|
111704
|
-
connectionId: conn.id,
|
|
111705
|
-
authorizationGeneration: authGen,
|
|
111706
|
-
resource: queryResource,
|
|
111707
|
-
issuer: mapping?.issuer
|
|
111708
|
-
});
|
|
111709
|
-
if (existingTokens) {
|
|
111710
|
-
const expectedResource = existingTokens.resource ?? mapping?.resource ?? conn.endpoint;
|
|
111711
|
-
const tokenOrigin = new URL(expectedResource).origin;
|
|
111712
|
-
const connOrigin = new URL(conn.endpoint).origin;
|
|
111713
|
-
if (tokenOrigin === connOrigin) {
|
|
111714
|
-
authProvider = new MrrlinOAuthClientProvider({
|
|
111715
|
-
store: target.store,
|
|
111716
|
-
connectionId: conn.id,
|
|
111717
|
-
authorizationGeneration: authGen,
|
|
111718
|
-
expectedIssuer: existingTokens.issuer ?? mapping?.issuer,
|
|
111719
|
-
expectedResource,
|
|
111720
|
-
allowLocalEndpoints: effectiveAllowLocal
|
|
111721
|
-
});
|
|
111722
|
-
}
|
|
111723
|
-
}
|
|
111724
|
-
} catch {
|
|
111725
|
-
}
|
|
111726
|
-
}
|
|
111727
|
-
return new HttpMcpClient(
|
|
111728
|
-
conn.endpoint,
|
|
111729
|
-
resolvedSecrets,
|
|
111730
|
-
effectiveAllowLocal,
|
|
111731
|
-
authProvider
|
|
111732
|
-
);
|
|
111733
|
-
}
|
|
111734
|
-
if (conn.transport === "stdio") {
|
|
111735
|
-
if (!conn.command) throw new Error("Missing command for stdio connection");
|
|
111736
|
-
return new StdioMcpClient(conn.command, conn.args ?? [], resolvedSecrets);
|
|
111737
|
-
}
|
|
111738
|
-
throw new Error(`Unsupported transport: ${conn.transport}`);
|
|
111739
|
-
}
|
|
111740
|
-
const srv = target.server;
|
|
111741
|
-
if (srv.transport === "http") {
|
|
111742
|
-
return new HttpMcpClient(srv.url, srv.headers ?? {}, options?.allowLocalEndpoints ?? false);
|
|
111743
|
-
}
|
|
111744
|
-
if (srv.transport === "stdio") {
|
|
111745
|
-
return new StdioMcpClient(srv.command, srv.args ?? [], srv.env ?? {});
|
|
111746
|
-
}
|
|
111747
|
-
throw new Error(`Unsupported legacy server transport: ${srv.transport}`);
|
|
111748
|
-
}
|
|
111749
|
-
async function probeConnection(client, timeoutMs = 1e4) {
|
|
111750
|
-
const startTime = Date.now();
|
|
111751
|
-
const timer = setTimeout(() => {
|
|
111752
|
-
client.close().catch(() => {
|
|
111753
|
-
});
|
|
111754
|
-
}, timeoutMs);
|
|
111755
|
-
try {
|
|
111756
|
-
const init = await client.initialize();
|
|
111757
|
-
const tools = await client.listTools();
|
|
111758
|
-
const latencyMs = Date.now() - startTime;
|
|
111759
|
-
return {
|
|
111760
|
-
ok: true,
|
|
111761
|
-
state: "ready",
|
|
111762
|
-
serverInfo: init.serverInfo,
|
|
111763
|
-
tools,
|
|
111764
|
-
latencyMs
|
|
111765
|
-
};
|
|
111766
|
-
} catch (err) {
|
|
111767
|
-
const code = err?.code ?? "PROBE_FAILED";
|
|
111768
|
-
const msg = err?.message ?? String(err);
|
|
111769
|
-
const state = code === "UNAUTHORIZED" ? "needs_auth" : "probe_failed";
|
|
111770
|
-
return {
|
|
111771
|
-
ok: false,
|
|
111772
|
-
state,
|
|
111773
|
-
error: {
|
|
111774
|
-
code,
|
|
111775
|
-
message: msg
|
|
111776
|
-
}
|
|
111777
|
-
};
|
|
111778
|
-
} finally {
|
|
111779
|
-
clearTimeout(timer);
|
|
111780
|
-
await client.close().catch(() => {
|
|
111781
|
-
});
|
|
111782
|
-
}
|
|
111783
|
-
}
|
|
111784
|
-
|
|
111785
112530
|
// src/connections/install-plan.ts
|
|
111786
112531
|
var SHELL_METASYMBOLS = /[;&|><$`\\]/;
|
|
111787
112532
|
function isSafeCommandName(command) {
|
|
@@ -112094,7 +112839,7 @@ init_install_public_mcp();
|
|
|
112094
112839
|
|
|
112095
112840
|
// src/connections/oauth-callback.ts
|
|
112096
112841
|
var import_node_http3 = __toESM(require("node:http"), 1);
|
|
112097
|
-
var
|
|
112842
|
+
var import_node_crypto31 = __toESM(require("node:crypto"), 1);
|
|
112098
112843
|
var activeFlowsByConnectionId = /* @__PURE__ */ new Map();
|
|
112099
112844
|
function getOAuthFlow(connectionId) {
|
|
112100
112845
|
return activeFlowsByConnectionId.get(connectionId);
|
|
@@ -112118,7 +112863,7 @@ async function startOAuthFlow(options) {
|
|
|
112118
112863
|
authorizationGeneration: options.authorizationGeneration ?? 1
|
|
112119
112864
|
});
|
|
112120
112865
|
}
|
|
112121
|
-
const flowId =
|
|
112866
|
+
const flowId = import_node_crypto31.default.randomUUID();
|
|
112122
112867
|
const timeoutMs = options.timeoutMs ?? 10 * 60 * 1e3;
|
|
112123
112868
|
const createdAt = Date.now();
|
|
112124
112869
|
const expiresAt = createdAt + timeoutMs;
|
|
@@ -112777,6 +113522,18 @@ async function handleIntegrationRpc(deps, msg) {
|
|
|
112777
113522
|
};
|
|
112778
113523
|
}
|
|
112779
113524
|
}
|
|
113525
|
+
const secRel = secretsToSave?.releaseToken ?? secretsToSave?.release_token ?? secretsToSave?.RELEASE_TOKEN;
|
|
113526
|
+
const secObs = secretsToSave?.observeToken ?? secretsToSave?.observe_token ?? secretsToSave?.OBSERVE_TOKEN;
|
|
113527
|
+
if (secRel && secObs && secRel === secObs) {
|
|
113528
|
+
return {
|
|
113529
|
+
requestId,
|
|
113530
|
+
ok: false,
|
|
113531
|
+
error: {
|
|
113532
|
+
code: "invalid_input",
|
|
113533
|
+
message: "Identical token values rejected: release and observe credentials must be distinct bearer tokens"
|
|
113534
|
+
}
|
|
113535
|
+
};
|
|
113536
|
+
}
|
|
112780
113537
|
try {
|
|
112781
113538
|
const saved = await deps.store.upsertConnection(
|
|
112782
113539
|
{
|
|
@@ -112848,6 +113605,18 @@ async function handleIntegrationRpc(deps, msg) {
|
|
|
112848
113605
|
const explicitHeaders = targetRaw.headers ?? {};
|
|
112849
113606
|
const secretHeaders = targetRaw.secrets ?? {};
|
|
112850
113607
|
const headers = { ...explicitHeaders, ...secretHeaders };
|
|
113608
|
+
const pRel = secretHeaders?.releaseToken ?? secretHeaders?.release_token ?? secretHeaders?.RELEASE_TOKEN;
|
|
113609
|
+
const pObs = secretHeaders?.observeToken ?? secretHeaders?.observe_token ?? secretHeaders?.OBSERVE_TOKEN;
|
|
113610
|
+
if (pRel && pObs && pRel === pObs) {
|
|
113611
|
+
return {
|
|
113612
|
+
requestId,
|
|
113613
|
+
ok: false,
|
|
113614
|
+
error: {
|
|
113615
|
+
code: "invalid_input",
|
|
113616
|
+
message: "Identical token values rejected: release and observe credentials must be distinct bearer tokens"
|
|
113617
|
+
}
|
|
113618
|
+
};
|
|
113619
|
+
}
|
|
112851
113620
|
const endpointExposureErr = detectSecretExposureInEndpoint(endpoint, Object.values(secretHeaders));
|
|
112852
113621
|
if (endpointExposureErr) {
|
|
112853
113622
|
return {
|
|
@@ -117510,13 +118279,13 @@ var import_node_dns3 = __toESM(require("node:dns"), 1);
|
|
|
117510
118279
|
// src/verification-broker.ts
|
|
117511
118280
|
var import_node_http4 = __toESM(require("node:http"), 1);
|
|
117512
118281
|
var import_node_https3 = __toESM(require("node:https"), 1);
|
|
117513
|
-
var
|
|
118282
|
+
var import_node_net7 = __toESM(require("node:net"), 1);
|
|
117514
118283
|
var import_node_tls = __toESM(require("node:tls"), 1);
|
|
117515
118284
|
var import_node_fs32 = __toESM(require("node:fs"), 1);
|
|
117516
118285
|
var import_node_os24 = __toESM(require("node:os"), 1);
|
|
117517
118286
|
var import_node_path47 = __toESM(require("node:path"), 1);
|
|
117518
|
-
var
|
|
117519
|
-
var
|
|
118287
|
+
var import_node_crypto32 = __toESM(require("node:crypto"), 1);
|
|
118288
|
+
var import_node_zlib2 = __toESM(require("node:zlib"), 1);
|
|
117520
118289
|
|
|
117521
118290
|
// src/verification-egress-policy.ts
|
|
117522
118291
|
var import_promises23 = __toESM(require("node:dns/promises"), 1);
|
|
@@ -117872,7 +118641,7 @@ function createBrokerSocketPath(runId, nonce, baseDirs = process.platform === "w
|
|
|
117872
118641
|
throw new Error(`BROKER_SOCKET_ERROR: no temp directory gives a socket path within ${MAX_UNIX_SOCKET_PATH_BYTES} bytes`);
|
|
117873
118642
|
}
|
|
117874
118643
|
async function createVerificationBrokerSession(options) {
|
|
117875
|
-
const nonce =
|
|
118644
|
+
const nonce = import_node_crypto32.default.randomBytes(16).toString("hex");
|
|
117876
118645
|
let createdDir = null;
|
|
117877
118646
|
let socketPath = options.socketPath;
|
|
117878
118647
|
if (!socketPath) {
|
|
@@ -117997,7 +118766,7 @@ async function createVerificationBrokerSession(options) {
|
|
|
117997
118766
|
let stream = res;
|
|
117998
118767
|
const encoding = resHeaders["content-encoding"]?.toLowerCase();
|
|
117999
118768
|
if (encoding === "gzip" || encoding === "deflate") {
|
|
118000
|
-
const decompressor = encoding === "gzip" ?
|
|
118769
|
+
const decompressor = encoding === "gzip" ? import_node_zlib2.default.createGunzip() : import_node_zlib2.default.createInflate();
|
|
118001
118770
|
let decompressedBytes = 0;
|
|
118002
118771
|
decompressor.on("data", (chunk) => {
|
|
118003
118772
|
decompressedBytes += chunk.length;
|
|
@@ -118159,7 +118928,7 @@ async function createVerificationBrokerSession(options) {
|
|
|
118159
118928
|
});
|
|
118160
118929
|
let clientSocket;
|
|
118161
118930
|
try {
|
|
118162
|
-
clientSocket =
|
|
118931
|
+
clientSocket = import_node_net7.default.connect(socketPath);
|
|
118163
118932
|
await new Promise((resolve3, reject) => {
|
|
118164
118933
|
clientSocket.on("connect", () => resolve3());
|
|
118165
118934
|
clientSocket.on("error", reject);
|
|
@@ -119174,9 +119943,9 @@ function readCodexFallbackModels() {
|
|
|
119174
119943
|
return [...models.values()];
|
|
119175
119944
|
}
|
|
119176
119945
|
function selfUpdateInboxItemId(offeredVersion) {
|
|
119177
|
-
if (!offeredVersion) return `II-MCPUPD-${(0,
|
|
119946
|
+
if (!offeredVersion) return `II-MCPUPD-${(0, import_node_crypto33.randomUUID)()}`;
|
|
119178
119947
|
if (/^[A-Za-z0-9._-]+$/.test(offeredVersion)) return `II-MCPUPD-${offeredVersion}`;
|
|
119179
|
-
const hash3 =
|
|
119948
|
+
const hash3 = import_node_crypto33.default.createHash("sha256").update(offeredVersion).digest("hex").slice(0, 10);
|
|
119180
119949
|
return `II-MCPUPD-${offeredVersion.replace(/[^A-Za-z0-9._-]/g, "-")}-${hash3}`;
|
|
119181
119950
|
}
|
|
119182
119951
|
function neutralCheckoutCwd(stateDir) {
|
|
@@ -119845,7 +120614,7 @@ async function recoverSingleLanding(client, checkoutPath, projectSlug, runId, re
|
|
|
119845
120614
|
return false;
|
|
119846
120615
|
}
|
|
119847
120616
|
const checkoutRealPath = import_node_fs35.default.realpathSync(checkoutPath);
|
|
119848
|
-
const currentCheckoutDigest =
|
|
120617
|
+
const currentCheckoutDigest = import_node_crypto33.default.createHash("sha256").update(checkoutRealPath).digest("hex");
|
|
119849
120618
|
if (git3.checkout_digest !== currentCheckoutDigest) {
|
|
119850
120619
|
return false;
|
|
119851
120620
|
}
|
|
@@ -120066,7 +120835,7 @@ function createBridgeRequestListener(opts) {
|
|
|
120066
120835
|
res.end(JSON.stringify({ ok: false, error: "Origin not allowed." }));
|
|
120067
120836
|
return;
|
|
120068
120837
|
}
|
|
120069
|
-
const nonce =
|
|
120838
|
+
const nonce = import_node_crypto33.default.randomBytes(16).toString("base64url");
|
|
120070
120839
|
res.writeHead(200, { "content-type": "application/json" });
|
|
120071
120840
|
const publicHost = host === "0.0.0.0" ? "127.0.0.1" : host;
|
|
120072
120841
|
res.end(JSON.stringify({ ok: true, wsUrl: `ws://${publicHost}:${port}/ws`, token, nonce }));
|
|
@@ -120362,7 +121131,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
120362
121131
|
}
|
|
120363
121132
|
}
|
|
120364
121133
|
socket.on("message", async (data) => {
|
|
120365
|
-
const spanId =
|
|
121134
|
+
const spanId = import_node_crypto33.default.randomUUID();
|
|
120366
121135
|
if (logCtx) {
|
|
120367
121136
|
logCtx.span.id = spanId;
|
|
120368
121137
|
logCtx.span.at = Date.now();
|
|
@@ -120843,7 +121612,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
120843
121612
|
let desiredInstructionHash = null;
|
|
120844
121613
|
try {
|
|
120845
121614
|
const startParams = deps.buildStartParams(msg, desiredModel);
|
|
120846
|
-
desiredInstructionHash =
|
|
121615
|
+
desiredInstructionHash = import_node_crypto33.default.createHash("sha256").update(startParams.baseInstructions ?? "").digest("hex");
|
|
120847
121616
|
if (!thread) {
|
|
120848
121617
|
const newThread = {
|
|
120849
121618
|
threadId: "",
|
|
@@ -120927,7 +121696,7 @@ function createBridgeMessageHandler(deps) {
|
|
|
120927
121696
|
thread.inFlight = true;
|
|
120928
121697
|
pendingTurnSessions.delete(directorSessionId);
|
|
120929
121698
|
thread.replay = createReplayBuffer({
|
|
120930
|
-
turnId: (0,
|
|
121699
|
+
turnId: (0, import_node_crypto33.randomUUID)(),
|
|
120931
121700
|
spanId,
|
|
120932
121701
|
...deps.retentionMs !== void 0 ? { retentionMs: deps.retentionMs } : {},
|
|
120933
121702
|
...deps.ackLingerMs !== void 0 ? { ackLingerMs: deps.ackLingerMs } : {}
|
|
@@ -121896,6 +122665,7 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
|
|
|
121896
122665
|
await schedulerGenerations?.dispose();
|
|
121897
122666
|
throw new Error("BRIDGE_COMPACT_HEARTBEAT_START_FAILED");
|
|
121898
122667
|
}
|
|
122668
|
+
if (!compactHeartbeatShutdown) throw new Error("Missing compactHeartbeatShutdown");
|
|
121899
122669
|
const lifetime = compactHeartbeatShutdown.signal;
|
|
121900
122670
|
const execution = heartbeat.touchExecutionRunLease.bind(heartbeat);
|
|
121901
122671
|
const asyncJob = heartbeat.touchAsyncJobLease.bind(heartbeat);
|
|
@@ -122068,7 +122838,7 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
|
|
|
122068
122838
|
};
|
|
122069
122839
|
const sessionSinks = createSessionSinkRegistry();
|
|
122070
122840
|
const tombstones = /* @__PURE__ */ new Map();
|
|
122071
|
-
const bridgeInstanceId = (0,
|
|
122841
|
+
const bridgeInstanceId = (0, import_node_crypto33.randomUUID)();
|
|
122072
122842
|
const boundReviewProject = process.env.MRRLIN_F37_REVIEW_WORKER_PROJECT?.trim();
|
|
122073
122843
|
const boundReviewSecret = process.env.MRRLIN_F37_REVIEW_WORKER_SECRET?.trim();
|
|
122074
122844
|
const boundReviewProvider = boundReviewProject && boundReviewSecret ? createAgentTokenProvider({ secret: boundReviewSecret, baseUrl: apiBaseUrl }) : void 0;
|
|
@@ -122430,7 +123200,7 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
|
|
|
122430
123200
|
const bridgeLogger = createBridgeLogger(config2.stateDir, process.env);
|
|
122431
123201
|
let bridgeBinShaShort = "unknown00000";
|
|
122432
123202
|
try {
|
|
122433
|
-
bridgeBinShaShort =
|
|
123203
|
+
bridgeBinShaShort = import_node_crypto33.default.createHash("sha256").update(import_node_fs35.default.readFileSync(process.argv[1] ?? "")).digest("hex").slice(0, 12);
|
|
122434
123204
|
} catch {
|
|
122435
123205
|
}
|
|
122436
123206
|
const bridgeWss = attachBridgeWss(server, {
|
|
@@ -122936,7 +123706,7 @@ function timingSafeTokenEqual(provided, expected) {
|
|
|
122936
123706
|
const a = Buffer.from(provided);
|
|
122937
123707
|
const b = Buffer.from(expected);
|
|
122938
123708
|
if (a.length !== b.length) return false;
|
|
122939
|
-
return
|
|
123709
|
+
return import_node_crypto33.default.timingSafeEqual(a, b);
|
|
122940
123710
|
}
|
|
122941
123711
|
function createWorkerDispatchListener(workerToken, driveRunNow, driveAsyncNow, shutdown) {
|
|
122942
123712
|
return (req, res) => {
|
|
@@ -123008,7 +123778,7 @@ function readOrCreateBridgeToken(stateDir) {
|
|
|
123008
123778
|
} catch {
|
|
123009
123779
|
}
|
|
123010
123780
|
import_node_fs35.default.mkdirSync(stateDir, { recursive: true, mode: 448 });
|
|
123011
|
-
const token =
|
|
123781
|
+
const token = import_node_crypto33.default.randomBytes(32).toString("base64url");
|
|
123012
123782
|
import_node_fs35.default.writeFileSync(tokenPath, `${token}
|
|
123013
123783
|
`, { mode: 384 });
|
|
123014
123784
|
return token;
|