@j0hanz/fetch-url-mcp 1.11.2 → 1.11.4
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/helpers.d.ts +1 -1
- package/dist/http/helpers.d.ts.map +1 -1
- package/dist/http/helpers.js +1 -1
- package/dist/http/native.js +1 -1
- package/dist/lib/config.d.ts +152 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +478 -0
- package/dist/lib/core.d.ts +1 -150
- package/dist/lib/core.d.ts.map +1 -1
- package/dist/lib/core.js +3 -459
- package/dist/lib/{mcp-tools.d.ts → mcp-interop.d.ts} +49 -1
- package/dist/lib/mcp-interop.d.ts.map +1 -0
- package/dist/lib/mcp-interop.js +354 -0
- package/dist/lib/task-handlers.js +1 -1
- package/dist/resources/index.js +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +1 -1
- package/dist/server.js +2 -2
- package/dist/tasks/handlers.d.ts +11 -0
- package/dist/tasks/handlers.d.ts.map +1 -0
- package/dist/tasks/handlers.js +151 -0
- package/dist/tasks/owner.d.ts +1 -2
- package/dist/tasks/owner.d.ts.map +1 -1
- package/dist/tasks/registry.d.ts +1 -1
- package/dist/tasks/registry.d.ts.map +1 -1
- package/dist/tools/fetch-url.d.ts +2 -3
- package/dist/tools/fetch-url.d.ts.map +1 -1
- package/dist/tools/fetch-url.js +3 -4
- package/dist/{lib → transform}/dom-prep.d.ts +1 -1
- package/dist/transform/dom-prep.d.ts.map +1 -0
- package/dist/{lib → transform}/dom-prep.js +2 -2
- package/dist/transform/html-translators.d.ts.map +1 -1
- package/dist/transform/html-translators.js +1 -1
- package/dist/transform/metadata.d.ts +8 -0
- package/dist/transform/metadata.d.ts.map +1 -1
- package/dist/transform/metadata.js +66 -0
- package/dist/transform/transform.d.ts.map +1 -1
- package/dist/transform/transform.js +2 -3
- package/package.json +1 -1
- package/dist/lib/dom-prep.d.ts.map +0 -1
- package/dist/lib/mcp-tools.d.ts.map +0 -1
- package/dist/lib/mcp-tools.js +0 -129
- package/dist/lib/progress.d.ts +0 -32
- package/dist/lib/progress.d.ts.map +0 -1
- package/dist/lib/progress.js +0 -143
- package/dist/lib/sdk-interop.d.ts +0 -20
- package/dist/lib/sdk-interop.d.ts.map +0 -1
- package/dist/lib/sdk-interop.js +0 -85
- package/dist/transform/title-policy.d.ts +0 -9
- package/dist/transform/title-policy.d.ts.map +0 -1
- package/dist/transform/title-policy.js +0 -67
package/dist/lib/sdk-interop.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { logWarn } from './core.js';
|
|
2
|
-
import { isObject } from './utils.js';
|
|
3
|
-
const patchedCleanupServers = new WeakSet();
|
|
4
|
-
const serverCleanupCallbacks = new WeakMap();
|
|
5
|
-
function getServerCleanupCallbackSet(server) {
|
|
6
|
-
let callbacks = serverCleanupCallbacks.get(server);
|
|
7
|
-
if (!callbacks) {
|
|
8
|
-
callbacks = new Set();
|
|
9
|
-
serverCleanupCallbacks.set(server, callbacks);
|
|
10
|
-
}
|
|
11
|
-
return callbacks;
|
|
12
|
-
}
|
|
13
|
-
function drainServerCleanupCallbacks(server) {
|
|
14
|
-
const callbacks = serverCleanupCallbacks.get(server);
|
|
15
|
-
if (!callbacks || callbacks.size === 0)
|
|
16
|
-
return;
|
|
17
|
-
const pending = [...callbacks];
|
|
18
|
-
callbacks.clear();
|
|
19
|
-
for (const callback of pending) {
|
|
20
|
-
try {
|
|
21
|
-
callback();
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
logWarn('Server cleanup callback failed', { error });
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function ensureServerCleanupHooks(server) {
|
|
29
|
-
if (patchedCleanupServers.has(server))
|
|
30
|
-
return;
|
|
31
|
-
patchedCleanupServers.add(server);
|
|
32
|
-
const originalOnClose = server.server.onclose;
|
|
33
|
-
server.server.onclose = () => {
|
|
34
|
-
drainServerCleanupCallbacks(server);
|
|
35
|
-
originalOnClose?.();
|
|
36
|
-
};
|
|
37
|
-
const originalClose = server.close.bind(server);
|
|
38
|
-
server.close = async () => {
|
|
39
|
-
drainServerCleanupCallbacks(server);
|
|
40
|
-
await originalClose();
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export function registerServerLifecycleCleanup(server, callback) {
|
|
44
|
-
ensureServerCleanupHooks(server);
|
|
45
|
-
getServerCleanupCallbackSet(server).add(callback);
|
|
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
|
-
*/
|
|
53
|
-
export function getSdkCallToolHandler(server) {
|
|
54
|
-
const maybeHandlers = Reflect.get(server.server, '_requestHandlers');
|
|
55
|
-
if (!(maybeHandlers instanceof Map))
|
|
56
|
-
return null;
|
|
57
|
-
const handler = maybeHandlers.get('tools/call');
|
|
58
|
-
return typeof handler === 'function' ? handler : null;
|
|
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
|
-
*/
|
|
66
|
-
export function setTaskToolCallCapability(server, enabled) {
|
|
67
|
-
const capabilities = Reflect.get(server.server, '_capabilities');
|
|
68
|
-
if (!isObject(capabilities))
|
|
69
|
-
return;
|
|
70
|
-
const tasks = isObject(capabilities.tasks)
|
|
71
|
-
? capabilities.tasks
|
|
72
|
-
: undefined;
|
|
73
|
-
if (!tasks)
|
|
74
|
-
return;
|
|
75
|
-
const requests = isObject(tasks.requests)
|
|
76
|
-
? tasks.requests
|
|
77
|
-
: undefined;
|
|
78
|
-
if (!requests)
|
|
79
|
-
return;
|
|
80
|
-
if (enabled) {
|
|
81
|
-
requests.tools = { call: {} };
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
delete requests.tools;
|
|
85
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export interface SyntheticTitleContext {
|
|
2
|
-
readonly title: string | undefined;
|
|
3
|
-
}
|
|
4
|
-
export declare function normalizeSyntheticTitleToken(value: string | undefined): string;
|
|
5
|
-
export declare function shouldPreferPrimaryHeadingTitle(primaryHeading: string | undefined, title: string | undefined): boolean;
|
|
6
|
-
export declare function isGithubRepositoryRootUrl(url: string): boolean;
|
|
7
|
-
export declare function maybeStripGithubPrimaryHeading(markdown: string, primaryHeading: string | undefined, url: string): string;
|
|
8
|
-
export declare function maybePrependSyntheticTitle(markdown: string, context: SyntheticTitleContext): string;
|
|
9
|
-
//# sourceMappingURL=title-policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"title-policy.d.ts","sourceRoot":"","sources":["../../src/transform/title-policy.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAMD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,CAER;AAED,wBAAgB,+BAA+B,CAC7C,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,OAAO,CAWT;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAU9D;AAkCD,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,GAAG,EAAE,MAAM,GACV,MAAM,CAMR;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,qBAAqB,GAC7B,MAAM,CAMR"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { parseUrlOrNull } from '../lib/utils.js';
|
|
2
|
-
const TITLE_PART_SEPARATOR = /\s*(?:[-|:•·]|–|—)\s*/u;
|
|
3
|
-
const LEADING_HEADING_PATTERN = /^(#{1,6})\s+(.+?)\s*$/;
|
|
4
|
-
const HEADING_SCAN_LIMIT = 12;
|
|
5
|
-
export function normalizeSyntheticTitleToken(value) {
|
|
6
|
-
return (value ?? '').replace(/\s+/g, ' ').trim().toLowerCase();
|
|
7
|
-
}
|
|
8
|
-
export function shouldPreferPrimaryHeadingTitle(primaryHeading, title) {
|
|
9
|
-
const primary = normalizeSyntheticTitleToken(primaryHeading);
|
|
10
|
-
if (!primary)
|
|
11
|
-
return false;
|
|
12
|
-
const normalizedTitle = normalizeSyntheticTitleToken(title);
|
|
13
|
-
if (!normalizedTitle)
|
|
14
|
-
return true;
|
|
15
|
-
if (normalizedTitle === primary)
|
|
16
|
-
return true;
|
|
17
|
-
return normalizedTitle
|
|
18
|
-
.split(TITLE_PART_SEPARATOR)
|
|
19
|
-
.some((part) => part === primary);
|
|
20
|
-
}
|
|
21
|
-
export function isGithubRepositoryRootUrl(url) {
|
|
22
|
-
const parsed = parseUrlOrNull(url);
|
|
23
|
-
if (!parsed)
|
|
24
|
-
return false;
|
|
25
|
-
const hostname = parsed.hostname.toLowerCase();
|
|
26
|
-
if (hostname !== 'github.com' && hostname !== 'www.github.com') {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
return parsed.pathname.split('/').filter(Boolean).length === 2;
|
|
30
|
-
}
|
|
31
|
-
function stripLeadingHeading(markdown, headingText) {
|
|
32
|
-
if (!markdown)
|
|
33
|
-
return markdown;
|
|
34
|
-
const lines = markdown.split('\n');
|
|
35
|
-
const target = normalizeSyntheticTitleToken(headingText);
|
|
36
|
-
let nonEmptySeen = 0;
|
|
37
|
-
for (let index = 0; index < lines.length && nonEmptySeen < HEADING_SCAN_LIMIT; index += 1) {
|
|
38
|
-
const trimmed = lines[index]?.trim() ?? '';
|
|
39
|
-
if (!trimmed)
|
|
40
|
-
continue;
|
|
41
|
-
nonEmptySeen += 1;
|
|
42
|
-
const match = LEADING_HEADING_PATTERN.exec(trimmed);
|
|
43
|
-
if (!match)
|
|
44
|
-
continue;
|
|
45
|
-
const current = normalizeSyntheticTitleToken(match[2] ?? '');
|
|
46
|
-
if (current !== target)
|
|
47
|
-
return markdown;
|
|
48
|
-
lines.splice(index, 1);
|
|
49
|
-
if ((lines[index] ?? '').trim() === '') {
|
|
50
|
-
lines.splice(index, 1);
|
|
51
|
-
}
|
|
52
|
-
return lines.join('\n');
|
|
53
|
-
}
|
|
54
|
-
return markdown;
|
|
55
|
-
}
|
|
56
|
-
export function maybeStripGithubPrimaryHeading(markdown, primaryHeading, url) {
|
|
57
|
-
if (primaryHeading === undefined || !isGithubRepositoryRootUrl(url)) {
|
|
58
|
-
return markdown;
|
|
59
|
-
}
|
|
60
|
-
return stripLeadingHeading(markdown, primaryHeading);
|
|
61
|
-
}
|
|
62
|
-
export function maybePrependSyntheticTitle(markdown, context) {
|
|
63
|
-
if (!context.title || /^#\s/.test(markdown.trimStart())) {
|
|
64
|
-
return markdown;
|
|
65
|
-
}
|
|
66
|
-
return `# ${context.title}\n\n${markdown}`;
|
|
67
|
-
}
|