mindforge-mcp-server 11.9.5 → 11.9.6
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/README.md +2 -1
- package/dist/index.js +734 -262
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3112,7 +3112,25 @@ var require_utils = __commonJS({
|
|
|
3112
3112
|
var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
3113
3113
|
var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
|
|
3114
3114
|
var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
|
|
3115
|
-
var isPathCharacter = RegExp.prototype.test.bind(/^[
|
|
3115
|
+
var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
|
|
3116
|
+
var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);
|
|
3117
|
+
var isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);
|
|
3118
|
+
var BYTE_HEX = new Array(256);
|
|
3119
|
+
{
|
|
3120
|
+
const HEX_DIGITS = "0123456789ABCDEF";
|
|
3121
|
+
for (let i = 0; i < 256; i++) {
|
|
3122
|
+
BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
|
|
3123
|
+
}
|
|
3124
|
+
}
|
|
3125
|
+
function percentEncodeNonAscii(cp) {
|
|
3126
|
+
if (cp < 2048) {
|
|
3127
|
+
return BYTE_HEX[192 | cp >> 6] + BYTE_HEX[128 | cp & 63];
|
|
3128
|
+
}
|
|
3129
|
+
if (cp < 65536) {
|
|
3130
|
+
return BYTE_HEX[224 | cp >> 12] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
|
|
3131
|
+
}
|
|
3132
|
+
return BYTE_HEX[240 | cp >> 18] + BYTE_HEX[128 | cp >> 12 & 63] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
|
|
3133
|
+
}
|
|
3116
3134
|
function stringArrayToHexStripped(input) {
|
|
3117
3135
|
let acc = "";
|
|
3118
3136
|
let code = 0;
|
|
@@ -3137,91 +3155,105 @@ var require_utils = __commonJS({
|
|
|
3137
3155
|
}
|
|
3138
3156
|
return acc;
|
|
3139
3157
|
}
|
|
3158
|
+
var isHextet = RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/);
|
|
3159
|
+
var isIPvFuture = RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/);
|
|
3160
|
+
var isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/);
|
|
3140
3161
|
var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
|
|
3141
|
-
function
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
if (hex !== "") {
|
|
3149
|
-
address.push(hex);
|
|
3150
|
-
} else {
|
|
3151
|
-
output.error = true;
|
|
3152
|
-
return false;
|
|
3162
|
+
function isZoneIdentifier(zone) {
|
|
3163
|
+
if (zone.length === 0) return false;
|
|
3164
|
+
for (let i = 0; i < zone.length; i++) {
|
|
3165
|
+
if (isZoneCharacter(zone[i])) continue;
|
|
3166
|
+
if (zone[i] === "%" && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) {
|
|
3167
|
+
i += 2;
|
|
3168
|
+
continue;
|
|
3153
3169
|
}
|
|
3154
|
-
|
|
3170
|
+
return false;
|
|
3155
3171
|
}
|
|
3156
3172
|
return true;
|
|
3157
3173
|
}
|
|
3158
|
-
function
|
|
3159
|
-
let
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
let
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
}
|
|
3171
|
-
if (cursor === ":") {
|
|
3172
|
-
if (endipv6Encountered === true) {
|
|
3173
|
-
endIpv6 = true;
|
|
3174
|
-
}
|
|
3175
|
-
if (!consume(buffer, address, output)) {
|
|
3176
|
-
break;
|
|
3177
|
-
}
|
|
3178
|
-
if (++tokenCount > 7) {
|
|
3179
|
-
output.error = true;
|
|
3180
|
-
break;
|
|
3181
|
-
}
|
|
3182
|
-
if (i > 0 && input[i - 1] === ":") {
|
|
3183
|
-
endipv6Encountered = true;
|
|
3174
|
+
function compressIPv6ZeroRun(hextets) {
|
|
3175
|
+
let bestStart = -1;
|
|
3176
|
+
let bestLength = 0;
|
|
3177
|
+
let runStart = -1;
|
|
3178
|
+
let runLength = 0;
|
|
3179
|
+
for (let i = 0; i < hextets.length; i++) {
|
|
3180
|
+
if (hextets[i] === "0") {
|
|
3181
|
+
if (runStart === -1) runStart = i;
|
|
3182
|
+
runLength++;
|
|
3183
|
+
if (runLength > bestLength) {
|
|
3184
|
+
bestLength = runLength;
|
|
3185
|
+
bestStart = runStart;
|
|
3184
3186
|
}
|
|
3185
|
-
address.push(":");
|
|
3186
|
-
continue;
|
|
3187
|
-
} else if (cursor === "%") {
|
|
3188
|
-
if (!consume(buffer, address, output)) {
|
|
3189
|
-
break;
|
|
3190
|
-
}
|
|
3191
|
-
consume = consumeIsZone;
|
|
3192
3187
|
} else {
|
|
3193
|
-
|
|
3188
|
+
runStart = -1;
|
|
3189
|
+
runLength = 0;
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
if (bestLength < 2) return hextets.join(":");
|
|
3193
|
+
const head = hextets.slice(0, bestStart).join(":");
|
|
3194
|
+
const tail = hextets.slice(bestStart + bestLength).join(":");
|
|
3195
|
+
return head + "::" + tail;
|
|
3196
|
+
}
|
|
3197
|
+
function normalizeIPv6Address(input) {
|
|
3198
|
+
const compression = input.indexOf("::");
|
|
3199
|
+
if (compression !== -1 && input.indexOf("::", compression + 1) !== -1) return void 0;
|
|
3200
|
+
const left = compression === -1 ? input.split(":") : input.slice(0, compression).split(":");
|
|
3201
|
+
const right = compression === -1 ? [] : input.slice(compression + 2).split(":");
|
|
3202
|
+
if (compression !== -1) {
|
|
3203
|
+
if (left.length === 1 && left[0] === "") left.length = 0;
|
|
3204
|
+
if (right.length === 1 && right[0] === "") right.length = 0;
|
|
3205
|
+
}
|
|
3206
|
+
const parts = left.concat(right);
|
|
3207
|
+
let hextetCount = 0;
|
|
3208
|
+
for (let i = 0; i < parts.length; i++) {
|
|
3209
|
+
const part = parts[i];
|
|
3210
|
+
if (part === "") return void 0;
|
|
3211
|
+
if (part.indexOf(".") !== -1) {
|
|
3212
|
+
if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv4(part)) return void 0;
|
|
3213
|
+
hextetCount += 2;
|
|
3194
3214
|
continue;
|
|
3195
3215
|
}
|
|
3216
|
+
if (!isHextet(part)) return void 0;
|
|
3217
|
+
parts[i] = parseInt(part, 16).toString(16);
|
|
3218
|
+
hextetCount++;
|
|
3196
3219
|
}
|
|
3197
|
-
if (
|
|
3198
|
-
if (
|
|
3199
|
-
|
|
3200
|
-
} else if (endIpv6) {
|
|
3201
|
-
address.push(buffer.join(""));
|
|
3202
|
-
} else {
|
|
3203
|
-
address.push(stringArrayToHexStripped(buffer));
|
|
3204
|
-
}
|
|
3220
|
+
if (compression === -1) {
|
|
3221
|
+
if (hextetCount !== 8) return void 0;
|
|
3222
|
+
return compressIPv6ZeroRun(parts);
|
|
3205
3223
|
}
|
|
3206
|
-
|
|
3207
|
-
|
|
3224
|
+
if (hextetCount >= 8) return void 0;
|
|
3225
|
+
const expanded = parts.slice(0, left.length);
|
|
3226
|
+
for (let i = hextetCount; i < 8; i++) expanded.push("0");
|
|
3227
|
+
for (let i = left.length; i < parts.length; i++) expanded.push(parts[i]);
|
|
3228
|
+
return compressIPv6ZeroRun(expanded);
|
|
3208
3229
|
}
|
|
3209
3230
|
function normalizeIPv6(host) {
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
}
|
|
3213
|
-
|
|
3214
|
-
if (
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3231
|
+
const bracketed = host[0] === "[" && host[host.length - 1] === "]";
|
|
3232
|
+
const hasBracket = host[0] === "[" || host[host.length - 1] === "]";
|
|
3233
|
+
if (hasBracket && !bracketed) return { host, isIPV6: false, error: true };
|
|
3234
|
+
let input = bracketed ? host.slice(1, -1) : host;
|
|
3235
|
+
if (bracketed && isIPvFuture(input)) {
|
|
3236
|
+
input = input.toLowerCase();
|
|
3237
|
+
return { host: `[${input}]`, escapedHost: input, isIPV6: false, isIPVFuture: true };
|
|
3238
|
+
}
|
|
3239
|
+
if (findToken(input, ":") < 2) {
|
|
3240
|
+
return { host, isIPV6: false, error: bracketed };
|
|
3241
|
+
}
|
|
3242
|
+
let zoneIdentifier = "";
|
|
3243
|
+
const zoneSeparator = input.indexOf("%");
|
|
3244
|
+
if (zoneSeparator !== -1) {
|
|
3245
|
+
const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === "%25" ? 3 : 1;
|
|
3246
|
+
zoneIdentifier = input.slice(zoneSeparator + separatorLength);
|
|
3247
|
+
if (!isZoneIdentifier(zoneIdentifier)) return { host, isIPV6: false, error: true };
|
|
3248
|
+
input = input.slice(0, zoneSeparator);
|
|
3249
|
+
}
|
|
3250
|
+
const address = normalizeIPv6Address(input);
|
|
3251
|
+
if (address === void 0) return { host, isIPV6: false, error: true };
|
|
3252
|
+
return {
|
|
3253
|
+
host: address + (zoneIdentifier ? "%" + zoneIdentifier : ""),
|
|
3254
|
+
escapedHost: address + (zoneIdentifier ? "%25" + zoneIdentifier : ""),
|
|
3255
|
+
isIPV6: true
|
|
3256
|
+
};
|
|
3225
3257
|
}
|
|
3226
3258
|
function findToken(str, token) {
|
|
3227
3259
|
let ind = 0;
|
|
@@ -3230,8 +3262,8 @@ var require_utils = __commonJS({
|
|
|
3230
3262
|
}
|
|
3231
3263
|
return ind;
|
|
3232
3264
|
}
|
|
3233
|
-
function removeDotSegments(
|
|
3234
|
-
let input =
|
|
3265
|
+
function removeDotSegments(path4) {
|
|
3266
|
+
let input = path4;
|
|
3235
3267
|
const output = [];
|
|
3236
3268
|
let nextSlash = -1;
|
|
3237
3269
|
let len = 0;
|
|
@@ -3340,7 +3372,8 @@ var require_utils = __commonJS({
|
|
|
3340
3372
|
function normalizePathEncoding(input) {
|
|
3341
3373
|
let output = "";
|
|
3342
3374
|
for (let i = 0; i < input.length; i++) {
|
|
3343
|
-
|
|
3375
|
+
const ch = input[i];
|
|
3376
|
+
if (ch === "%" && i + 2 < input.length) {
|
|
3344
3377
|
const hex = input.slice(i + 1, i + 3);
|
|
3345
3378
|
if (isHexPair(hex)) {
|
|
3346
3379
|
const normalizedHex = hex.toUpperCase();
|
|
@@ -3354,10 +3387,152 @@ var require_utils = __commonJS({
|
|
|
3354
3387
|
continue;
|
|
3355
3388
|
}
|
|
3356
3389
|
}
|
|
3357
|
-
if (isPathCharacter(
|
|
3358
|
-
output +=
|
|
3390
|
+
if (isPathCharacter(ch)) {
|
|
3391
|
+
output += ch;
|
|
3392
|
+
} else {
|
|
3393
|
+
const code = input.charCodeAt(i);
|
|
3394
|
+
if (code < 128) {
|
|
3395
|
+
output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
|
|
3396
|
+
} else if (code < 55296 || code > 57343) {
|
|
3397
|
+
output += percentEncodeNonAscii(code);
|
|
3398
|
+
} else if (code <= 56319 && i + 1 < input.length) {
|
|
3399
|
+
const low = input.charCodeAt(i + 1);
|
|
3400
|
+
if (low >= 56320 && low <= 57343) {
|
|
3401
|
+
output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
|
|
3402
|
+
i++;
|
|
3403
|
+
} else {
|
|
3404
|
+
output += percentEncodeNonAscii(65533);
|
|
3405
|
+
}
|
|
3406
|
+
} else {
|
|
3407
|
+
output += percentEncodeNonAscii(65533);
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
}
|
|
3411
|
+
return output;
|
|
3412
|
+
}
|
|
3413
|
+
function serializePathEncoding(input, pathNoScheme = false) {
|
|
3414
|
+
let output = "";
|
|
3415
|
+
let firstSegment = pathNoScheme && input[0] !== "/";
|
|
3416
|
+
for (let i = 0; i < input.length; i++) {
|
|
3417
|
+
const ch = input[i];
|
|
3418
|
+
if (ch === "%" && i + 2 < input.length) {
|
|
3419
|
+
const hex = input.slice(i + 1, i + 3);
|
|
3420
|
+
if (isHexPair(hex)) {
|
|
3421
|
+
output += "%" + hex.toUpperCase();
|
|
3422
|
+
i += 2;
|
|
3423
|
+
continue;
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
if (ch === "/") {
|
|
3427
|
+
firstSegment = false;
|
|
3428
|
+
}
|
|
3429
|
+
if (isPathCharacter(ch) && (ch !== ":" || !firstSegment)) {
|
|
3430
|
+
output += ch;
|
|
3359
3431
|
} else {
|
|
3360
|
-
|
|
3432
|
+
const code = input.charCodeAt(i);
|
|
3433
|
+
if (code < 128) {
|
|
3434
|
+
output += BYTE_HEX[code];
|
|
3435
|
+
} else if (code < 55296 || code > 57343) {
|
|
3436
|
+
output += percentEncodeNonAscii(code);
|
|
3437
|
+
} else if (code <= 56319 && i + 1 < input.length) {
|
|
3438
|
+
const low = input.charCodeAt(i + 1);
|
|
3439
|
+
if (low >= 56320 && low <= 57343) {
|
|
3440
|
+
output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
|
|
3441
|
+
i++;
|
|
3442
|
+
} else {
|
|
3443
|
+
output += percentEncodeNonAscii(65533);
|
|
3444
|
+
}
|
|
3445
|
+
} else {
|
|
3446
|
+
output += percentEncodeNonAscii(65533);
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
}
|
|
3450
|
+
return output;
|
|
3451
|
+
}
|
|
3452
|
+
function encodeComponent(input, isAllowed) {
|
|
3453
|
+
let output = "";
|
|
3454
|
+
for (let i = 0; i < input.length; i++) {
|
|
3455
|
+
const ch = input[i];
|
|
3456
|
+
if (ch === "%" && i + 2 < input.length) {
|
|
3457
|
+
const hex = input.slice(i + 1, i + 3);
|
|
3458
|
+
if (isHexPair(hex)) {
|
|
3459
|
+
output += "%" + hex.toUpperCase();
|
|
3460
|
+
i += 2;
|
|
3461
|
+
continue;
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
if (isAllowed(ch)) {
|
|
3465
|
+
output += ch;
|
|
3466
|
+
} else {
|
|
3467
|
+
const code = input.charCodeAt(i);
|
|
3468
|
+
if (code < 128) {
|
|
3469
|
+
output += BYTE_HEX[code];
|
|
3470
|
+
} else if (code < 55296 || code > 57343) {
|
|
3471
|
+
output += percentEncodeNonAscii(code);
|
|
3472
|
+
} else if (code <= 56319 && i + 1 < input.length) {
|
|
3473
|
+
const low = input.charCodeAt(i + 1);
|
|
3474
|
+
if (low >= 56320 && low <= 57343) {
|
|
3475
|
+
output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
|
|
3476
|
+
i++;
|
|
3477
|
+
} else {
|
|
3478
|
+
output += percentEncodeNonAscii(65533);
|
|
3479
|
+
}
|
|
3480
|
+
} else {
|
|
3481
|
+
output += percentEncodeNonAscii(65533);
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
return output;
|
|
3486
|
+
}
|
|
3487
|
+
function encodeUserinfo(input) {
|
|
3488
|
+
return encodeComponent(input, isUserinfoCharacter);
|
|
3489
|
+
}
|
|
3490
|
+
function encodeQuery(input) {
|
|
3491
|
+
return encodeComponent(input, isQueryFragmentCharacter);
|
|
3492
|
+
}
|
|
3493
|
+
function encodeFragment(input) {
|
|
3494
|
+
return encodeComponent(input, isQueryFragmentCharacter);
|
|
3495
|
+
}
|
|
3496
|
+
function isEscapeSafe(cp) {
|
|
3497
|
+
return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 42 || cp === 43 || cp === 45 || cp === 46 || cp === 47 || cp === 64 || cp === 95;
|
|
3498
|
+
}
|
|
3499
|
+
function normalizeQueryFragmentEncoding(input) {
|
|
3500
|
+
let output = "";
|
|
3501
|
+
for (let i = 0; i < input.length; i++) {
|
|
3502
|
+
const ch = input[i];
|
|
3503
|
+
if (ch === "%" && i + 2 < input.length) {
|
|
3504
|
+
const hex = input.slice(i + 1, i + 3);
|
|
3505
|
+
if (isHexPair(hex)) {
|
|
3506
|
+
const normalizedHex = hex.toUpperCase();
|
|
3507
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
3508
|
+
if (isUnreserved(decoded)) {
|
|
3509
|
+
output += decoded;
|
|
3510
|
+
} else {
|
|
3511
|
+
output += "%" + normalizedHex;
|
|
3512
|
+
}
|
|
3513
|
+
i += 2;
|
|
3514
|
+
continue;
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3517
|
+
if (isQueryFragmentCharacter(ch)) {
|
|
3518
|
+
output += ch;
|
|
3519
|
+
} else {
|
|
3520
|
+
const code = input.charCodeAt(i);
|
|
3521
|
+
if (code < 128) {
|
|
3522
|
+
output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
|
|
3523
|
+
} else if (code < 55296 || code > 57343) {
|
|
3524
|
+
output += percentEncodeNonAscii(code);
|
|
3525
|
+
} else if (code <= 56319 && i + 1 < input.length) {
|
|
3526
|
+
const low = input.charCodeAt(i + 1);
|
|
3527
|
+
if (low >= 56320 && low <= 57343) {
|
|
3528
|
+
output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
|
|
3529
|
+
i++;
|
|
3530
|
+
} else {
|
|
3531
|
+
output += percentEncodeNonAscii(65533);
|
|
3532
|
+
}
|
|
3533
|
+
} else {
|
|
3534
|
+
output += percentEncodeNonAscii(65533);
|
|
3535
|
+
}
|
|
3361
3536
|
}
|
|
3362
3537
|
}
|
|
3363
3538
|
return output;
|
|
@@ -3380,14 +3555,18 @@ var require_utils = __commonJS({
|
|
|
3380
3555
|
function recomposeAuthority(component) {
|
|
3381
3556
|
const uriTokens = [];
|
|
3382
3557
|
if (component.userinfo !== void 0) {
|
|
3383
|
-
uriTokens.push(component.userinfo);
|
|
3558
|
+
uriTokens.push(encodeUserinfo(component.userinfo));
|
|
3384
3559
|
uriTokens.push("@");
|
|
3385
3560
|
}
|
|
3386
3561
|
if (component.host !== void 0) {
|
|
3387
|
-
let host =
|
|
3562
|
+
let host = component.host;
|
|
3388
3563
|
if (!isIPv4(host)) {
|
|
3389
|
-
|
|
3390
|
-
if (ipV6res.isIPV6
|
|
3564
|
+
let ipV6res = normalizeIPv6(host);
|
|
3565
|
+
if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
|
|
3566
|
+
host = normalizePercentEncoding(host, true);
|
|
3567
|
+
ipV6res = normalizeIPv6(host);
|
|
3568
|
+
}
|
|
3569
|
+
if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) {
|
|
3391
3570
|
host = `[${ipV6res.escapedHost}]`;
|
|
3392
3571
|
} else {
|
|
3393
3572
|
host = reescapeHostDelimiters(host, false);
|
|
@@ -3407,6 +3586,11 @@ var require_utils = __commonJS({
|
|
|
3407
3586
|
reescapeHostDelimiters,
|
|
3408
3587
|
normalizePercentEncoding,
|
|
3409
3588
|
normalizePathEncoding,
|
|
3589
|
+
serializePathEncoding,
|
|
3590
|
+
normalizeQueryFragmentEncoding,
|
|
3591
|
+
encodeUserinfo,
|
|
3592
|
+
encodeQuery,
|
|
3593
|
+
encodeFragment,
|
|
3410
3594
|
escapePreservingEscapes,
|
|
3411
3595
|
removeDotSegments,
|
|
3412
3596
|
isIPv4,
|
|
@@ -3422,7 +3606,7 @@ var require_schemes = __commonJS({
|
|
|
3422
3606
|
"node_modules/fast-uri/lib/schemes.js"(exports2, module2) {
|
|
3423
3607
|
"use strict";
|
|
3424
3608
|
var { isUUID } = require_utils();
|
|
3425
|
-
var URN_REG =
|
|
3609
|
+
var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
|
|
3426
3610
|
var supportedSchemeNames = (
|
|
3427
3611
|
/** @type {const} */
|
|
3428
3612
|
[
|
|
@@ -3483,9 +3667,10 @@ var require_schemes = __commonJS({
|
|
|
3483
3667
|
wsComponent.secure = void 0;
|
|
3484
3668
|
}
|
|
3485
3669
|
if (wsComponent.resourceName) {
|
|
3486
|
-
const
|
|
3487
|
-
|
|
3488
|
-
wsComponent.
|
|
3670
|
+
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
3671
|
+
const path4 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
3672
|
+
wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
|
|
3673
|
+
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
3489
3674
|
wsComponent.resourceName = void 0;
|
|
3490
3675
|
}
|
|
3491
3676
|
wsComponent.fragment = void 0;
|
|
@@ -3497,7 +3682,7 @@ var require_schemes = __commonJS({
|
|
|
3497
3682
|
return urnComponent;
|
|
3498
3683
|
}
|
|
3499
3684
|
const matches = urnComponent.path.match(URN_REG);
|
|
3500
|
-
if (matches) {
|
|
3685
|
+
if (matches && matches[0] === urnComponent.path) {
|
|
3501
3686
|
const scheme = options.scheme || urnComponent.scheme || "urn";
|
|
3502
3687
|
urnComponent.nid = matches[1].toLowerCase();
|
|
3503
3688
|
urnComponent.nss = matches[2];
|
|
@@ -3543,7 +3728,7 @@ var require_schemes = __commonJS({
|
|
|
3543
3728
|
urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
|
|
3544
3729
|
return urnComponent;
|
|
3545
3730
|
}
|
|
3546
|
-
var
|
|
3731
|
+
var http2 = (
|
|
3547
3732
|
/** @type {SchemeHandler} */
|
|
3548
3733
|
{
|
|
3549
3734
|
scheme: "http",
|
|
@@ -3556,7 +3741,7 @@ var require_schemes = __commonJS({
|
|
|
3556
3741
|
/** @type {SchemeHandler} */
|
|
3557
3742
|
{
|
|
3558
3743
|
scheme: "https",
|
|
3559
|
-
domainHost:
|
|
3744
|
+
domainHost: http2.domainHost,
|
|
3560
3745
|
parse: httpParse,
|
|
3561
3746
|
serialize: httpSerialize
|
|
3562
3747
|
}
|
|
@@ -3600,7 +3785,7 @@ var require_schemes = __commonJS({
|
|
|
3600
3785
|
var SCHEMES = (
|
|
3601
3786
|
/** @type {Record<SchemeName, SchemeHandler>} */
|
|
3602
3787
|
{
|
|
3603
|
-
http,
|
|
3788
|
+
http: http2,
|
|
3604
3789
|
https,
|
|
3605
3790
|
ws,
|
|
3606
3791
|
wss,
|
|
@@ -3631,8 +3816,17 @@ var require_schemes = __commonJS({
|
|
|
3631
3816
|
var require_fast_uri = __commonJS({
|
|
3632
3817
|
"node_modules/fast-uri/index.js"(exports2, module2) {
|
|
3633
3818
|
"use strict";
|
|
3634
|
-
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding,
|
|
3819
|
+
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
3635
3820
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
3821
|
+
var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
|
|
3822
|
+
var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
|
|
3823
|
+
function decodeValidScheme(scheme) {
|
|
3824
|
+
const decodedScheme = unescape(String(scheme));
|
|
3825
|
+
if (!VALID_SCHEME.test(decodedScheme)) {
|
|
3826
|
+
throw new TypeError(MALFORMED_SCHEME_ERROR);
|
|
3827
|
+
}
|
|
3828
|
+
return decodedScheme;
|
|
3829
|
+
}
|
|
3636
3830
|
function normalize(uri, options) {
|
|
3637
3831
|
if (typeof uri === "string") {
|
|
3638
3832
|
uri = /** @type {T} */
|
|
@@ -3645,7 +3839,34 @@ var require_fast_uri = __commonJS({
|
|
|
3645
3839
|
}
|
|
3646
3840
|
function resolve(baseURI, relativeURI, options) {
|
|
3647
3841
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
3648
|
-
const
|
|
3842
|
+
const {
|
|
3843
|
+
parsed: baseParsed,
|
|
3844
|
+
malformedAuthorityOrPort: baseMalformed,
|
|
3845
|
+
malformedPercentEncoding: baseMalformedPercentEncoding,
|
|
3846
|
+
malformedSchemeSpecific: baseMalformedSchemeSpecific,
|
|
3847
|
+
malformedHost: baseMalformedHost,
|
|
3848
|
+
malformedScheme: baseMalformedScheme
|
|
3849
|
+
} = parseWithStatus(baseURI, schemelessOptions);
|
|
3850
|
+
const {
|
|
3851
|
+
parsed: relativeParsed,
|
|
3852
|
+
malformedAuthorityOrPort: relativeMalformed,
|
|
3853
|
+
malformedPercentEncoding: relativeMalformedPercentEncoding,
|
|
3854
|
+
malformedSchemeSpecific: relativeMalformedSchemeSpecific,
|
|
3855
|
+
malformedHost: relativeMalformedHost,
|
|
3856
|
+
malformedScheme: relativeMalformedScheme
|
|
3857
|
+
} = parseWithStatus(relativeURI, schemelessOptions);
|
|
3858
|
+
if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) {
|
|
3859
|
+
throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
|
|
3860
|
+
}
|
|
3861
|
+
const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
|
|
3862
|
+
const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
|
|
3863
|
+
const resolvedHost = resolved.host;
|
|
3864
|
+
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
|
|
3865
|
+
canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
|
|
3866
|
+
const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !new RegExp("\\P{ASCII}", "u").test(resolvedHost);
|
|
3867
|
+
if (resolved.error && !encodedASCIIHost) {
|
|
3868
|
+
throw new Error(resolved.error);
|
|
3869
|
+
}
|
|
3649
3870
|
schemelessOptions.skipEscape = true;
|
|
3650
3871
|
return serialize(resolved, schemelessOptions);
|
|
3651
3872
|
}
|
|
@@ -3705,7 +3926,7 @@ var require_fast_uri = __commonJS({
|
|
|
3705
3926
|
function equal(uriA, uriB, options) {
|
|
3706
3927
|
const normalizedA = normalizeComparableURI(uriA, options);
|
|
3707
3928
|
const normalizedB = normalizeComparableURI(uriB, options);
|
|
3708
|
-
return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA
|
|
3929
|
+
return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA === normalizedB;
|
|
3709
3930
|
}
|
|
3710
3931
|
function serialize(cmpts, opts) {
|
|
3711
3932
|
const component = {
|
|
@@ -3726,19 +3947,22 @@ var require_fast_uri = __commonJS({
|
|
|
3726
3947
|
};
|
|
3727
3948
|
const options = Object.assign({}, opts);
|
|
3728
3949
|
const uriTokens = [];
|
|
3950
|
+
if (component.scheme) {
|
|
3951
|
+
component.scheme = decodeValidScheme(component.scheme);
|
|
3952
|
+
}
|
|
3729
3953
|
const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
|
|
3730
3954
|
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
3955
|
+
const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
|
|
3956
|
+
const pathNoScheme = !options.skipEscape && component.scheme === void 0 && !hasAuthority;
|
|
3731
3957
|
if (component.path !== void 0) {
|
|
3732
3958
|
if (!options.skipEscape) {
|
|
3733
|
-
component.path =
|
|
3734
|
-
if (component.scheme !== void 0) {
|
|
3735
|
-
component.path = component.path.split("%3A").join(":");
|
|
3736
|
-
}
|
|
3959
|
+
component.path = serializePathEncoding(component.path, pathNoScheme);
|
|
3737
3960
|
} else {
|
|
3738
3961
|
component.path = normalizePercentEncoding(component.path);
|
|
3739
3962
|
}
|
|
3740
3963
|
}
|
|
3741
3964
|
if (options.reference !== "suffix" && component.scheme) {
|
|
3965
|
+
component.scheme = decodeValidScheme(component.scheme);
|
|
3742
3966
|
uriTokens.push(component.scheme, ":");
|
|
3743
3967
|
}
|
|
3744
3968
|
const authority = recomposeAuthority(component);
|
|
@@ -3756,20 +3980,25 @@ var require_fast_uri = __commonJS({
|
|
|
3756
3980
|
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
|
3757
3981
|
s = removeDotSegments(s);
|
|
3758
3982
|
}
|
|
3983
|
+
if (pathNoScheme) {
|
|
3984
|
+
s = serializePathEncoding(s, true);
|
|
3985
|
+
}
|
|
3759
3986
|
if (authority === void 0 && s[0] === "/" && s[1] === "/") {
|
|
3760
3987
|
s = "/%2F" + s.slice(2);
|
|
3761
3988
|
}
|
|
3762
3989
|
uriTokens.push(s);
|
|
3763
3990
|
}
|
|
3764
3991
|
if (component.query !== void 0) {
|
|
3765
|
-
uriTokens.push("?", component.query);
|
|
3992
|
+
uriTokens.push("?", encodeQuery(component.query));
|
|
3766
3993
|
}
|
|
3767
3994
|
if (component.fragment !== void 0) {
|
|
3768
|
-
uriTokens.push("#", component.fragment);
|
|
3995
|
+
uriTokens.push("#", encodeFragment(component.fragment));
|
|
3769
3996
|
}
|
|
3770
3997
|
return uriTokens.join("");
|
|
3771
3998
|
}
|
|
3772
3999
|
var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
4000
|
+
var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
|
|
4001
|
+
var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
|
|
3773
4002
|
function getParseError(parsed, matches) {
|
|
3774
4003
|
if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
|
|
3775
4004
|
return 'URI path must start with "/" when authority is present.';
|
|
@@ -3779,6 +4008,32 @@ var require_fast_uri = __commonJS({
|
|
|
3779
4008
|
}
|
|
3780
4009
|
return void 0;
|
|
3781
4010
|
}
|
|
4011
|
+
function hasMalformedPercentEncoding(component) {
|
|
4012
|
+
if (component === void 0) return false;
|
|
4013
|
+
let percent = component.indexOf("%");
|
|
4014
|
+
while (percent !== -1) {
|
|
4015
|
+
if (percent + 2 >= component.length || !/^[\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) {
|
|
4016
|
+
return true;
|
|
4017
|
+
}
|
|
4018
|
+
percent = component.indexOf("%", percent + 3);
|
|
4019
|
+
}
|
|
4020
|
+
return false;
|
|
4021
|
+
}
|
|
4022
|
+
function hasMalformedComponentPercentEncoding(matches) {
|
|
4023
|
+
const host = matches[4];
|
|
4024
|
+
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !(host[0] === "[" && host[host.length - 1] === "]") && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
|
|
4025
|
+
}
|
|
4026
|
+
function canonicalizeHost(parsed, options, schemeHandler, isIP) {
|
|
4027
|
+
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && parsed.host[0] !== "[" && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
4028
|
+
try {
|
|
4029
|
+
parsed.host = new URL("http://" + parsed.host).hostname;
|
|
4030
|
+
} catch (e) {
|
|
4031
|
+
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
4032
|
+
return true;
|
|
4033
|
+
}
|
|
4034
|
+
}
|
|
4035
|
+
return false;
|
|
4036
|
+
}
|
|
3782
4037
|
function parseWithStatus(uri, opts) {
|
|
3783
4038
|
const options = Object.assign({}, opts);
|
|
3784
4039
|
const parsed = {
|
|
@@ -3791,6 +4046,11 @@ var require_fast_uri = __commonJS({
|
|
|
3791
4046
|
fragment: void 0
|
|
3792
4047
|
};
|
|
3793
4048
|
let malformedAuthorityOrPort = false;
|
|
4049
|
+
let malformedPercentEncoding = false;
|
|
4050
|
+
let malformedSchemeSpecific = false;
|
|
4051
|
+
let malformedHost = false;
|
|
4052
|
+
let malformedIPLiteral = false;
|
|
4053
|
+
let malformedScheme = false;
|
|
3794
4054
|
let isIP = false;
|
|
3795
4055
|
if (options.reference === "suffix") {
|
|
3796
4056
|
if (options.scheme) {
|
|
@@ -3799,6 +4059,25 @@ var require_fast_uri = __commonJS({
|
|
|
3799
4059
|
uri = "//" + uri;
|
|
3800
4060
|
}
|
|
3801
4061
|
}
|
|
4062
|
+
const authorityMatch = uri.match(AUTHORITY_PREFIX);
|
|
4063
|
+
if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) {
|
|
4064
|
+
parsed.error = "URI authority must not contain a literal backslash.";
|
|
4065
|
+
malformedAuthorityOrPort = true;
|
|
4066
|
+
}
|
|
4067
|
+
const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
|
|
4068
|
+
if (introducerMatch !== null) {
|
|
4069
|
+
const region = introducerMatch[1];
|
|
4070
|
+
const normalizedRegion = region.replace(/[\t\n\r]/g, "");
|
|
4071
|
+
if (normalizedRegion.length >= 2) {
|
|
4072
|
+
if (normalizedRegion.slice(0, 2) !== "//") {
|
|
4073
|
+
parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
|
|
4074
|
+
malformedAuthorityOrPort = true;
|
|
4075
|
+
} else if (region.length !== normalizedRegion.length) {
|
|
4076
|
+
parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
|
|
4077
|
+
malformedAuthorityOrPort = true;
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4080
|
+
}
|
|
3802
4081
|
const matches = uri.match(URI_PARSE);
|
|
3803
4082
|
if (matches) {
|
|
3804
4083
|
parsed.scheme = matches[1];
|
|
@@ -3808,6 +4087,19 @@ var require_fast_uri = __commonJS({
|
|
|
3808
4087
|
parsed.path = matches[6] || "";
|
|
3809
4088
|
parsed.query = matches[7];
|
|
3810
4089
|
parsed.fragment = matches[8];
|
|
4090
|
+
if (parsed.scheme !== void 0) {
|
|
4091
|
+
const decodedScheme = unescape(parsed.scheme);
|
|
4092
|
+
if (VALID_SCHEME.test(decodedScheme)) {
|
|
4093
|
+
parsed.scheme = decodedScheme.toLowerCase();
|
|
4094
|
+
} else {
|
|
4095
|
+
parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
|
|
4096
|
+
malformedScheme = true;
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches);
|
|
4100
|
+
if (malformedPercentEncoding) {
|
|
4101
|
+
parsed.error = parsed.error || "URI contains malformed percent-encoding.";
|
|
4102
|
+
}
|
|
3811
4103
|
if (isNaN(parsed.port)) {
|
|
3812
4104
|
parsed.port = matches[5];
|
|
3813
4105
|
}
|
|
@@ -3819,9 +4111,15 @@ var require_fast_uri = __commonJS({
|
|
|
3819
4111
|
if (parsed.host) {
|
|
3820
4112
|
const ipv4result = isIPv4(parsed.host);
|
|
3821
4113
|
if (ipv4result === false) {
|
|
4114
|
+
const bracketedIPLiteral = parsed.host[0] === "[" && parsed.host[parsed.host.length - 1] === "]";
|
|
3822
4115
|
const ipv6result = normalizeIPv6(parsed.host);
|
|
3823
|
-
|
|
3824
|
-
|
|
4116
|
+
isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
|
|
4117
|
+
malformedIPLiteral = bracketedIPLiteral && ipv6result.error === true;
|
|
4118
|
+
parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
|
|
4119
|
+
if (malformedIPLiteral) {
|
|
4120
|
+
parsed.error = parsed.error || "URI host is malformed.";
|
|
4121
|
+
malformedAuthorityOrPort = true;
|
|
4122
|
+
}
|
|
3825
4123
|
} else {
|
|
3826
4124
|
isIP = true;
|
|
3827
4125
|
}
|
|
@@ -3839,42 +4137,34 @@ var require_fast_uri = __commonJS({
|
|
|
3839
4137
|
parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
|
|
3840
4138
|
}
|
|
3841
4139
|
const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
|
|
3842
|
-
|
|
3843
|
-
if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
3844
|
-
try {
|
|
3845
|
-
parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
|
|
3846
|
-
} catch (e) {
|
|
3847
|
-
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
3848
|
-
}
|
|
3849
|
-
}
|
|
3850
|
-
}
|
|
4140
|
+
malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
|
|
3851
4141
|
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
3852
4142
|
if (uri.indexOf("%") !== -1) {
|
|
3853
|
-
if (parsed.
|
|
3854
|
-
parsed.
|
|
3855
|
-
|
|
3856
|
-
if (parsed.host !== void 0) {
|
|
3857
|
-
parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
|
|
4143
|
+
if (parsed.host !== void 0 && !malformedIPLiteral) {
|
|
4144
|
+
const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
|
|
4145
|
+
parsed.host = reescapeHostDelimiters(host, isIP);
|
|
3858
4146
|
}
|
|
3859
4147
|
}
|
|
3860
4148
|
if (parsed.path) {
|
|
3861
4149
|
parsed.path = normalizePathEncoding(parsed.path);
|
|
3862
4150
|
}
|
|
4151
|
+
if (parsed.query) {
|
|
4152
|
+
parsed.query = normalizeQueryFragmentEncoding(parsed.query);
|
|
4153
|
+
}
|
|
3863
4154
|
if (parsed.fragment) {
|
|
3864
|
-
|
|
3865
|
-
parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
|
|
3866
|
-
} catch {
|
|
3867
|
-
parsed.error = parsed.error || "URI malformed";
|
|
3868
|
-
}
|
|
4155
|
+
parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
|
|
3869
4156
|
}
|
|
3870
4157
|
}
|
|
3871
4158
|
if (schemeHandler && schemeHandler.parse) {
|
|
3872
4159
|
schemeHandler.parse(parsed, options);
|
|
4160
|
+
if (schemeHandler === SCHEMES.urn && parsed.nid === void 0) {
|
|
4161
|
+
malformedSchemeSpecific = true;
|
|
4162
|
+
}
|
|
3873
4163
|
}
|
|
3874
4164
|
} else {
|
|
3875
4165
|
parsed.error = parsed.error || "URI can not be parsed.";
|
|
3876
4166
|
}
|
|
3877
|
-
return { parsed, malformedAuthorityOrPort };
|
|
4167
|
+
return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
|
|
3878
4168
|
}
|
|
3879
4169
|
function parse3(uri, opts) {
|
|
3880
4170
|
return parseWithStatus(uri, opts).parsed;
|
|
@@ -3883,20 +4173,28 @@ var require_fast_uri = __commonJS({
|
|
|
3883
4173
|
return normalizeStringWithStatus(uri, opts).normalized;
|
|
3884
4174
|
}
|
|
3885
4175
|
function normalizeStringWithStatus(uri, opts) {
|
|
3886
|
-
const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
|
|
4176
|
+
const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
|
|
3887
4177
|
return {
|
|
3888
|
-
normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
|
|
3889
|
-
malformedAuthorityOrPort
|
|
4178
|
+
normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
|
|
4179
|
+
malformedAuthorityOrPort,
|
|
4180
|
+
malformedPercentEncoding,
|
|
4181
|
+
malformedSchemeSpecific,
|
|
4182
|
+
malformedHost,
|
|
4183
|
+
malformedScheme
|
|
3890
4184
|
};
|
|
3891
4185
|
}
|
|
3892
4186
|
function normalizeComparableURI(uri, opts) {
|
|
3893
|
-
if (typeof uri
|
|
3894
|
-
|
|
3895
|
-
return malformedAuthorityOrPort ? void 0 : normalized;
|
|
4187
|
+
if (typeof uri !== "string" && typeof uri !== "object") {
|
|
4188
|
+
return void 0;
|
|
3896
4189
|
}
|
|
3897
|
-
|
|
3898
|
-
|
|
4190
|
+
let value;
|
|
4191
|
+
try {
|
|
4192
|
+
value = typeof uri === "string" ? uri : serialize(uri, opts);
|
|
4193
|
+
} catch {
|
|
4194
|
+
return void 0;
|
|
3899
4195
|
}
|
|
4196
|
+
const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
|
|
4197
|
+
return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
|
|
3900
4198
|
}
|
|
3901
4199
|
var fastUri = {
|
|
3902
4200
|
SCHEMES,
|
|
@@ -6877,12 +7175,12 @@ var require_dist = __commonJS({
|
|
|
6877
7175
|
throw new Error(`Unknown format "${name}"`);
|
|
6878
7176
|
return f;
|
|
6879
7177
|
};
|
|
6880
|
-
function addFormats(ajv, list,
|
|
7178
|
+
function addFormats(ajv, list, fs4, exportName) {
|
|
6881
7179
|
var _a;
|
|
6882
7180
|
var _b;
|
|
6883
7181
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
6884
7182
|
for (const f of list)
|
|
6885
|
-
ajv.addFormat(f,
|
|
7183
|
+
ajv.addFormat(f, fs4[f]);
|
|
6886
7184
|
}
|
|
6887
7185
|
module2.exports = exports2 = formatsPlugin;
|
|
6888
7186
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -7368,8 +7666,8 @@ function getErrorMap() {
|
|
|
7368
7666
|
|
|
7369
7667
|
// node_modules/zod/v3/helpers/parseUtil.js
|
|
7370
7668
|
var makeIssue = (params) => {
|
|
7371
|
-
const { data, path:
|
|
7372
|
-
const fullPath = [...
|
|
7669
|
+
const { data, path: path4, errorMaps, issueData } = params;
|
|
7670
|
+
const fullPath = [...path4, ...issueData.path || []];
|
|
7373
7671
|
const fullIssue = {
|
|
7374
7672
|
...issueData,
|
|
7375
7673
|
path: fullPath
|
|
@@ -7485,11 +7783,11 @@ var errorUtil;
|
|
|
7485
7783
|
|
|
7486
7784
|
// node_modules/zod/v3/types.js
|
|
7487
7785
|
var ParseInputLazyPath = class {
|
|
7488
|
-
constructor(parent, value,
|
|
7786
|
+
constructor(parent, value, path4, key) {
|
|
7489
7787
|
this._cachedPath = [];
|
|
7490
7788
|
this.parent = parent;
|
|
7491
7789
|
this.data = value;
|
|
7492
|
-
this._path =
|
|
7790
|
+
this._path = path4;
|
|
7493
7791
|
this._key = key;
|
|
7494
7792
|
}
|
|
7495
7793
|
get path() {
|
|
@@ -11126,10 +11424,10 @@ function assignProp(target, prop, value) {
|
|
|
11126
11424
|
configurable: true
|
|
11127
11425
|
});
|
|
11128
11426
|
}
|
|
11129
|
-
function getElementAtPath(obj,
|
|
11130
|
-
if (!
|
|
11427
|
+
function getElementAtPath(obj, path4) {
|
|
11428
|
+
if (!path4)
|
|
11131
11429
|
return obj;
|
|
11132
|
-
return
|
|
11430
|
+
return path4.reduce((acc, key) => acc?.[key], obj);
|
|
11133
11431
|
}
|
|
11134
11432
|
function promiseAllObject(promisesObj) {
|
|
11135
11433
|
const keys = Object.keys(promisesObj);
|
|
@@ -11449,11 +11747,11 @@ function aborted(x, startIndex = 0) {
|
|
|
11449
11747
|
}
|
|
11450
11748
|
return false;
|
|
11451
11749
|
}
|
|
11452
|
-
function prefixIssues(
|
|
11750
|
+
function prefixIssues(path4, issues) {
|
|
11453
11751
|
return issues.map((iss) => {
|
|
11454
11752
|
var _a;
|
|
11455
11753
|
(_a = iss).path ?? (_a.path = []);
|
|
11456
|
-
iss.path.unshift(
|
|
11754
|
+
iss.path.unshift(path4);
|
|
11457
11755
|
return iss;
|
|
11458
11756
|
});
|
|
11459
11757
|
}
|
|
@@ -16993,17 +17291,17 @@ var CompleteRequestSchema = RequestSchema.extend({
|
|
|
16993
17291
|
method: literal("completion/complete"),
|
|
16994
17292
|
params: CompleteRequestParamsSchema
|
|
16995
17293
|
});
|
|
16996
|
-
function assertCompleteRequestPrompt(
|
|
16997
|
-
if (
|
|
16998
|
-
throw new TypeError(`Expected CompleteRequestPrompt, but got ${
|
|
17294
|
+
function assertCompleteRequestPrompt(request2) {
|
|
17295
|
+
if (request2.params.ref.type !== "ref/prompt") {
|
|
17296
|
+
throw new TypeError(`Expected CompleteRequestPrompt, but got ${request2.params.ref.type}`);
|
|
16999
17297
|
}
|
|
17000
|
-
void
|
|
17298
|
+
void request2;
|
|
17001
17299
|
}
|
|
17002
|
-
function assertCompleteRequestResourceTemplate(
|
|
17003
|
-
if (
|
|
17004
|
-
throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${
|
|
17300
|
+
function assertCompleteRequestResourceTemplate(request2) {
|
|
17301
|
+
if (request2.params.ref.type !== "ref/resource") {
|
|
17302
|
+
throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request2.params.ref.type}`);
|
|
17005
17303
|
}
|
|
17006
|
-
void
|
|
17304
|
+
void request2;
|
|
17007
17305
|
}
|
|
17008
17306
|
var CompleteResultSchema = ResultSchema.extend({
|
|
17009
17307
|
completion: looseObject({
|
|
@@ -18510,8 +18808,8 @@ var Protocol = class {
|
|
|
18510
18808
|
this._taskStore = _options?.taskStore;
|
|
18511
18809
|
this._taskMessageQueue = _options?.taskMessageQueue;
|
|
18512
18810
|
if (this._taskStore) {
|
|
18513
|
-
this.setRequestHandler(GetTaskRequestSchema, async (
|
|
18514
|
-
const task = await this._taskStore.getTask(
|
|
18811
|
+
this.setRequestHandler(GetTaskRequestSchema, async (request2, extra) => {
|
|
18812
|
+
const task = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
|
|
18515
18813
|
if (!task) {
|
|
18516
18814
|
throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
|
|
18517
18815
|
}
|
|
@@ -18519,9 +18817,9 @@ var Protocol = class {
|
|
|
18519
18817
|
...task
|
|
18520
18818
|
};
|
|
18521
18819
|
});
|
|
18522
|
-
this.setRequestHandler(GetTaskPayloadRequestSchema, async (
|
|
18820
|
+
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request2, extra) => {
|
|
18523
18821
|
const handleTaskResult = async () => {
|
|
18524
|
-
const taskId =
|
|
18822
|
+
const taskId = request2.params.taskId;
|
|
18525
18823
|
if (this._taskMessageQueue) {
|
|
18526
18824
|
let queuedMessage;
|
|
18527
18825
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -18572,9 +18870,9 @@ var Protocol = class {
|
|
|
18572
18870
|
};
|
|
18573
18871
|
return await handleTaskResult();
|
|
18574
18872
|
});
|
|
18575
|
-
this.setRequestHandler(ListTasksRequestSchema, async (
|
|
18873
|
+
this.setRequestHandler(ListTasksRequestSchema, async (request2, extra) => {
|
|
18576
18874
|
try {
|
|
18577
|
-
const { tasks, nextCursor } = await this._taskStore.listTasks(
|
|
18875
|
+
const { tasks, nextCursor } = await this._taskStore.listTasks(request2.params?.cursor, extra.sessionId);
|
|
18578
18876
|
return {
|
|
18579
18877
|
tasks,
|
|
18580
18878
|
nextCursor,
|
|
@@ -18584,20 +18882,20 @@ var Protocol = class {
|
|
|
18584
18882
|
throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
18585
18883
|
}
|
|
18586
18884
|
});
|
|
18587
|
-
this.setRequestHandler(CancelTaskRequestSchema, async (
|
|
18885
|
+
this.setRequestHandler(CancelTaskRequestSchema, async (request2, extra) => {
|
|
18588
18886
|
try {
|
|
18589
|
-
const task = await this._taskStore.getTask(
|
|
18887
|
+
const task = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
|
|
18590
18888
|
if (!task) {
|
|
18591
|
-
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${
|
|
18889
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${request2.params.taskId}`);
|
|
18592
18890
|
}
|
|
18593
18891
|
if (isTerminal(task.status)) {
|
|
18594
18892
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
18595
18893
|
}
|
|
18596
|
-
await this._taskStore.updateTaskStatus(
|
|
18597
|
-
this._clearTaskQueue(
|
|
18598
|
-
const cancelledTask = await this._taskStore.getTask(
|
|
18894
|
+
await this._taskStore.updateTaskStatus(request2.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
18895
|
+
this._clearTaskQueue(request2.params.taskId);
|
|
18896
|
+
const cancelledTask = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
|
|
18599
18897
|
if (!cancelledTask) {
|
|
18600
|
-
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${
|
|
18898
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request2.params.taskId}`);
|
|
18601
18899
|
}
|
|
18602
18900
|
return {
|
|
18603
18901
|
_meta: {},
|
|
@@ -18718,14 +19016,14 @@ var Protocol = class {
|
|
|
18718
19016
|
}
|
|
18719
19017
|
Promise.resolve().then(() => handler(notification)).catch((error2) => this._onerror(new Error(`Uncaught error in notification handler: ${error2}`)));
|
|
18720
19018
|
}
|
|
18721
|
-
_onrequest(
|
|
18722
|
-
const handler = this._requestHandlers.get(
|
|
19019
|
+
_onrequest(request2, extra) {
|
|
19020
|
+
const handler = this._requestHandlers.get(request2.method) ?? this.fallbackRequestHandler;
|
|
18723
19021
|
const capturedTransport = this._transport;
|
|
18724
|
-
const relatedTaskId =
|
|
19022
|
+
const relatedTaskId = request2.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
18725
19023
|
if (handler === void 0) {
|
|
18726
19024
|
const errorResponse = {
|
|
18727
19025
|
jsonrpc: "2.0",
|
|
18728
|
-
id:
|
|
19026
|
+
id: request2.id,
|
|
18729
19027
|
error: {
|
|
18730
19028
|
code: ErrorCode.MethodNotFound,
|
|
18731
19029
|
message: "Method not found"
|
|
@@ -18743,17 +19041,17 @@ var Protocol = class {
|
|
|
18743
19041
|
return;
|
|
18744
19042
|
}
|
|
18745
19043
|
const abortController = new AbortController();
|
|
18746
|
-
this._requestHandlerAbortControllers.set(
|
|
18747
|
-
const taskCreationParams = isTaskAugmentedRequestParams(
|
|
18748
|
-
const taskStore = this._taskStore ? this.requestTaskStore(
|
|
19044
|
+
this._requestHandlerAbortControllers.set(request2.id, abortController);
|
|
19045
|
+
const taskCreationParams = isTaskAugmentedRequestParams(request2.params) ? request2.params.task : void 0;
|
|
19046
|
+
const taskStore = this._taskStore ? this.requestTaskStore(request2, capturedTransport?.sessionId) : void 0;
|
|
18749
19047
|
const fullExtra = {
|
|
18750
19048
|
signal: abortController.signal,
|
|
18751
19049
|
sessionId: capturedTransport?.sessionId,
|
|
18752
|
-
_meta:
|
|
19050
|
+
_meta: request2.params?._meta,
|
|
18753
19051
|
sendNotification: async (notification) => {
|
|
18754
19052
|
if (abortController.signal.aborted)
|
|
18755
19053
|
return;
|
|
18756
|
-
const notificationOptions = { relatedRequestId:
|
|
19054
|
+
const notificationOptions = { relatedRequestId: request2.id };
|
|
18757
19055
|
if (relatedTaskId) {
|
|
18758
19056
|
notificationOptions.relatedTask = { taskId: relatedTaskId };
|
|
18759
19057
|
}
|
|
@@ -18763,7 +19061,7 @@ var Protocol = class {
|
|
|
18763
19061
|
if (abortController.signal.aborted) {
|
|
18764
19062
|
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
18765
19063
|
}
|
|
18766
|
-
const requestOptions = { ...options, relatedRequestId:
|
|
19064
|
+
const requestOptions = { ...options, relatedRequestId: request2.id };
|
|
18767
19065
|
if (relatedTaskId && !requestOptions.relatedTask) {
|
|
18768
19066
|
requestOptions.relatedTask = { taskId: relatedTaskId };
|
|
18769
19067
|
}
|
|
@@ -18774,7 +19072,7 @@ var Protocol = class {
|
|
|
18774
19072
|
return await this.request(r, resultSchema, requestOptions);
|
|
18775
19073
|
},
|
|
18776
19074
|
authInfo: extra?.authInfo,
|
|
18777
|
-
requestId:
|
|
19075
|
+
requestId: request2.id,
|
|
18778
19076
|
requestInfo: extra?.requestInfo,
|
|
18779
19077
|
taskId: relatedTaskId,
|
|
18780
19078
|
taskStore,
|
|
@@ -18784,16 +19082,16 @@ var Protocol = class {
|
|
|
18784
19082
|
};
|
|
18785
19083
|
Promise.resolve().then(() => {
|
|
18786
19084
|
if (taskCreationParams) {
|
|
18787
|
-
this.assertTaskHandlerCapability(
|
|
19085
|
+
this.assertTaskHandlerCapability(request2.method);
|
|
18788
19086
|
}
|
|
18789
|
-
}).then(() => handler(
|
|
19087
|
+
}).then(() => handler(request2, fullExtra)).then(async (result) => {
|
|
18790
19088
|
if (abortController.signal.aborted) {
|
|
18791
19089
|
return;
|
|
18792
19090
|
}
|
|
18793
19091
|
const response = {
|
|
18794
19092
|
result,
|
|
18795
19093
|
jsonrpc: "2.0",
|
|
18796
|
-
id:
|
|
19094
|
+
id: request2.id
|
|
18797
19095
|
};
|
|
18798
19096
|
if (relatedTaskId && this._taskMessageQueue) {
|
|
18799
19097
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
@@ -18810,7 +19108,7 @@ var Protocol = class {
|
|
|
18810
19108
|
}
|
|
18811
19109
|
const errorResponse = {
|
|
18812
19110
|
jsonrpc: "2.0",
|
|
18813
|
-
id:
|
|
19111
|
+
id: request2.id,
|
|
18814
19112
|
error: {
|
|
18815
19113
|
code: Number.isSafeInteger(error2["code"]) ? error2["code"] : ErrorCode.InternalError,
|
|
18816
19114
|
message: error2.message ?? "Internal error",
|
|
@@ -18827,8 +19125,8 @@ var Protocol = class {
|
|
|
18827
19125
|
await capturedTransport?.send(errorResponse);
|
|
18828
19126
|
}
|
|
18829
19127
|
}).catch((error2) => this._onerror(new Error(`Failed to send response: ${error2}`))).finally(() => {
|
|
18830
|
-
if (this._requestHandlerAbortControllers.get(
|
|
18831
|
-
this._requestHandlerAbortControllers.delete(
|
|
19128
|
+
if (this._requestHandlerAbortControllers.get(request2.id) === abortController) {
|
|
19129
|
+
this._requestHandlerAbortControllers.delete(request2.id);
|
|
18832
19130
|
}
|
|
18833
19131
|
});
|
|
18834
19132
|
}
|
|
@@ -18932,11 +19230,11 @@ var Protocol = class {
|
|
|
18932
19230
|
*
|
|
18933
19231
|
* @experimental Use `client.experimental.tasks.requestStream()` to access this method.
|
|
18934
19232
|
*/
|
|
18935
|
-
async *requestStream(
|
|
19233
|
+
async *requestStream(request2, resultSchema, options) {
|
|
18936
19234
|
const { task } = options ?? {};
|
|
18937
19235
|
if (!task) {
|
|
18938
19236
|
try {
|
|
18939
|
-
const result = await this.request(
|
|
19237
|
+
const result = await this.request(request2, resultSchema, options);
|
|
18940
19238
|
yield { type: "result", result };
|
|
18941
19239
|
} catch (error2) {
|
|
18942
19240
|
yield {
|
|
@@ -18948,7 +19246,7 @@ var Protocol = class {
|
|
|
18948
19246
|
}
|
|
18949
19247
|
let taskId;
|
|
18950
19248
|
try {
|
|
18951
|
-
const createResult = await this.request(
|
|
19249
|
+
const createResult = await this.request(request2, CreateTaskResultSchema, options);
|
|
18952
19250
|
if (createResult.task) {
|
|
18953
19251
|
taskId = createResult.task.taskId;
|
|
18954
19252
|
yield { type: "taskCreated", task: createResult.task };
|
|
@@ -18996,7 +19294,7 @@ var Protocol = class {
|
|
|
18996
19294
|
*
|
|
18997
19295
|
* Do not use this method to emit notifications! Use notification() instead.
|
|
18998
19296
|
*/
|
|
18999
|
-
request(
|
|
19297
|
+
request(request2, resultSchema, options) {
|
|
19000
19298
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
19001
19299
|
return new Promise((resolve, reject) => {
|
|
19002
19300
|
const earlyReject = (error2) => {
|
|
@@ -19008,9 +19306,9 @@ var Protocol = class {
|
|
|
19008
19306
|
}
|
|
19009
19307
|
if (this._options?.enforceStrictCapabilities === true) {
|
|
19010
19308
|
try {
|
|
19011
|
-
this.assertCapabilityForMethod(
|
|
19309
|
+
this.assertCapabilityForMethod(request2.method);
|
|
19012
19310
|
if (task) {
|
|
19013
|
-
this.assertTaskCapability(
|
|
19311
|
+
this.assertTaskCapability(request2.method);
|
|
19014
19312
|
}
|
|
19015
19313
|
} catch (e) {
|
|
19016
19314
|
earlyReject(e);
|
|
@@ -19020,16 +19318,16 @@ var Protocol = class {
|
|
|
19020
19318
|
options?.signal?.throwIfAborted();
|
|
19021
19319
|
const messageId = this._requestMessageId++;
|
|
19022
19320
|
const jsonrpcRequest = {
|
|
19023
|
-
...
|
|
19321
|
+
...request2,
|
|
19024
19322
|
jsonrpc: "2.0",
|
|
19025
19323
|
id: messageId
|
|
19026
19324
|
};
|
|
19027
19325
|
if (options?.onprogress) {
|
|
19028
19326
|
this._progressHandlers.set(messageId, options.onprogress);
|
|
19029
19327
|
jsonrpcRequest.params = {
|
|
19030
|
-
...
|
|
19328
|
+
...request2.params,
|
|
19031
19329
|
_meta: {
|
|
19032
|
-
...
|
|
19330
|
+
...request2.params?._meta || {},
|
|
19033
19331
|
progressToken: messageId
|
|
19034
19332
|
}
|
|
19035
19333
|
};
|
|
@@ -19233,8 +19531,8 @@ var Protocol = class {
|
|
|
19233
19531
|
setRequestHandler(requestSchema, handler) {
|
|
19234
19532
|
const method = getMethodLiteral(requestSchema);
|
|
19235
19533
|
this.assertRequestHandlerCapability(method);
|
|
19236
|
-
this._requestHandlers.set(method, (
|
|
19237
|
-
const parsed = parseWithCompat(requestSchema,
|
|
19534
|
+
this._requestHandlers.set(method, (request2, extra) => {
|
|
19535
|
+
const parsed = parseWithCompat(requestSchema, request2);
|
|
19238
19536
|
return Promise.resolve(handler(parsed, extra));
|
|
19239
19537
|
});
|
|
19240
19538
|
}
|
|
@@ -19349,19 +19647,19 @@ var Protocol = class {
|
|
|
19349
19647
|
}, { once: true });
|
|
19350
19648
|
});
|
|
19351
19649
|
}
|
|
19352
|
-
requestTaskStore(
|
|
19650
|
+
requestTaskStore(request2, sessionId) {
|
|
19353
19651
|
const taskStore = this._taskStore;
|
|
19354
19652
|
if (!taskStore) {
|
|
19355
19653
|
throw new Error("No task store configured");
|
|
19356
19654
|
}
|
|
19357
19655
|
return {
|
|
19358
19656
|
createTask: async (taskParams) => {
|
|
19359
|
-
if (!
|
|
19657
|
+
if (!request2) {
|
|
19360
19658
|
throw new Error("No request provided");
|
|
19361
19659
|
}
|
|
19362
|
-
return await taskStore.createTask(taskParams,
|
|
19363
|
-
method:
|
|
19364
|
-
params:
|
|
19660
|
+
return await taskStore.createTask(taskParams, request2.id, {
|
|
19661
|
+
method: request2.method,
|
|
19662
|
+
params: request2.params
|
|
19365
19663
|
}, sessionId);
|
|
19366
19664
|
},
|
|
19367
19665
|
getTask: async (taskId) => {
|
|
@@ -19522,8 +19820,8 @@ var ExperimentalServerTasks = class {
|
|
|
19522
19820
|
*
|
|
19523
19821
|
* @experimental
|
|
19524
19822
|
*/
|
|
19525
|
-
requestStream(
|
|
19526
|
-
return this._server.requestStream(
|
|
19823
|
+
requestStream(request2, resultSchema, options) {
|
|
19824
|
+
return this._server.requestStream(request2, resultSchema, options);
|
|
19527
19825
|
}
|
|
19528
19826
|
/**
|
|
19529
19827
|
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
@@ -19768,12 +20066,12 @@ var Server = class extends Protocol {
|
|
|
19768
20066
|
this._capabilities = options?.capabilities ?? {};
|
|
19769
20067
|
this._instructions = options?.instructions;
|
|
19770
20068
|
this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
|
|
19771
|
-
this.setRequestHandler(InitializeRequestSchema, (
|
|
20069
|
+
this.setRequestHandler(InitializeRequestSchema, (request2) => this._oninitialize(request2));
|
|
19772
20070
|
this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.());
|
|
19773
20071
|
if (this._capabilities.logging) {
|
|
19774
|
-
this.setRequestHandler(SetLevelRequestSchema, async (
|
|
20072
|
+
this.setRequestHandler(SetLevelRequestSchema, async (request2, extra) => {
|
|
19775
20073
|
const transportSessionId = extra.sessionId || extra.requestInfo?.headers["mcp-session-id"] || void 0;
|
|
19776
|
-
const { level } =
|
|
20074
|
+
const { level } = request2.params;
|
|
19777
20075
|
const parseResult = LoggingLevelSchema.safeParse(level);
|
|
19778
20076
|
if (parseResult.success) {
|
|
19779
20077
|
this._loggingLevels.set(transportSessionId, parseResult.data);
|
|
@@ -19832,14 +20130,14 @@ var Server = class extends Protocol {
|
|
|
19832
20130
|
}
|
|
19833
20131
|
const method = methodValue;
|
|
19834
20132
|
if (method === "tools/call") {
|
|
19835
|
-
const wrappedHandler = async (
|
|
19836
|
-
const validatedRequest = safeParse2(CallToolRequestSchema,
|
|
20133
|
+
const wrappedHandler = async (request2, extra) => {
|
|
20134
|
+
const validatedRequest = safeParse2(CallToolRequestSchema, request2);
|
|
19837
20135
|
if (!validatedRequest.success) {
|
|
19838
20136
|
const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
|
|
19839
20137
|
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
|
|
19840
20138
|
}
|
|
19841
20139
|
const { params } = validatedRequest.data;
|
|
19842
|
-
const result = await Promise.resolve(handler(
|
|
20140
|
+
const result = await Promise.resolve(handler(request2, extra));
|
|
19843
20141
|
if (params.task) {
|
|
19844
20142
|
const taskValidationResult = safeParse2(CreateTaskResultSchema, result);
|
|
19845
20143
|
if (!taskValidationResult.success) {
|
|
@@ -19970,10 +20268,10 @@ var Server = class extends Protocol {
|
|
|
19970
20268
|
}
|
|
19971
20269
|
assertToolsCallTaskCapability(this._capabilities.tasks?.requests, method, "Server");
|
|
19972
20270
|
}
|
|
19973
|
-
async _oninitialize(
|
|
19974
|
-
const requestedVersion =
|
|
19975
|
-
this._clientCapabilities =
|
|
19976
|
-
this._clientVersion =
|
|
20271
|
+
async _oninitialize(request2) {
|
|
20272
|
+
const requestedVersion = request2.params.protocolVersion;
|
|
20273
|
+
this._clientCapabilities = request2.params.capabilities;
|
|
20274
|
+
this._clientVersion = request2.params.clientInfo;
|
|
19977
20275
|
const protocolVersion = SUPPORTED_PROTOCOL_VERSIONS.includes(requestedVersion) ? requestedVersion : LATEST_PROTOCOL_VERSION;
|
|
19978
20276
|
return {
|
|
19979
20277
|
protocolVersion,
|
|
@@ -20300,33 +20598,33 @@ var McpServer = class {
|
|
|
20300
20598
|
return toolDefinition;
|
|
20301
20599
|
})
|
|
20302
20600
|
}));
|
|
20303
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (
|
|
20601
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request2, extra) => {
|
|
20304
20602
|
try {
|
|
20305
|
-
const tool = this._registeredTools[
|
|
20603
|
+
const tool = this._registeredTools[request2.params.name];
|
|
20306
20604
|
if (!tool) {
|
|
20307
|
-
throw new McpError(ErrorCode.InvalidParams, `Tool ${
|
|
20605
|
+
throw new McpError(ErrorCode.InvalidParams, `Tool ${request2.params.name} not found`);
|
|
20308
20606
|
}
|
|
20309
20607
|
if (!tool.enabled) {
|
|
20310
|
-
throw new McpError(ErrorCode.InvalidParams, `Tool ${
|
|
20608
|
+
throw new McpError(ErrorCode.InvalidParams, `Tool ${request2.params.name} disabled`);
|
|
20311
20609
|
}
|
|
20312
|
-
const isTaskRequest = !!
|
|
20610
|
+
const isTaskRequest = !!request2.params.task;
|
|
20313
20611
|
const taskSupport = tool.execution?.taskSupport;
|
|
20314
20612
|
const isTaskHandler = "createTask" in tool.handler;
|
|
20315
20613
|
if ((taskSupport === "required" || taskSupport === "optional") && !isTaskHandler) {
|
|
20316
|
-
throw new McpError(ErrorCode.InternalError, `Tool ${
|
|
20614
|
+
throw new McpError(ErrorCode.InternalError, `Tool ${request2.params.name} has taskSupport '${taskSupport}' but was not registered with registerToolTask`);
|
|
20317
20615
|
}
|
|
20318
20616
|
if (taskSupport === "required" && !isTaskRequest) {
|
|
20319
|
-
throw new McpError(ErrorCode.MethodNotFound, `Tool ${
|
|
20617
|
+
throw new McpError(ErrorCode.MethodNotFound, `Tool ${request2.params.name} requires task augmentation (taskSupport: 'required')`);
|
|
20320
20618
|
}
|
|
20321
20619
|
if (taskSupport === "optional" && !isTaskRequest && isTaskHandler) {
|
|
20322
|
-
return await this.handleAutomaticTaskPolling(tool,
|
|
20620
|
+
return await this.handleAutomaticTaskPolling(tool, request2, extra);
|
|
20323
20621
|
}
|
|
20324
|
-
const args = await this.validateToolInput(tool,
|
|
20622
|
+
const args = await this.validateToolInput(tool, request2.params.arguments, request2.params.name);
|
|
20325
20623
|
const result = await this.executeToolHandler(tool, args, extra);
|
|
20326
20624
|
if (isTaskRequest) {
|
|
20327
20625
|
return result;
|
|
20328
20626
|
}
|
|
20329
|
-
await this.validateToolOutput(tool, result,
|
|
20627
|
+
await this.validateToolOutput(tool, result, request2.params.name);
|
|
20330
20628
|
return result;
|
|
20331
20629
|
} catch (error2) {
|
|
20332
20630
|
if (error2 instanceof McpError) {
|
|
@@ -20427,11 +20725,11 @@ var McpServer = class {
|
|
|
20427
20725
|
/**
|
|
20428
20726
|
* Handles automatic task polling for tools with taskSupport 'optional'.
|
|
20429
20727
|
*/
|
|
20430
|
-
async handleAutomaticTaskPolling(tool,
|
|
20728
|
+
async handleAutomaticTaskPolling(tool, request2, extra) {
|
|
20431
20729
|
if (!extra.taskStore) {
|
|
20432
20730
|
throw new Error("No task store provided for task-capable tool.");
|
|
20433
20731
|
}
|
|
20434
|
-
const args = await this.validateToolInput(tool,
|
|
20732
|
+
const args = await this.validateToolInput(tool, request2.params.arguments, request2.params.name);
|
|
20435
20733
|
const handler = tool.handler;
|
|
20436
20734
|
const taskExtra = { ...extra, taskStore: extra.taskStore };
|
|
20437
20735
|
const createTaskResult = args ? await Promise.resolve(handler.createTask(args, taskExtra)) : (
|
|
@@ -20459,21 +20757,21 @@ var McpServer = class {
|
|
|
20459
20757
|
this.server.registerCapabilities({
|
|
20460
20758
|
completions: {}
|
|
20461
20759
|
});
|
|
20462
|
-
this.server.setRequestHandler(CompleteRequestSchema, async (
|
|
20463
|
-
switch (
|
|
20760
|
+
this.server.setRequestHandler(CompleteRequestSchema, async (request2) => {
|
|
20761
|
+
switch (request2.params.ref.type) {
|
|
20464
20762
|
case "ref/prompt":
|
|
20465
|
-
assertCompleteRequestPrompt(
|
|
20466
|
-
return this.handlePromptCompletion(
|
|
20763
|
+
assertCompleteRequestPrompt(request2);
|
|
20764
|
+
return this.handlePromptCompletion(request2, request2.params.ref);
|
|
20467
20765
|
case "ref/resource":
|
|
20468
|
-
assertCompleteRequestResourceTemplate(
|
|
20469
|
-
return this.handleResourceCompletion(
|
|
20766
|
+
assertCompleteRequestResourceTemplate(request2);
|
|
20767
|
+
return this.handleResourceCompletion(request2, request2.params.ref);
|
|
20470
20768
|
default:
|
|
20471
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid completion reference: ${
|
|
20769
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid completion reference: ${request2.params.ref}`);
|
|
20472
20770
|
}
|
|
20473
20771
|
});
|
|
20474
20772
|
this._completionHandlerInitialized = true;
|
|
20475
20773
|
}
|
|
20476
|
-
async handlePromptCompletion(
|
|
20774
|
+
async handlePromptCompletion(request2, ref) {
|
|
20477
20775
|
const prompt = this._registeredPrompts[ref.name];
|
|
20478
20776
|
if (!prompt) {
|
|
20479
20777
|
throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} not found`);
|
|
@@ -20485,7 +20783,7 @@ var McpServer = class {
|
|
|
20485
20783
|
return EMPTY_COMPLETION_RESULT;
|
|
20486
20784
|
}
|
|
20487
20785
|
const promptShape = getObjectShape(prompt.argsSchema);
|
|
20488
|
-
const field = promptShape?.[
|
|
20786
|
+
const field = promptShape?.[request2.params.argument.name];
|
|
20489
20787
|
if (!isCompletable(field)) {
|
|
20490
20788
|
return EMPTY_COMPLETION_RESULT;
|
|
20491
20789
|
}
|
|
@@ -20493,22 +20791,22 @@ var McpServer = class {
|
|
|
20493
20791
|
if (!completer) {
|
|
20494
20792
|
return EMPTY_COMPLETION_RESULT;
|
|
20495
20793
|
}
|
|
20496
|
-
const suggestions = await completer(
|
|
20794
|
+
const suggestions = await completer(request2.params.argument.value, request2.params.context);
|
|
20497
20795
|
return createCompletionResult(suggestions);
|
|
20498
20796
|
}
|
|
20499
|
-
async handleResourceCompletion(
|
|
20797
|
+
async handleResourceCompletion(request2, ref) {
|
|
20500
20798
|
const template = Object.values(this._registeredResourceTemplates).find((t) => t.resourceTemplate.uriTemplate.toString() === ref.uri);
|
|
20501
20799
|
if (!template) {
|
|
20502
20800
|
if (this._registeredResources[ref.uri]) {
|
|
20503
20801
|
return EMPTY_COMPLETION_RESULT;
|
|
20504
20802
|
}
|
|
20505
|
-
throw new McpError(ErrorCode.InvalidParams, `Resource template ${
|
|
20803
|
+
throw new McpError(ErrorCode.InvalidParams, `Resource template ${request2.params.ref.uri} not found`);
|
|
20506
20804
|
}
|
|
20507
|
-
const completer = template.resourceTemplate.completeCallback(
|
|
20805
|
+
const completer = template.resourceTemplate.completeCallback(request2.params.argument.name);
|
|
20508
20806
|
if (!completer) {
|
|
20509
20807
|
return EMPTY_COMPLETION_RESULT;
|
|
20510
20808
|
}
|
|
20511
|
-
const suggestions = await completer(
|
|
20809
|
+
const suggestions = await completer(request2.params.argument.value, request2.params.context);
|
|
20512
20810
|
return createCompletionResult(suggestions);
|
|
20513
20811
|
}
|
|
20514
20812
|
setResourceRequestHandlers() {
|
|
@@ -20523,7 +20821,7 @@ var McpServer = class {
|
|
|
20523
20821
|
listChanged: true
|
|
20524
20822
|
}
|
|
20525
20823
|
});
|
|
20526
|
-
this.server.setRequestHandler(ListResourcesRequestSchema, async (
|
|
20824
|
+
this.server.setRequestHandler(ListResourcesRequestSchema, async (request2, extra) => {
|
|
20527
20825
|
const resources = Object.entries(this._registeredResources).filter(([_, resource]) => resource.enabled).map(([uri, resource]) => ({
|
|
20528
20826
|
uri,
|
|
20529
20827
|
name: resource.name,
|
|
@@ -20553,8 +20851,8 @@ var McpServer = class {
|
|
|
20553
20851
|
}));
|
|
20554
20852
|
return { resourceTemplates };
|
|
20555
20853
|
});
|
|
20556
|
-
this.server.setRequestHandler(ReadResourceRequestSchema, async (
|
|
20557
|
-
const uri = new URL(
|
|
20854
|
+
this.server.setRequestHandler(ReadResourceRequestSchema, async (request2, extra) => {
|
|
20855
|
+
const uri = new URL(request2.params.uri);
|
|
20558
20856
|
const resource = this._registeredResources[uri.toString()];
|
|
20559
20857
|
if (resource) {
|
|
20560
20858
|
if (!resource.enabled) {
|
|
@@ -20593,21 +20891,21 @@ var McpServer = class {
|
|
|
20593
20891
|
};
|
|
20594
20892
|
})
|
|
20595
20893
|
}));
|
|
20596
|
-
this.server.setRequestHandler(GetPromptRequestSchema, async (
|
|
20597
|
-
const prompt = this._registeredPrompts[
|
|
20894
|
+
this.server.setRequestHandler(GetPromptRequestSchema, async (request2, extra) => {
|
|
20895
|
+
const prompt = this._registeredPrompts[request2.params.name];
|
|
20598
20896
|
if (!prompt) {
|
|
20599
|
-
throw new McpError(ErrorCode.InvalidParams, `Prompt ${
|
|
20897
|
+
throw new McpError(ErrorCode.InvalidParams, `Prompt ${request2.params.name} not found`);
|
|
20600
20898
|
}
|
|
20601
20899
|
if (!prompt.enabled) {
|
|
20602
|
-
throw new McpError(ErrorCode.InvalidParams, `Prompt ${
|
|
20900
|
+
throw new McpError(ErrorCode.InvalidParams, `Prompt ${request2.params.name} disabled`);
|
|
20603
20901
|
}
|
|
20604
20902
|
if (prompt.argsSchema) {
|
|
20605
20903
|
const argsObj = normalizeObjectSchema(prompt.argsSchema);
|
|
20606
|
-
const parseResult = await safeParseAsync2(argsObj,
|
|
20904
|
+
const parseResult = await safeParseAsync2(argsObj, request2.params.arguments);
|
|
20607
20905
|
if (!parseResult.success) {
|
|
20608
20906
|
const error2 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
20609
20907
|
const errorMessage = getParseErrorMessage(error2);
|
|
20610
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${
|
|
20908
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request2.params.name}: ${errorMessage}`);
|
|
20611
20909
|
}
|
|
20612
20910
|
const args = parseResult.data;
|
|
20613
20911
|
const cb = prompt.callback;
|
|
@@ -21934,12 +22232,12 @@ var MindForgeClient = class extends import_events.EventEmitter {
|
|
|
21934
22232
|
return { phaseId: phase, taskId: options?.taskFilter || "*", stream };
|
|
21935
22233
|
}
|
|
21936
22234
|
// ── v11 Phase 5B: Batch execution with semaphore-based concurrency ────────
|
|
21937
|
-
async batchExecute(
|
|
22235
|
+
async batchExecute(request2) {
|
|
21938
22236
|
const startTime = Date.now();
|
|
21939
|
-
const maxConcurrency =
|
|
22237
|
+
const maxConcurrency = request2.maxConcurrency || 3;
|
|
21940
22238
|
const results = [];
|
|
21941
22239
|
let running = 0;
|
|
21942
|
-
const queue = [...
|
|
22240
|
+
const queue = [...request2.tasks];
|
|
21943
22241
|
await new Promise((resolve) => {
|
|
21944
22242
|
const processNext = () => {
|
|
21945
22243
|
if (queue.length === 0 && running === 0) {
|
|
@@ -22011,8 +22309,63 @@ var MindForgeClient = class extends import_events.EventEmitter {
|
|
|
22011
22309
|
}
|
|
22012
22310
|
};
|
|
22013
22311
|
|
|
22312
|
+
// src/browser-client.ts
|
|
22313
|
+
var http = __toESM(require("http"));
|
|
22314
|
+
var fs3 = __toESM(require("fs"));
|
|
22315
|
+
var path3 = __toESM(require("path"));
|
|
22316
|
+
var BROWSER_PORT = Number(process.env.BROWSER_PORT) || 7338;
|
|
22317
|
+
function readDaemonToken(projectRoot) {
|
|
22318
|
+
const tokenPath = path3.join(projectRoot, ".mindforge", ".browser-daemon-token");
|
|
22319
|
+
try {
|
|
22320
|
+
return fs3.readFileSync(tokenPath, "utf8").trim();
|
|
22321
|
+
} catch {
|
|
22322
|
+
return null;
|
|
22323
|
+
}
|
|
22324
|
+
}
|
|
22325
|
+
function browserRequest(projectRoot, method, endpoint, body = null) {
|
|
22326
|
+
return new Promise((resolve, reject) => {
|
|
22327
|
+
const token = readDaemonToken(projectRoot);
|
|
22328
|
+
const headers = { "Content-Type": "application/json" };
|
|
22329
|
+
if (token) headers.Authorization = `Bearer ${token}`;
|
|
22330
|
+
const req = http.request(
|
|
22331
|
+
{ hostname: "127.0.0.1", port: BROWSER_PORT, path: endpoint, method, headers },
|
|
22332
|
+
(res) => {
|
|
22333
|
+
let data = "";
|
|
22334
|
+
res.on("data", (chunk) => {
|
|
22335
|
+
data += chunk;
|
|
22336
|
+
});
|
|
22337
|
+
res.on("end", () => {
|
|
22338
|
+
try {
|
|
22339
|
+
resolve(JSON.parse(data));
|
|
22340
|
+
} catch {
|
|
22341
|
+
resolve({ success: false, error: "Invalid JSON response" });
|
|
22342
|
+
}
|
|
22343
|
+
});
|
|
22344
|
+
}
|
|
22345
|
+
);
|
|
22346
|
+
req.setTimeout(1e4, () => req.destroy(new Error("Browser daemon request timed out")));
|
|
22347
|
+
req.on("error", reject);
|
|
22348
|
+
if (body) req.write(JSON.stringify(body));
|
|
22349
|
+
req.end();
|
|
22350
|
+
});
|
|
22351
|
+
}
|
|
22352
|
+
async function isDaemonRunning(projectRoot) {
|
|
22353
|
+
try {
|
|
22354
|
+
const result = await browserRequest(projectRoot, "GET", "/status");
|
|
22355
|
+
return result.alive === true;
|
|
22356
|
+
} catch {
|
|
22357
|
+
return false;
|
|
22358
|
+
}
|
|
22359
|
+
}
|
|
22360
|
+
var DAEMON_NOT_RUNNING_HINT = "The MindForge browser daemon is not running. Start it first with `/mindforge:browse --start` (requires a full `npx mindforge-cc@latest --claude --local` install in this project \u2014 this MCP tool never spawns the daemon itself).";
|
|
22361
|
+
async function ensureDaemonRunning(projectRoot) {
|
|
22362
|
+
if (!await isDaemonRunning(projectRoot)) {
|
|
22363
|
+
throw new Error(DAEMON_NOT_RUNNING_HINT);
|
|
22364
|
+
}
|
|
22365
|
+
}
|
|
22366
|
+
|
|
22014
22367
|
// package.json
|
|
22015
|
-
var version2 = "11.9.
|
|
22368
|
+
var version2 = "11.9.6";
|
|
22016
22369
|
|
|
22017
22370
|
// src/index.ts
|
|
22018
22371
|
var PROJECT_ROOT = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
@@ -22028,17 +22381,22 @@ async function safe(label, fn) {
|
|
|
22028
22381
|
} catch (err) {
|
|
22029
22382
|
const message = err instanceof Error ? err.message : String(err);
|
|
22030
22383
|
return {
|
|
22031
|
-
content: [
|
|
22032
|
-
|
|
22033
|
-
|
|
22384
|
+
content: [
|
|
22385
|
+
{
|
|
22386
|
+
type: "text",
|
|
22387
|
+
text: `MindForge ${label} failed: ${message}
|
|
22034
22388
|
|
|
22035
22389
|
If MindForge is not set up in this project, run \`npx mindforge-cc@latest --claude --local\` or \`/mindforge:init-project\` first.`
|
|
22036
|
-
|
|
22390
|
+
}
|
|
22391
|
+
],
|
|
22037
22392
|
isError: true
|
|
22038
22393
|
};
|
|
22039
22394
|
}
|
|
22040
22395
|
}
|
|
22041
|
-
var server = new McpServer({
|
|
22396
|
+
var server = new McpServer({
|
|
22397
|
+
name: "mindforge",
|
|
22398
|
+
version: version2
|
|
22399
|
+
});
|
|
22042
22400
|
function registerTool(name, config2, handler) {
|
|
22043
22401
|
server.registerTool(name, config2, handler);
|
|
22044
22402
|
}
|
|
@@ -22048,7 +22406,11 @@ registerTool(
|
|
|
22048
22406
|
title: "MindForge project health",
|
|
22049
22407
|
description: "Run a MindForge health check on the current project: verifies required planning/governance files exist, validates HANDOFF.json, and reports the audit-log size. Returns overallStatus (healthy|warning|error) with details.",
|
|
22050
22408
|
inputSchema: {},
|
|
22051
|
-
annotations: {
|
|
22409
|
+
annotations: {
|
|
22410
|
+
readOnlyHint: true,
|
|
22411
|
+
destructiveHint: false,
|
|
22412
|
+
openWorldHint: false
|
|
22413
|
+
}
|
|
22052
22414
|
},
|
|
22053
22415
|
async () => safe("health", async () => client().health())
|
|
22054
22416
|
);
|
|
@@ -22058,7 +22420,11 @@ registerTool(
|
|
|
22058
22420
|
title: "MindForge project status",
|
|
22059
22421
|
description: "Read the current MindForge project status: whether the project is initialized, the raw STATE.md, the HANDOFF.json contents, and the autonomous-run auto-state.json if present. Use to understand where a MindForge project currently stands.",
|
|
22060
22422
|
inputSchema: {},
|
|
22061
|
-
annotations: {
|
|
22423
|
+
annotations: {
|
|
22424
|
+
readOnlyHint: true,
|
|
22425
|
+
destructiveHint: false,
|
|
22426
|
+
openWorldHint: false
|
|
22427
|
+
}
|
|
22062
22428
|
},
|
|
22063
22429
|
async () => safe("status", async () => {
|
|
22064
22430
|
const c = client();
|
|
@@ -22092,7 +22458,11 @@ registerTool(
|
|
|
22092
22458
|
title: "Query MindForge knowledge base",
|
|
22093
22459
|
description: "Search the MindForge knowledge graph (architectural decisions, code/bug patterns, team preferences, domain knowledge) by topic text, tags, and type. Results are relevance-ranked. Use to recall prior decisions and patterns for the current project.",
|
|
22094
22460
|
inputSchema: memoryQuerySchema,
|
|
22095
|
-
annotations: {
|
|
22461
|
+
annotations: {
|
|
22462
|
+
readOnlyHint: true,
|
|
22463
|
+
destructiveHint: false,
|
|
22464
|
+
openWorldHint: false
|
|
22465
|
+
}
|
|
22096
22466
|
},
|
|
22097
22467
|
async (args) => safe("memory_query", async () => {
|
|
22098
22468
|
const results = await memory().query({
|
|
@@ -22112,7 +22482,11 @@ registerTool(
|
|
|
22112
22482
|
title: "MindForge memory statistics",
|
|
22113
22483
|
description: "Report statistics for the MindForge knowledge graph: total/active/deprecated entries, breakdown by type, average confidence, plus graph metrics (nodes, edges, edges by type, orphan ratio). Use to gauge how much project memory exists.",
|
|
22114
22484
|
inputSchema: {},
|
|
22115
|
-
annotations: {
|
|
22485
|
+
annotations: {
|
|
22486
|
+
readOnlyHint: true,
|
|
22487
|
+
destructiveHint: false,
|
|
22488
|
+
openWorldHint: false
|
|
22489
|
+
}
|
|
22116
22490
|
},
|
|
22117
22491
|
async () => safe("memory_stats", async () => {
|
|
22118
22492
|
const m = memory();
|
|
@@ -22129,10 +22503,17 @@ registerTool(
|
|
|
22129
22503
|
maxHops: external_exports.number().int().min(0).max(5).optional().describe("Graph traversal depth (default 2)"),
|
|
22130
22504
|
topK: external_exports.number().int().positive().max(50).optional().describe("Max results (default 10)")
|
|
22131
22505
|
},
|
|
22132
|
-
annotations: {
|
|
22506
|
+
annotations: {
|
|
22507
|
+
readOnlyHint: true,
|
|
22508
|
+
destructiveHint: false,
|
|
22509
|
+
openWorldHint: false
|
|
22510
|
+
}
|
|
22133
22511
|
},
|
|
22134
22512
|
async (args) => safe("memory_find_related", async () => {
|
|
22135
|
-
const results = await memory().findRelated(args.query, {
|
|
22513
|
+
const results = await memory().findRelated(args.query, {
|
|
22514
|
+
maxHops: args.maxHops,
|
|
22515
|
+
topK: args.topK
|
|
22516
|
+
});
|
|
22136
22517
|
return { count: results.length, related: results };
|
|
22137
22518
|
})
|
|
22138
22519
|
);
|
|
@@ -22147,10 +22528,17 @@ registerTool(
|
|
|
22147
22528
|
title: "Read MindForge audit log",
|
|
22148
22529
|
description: "Read entries from the MindForge audit log (.planning/AUDIT.jsonl), optionally filtered by event type or phase. Use to review what the framework has recorded for this project (task completions, security findings, decisions).",
|
|
22149
22530
|
inputSchema: auditLogSchema,
|
|
22150
|
-
annotations: {
|
|
22531
|
+
annotations: {
|
|
22532
|
+
readOnlyHint: true,
|
|
22533
|
+
destructiveHint: false,
|
|
22534
|
+
openWorldHint: false
|
|
22535
|
+
}
|
|
22151
22536
|
},
|
|
22152
22537
|
async (args) => safe("audit_log", async () => {
|
|
22153
|
-
const all = client().readAuditLog({
|
|
22538
|
+
const all = client().readAuditLog({
|
|
22539
|
+
event: args.event,
|
|
22540
|
+
phase: args.phase
|
|
22541
|
+
});
|
|
22154
22542
|
const limit = args.limit ?? 50;
|
|
22155
22543
|
const entries = all.slice(-limit);
|
|
22156
22544
|
return { total: all.length, returned: entries.length, entries };
|
|
@@ -22168,7 +22556,12 @@ registerTool(
|
|
|
22168
22556
|
confidence: external_exports.number().min(0).max(1).optional().describe("Confidence 0-1 (default 0.7)"),
|
|
22169
22557
|
tags: external_exports.array(external_exports.string()).optional().describe("Tags for later retrieval")
|
|
22170
22558
|
},
|
|
22171
|
-
annotations: {
|
|
22559
|
+
annotations: {
|
|
22560
|
+
readOnlyHint: false,
|
|
22561
|
+
destructiveHint: false,
|
|
22562
|
+
idempotentHint: false,
|
|
22563
|
+
openWorldHint: false
|
|
22564
|
+
}
|
|
22172
22565
|
},
|
|
22173
22566
|
async (args) => safe("memory_remember", async () => {
|
|
22174
22567
|
const id = await memory().remember({
|
|
@@ -22182,6 +22575,83 @@ registerTool(
|
|
|
22182
22575
|
return { id, stored: true };
|
|
22183
22576
|
})
|
|
22184
22577
|
);
|
|
22578
|
+
var BROWSE_ACTIONS = [
|
|
22579
|
+
"status",
|
|
22580
|
+
"navigate",
|
|
22581
|
+
"click",
|
|
22582
|
+
"type",
|
|
22583
|
+
"screenshot",
|
|
22584
|
+
"assert"
|
|
22585
|
+
];
|
|
22586
|
+
var browseSchema = {
|
|
22587
|
+
action: external_exports.enum(BROWSE_ACTIONS).describe("Browser action to perform"),
|
|
22588
|
+
url: external_exports.string().optional().describe("URL to navigate to (action=navigate)"),
|
|
22589
|
+
selector: external_exports.string().optional().describe("CSS selector (action=click|type|assert)"),
|
|
22590
|
+
text: external_exports.string().optional().describe("Text to type, or fallback click-by-text (action=click|type)"),
|
|
22591
|
+
session: external_exports.string().optional().describe('Named browser session/context (default "default")'),
|
|
22592
|
+
assertType: external_exports.enum(["visible", "url", "title"]).optional().describe("Assertion kind (action=assert)"),
|
|
22593
|
+
expectedText: external_exports.string().optional().describe("Expected value for the assertion (action=assert)")
|
|
22594
|
+
};
|
|
22595
|
+
registerTool(
|
|
22596
|
+
"mindforge_browse",
|
|
22597
|
+
{
|
|
22598
|
+
title: "Control the MindForge browser daemon",
|
|
22599
|
+
description: "Drive the persistent MindForge Playwright/Chromium daemon (the same one behind /mindforge:browse): check status, navigate, click, type, screenshot, or assert on the current page. The daemon binds to 127.0.0.1 only (ADR-024) and must already be running \u2014 start it with `/mindforge:browse --start` first; this tool never spawns it. Arbitrary JS evaluation and native-browser cookie import are intentionally NOT exposed here.",
|
|
22600
|
+
inputSchema: browseSchema,
|
|
22601
|
+
annotations: {
|
|
22602
|
+
readOnlyHint: false,
|
|
22603
|
+
destructiveHint: true,
|
|
22604
|
+
idempotentHint: false,
|
|
22605
|
+
openWorldHint: true
|
|
22606
|
+
}
|
|
22607
|
+
},
|
|
22608
|
+
async (args) => safe("browse", async () => {
|
|
22609
|
+
const session = args.session ?? "default";
|
|
22610
|
+
await ensureDaemonRunning(PROJECT_ROOT);
|
|
22611
|
+
switch (args.action) {
|
|
22612
|
+
case "status":
|
|
22613
|
+
return browserRequest(PROJECT_ROOT, "GET", "/status");
|
|
22614
|
+
case "navigate":
|
|
22615
|
+
if (!args.url)
|
|
22616
|
+
throw new Error("action=navigate requires a `url` argument");
|
|
22617
|
+
return browserRequest(PROJECT_ROOT, "POST", "/navigate", {
|
|
22618
|
+
url: args.url,
|
|
22619
|
+
session
|
|
22620
|
+
});
|
|
22621
|
+
case "click":
|
|
22622
|
+
if (!args.selector && !args.text)
|
|
22623
|
+
throw new Error("action=click requires `selector` or `text`");
|
|
22624
|
+
return browserRequest(PROJECT_ROOT, "POST", "/click", {
|
|
22625
|
+
selector: args.selector,
|
|
22626
|
+
text: args.text,
|
|
22627
|
+
session
|
|
22628
|
+
});
|
|
22629
|
+
case "type":
|
|
22630
|
+
if (!args.selector || args.text === void 0)
|
|
22631
|
+
throw new Error("action=type requires `selector` and `text`");
|
|
22632
|
+
return browserRequest(PROJECT_ROOT, "POST", "/type", {
|
|
22633
|
+
selector: args.selector,
|
|
22634
|
+
text: args.text,
|
|
22635
|
+
session
|
|
22636
|
+
});
|
|
22637
|
+
case "screenshot":
|
|
22638
|
+
return browserRequest(PROJECT_ROOT, "POST", "/screenshot", {
|
|
22639
|
+
session
|
|
22640
|
+
});
|
|
22641
|
+
case "assert":
|
|
22642
|
+
if (!args.assertType)
|
|
22643
|
+
throw new Error("action=assert requires `assertType`");
|
|
22644
|
+
return browserRequest(PROJECT_ROOT, "POST", "/assert", {
|
|
22645
|
+
type: args.assertType,
|
|
22646
|
+
selector: args.selector,
|
|
22647
|
+
expected_text: args.expectedText,
|
|
22648
|
+
session
|
|
22649
|
+
});
|
|
22650
|
+
default:
|
|
22651
|
+
throw new Error(`Unsupported action: ${String(args.action)}`);
|
|
22652
|
+
}
|
|
22653
|
+
})
|
|
22654
|
+
);
|
|
22185
22655
|
async function main() {
|
|
22186
22656
|
const transport = new StdioServerTransport();
|
|
22187
22657
|
await server.connect(transport);
|
|
@@ -22189,7 +22659,9 @@ async function main() {
|
|
|
22189
22659
|
`);
|
|
22190
22660
|
}
|
|
22191
22661
|
main().catch((err) => {
|
|
22192
|
-
process.stderr.write(
|
|
22193
|
-
`)
|
|
22662
|
+
process.stderr.write(
|
|
22663
|
+
`[mindforge-mcp] fatal: ${err instanceof Error ? err.stack : String(err)}
|
|
22664
|
+
`
|
|
22665
|
+
);
|
|
22194
22666
|
process.exit(1);
|
|
22195
22667
|
});
|