@j0hanz/fetch-url-mcp 1.10.21 → 1.10.23
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/http/auth.d.ts +2 -0
- package/dist/http/auth.d.ts.map +1 -1
- package/dist/http/auth.js +30 -0
- package/dist/lib/core.d.ts +1 -1
- package/dist/lib/core.d.ts.map +1 -1
- package/dist/lib/core.js +44 -28
- package/dist/lib/dom-prep.d.ts +2 -0
- package/dist/lib/dom-prep.d.ts.map +1 -1
- package/dist/lib/dom-prep.js +88 -23
- package/dist/lib/http.d.ts.map +1 -1
- package/dist/lib/http.js +84 -55
- package/dist/lib/sdk-interop.d.ts +12 -0
- package/dist/lib/sdk-interop.d.ts.map +1 -1
- package/dist/lib/sdk-interop.js +12 -0
- package/dist/lib/session.d.ts +4 -1
- package/dist/lib/session.d.ts.map +1 -1
- package/dist/lib/session.js +1 -1
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +5 -0
- package/dist/resources/index.js +2 -2
- package/dist/schemas.js +1 -1
- package/dist/transform/html-translators.d.ts.map +1 -1
- package/dist/transform/html-translators.js +50 -8
- package/dist/transform/markdown-cleanup.d.ts.map +1 -1
- package/dist/transform/markdown-cleanup.js +71 -63
- package/dist/transform/title-policy.d.ts +1 -3
- package/dist/transform/title-policy.d.ts.map +1 -1
- package/dist/transform/title-policy.js +3 -8
- package/dist/transform/transform.d.ts.map +1 -1
- package/dist/transform/transform.js +120 -64
- package/dist/transform/worker-pool.d.ts +2 -0
- package/dist/transform/worker-pool.d.ts.map +1 -1
- package/dist/transform/worker-pool.js +38 -17
- package/package.json +1 -1
package/dist/lib/http.js
CHANGED
|
@@ -252,7 +252,7 @@ function extractXmlEncoding(headSnippet) {
|
|
|
252
252
|
return encoding ? encoding.toLowerCase() : undefined;
|
|
253
253
|
}
|
|
254
254
|
function detectHtmlDeclaredEncoding(buffer) {
|
|
255
|
-
const scanSize = Math.min(buffer.length,
|
|
255
|
+
const scanSize = Math.min(buffer.length, ENCODING_SCAN_LIMIT);
|
|
256
256
|
if (scanSize === 0)
|
|
257
257
|
return undefined;
|
|
258
258
|
const headSnippet = createDecoder('latin1').decode(buffer.subarray(0, scanSize));
|
|
@@ -269,38 +269,41 @@ function resolveEncoding(declared, sample) {
|
|
|
269
269
|
// ═══════════════════════════════════════════════════════════════════
|
|
270
270
|
// BINARY DETECTION
|
|
271
271
|
// ═══════════════════════════════════════════════════════════════════
|
|
272
|
+
const ENCODING_SCAN_LIMIT = 8_192;
|
|
273
|
+
const BINARY_SCAN_LIMIT = 8_192;
|
|
274
|
+
const BINARY_NULL_CHECK_LIMIT = 1_000;
|
|
272
275
|
const BINARY_SIGNATURES = [
|
|
273
|
-
[0x25, 0x50, 0x44, 0x46],
|
|
274
|
-
[0x89, 0x50, 0x4e, 0x47],
|
|
275
|
-
[0x47, 0x49, 0x46, 0x38],
|
|
276
|
-
[0xff, 0xd8, 0xff],
|
|
277
|
-
[0x52, 0x49, 0x46, 0x46],
|
|
278
|
-
[0x42, 0x4d],
|
|
279
|
-
[0x49, 0x49, 0x2a, 0x00],
|
|
280
|
-
[0x4d, 0x4d, 0x00, 0x2a],
|
|
281
|
-
[0x00, 0x00, 0x01, 0x00],
|
|
282
|
-
[0x50, 0x4b, 0x03, 0x04],
|
|
283
|
-
[0x1f, 0x8b],
|
|
284
|
-
[0x42, 0x5a, 0x68],
|
|
285
|
-
[0x52, 0x61, 0x72, 0x21],
|
|
286
|
-
[0x37, 0x7a, 0xbc, 0xaf],
|
|
287
|
-
[0x7f, 0x45, 0x4c, 0x46],
|
|
288
|
-
[0x4d, 0x5a],
|
|
289
|
-
[0xcf, 0xfa, 0xed, 0xfe],
|
|
290
|
-
[0x00, 0x61, 0x73, 0x6d],
|
|
291
|
-
[0x1a, 0x45, 0xdf, 0xa3],
|
|
292
|
-
[0x66, 0x74, 0x79, 0x70],
|
|
293
|
-
[0x46, 0x4c, 0x56],
|
|
294
|
-
[0x49, 0x44, 0x33],
|
|
295
|
-
[0xff, 0xfb],
|
|
296
|
-
[0xff, 0xfa],
|
|
297
|
-
[0x4f, 0x67, 0x67, 0x53],
|
|
298
|
-
[0x66, 0x4c, 0x61, 0x43],
|
|
299
|
-
[0x4d, 0x54, 0x68, 0x64],
|
|
300
|
-
[0x77, 0x4f, 0x46, 0x46],
|
|
301
|
-
[0x00, 0x01, 0x00, 0x00],
|
|
302
|
-
[0x4f, 0x54, 0x54, 0x4f],
|
|
303
|
-
[0x53, 0x51, 0x4c, 0x69],
|
|
276
|
+
[0x25, 0x50, 0x44, 0x46], // PDF
|
|
277
|
+
[0x89, 0x50, 0x4e, 0x47], // PNG
|
|
278
|
+
[0x47, 0x49, 0x46, 0x38], // GIF
|
|
279
|
+
[0xff, 0xd8, 0xff], // JPEG
|
|
280
|
+
[0x52, 0x49, 0x46, 0x46], // RIFF (WebP/AVI/WAV)
|
|
281
|
+
[0x42, 0x4d], // BMP
|
|
282
|
+
[0x49, 0x49, 0x2a, 0x00], // TIFF (little-endian)
|
|
283
|
+
[0x4d, 0x4d, 0x00, 0x2a], // TIFF (big-endian)
|
|
284
|
+
[0x00, 0x00, 0x01, 0x00], // ICO
|
|
285
|
+
[0x50, 0x4b, 0x03, 0x04], // ZIP/XLSX/DOCX
|
|
286
|
+
[0x1f, 0x8b], // GZIP
|
|
287
|
+
[0x42, 0x5a, 0x68], // BZIP2
|
|
288
|
+
[0x52, 0x61, 0x72, 0x21], // RAR
|
|
289
|
+
[0x37, 0x7a, 0xbc, 0xaf], // 7-Zip
|
|
290
|
+
[0x7f, 0x45, 0x4c, 0x46], // ELF
|
|
291
|
+
[0x4d, 0x5a], // PE/MZ (Windows executable)
|
|
292
|
+
[0xcf, 0xfa, 0xed, 0xfe], // Mach-O
|
|
293
|
+
[0x00, 0x61, 0x73, 0x6d], // WebAssembly
|
|
294
|
+
[0x1a, 0x45, 0xdf, 0xa3], // MKV/WebM (EBML)
|
|
295
|
+
[0x66, 0x74, 0x79, 0x70], // MP4/MOV (ftyp)
|
|
296
|
+
[0x46, 0x4c, 0x56], // FLV
|
|
297
|
+
[0x49, 0x44, 0x33], // MP3 (ID3 tag)
|
|
298
|
+
[0xff, 0xfb], // MP3 (sync frame)
|
|
299
|
+
[0xff, 0xfa], // MP3 (sync frame, alt)
|
|
300
|
+
[0x4f, 0x67, 0x67, 0x53], // OGG
|
|
301
|
+
[0x66, 0x4c, 0x61, 0x43], // FLAC
|
|
302
|
+
[0x4d, 0x54, 0x68, 0x64], // MIDI
|
|
303
|
+
[0x77, 0x4f, 0x46, 0x46], // WOFF
|
|
304
|
+
[0x00, 0x01, 0x00, 0x00], // TrueType font
|
|
305
|
+
[0x4f, 0x54, 0x54, 0x4f], // OpenType font
|
|
306
|
+
[0x53, 0x51, 0x4c, 0x69], // SQLite
|
|
304
307
|
];
|
|
305
308
|
const BINARY_SIG_BY_FIRST_BYTE = createSignatureMap(BINARY_SIGNATURES, (sig) => sig[0]);
|
|
306
309
|
function hasNullByte(buffer, limit) {
|
|
@@ -327,10 +330,12 @@ function isBinaryContent(buffer, encoding) {
|
|
|
327
330
|
return true;
|
|
328
331
|
if (isUnicodeWideEncoding(encoding))
|
|
329
332
|
return false;
|
|
330
|
-
const sample = buffer.length >
|
|
333
|
+
const sample = buffer.length > BINARY_SCAN_LIMIT
|
|
334
|
+
? buffer.subarray(0, BINARY_SCAN_LIMIT)
|
|
335
|
+
: buffer;
|
|
331
336
|
if (isUtf8(sample))
|
|
332
337
|
return false;
|
|
333
|
-
return hasNullByte(buffer,
|
|
338
|
+
return hasNullByte(buffer, BINARY_SCAN_LIMIT);
|
|
334
339
|
}
|
|
335
340
|
function createBinaryContentError(url) {
|
|
336
341
|
return new FetchError('Detailed content type check failed: binary content detected', url, 500, { reason: 'binary_content_detected' });
|
|
@@ -395,6 +400,13 @@ function resolveErrorUrl(error, fallback) {
|
|
|
395
400
|
const { requestUrl } = error;
|
|
396
401
|
return typeof requestUrl === 'string' ? requestUrl : fallback;
|
|
397
402
|
}
|
|
403
|
+
const CLIENT_ERROR_CODES = new Set([
|
|
404
|
+
VALIDATION_ERROR_CODE,
|
|
405
|
+
'EBADREDIRECT',
|
|
406
|
+
'EBLOCKED',
|
|
407
|
+
'ENODATA',
|
|
408
|
+
'EINVAL',
|
|
409
|
+
]);
|
|
398
410
|
function mapFetchError(error, fallbackUrl, timeoutMs) {
|
|
399
411
|
if (error instanceof FetchError)
|
|
400
412
|
return error;
|
|
@@ -415,11 +427,7 @@ function mapFetchError(error, fallbackUrl, timeoutMs) {
|
|
|
415
427
|
if (code === 'ETIMEOUT') {
|
|
416
428
|
return new FetchError(error.message, url, 504, { code });
|
|
417
429
|
}
|
|
418
|
-
if (code
|
|
419
|
-
code === 'EBADREDIRECT' ||
|
|
420
|
-
code === 'EBLOCKED' ||
|
|
421
|
-
code === 'ENODATA' ||
|
|
422
|
-
code === 'EINVAL') {
|
|
430
|
+
if (code && CLIENT_ERROR_CODES.has(code)) {
|
|
423
431
|
return new FetchError(error.message, url, 400, { code });
|
|
424
432
|
}
|
|
425
433
|
return createFetchError({ kind: 'network', message: error.message }, url);
|
|
@@ -525,11 +533,7 @@ class RedirectFollower {
|
|
|
525
533
|
const location = this.getRedirectLocation(response, currentUrl);
|
|
526
534
|
cancelResponseBody(response);
|
|
527
535
|
const nextUrl = this.resolveRedirectTarget(currentUrl, location);
|
|
528
|
-
|
|
529
|
-
if (parsedNextUrl.protocol !== 'http:' &&
|
|
530
|
-
parsedNextUrl.protocol !== 'https:') {
|
|
531
|
-
throw createErrorWithCode(`Unsupported redirect protocol: ${parsedNextUrl.protocol}`, 'EUNSUPPORTEDPROTOCOL');
|
|
532
|
-
}
|
|
536
|
+
this.assertHttpProtocol(nextUrl);
|
|
533
537
|
return {
|
|
534
538
|
response,
|
|
535
539
|
nextUrl,
|
|
@@ -563,6 +567,12 @@ class RedirectFollower {
|
|
|
563
567
|
return;
|
|
564
568
|
error['requestUrl'] = url;
|
|
565
569
|
}
|
|
570
|
+
assertHttpProtocol(url) {
|
|
571
|
+
const parsed = new URL(url);
|
|
572
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
|
|
573
|
+
throw createErrorWithCode(`Unsupported redirect protocol: ${parsed.protocol}`, 'EUNSUPPORTEDPROTOCOL');
|
|
574
|
+
}
|
|
575
|
+
}
|
|
566
576
|
async withRedirectErrorContext(url, fn) {
|
|
567
577
|
try {
|
|
568
578
|
return await fn();
|
|
@@ -838,7 +848,8 @@ class BoundedBufferTransform extends Transform {
|
|
|
838
848
|
const isFirst = this.firstChunk;
|
|
839
849
|
this.firstChunk = false;
|
|
840
850
|
if ((isFirst && hasBinarySignature(buf)) ||
|
|
841
|
-
(!isUnicodeWideEncoding(this.effectiveEncoding) &&
|
|
851
|
+
(!isUnicodeWideEncoding(this.effectiveEncoding) &&
|
|
852
|
+
hasNullByte(buf, BINARY_NULL_CHECK_LIMIT))) {
|
|
842
853
|
return createBinaryContentError(this.url);
|
|
843
854
|
}
|
|
844
855
|
return null;
|
|
@@ -869,22 +880,24 @@ function assertNonBinaryContent(buffer, encoding, url) {
|
|
|
869
880
|
}
|
|
870
881
|
}
|
|
871
882
|
class ResponseTextReader {
|
|
872
|
-
async read(response,
|
|
873
|
-
const { buffer, encoding: effectiveEncoding, truncated, } = await this.readBuffer(response,
|
|
883
|
+
async read(response, opts) {
|
|
884
|
+
const { buffer, encoding: effectiveEncoding, truncated, } = await this.readBuffer(response, opts);
|
|
874
885
|
const text = decodeBuffer(buffer, effectiveEncoding);
|
|
875
886
|
return { text, size: buffer.byteLength, truncated };
|
|
876
887
|
}
|
|
877
|
-
async readBuffer(response,
|
|
888
|
+
async readBuffer(response, opts) {
|
|
889
|
+
const { url, signal } = opts;
|
|
878
890
|
if (signal?.aborted) {
|
|
879
891
|
cancelResponseBody(response);
|
|
880
892
|
throw createFetchError({ kind: 'aborted' }, url);
|
|
881
893
|
}
|
|
882
894
|
if (!response.body) {
|
|
883
|
-
return this.readNonStreamBuffer(response,
|
|
895
|
+
return this.readNonStreamBuffer(response, opts);
|
|
884
896
|
}
|
|
885
|
-
return this.readStreamToBuffer(response.body,
|
|
897
|
+
return this.readStreamToBuffer(response.body, opts);
|
|
886
898
|
}
|
|
887
|
-
async readNonStreamBuffer(response,
|
|
899
|
+
async readNonStreamBuffer(response, opts) {
|
|
900
|
+
const { url, maxBytes, signal, encoding } = opts;
|
|
888
901
|
if (signal?.aborted)
|
|
889
902
|
throw createFetchError({ kind: 'canceled' }, url);
|
|
890
903
|
const limit = maxBytes <= 0 ? Number.POSITIVE_INFINITY : maxBytes;
|
|
@@ -901,7 +914,8 @@ class ResponseTextReader {
|
|
|
901
914
|
truncated,
|
|
902
915
|
};
|
|
903
916
|
}
|
|
904
|
-
async readStreamToBuffer(stream,
|
|
917
|
+
async readStreamToBuffer(stream, opts) {
|
|
918
|
+
const { url, maxBytes, signal, encoding } = opts;
|
|
905
919
|
const byteLimit = maxBytes <= 0 ? Number.POSITIVE_INFINITY : maxBytes;
|
|
906
920
|
const captureChunks = byteLimit !== Number.POSITIVE_INFINITY;
|
|
907
921
|
const source = Readable.fromWeb(toNodeReadableStream(stream, url, 'response:read-stream-buffer'));
|
|
@@ -958,11 +972,21 @@ async function readAndRecordDecodedResponse(opts) {
|
|
|
958
972
|
assertSupportedContentType(contentType, finalUrl);
|
|
959
973
|
const declaredEncoding = getCharsetFromContentType(contentType ?? null);
|
|
960
974
|
if (mode === 'text') {
|
|
961
|
-
const { text, size, truncated } = await reader.read(response,
|
|
975
|
+
const { text, size, truncated } = await reader.read(response, {
|
|
976
|
+
url: finalUrl,
|
|
977
|
+
maxBytes,
|
|
978
|
+
signal,
|
|
979
|
+
encoding: declaredEncoding,
|
|
980
|
+
});
|
|
962
981
|
telemetry.recordResponse(ctx, response, size);
|
|
963
982
|
return { kind: 'text', text, size, truncated };
|
|
964
983
|
}
|
|
965
|
-
const { buffer, encoding, size, truncated } = await reader.readBuffer(response,
|
|
984
|
+
const { buffer, encoding, size, truncated } = await reader.readBuffer(response, {
|
|
985
|
+
url: finalUrl,
|
|
986
|
+
maxBytes,
|
|
987
|
+
signal,
|
|
988
|
+
encoding: declaredEncoding,
|
|
989
|
+
});
|
|
966
990
|
telemetry.recordResponse(ctx, response, size);
|
|
967
991
|
return { kind: 'buffer', buffer, encoding, size, truncated };
|
|
968
992
|
}
|
|
@@ -1268,7 +1292,12 @@ export async function fetchWithRedirects(url, init, maxRedirects) {
|
|
|
1268
1292
|
}
|
|
1269
1293
|
export async function readResponseText(response, url, maxBytes, signal, encoding) {
|
|
1270
1294
|
const decodedResponse = await decodeResponseIfNeeded(response, url, signal);
|
|
1271
|
-
const { text, size } = await responseReader.read(decodedResponse,
|
|
1295
|
+
const { text, size } = await responseReader.read(decodedResponse, {
|
|
1296
|
+
url,
|
|
1297
|
+
maxBytes,
|
|
1298
|
+
signal,
|
|
1299
|
+
encoding,
|
|
1300
|
+
});
|
|
1272
1301
|
return { text, size };
|
|
1273
1302
|
}
|
|
1274
1303
|
export async function fetchNormalizedUrl(normalizedUrl, options) {
|
|
@@ -2,7 +2,19 @@ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
2
2
|
type CleanupCallback = () => void;
|
|
3
3
|
type RequestHandlerFn = (request: unknown, extra?: unknown) => Promise<unknown>;
|
|
4
4
|
export declare function registerServerLifecycleCleanup(server: McpServer, callback: CleanupCallback): void;
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves the SDK's internal request-handler map.
|
|
7
|
+
*
|
|
8
|
+
* Depends on SDK private API `_requestHandlers` (verified against ^1.27.1).
|
|
9
|
+
* If the SDK changes this internal, the sdk-compat-guard.test.ts tests will fail.
|
|
10
|
+
*/
|
|
5
11
|
export declare function getSdkCallToolHandler(server: McpServer): RequestHandlerFn | null;
|
|
12
|
+
/**
|
|
13
|
+
* Patches the SDK's internal capabilities to enable/disable task-mode tool calls.
|
|
14
|
+
*
|
|
15
|
+
* Depends on SDK private API `_capabilities.tasks.requests` (verified against ^1.27.1).
|
|
16
|
+
* If the SDK changes this internal, the sdk-compat-guard.test.ts tests will fail.
|
|
17
|
+
*/
|
|
6
18
|
export declare function setTaskToolCallCapability(server: McpServer, enabled: boolean): void;
|
|
7
19
|
export {};
|
|
8
20
|
//# sourceMappingURL=sdk-interop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-interop.d.ts","sourceRoot":"","sources":["../../src/lib/sdk-interop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,KAAK,eAAe,GAAG,MAAM,IAAI,CAAC;AAClC,KAAK,gBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AA8ChF,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,eAAe,GACxB,IAAI,CAGN;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,GAChB,gBAAgB,GAAG,IAAI,CAMzB;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,OAAO,GACf,IAAI,CAoBN"}
|
|
1
|
+
{"version":3,"file":"sdk-interop.d.ts","sourceRoot":"","sources":["../../src/lib/sdk-interop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKzE,KAAK,eAAe,GAAG,MAAM,IAAI,CAAC;AAClC,KAAK,gBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AA8ChF,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,eAAe,GACxB,IAAI,CAGN;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,GAChB,gBAAgB,GAAG,IAAI,CAMzB;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,OAAO,GACf,IAAI,CAoBN"}
|
package/dist/lib/sdk-interop.js
CHANGED
|
@@ -44,6 +44,12 @@ export function registerServerLifecycleCleanup(server, callback) {
|
|
|
44
44
|
ensureServerCleanupHooks(server);
|
|
45
45
|
getServerCleanupCallbackSet(server).add(callback);
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the SDK's internal request-handler map.
|
|
49
|
+
*
|
|
50
|
+
* Depends on SDK private API `_requestHandlers` (verified against ^1.27.1).
|
|
51
|
+
* If the SDK changes this internal, the sdk-compat-guard.test.ts tests will fail.
|
|
52
|
+
*/
|
|
47
53
|
export function getSdkCallToolHandler(server) {
|
|
48
54
|
const maybeHandlers = Reflect.get(server.server, '_requestHandlers');
|
|
49
55
|
if (!(maybeHandlers instanceof Map))
|
|
@@ -51,6 +57,12 @@ export function getSdkCallToolHandler(server) {
|
|
|
51
57
|
const handler = maybeHandlers.get('tools/call');
|
|
52
58
|
return typeof handler === 'function' ? handler : null;
|
|
53
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Patches the SDK's internal capabilities to enable/disable task-mode tool calls.
|
|
62
|
+
*
|
|
63
|
+
* Depends on SDK private API `_capabilities.tasks.requests` (verified against ^1.27.1).
|
|
64
|
+
* If the SDK changes this internal, the sdk-compat-guard.test.ts tests will fail.
|
|
65
|
+
*/
|
|
54
66
|
export function setTaskToolCallCapability(server, enabled) {
|
|
55
67
|
const capabilities = Reflect.get(server.server, '_capabilities');
|
|
56
68
|
if (!isObject(capabilities))
|
package/dist/lib/session.d.ts
CHANGED
|
@@ -19,7 +19,10 @@ export interface SessionStore {
|
|
|
19
19
|
incrementInFlight: () => void;
|
|
20
20
|
decrementInFlight: () => void;
|
|
21
21
|
clear: () => SessionEntry[];
|
|
22
|
-
evictExpired: () =>
|
|
22
|
+
evictExpired: () => {
|
|
23
|
+
id: string;
|
|
24
|
+
entry: SessionEntry;
|
|
25
|
+
}[];
|
|
23
26
|
evictOldest: () => SessionEntry | undefined;
|
|
24
27
|
}
|
|
25
28
|
interface SlotTracker {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/lib/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAMxG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,6BAA6B,CAAC;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,yBAAyB,EAAE,MAAM,CAAC;IAClC,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,YAAY,GAAG,SAAS,CAAC;IACrD,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,GAAG,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACtD,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,YAAY,GAAG,SAAS,CAAC;IACxD,IAAI,EAAE,MAAM,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,KAAK,EAAE,MAAM,YAAY,EAAE,CAAC;IAC5B,YAAY,EAAE,MAAM,YAAY,EAAE,CAAC;
|
|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E,MAAM,IAAI,CAAC;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,OAAO,CAAC;CACvC;AAMD,KAAK,YAAY,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;AAE7C,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,YAAY,GACnB,YAAY,CAWd;AA0FD,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,CAErE;AAMD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,CAiBlE;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,MAAM,GAClB,OAAO,CAMT;AAED,wBAAgB,qBAAqB,CAAC,EACpC,KAAK,EACL,WAAW,EACX,WAAW,GACZ,EAAE;IACD,KAAK,EAAE,YAAY,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC;CAC/C,GAAG,OAAO,CAeV"}
|
package/dist/lib/session.js
CHANGED
|
@@ -75,7 +75,7 @@ class InMemorySessionStore {
|
|
|
75
75
|
for (const [id, session] of this.sessions.entries()) {
|
|
76
76
|
if (this.sessionTtlMs > 0 && now - session.lastSeen > this.sessionTtlMs) {
|
|
77
77
|
this.sessions.delete(id);
|
|
78
|
-
evicted.push(session);
|
|
78
|
+
evicted.push({ id, entry: session });
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
81
81
|
break;
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -76,6 +76,11 @@ export declare const CharCode: {
|
|
|
76
76
|
readonly Z_UPPER: 90;
|
|
77
77
|
readonly A_LOWER: 97;
|
|
78
78
|
readonly Z_LOWER: 122;
|
|
79
|
+
readonly DOUBLE_QUOTE: 34;
|
|
80
|
+
readonly SINGLE_QUOTE: 39;
|
|
81
|
+
readonly RIGHT_PAREN: 41;
|
|
82
|
+
readonly RIGHT_BRACKET: 93;
|
|
83
|
+
readonly BACKTICK: 96;
|
|
79
84
|
};
|
|
80
85
|
export declare function isWhitespaceChar(code: number): boolean;
|
|
81
86
|
export declare function getUtf8ByteLength(html: string): number;
|
package/dist/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAaA,wBAAgB,kBAAkB,CAChC,MAAM,CAAC,EAAE,WAAW,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,WAAW,GAAG,SAAS,CAOzB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,IAAI,CAEvE;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,IAAI,CAWN;AACD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAKvE;AACD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAKjE;AACD,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,MAAM,CAE5D;AACD,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,GAAG,UAAU,EACxB,KAAK,EAAE,MAAM,GAAG,UAAU,GACzB,MAAM,CAER;AAED,qBAAa,UAAW,SAAQ,KAAK;IAOjC,QAAQ,CAAC,GAAG,EAAE,MAAM;IANtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;gBAG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M,CAK7E;AACD,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,CAAC,EAAE,QAAQ,GAClB;IAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAU/C"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -252,6 +252,11 @@ export const CharCode = {
|
|
|
252
252
|
Z_UPPER: 90,
|
|
253
253
|
A_LOWER: 97,
|
|
254
254
|
Z_LOWER: 122,
|
|
255
|
+
DOUBLE_QUOTE: 34,
|
|
256
|
+
SINGLE_QUOTE: 39,
|
|
257
|
+
RIGHT_PAREN: 41,
|
|
258
|
+
RIGHT_BRACKET: 93,
|
|
259
|
+
BACKTICK: 96,
|
|
255
260
|
};
|
|
256
261
|
export function isWhitespaceChar(code) {
|
|
257
262
|
return (code === CharCode.TAB ||
|
package/dist/resources/index.js
CHANGED
|
@@ -332,7 +332,7 @@ export function registerCacheResourceTemplate(server, iconInfo) {
|
|
|
332
332
|
registerCacheResourceNotifications(server);
|
|
333
333
|
}
|
|
334
334
|
export function buildServerInstructions() {
|
|
335
|
-
const maxHtmlSizeMb = config.constants.
|
|
335
|
+
const maxHtmlSizeMb = config.constants.maxHtmlBytes / 1024 / 1024;
|
|
336
336
|
const cacheSizeMb = config.cache.maxSizeBytes / 1024 / 1024;
|
|
337
337
|
const cacheTtlHours = config.cache.ttl / 3600;
|
|
338
338
|
return `# Fetch public webpages and return clean, readable Markdown.
|
|
@@ -377,7 +377,7 @@ export function registerGetHelpPrompt(server, instructions, iconInfo) {
|
|
|
377
377
|
description,
|
|
378
378
|
messages: [
|
|
379
379
|
{
|
|
380
|
-
role: '
|
|
380
|
+
role: 'user',
|
|
381
381
|
content: {
|
|
382
382
|
type: 'text',
|
|
383
383
|
text: instructions,
|
package/dist/schemas.js
CHANGED
|
@@ -147,7 +147,7 @@ export const fetchUrlOutputSchema = z.strictObject({
|
|
|
147
147
|
.number()
|
|
148
148
|
.int()
|
|
149
149
|
.min(0)
|
|
150
|
-
.max(config.constants.
|
|
150
|
+
.max(config.constants.maxHtmlBytes * 4)
|
|
151
151
|
.optional()
|
|
152
152
|
.describe('Full markdown size before truncation.'),
|
|
153
153
|
truncated: z.boolean().optional().describe('True if markdown was truncated.'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-translators.d.ts","sourceRoot":"","sources":["../../src/transform/html-translators.ts"],"names":[],"mappings":"AAohBA,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpE;
|
|
1
|
+
{"version":3,"file":"html-translators.d.ts","sourceRoot":"","sources":["../../src/transform/html-translators.ts"],"names":[],"mappings":"AAohBA,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpE;AAsRD,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAkCpB;AAOD,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,SAAS,CAKpB;AACD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKvE"}
|
|
@@ -632,6 +632,37 @@ const LANGUAGES = [
|
|
|
632
632
|
match: (ctx) => ctx.trimmedStart.startsWith('{') || ctx.trimmedStart.startsWith('['),
|
|
633
633
|
},
|
|
634
634
|
];
|
|
635
|
+
const KNOWN_LANG_PREFIXES = new Set([
|
|
636
|
+
'css',
|
|
637
|
+
'javascript',
|
|
638
|
+
'js',
|
|
639
|
+
'typescript',
|
|
640
|
+
'ts',
|
|
641
|
+
'python',
|
|
642
|
+
'py',
|
|
643
|
+
'html',
|
|
644
|
+
'xml',
|
|
645
|
+
'sql',
|
|
646
|
+
'bash',
|
|
647
|
+
'sh',
|
|
648
|
+
'yaml',
|
|
649
|
+
'json',
|
|
650
|
+
'ruby',
|
|
651
|
+
'go',
|
|
652
|
+
'rust',
|
|
653
|
+
'java',
|
|
654
|
+
'php',
|
|
655
|
+
'c',
|
|
656
|
+
'cpp',
|
|
657
|
+
'swift',
|
|
658
|
+
'kotlin',
|
|
659
|
+
'scss',
|
|
660
|
+
'sass',
|
|
661
|
+
'less',
|
|
662
|
+
'graphql',
|
|
663
|
+
'markdown',
|
|
664
|
+
'md',
|
|
665
|
+
]);
|
|
635
666
|
export function extractLanguageFromClassName(className) {
|
|
636
667
|
if (!className)
|
|
637
668
|
return undefined;
|
|
@@ -649,14 +680,25 @@ export function extractLanguageFromClassName(className) {
|
|
|
649
680
|
if (lower.startsWith('highlight-'))
|
|
650
681
|
return token.slice(10);
|
|
651
682
|
}
|
|
652
|
-
//
|
|
653
|
-
if (
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
683
|
+
// Special handling for hljs which often appears with a separate language class
|
|
684
|
+
if (tokens.includes('hljs')) {
|
|
685
|
+
const langClass = tokens.find((t) => {
|
|
686
|
+
const l = t.toLowerCase();
|
|
687
|
+
return l !== 'hljs' && !l.startsWith('hljs-');
|
|
688
|
+
});
|
|
689
|
+
if (langClass)
|
|
690
|
+
return langClass;
|
|
691
|
+
}
|
|
692
|
+
// Last resort: look for any known language prefix followed by a dash
|
|
693
|
+
for (const token of tokens) {
|
|
694
|
+
const dashIdx = token.indexOf('-');
|
|
695
|
+
if (dashIdx > 0) {
|
|
696
|
+
const prefix = token.slice(0, dashIdx).toLowerCase();
|
|
697
|
+
if (KNOWN_LANG_PREFIXES.has(prefix))
|
|
698
|
+
return prefix;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
return undefined;
|
|
660
702
|
}
|
|
661
703
|
function resolveLanguageFromDataAttribute(dataLang) {
|
|
662
704
|
const trimmed = dataLang.trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-cleanup.d.ts","sourceRoot":"","sources":["../../src/transform/markdown-cleanup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown-cleanup.d.ts","sourceRoot":"","sources":["../../src/transform/markdown-cleanup.ts"],"names":[],"mappings":"AA4HA,UAAU,cAAc;IACtB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAyeD,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,kBAAkB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAC3C,MAAM,CAyBR;AAaD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,KAAK,CAAC,GAC/C,MAAM,CAUR;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM,CAkBR"}
|