@j0hanz/fetch-url-mcp 1.7.0 → 1.8.0
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 +7 -7
- package/dist/lib/core.d.ts +0 -3
- package/dist/lib/core.d.ts.map +1 -1
- package/dist/lib/core.js +0 -14
- package/dist/lib/fetch-pipeline.d.ts.map +1 -1
- package/dist/lib/fetch-pipeline.js +7 -22
- package/dist/lib/http.d.ts.map +1 -1
- package/dist/lib/http.js +4 -2
- package/dist/lib/mcp-tools.d.ts.map +1 -1
- package/dist/lib/mcp-tools.js +28 -3
- package/dist/lib/task-handlers.js +6 -6
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +2 -1
- package/dist/schemas.d.ts +60 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +173 -0
- package/dist/tasks/owner.d.ts.map +1 -1
- package/dist/tasks/owner.js +12 -6
- package/dist/tools/fetch-url.d.ts +1 -1
- package/dist/tools/fetch-url.d.ts.map +1 -1
- package/dist/tools/fetch-url.js +6 -22
- package/dist/transform/worker-pool.d.ts.map +1 -1
- package/dist/transform/worker-pool.js +41 -54
- package/package.json +1 -1
- package/dist/schemas/cache.d.ts +0 -18
- package/dist/schemas/cache.d.ts.map +0 -1
- package/dist/schemas/cache.js +0 -19
- package/dist/schemas/inputs.d.ts +0 -8
- package/dist/schemas/inputs.d.ts.map +0 -1
- package/dist/schemas/inputs.js +0 -24
- package/dist/schemas/outputs.d.ts +0 -23
- package/dist/schemas/outputs.d.ts.map +0 -1
- package/dist/schemas/outputs.js +0 -68
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/%40j0hanz%2Ffetch-url-mcp) [](#contributing-and-license)
|
|
4
4
|
|
|
5
|
-
[](https://insiders.vscode.dev/redirect/mcp/install?name=fetch-url
|
|
5
|
+
[](https://insiders.vscode.dev/redirect/mcp/install?name=fetch-url&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Ffetch-url-mcp%40latest%22%5D%7D) [](https://insiders.vscode.dev/redirect/mcp/install?name=fetch-url&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Ffetch-url-mcp%40latest%22%5D%7D&quality=insiders) [](https://vs-open.link/mcp-install?%7B%22fetch-url-mcp%22%3A%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Ffetch-url-mcp%40latest%22%5D%7D%7D)
|
|
6
6
|
|
|
7
|
-
[](https://lmstudio.ai/install-mcp?name=fetch-url
|
|
7
|
+
[](https://lmstudio.ai/install-mcp?name=fetch-url&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovZmV0Y2gtdXJsLW1jcEBsYXRlc3QiXX0%3D) [](https://cursor.com/en/install-mcp?name=fetch-url&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovZmV0Y2gtdXJsLW1jcEBsYXRlc3QiXX0%3D) [](https://block.github.io/goose/extension?cmd=npx&arg=-y&arg=%40j0hanz%2Ffetch-url-mcp%40latest&id=%40j0hanz%2Ffetch-url-mcp&name=fetch-url&description=fetch-url%20MCP%20server)
|
|
8
8
|
|
|
9
9
|
A web content fetcher MCP server that converts HTML to clean, AI and human readable markdown.
|
|
10
10
|
|
|
@@ -45,7 +45,7 @@ Use this standard MCP client configuration:
|
|
|
45
45
|
<details>
|
|
46
46
|
<summary><b>Install in VS Code</b></summary>
|
|
47
47
|
|
|
48
|
-
[](https://insiders.vscode.dev/redirect/mcp/install?name=fetch-url
|
|
48
|
+
[](https://insiders.vscode.dev/redirect/mcp/install?name=fetch-url&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Ffetch-url-mcp%40latest%22%5D%7D)
|
|
49
49
|
|
|
50
50
|
Add to `.vscode/mcp.json`:
|
|
51
51
|
|
|
@@ -74,7 +74,7 @@ For more info, see [VS Code MCP docs](https://code.visualstudio.com/docs/copilot
|
|
|
74
74
|
<details>
|
|
75
75
|
<summary><b>Install in VS Code Insiders</b></summary>
|
|
76
76
|
|
|
77
|
-
[](https://insiders.vscode.dev/redirect/mcp/install?name=fetch-url
|
|
77
|
+
[](https://insiders.vscode.dev/redirect/mcp/install?name=fetch-url&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Ffetch-url-mcp%40latest%22%5D%7D&quality=insiders)
|
|
78
78
|
|
|
79
79
|
Add to `.vscode/mcp.json`:
|
|
80
80
|
|
|
@@ -103,7 +103,7 @@ For more info, see [VS Code Insiders MCP docs](https://code.visualstudio.com/doc
|
|
|
103
103
|
<details>
|
|
104
104
|
<summary><b>Install in Cursor</b></summary>
|
|
105
105
|
|
|
106
|
-
[](https://cursor.com/en/install-mcp?name=fetch-url
|
|
106
|
+
[](https://cursor.com/en/install-mcp?name=fetch-url&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovZmV0Y2gtdXJsLW1jcEBsYXRlc3QiXX0%3D)
|
|
107
107
|
|
|
108
108
|
Add to `~/.cursor/mcp.json`:
|
|
109
109
|
|
|
@@ -148,7 +148,7 @@ For more info, see [Visual Studio MCP docs](https://learn.microsoft.com/en-us/vi
|
|
|
148
148
|
<details>
|
|
149
149
|
<summary><b>Install in Goose</b></summary>
|
|
150
150
|
|
|
151
|
-
[](https://block.github.io/goose/extension?cmd=npx&arg=-y&arg=%40j0hanz%2Ffetch-url-mcp%40latest&id=%40j0hanz%2Ffetch-url-mcp&name=fetch-url
|
|
151
|
+
[](https://block.github.io/goose/extension?cmd=npx&arg=-y&arg=%40j0hanz%2Ffetch-url-mcp%40latest&id=%40j0hanz%2Ffetch-url-mcp&name=fetch-url&description=A%20web%20content%20fetcher%20MCP%20server%20that%20converts%20HTML%20to%20clean%2C%20AI%20and%20human%20readable%20markdown.)
|
|
152
152
|
|
|
153
153
|
Add to `~/.config/goose/config.yaml` on macOS/Linux or `%APPDATA%\Block\goose\config\config.yaml` on Windows:
|
|
154
154
|
|
|
@@ -170,7 +170,7 @@ For more info, see [Goose extension docs](https://block.github.io/goose/docs/get
|
|
|
170
170
|
<details>
|
|
171
171
|
<summary><b>Install in LM Studio</b></summary>
|
|
172
172
|
|
|
173
|
-
[](https://lmstudio.ai/install-mcp?name=fetch-url
|
|
173
|
+
[](https://lmstudio.ai/install-mcp?name=fetch-url&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovZmV0Y2gtdXJsLW1jcEBsYXRlc3QiXX0%3D)
|
|
174
174
|
|
|
175
175
|
Add to `~/.lmstudio/mcp.json` on macOS/Linux or `%USERPROFILE%/.lmstudio/mcp.json` on Windows:
|
|
176
176
|
|
package/dist/lib/core.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { type StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
|
-
import { type CachedPayload } from '../schemas/cache.js';
|
|
4
3
|
export declare const serverVersion: string;
|
|
5
4
|
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
6
5
|
type TransformWorkerMode = 'threads' | 'process';
|
|
@@ -172,8 +171,6 @@ interface CacheUpdateEvent {
|
|
|
172
171
|
listChanged: boolean;
|
|
173
172
|
}
|
|
174
173
|
type CacheUpdateListener = (event: CacheUpdateEvent) => unknown;
|
|
175
|
-
export declare function parseCachedPayload(raw: string): CachedPayload | null;
|
|
176
|
-
export declare function resolveCachedPayloadContent(payload: CachedPayload): string | null;
|
|
177
174
|
export declare function createCacheKey(namespace: string, url: string, vary?: Record<string, unknown> | string): string | null;
|
|
178
175
|
export declare function parseCacheKey(cacheKey: string): CacheKeyParts | null;
|
|
179
176
|
export declare function onCacheUpdate(listener: CacheUpdateListener): () => void;
|
package/dist/lib/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/lib/core.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/lib/core.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAexG,eAAO,MAAM,aAAa,EAAE,MAA2C,CAAC;AACxE,KAAK,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAwBpD,KAAK,mBAAmB,GAAG,SAAS,GAAG,SAAS,CAAC;AACjD,KAAK,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AAyNnC,UAAU,oBAAoB;IAC5B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA+BD,UAAU,UAAU;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,GAAG,GAAG,SAAS,CAAC;IAC3B,gBAAgB,EAAE,GAAG,GAAG,SAAS,CAAC;IAClC,QAAQ,EAAE,GAAG,GAAG,SAAS,CAAC;IAC1B,aAAa,EAAE,GAAG,GAAG,SAAS,CAAC;IAC/B,eAAe,EAAE,GAAG,GAAG,SAAS,CAAC;IACjC,gBAAgB,EAAE,GAAG,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,GAAG,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YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjE,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GACA,eAAe,CAOjB;AA8FD,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,YAAY,CAErE;AAqBD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,WAAW,CAElE;AAID,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,MAAM,GAClB,OAAO,CAMT;AAID,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/core.js
CHANGED
|
@@ -7,7 +7,6 @@ import process from 'node:process';
|
|
|
7
7
|
import { getSystemErrorMessage, inspect, stripVTControlCharacters, } from 'node:util';
|
|
8
8
|
import {} from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
9
|
import {} from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
10
|
-
import { cachedPayloadSchema } from '../schemas/cache.js';
|
|
11
10
|
import { buildIpv4, normalizeHostname, stripTrailingDots, } from './net-utils.js';
|
|
12
11
|
import { getErrorMessage, isAbortError, sha256Hex, stableStringify as stableJsonStringify, startAbortableIntervalLoop, } from './utils.js';
|
|
13
12
|
export const serverVersion = readServerVersion(import.meta.url);
|
|
@@ -446,19 +445,6 @@ const CACHE_CONSTANTS = {
|
|
|
446
445
|
URL_HASH_LENGTH: 32,
|
|
447
446
|
VARY_HASH_LENGTH: 16,
|
|
448
447
|
};
|
|
449
|
-
export function parseCachedPayload(raw) {
|
|
450
|
-
try {
|
|
451
|
-
const parsed = JSON.parse(raw);
|
|
452
|
-
const result = cachedPayloadSchema.safeParse(parsed);
|
|
453
|
-
return result.success ? result.data : null;
|
|
454
|
-
}
|
|
455
|
-
catch {
|
|
456
|
-
return null;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
export function resolveCachedPayloadContent(payload) {
|
|
460
|
-
return payload.markdown ?? payload.content ?? null;
|
|
461
|
-
}
|
|
462
448
|
function createHashFragment(input, length) {
|
|
463
449
|
return sha256Hex(input).substring(0, length);
|
|
464
450
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-pipeline.d.ts","sourceRoot":"","sources":["../../src/lib/fetch-pipeline.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch-pipeline.d.ts","sourceRoot":"","sources":["../../src/lib/fetch-pipeline.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAqBrE,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAY1C,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,UAAU,GAAG,SAAS,CAOxB;AACD,wBAAgB,UAAU,CACxB,MAAM,CAAC,EAAE,WAAW,GACnB;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAEjD;AAMD,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAClD,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAuED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,MAAM,CAkBR;AAoDD,UAAU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AY,EAAE,mBAAmB,CAAC;CACnC,CAAC,CAWD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeExtractedMetadata, parseCachedPayload, } from '../schemas.js';
|
|
2
2
|
import { transformBufferToMarkdown } from '../transform/transform.js';
|
|
3
3
|
import {} from '../transform/types.js';
|
|
4
4
|
import { config, createCacheKey, get, isEnabled, logDebug, logWarn, set, } from './core.js';
|
|
@@ -24,14 +24,6 @@ export function readNestedRecord(obj, keys) {
|
|
|
24
24
|
}
|
|
25
25
|
return asRecord(current);
|
|
26
26
|
}
|
|
27
|
-
function safeJsonParse(value) {
|
|
28
|
-
try {
|
|
29
|
-
return JSON.parse(value);
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
27
|
export function withSignal(signal) {
|
|
36
28
|
return signal === undefined ? {} : { signal };
|
|
37
29
|
}
|
|
@@ -322,29 +314,22 @@ export async function executeFetchPipeline(options) {
|
|
|
322
314
|
cacheKey,
|
|
323
315
|
};
|
|
324
316
|
}
|
|
325
|
-
function normalizeExtractedMetadata(metadata) {
|
|
326
|
-
if (!metadata)
|
|
327
|
-
return undefined;
|
|
328
|
-
const normalized = Object.fromEntries(Object.entries(metadata).filter(([, v]) => Boolean(v)));
|
|
329
|
-
return Object.keys(normalized).length > 0 ? normalized : undefined;
|
|
330
|
-
}
|
|
331
317
|
export function parseCachedMarkdownResult(cached) {
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
if (!result.success)
|
|
318
|
+
const payload = parseCachedPayload(cached);
|
|
319
|
+
if (!payload)
|
|
335
320
|
return undefined;
|
|
336
|
-
const markdown =
|
|
321
|
+
const markdown = payload.markdown ?? payload.content;
|
|
337
322
|
if (typeof markdown !== 'string')
|
|
338
323
|
return undefined;
|
|
339
|
-
const metadata = normalizeExtractedMetadata(
|
|
340
|
-
const truncated =
|
|
324
|
+
const metadata = normalizeExtractedMetadata(payload.metadata);
|
|
325
|
+
const truncated = payload.truncated ?? false;
|
|
341
326
|
const persistedMarkdown = truncated
|
|
342
327
|
? appendTruncationMarker(markdown, TRUNCATION_MARKER)
|
|
343
328
|
: markdown;
|
|
344
329
|
return {
|
|
345
330
|
content: persistedMarkdown,
|
|
346
331
|
markdown: persistedMarkdown,
|
|
347
|
-
title:
|
|
332
|
+
title: payload.title,
|
|
348
333
|
...(metadata ? { metadata } : {}),
|
|
349
334
|
truncated,
|
|
350
335
|
};
|
package/dist/lib/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/lib/http.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAWhD,OAAO,EAAE,KAAK,EAAmB,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/lib/http.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAWhD,OAAO,EAAE,KAAK,EAAmB,MAAM,QAAQ,CAAC;AAchD,OAAO,EAOL,KAAK,eAAe,EAGrB,MAAM,UAAU,CAAC;AAiElB,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,EACrB,SAAS,SAAQ,GAChB,MAAM,CAIR;AAkBD,wBAAgB,cAAc,CAC5B,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,GACX,IAAI,CA6CN;AAmoCD,UAAU,qBAAqB;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,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AE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAUzC;AACD,wBAAsB,kBAAkB,CACtC,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,MAAM,CAAC,CAEjB;AACD,wBAAsB,wBAAwB,CAC5C,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC;IACT,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CAED"}
|
package/dist/lib/http.js
CHANGED
|
@@ -13,9 +13,11 @@ import tls from 'node:tls';
|
|
|
13
13
|
import { createBrotliDecompress, createGunzip, createInflate } from 'node:zlib';
|
|
14
14
|
import { Agent } from 'undici';
|
|
15
15
|
import { z } from 'zod';
|
|
16
|
-
import {
|
|
16
|
+
import { parseCachedPayload, resolveCachedPayloadContent } from '../schemas.js';
|
|
17
|
+
import { get as cacheGet, config, getOperationId, getRequestId, logDebug, logError, logWarn, redactUrl, } from './core.js';
|
|
17
18
|
import { BLOCKED_HOST_SUFFIXES, createDnsPreflight, IpBlocker, RawUrlTransformer, SafeDnsResolver, UrlNormalizer, VALIDATION_ERROR_CODE, } from './url.js';
|
|
18
19
|
import { createErrorWithCode, FetchError, isAbortError, isError, isObject, isSystemError, toError, } from './utils.js';
|
|
20
|
+
import { formatZodError } from './zod.js';
|
|
19
21
|
const FILENAME_RULES = {
|
|
20
22
|
MAX_LEN: 200,
|
|
21
23
|
UNSAFE_CHARS: /[<>:"/\\|?*\p{C}]/gu,
|
|
@@ -87,7 +89,7 @@ function writeJsonError(res, status, message, code) {
|
|
|
87
89
|
export function handleDownload(res, namespace, hash) {
|
|
88
90
|
const parsed = DownloadParamsSchema.safeParse({ namespace, hash });
|
|
89
91
|
if (!parsed.success) {
|
|
90
|
-
writeJsonError(res, 400,
|
|
92
|
+
writeJsonError(res, 400, `Invalid download parameters: ${formatZodError(parsed.error)}`, 'BAD_REQUEST');
|
|
91
93
|
return;
|
|
92
94
|
}
|
|
93
95
|
const cacheKey = `${parsed.data.namespace}:${parsed.data.hash}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-tools.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAC/C,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAGD,QAAA,MAAM,oBAAoB;;;;;kBAKxB,CAAC;AAeH,QAAA,MAAM,qBAAqB;;;;;;;;;;;;oBAGzB,CAAC;AACH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;sBAGxB,CAAC;AACH,KAAK,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAC3D,KAAK,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACjE,KAAK,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAC/D,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAE5D;AACD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,cAAc,CAEtE;AACD,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,mBAAmB,CAE7B;AACD,wBAAgB,gBAAgB,CAAC,IAAI,EA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Ae,CAAC"}
|
package/dist/lib/mcp-tools.js
CHANGED
|
@@ -72,6 +72,31 @@ export function acceptsJsonAndEventStream(header) {
|
|
|
72
72
|
return false;
|
|
73
73
|
return hasAcceptedMediaType(mediaTypes, 'text/event-stream', 'text/*');
|
|
74
74
|
}
|
|
75
|
+
const PUBLIC_ERROR_REASONS = new Set(['aborted', 'queue_full', 'timeout']);
|
|
76
|
+
function sanitizeToolErrorDetails(details) {
|
|
77
|
+
const sanitized = {};
|
|
78
|
+
const { retryAfter, timeout, reason } = details;
|
|
79
|
+
if (typeof retryAfter === 'number' ||
|
|
80
|
+
typeof retryAfter === 'string' ||
|
|
81
|
+
retryAfter === null) {
|
|
82
|
+
sanitized['retryAfter'] = retryAfter;
|
|
83
|
+
}
|
|
84
|
+
if (typeof timeout === 'number' && Number.isFinite(timeout) && timeout >= 0) {
|
|
85
|
+
sanitized['timeout'] = timeout;
|
|
86
|
+
}
|
|
87
|
+
if (typeof reason === 'string' && PUBLIC_ERROR_REASONS.has(reason)) {
|
|
88
|
+
sanitized['reason'] = reason;
|
|
89
|
+
}
|
|
90
|
+
return Object.keys(sanitized).length > 0 ? sanitized : undefined;
|
|
91
|
+
}
|
|
92
|
+
function resolvePublicFetchErrorCode(error) {
|
|
93
|
+
const { code: detailsCode, reason } = error.details;
|
|
94
|
+
if (typeof detailsCode === 'string')
|
|
95
|
+
return detailsCode;
|
|
96
|
+
if (reason === 'queue_full')
|
|
97
|
+
return 'queue_full';
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
75
100
|
export function createToolErrorResponse(message, url, extra) {
|
|
76
101
|
const errorContent = {
|
|
77
102
|
error: message,
|
|
@@ -106,8 +131,7 @@ function resolveToolErrorMessage(error, fallbackMessage) {
|
|
|
106
131
|
}
|
|
107
132
|
function resolveToolErrorCode(error) {
|
|
108
133
|
if (error instanceof FetchError) {
|
|
109
|
-
|
|
110
|
-
return typeof detailsCode === 'string' ? detailsCode : error.code;
|
|
134
|
+
return resolvePublicFetchErrorCode(error) ?? error.code;
|
|
111
135
|
}
|
|
112
136
|
if (isValidationError(error))
|
|
113
137
|
return 'VALIDATION_ERROR';
|
|
@@ -119,10 +143,11 @@ export function handleToolError(error, url, fallbackMessage = 'Operation failed'
|
|
|
119
143
|
const message = resolveToolErrorMessage(error, fallbackMessage);
|
|
120
144
|
const code = resolveToolErrorCode(error);
|
|
121
145
|
if (error instanceof FetchError) {
|
|
146
|
+
const details = sanitizeToolErrorDetails(error.details);
|
|
122
147
|
return createToolErrorResponse(message, url, {
|
|
123
148
|
code,
|
|
124
149
|
statusCode: error.statusCode,
|
|
125
|
-
details:
|
|
150
|
+
...(details ? { details } : {}),
|
|
126
151
|
});
|
|
127
152
|
}
|
|
128
153
|
return createToolErrorResponse(message, url, { code });
|
|
@@ -58,29 +58,29 @@ export { cancelTasksForOwner, abortAllTaskExecutions, } from '../tasks/execution
|
|
|
58
58
|
* ------------------------------------------------------------------------------------------------- */
|
|
59
59
|
const TaskGetSchema = z.looseObject({
|
|
60
60
|
method: z.literal('tasks/get'),
|
|
61
|
-
params: z.
|
|
61
|
+
params: z.strictObject({ taskId: z.string() }),
|
|
62
62
|
});
|
|
63
63
|
const TaskListSchema = z.looseObject({
|
|
64
64
|
method: z.literal('tasks/list'),
|
|
65
65
|
params: z
|
|
66
|
-
.
|
|
66
|
+
.strictObject({
|
|
67
67
|
cursor: z.string().optional(),
|
|
68
68
|
})
|
|
69
69
|
.optional(),
|
|
70
70
|
});
|
|
71
71
|
const TaskCancelSchema = z.looseObject({
|
|
72
72
|
method: z.literal('tasks/cancel'),
|
|
73
|
-
params: z.
|
|
73
|
+
params: z.strictObject({ taskId: z.string() }),
|
|
74
74
|
});
|
|
75
75
|
const TaskResultSchema = z.looseObject({
|
|
76
76
|
method: z.literal('tasks/result'),
|
|
77
|
-
params: z.
|
|
77
|
+
params: z.strictObject({ taskId: z.string() }),
|
|
78
78
|
});
|
|
79
79
|
const MIN_TASK_TTL_MS = 1_000;
|
|
80
80
|
const MAX_TASK_TTL_MS = 86_400_000;
|
|
81
81
|
const ExtendedCallToolRequestSchema = z.looseObject({
|
|
82
82
|
method: z.literal('tools/call'),
|
|
83
|
-
params: z.
|
|
83
|
+
params: z.strictObject({
|
|
84
84
|
name: z.string().min(1),
|
|
85
85
|
arguments: z.record(z.string(), z.unknown()).optional(),
|
|
86
86
|
task: z
|
|
@@ -94,7 +94,7 @@ const ExtendedCallToolRequestSchema = z.looseObject({
|
|
|
94
94
|
})
|
|
95
95
|
.optional(),
|
|
96
96
|
_meta: z
|
|
97
|
-
.
|
|
97
|
+
.strictObject({
|
|
98
98
|
progressToken: z.union([z.string(), z.number()]).optional(),
|
|
99
99
|
'io.modelcontextprotocol/related-task': z
|
|
100
100
|
.strictObject({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EAEf,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/resources/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EAEf,MAAM,yCAAyC,CAAC;AAkBjD,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAkXpE,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,QAAQ,GAClB,IAAI,CAwBN;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,SAAS,EACjB,QAAQ,CAAC,EAAE,QAAQ,GAClB,IAAI,CA4BN"}
|
package/dist/resources/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ResourceTemplate, } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
2
|
import { ErrorCode, McpError, SubscribeRequestSchema, UnsubscribeRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
-
import { get as getCacheEntry, getEntryMeta, keys as listCacheKeys, onCacheUpdate,
|
|
3
|
+
import { get as getCacheEntry, getEntryMeta, keys as listCacheKeys, onCacheUpdate, parseCacheKey, } from '../lib/core.js';
|
|
4
4
|
import { logWarn } from '../lib/core.js';
|
|
5
5
|
import { registerServerLifecycleCleanup } from '../lib/mcp-tools.js';
|
|
6
6
|
import { buildOptionalIcons } from '../lib/types.js';
|
|
7
7
|
import { isObject } from '../lib/utils.js';
|
|
8
|
+
import { parseCachedPayload, resolveCachedPayloadContent } from '../schemas.js';
|
|
8
9
|
const RESOURCE_NOT_FOUND_ERROR_CODE = -32002;
|
|
9
10
|
const CACHE_RESOURCE_TEMPLATE_URI = 'internal://cache/{namespace}/{hash}';
|
|
10
11
|
const CACHE_RESOURCE_PREFIX = 'internal://cache/';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ExtractedMetadata } from './transform/types.js';
|
|
3
|
+
export declare const METADATA_LIMITS: {
|
|
4
|
+
readonly title: 512;
|
|
5
|
+
readonly description: 2048;
|
|
6
|
+
readonly author: 512;
|
|
7
|
+
readonly image: 2048;
|
|
8
|
+
readonly favicon: 2048;
|
|
9
|
+
readonly publishedAt: 64;
|
|
10
|
+
readonly modifiedAt: 64;
|
|
11
|
+
};
|
|
12
|
+
export declare const extractedMetadataSchema: z.ZodObject<{
|
|
13
|
+
title: z.ZodOptional<z.ZodString>;
|
|
14
|
+
description: z.ZodOptional<z.ZodString>;
|
|
15
|
+
author: z.ZodOptional<z.ZodString>;
|
|
16
|
+
image: z.ZodOptional<z.ZodString>;
|
|
17
|
+
favicon: z.ZodOptional<z.ZodString>;
|
|
18
|
+
publishedAt: z.ZodOptional<z.ZodString>;
|
|
19
|
+
modifiedAt: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strict>;
|
|
21
|
+
export declare function normalizeExtractedMetadata(value: unknown): ExtractedMetadata | undefined;
|
|
22
|
+
export declare function normalizePageTitle(value: unknown): string | undefined;
|
|
23
|
+
export declare const cachedPayloadSchema: z.ZodObject<{
|
|
24
|
+
markdown: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string | undefined, unknown>>>;
|
|
25
|
+
content: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string | undefined, unknown>>>;
|
|
26
|
+
title: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<string | undefined, unknown>>>;
|
|
27
|
+
metadata: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<ExtractedMetadata | undefined, unknown>>>;
|
|
28
|
+
truncated: z.ZodOptional<z.ZodPipe<z.ZodUnknown, z.ZodTransform<boolean | undefined, unknown>>>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export type CachedPayload = z.infer<typeof cachedPayloadSchema>;
|
|
31
|
+
export declare const fetchUrlInputSchema: z.ZodObject<{
|
|
32
|
+
url: z.ZodURL;
|
|
33
|
+
skipNoiseRemoval: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
forceRefresh: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
maxInlineChars: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
export declare const fetchUrlOutputSchema: z.ZodObject<{
|
|
38
|
+
url: z.ZodURL;
|
|
39
|
+
inputUrl: z.ZodOptional<z.ZodURL>;
|
|
40
|
+
resolvedUrl: z.ZodOptional<z.ZodURL>;
|
|
41
|
+
finalUrl: z.ZodOptional<z.ZodURL>;
|
|
42
|
+
title: z.ZodOptional<z.ZodString>;
|
|
43
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
44
|
+
title: z.ZodOptional<z.ZodString>;
|
|
45
|
+
description: z.ZodOptional<z.ZodString>;
|
|
46
|
+
author: z.ZodOptional<z.ZodString>;
|
|
47
|
+
image: z.ZodOptional<z.ZodString>;
|
|
48
|
+
favicon: z.ZodOptional<z.ZodString>;
|
|
49
|
+
publishedAt: z.ZodOptional<z.ZodString>;
|
|
50
|
+
modifiedAt: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, z.core.$strict>>;
|
|
52
|
+
markdown: z.ZodOptional<z.ZodString>;
|
|
53
|
+
fromCache: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
+
fetchedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
55
|
+
contentSize: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
}, z.core.$strict>;
|
|
58
|
+
export declare function parseCachedPayload(raw: string): CachedPayload | null;
|
|
59
|
+
export declare function resolveCachedPayloadContent(payload: CachedPayload): string | null;
|
|
60
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9D,eAAO,MAAM,eAAe;;;;;;;;CAQlB,CAAC;AAiCX,eAAO,MAAM,uBAAuB;;;;;;;;kBAQlC,CAAC;AAgBH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GACb,iBAAiB,GAAG,SAAS,CAQ/B;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAErE;AAUD,eAAO,MAAM,mBAAmB;;;;;;iBA2B7B,CAAC;AAEJ,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,mBAAmB;;;;;kBAuB9B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;kBAqC/B,CAAC;AAEH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAkBpE;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,aAAa,GACrB,MAAM,GAAG,IAAI,CAEf"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { config, logWarn } from './lib/core.js';
|
|
3
|
+
const URL_FIELD_MAX_LENGTH = 2048;
|
|
4
|
+
export const METADATA_LIMITS = {
|
|
5
|
+
title: 512,
|
|
6
|
+
description: 2048,
|
|
7
|
+
author: 512,
|
|
8
|
+
image: URL_FIELD_MAX_LENGTH,
|
|
9
|
+
favicon: URL_FIELD_MAX_LENGTH,
|
|
10
|
+
publishedAt: 64,
|
|
11
|
+
modifiedAt: 64,
|
|
12
|
+
};
|
|
13
|
+
const pageTitleSchema = z.string().trim().min(1).max(METADATA_LIMITS.title);
|
|
14
|
+
const metadataTextField = (max) => z.string().trim().min(1).max(max);
|
|
15
|
+
function normalizeWithSchema(schema, value) {
|
|
16
|
+
const parsed = schema.safeParse(value);
|
|
17
|
+
return parsed.success ? parsed.data : undefined;
|
|
18
|
+
}
|
|
19
|
+
const normalizedMetadataField = (max) => z
|
|
20
|
+
.unknown()
|
|
21
|
+
.transform((value) => normalizeWithSchema(metadataTextField(max), value))
|
|
22
|
+
.optional();
|
|
23
|
+
const normalizedMetadataSchema = z.object({
|
|
24
|
+
title: normalizedMetadataField(METADATA_LIMITS.title),
|
|
25
|
+
description: normalizedMetadataField(METADATA_LIMITS.description),
|
|
26
|
+
author: normalizedMetadataField(METADATA_LIMITS.author),
|
|
27
|
+
image: normalizedMetadataField(METADATA_LIMITS.image),
|
|
28
|
+
favicon: normalizedMetadataField(METADATA_LIMITS.favicon),
|
|
29
|
+
publishedAt: normalizedMetadataField(METADATA_LIMITS.publishedAt),
|
|
30
|
+
modifiedAt: normalizedMetadataField(METADATA_LIMITS.modifiedAt),
|
|
31
|
+
});
|
|
32
|
+
export const extractedMetadataSchema = z.strictObject({
|
|
33
|
+
title: metadataTextField(METADATA_LIMITS.title).optional(),
|
|
34
|
+
description: metadataTextField(METADATA_LIMITS.description).optional(),
|
|
35
|
+
author: metadataTextField(METADATA_LIMITS.author).optional(),
|
|
36
|
+
image: metadataTextField(METADATA_LIMITS.image).optional(),
|
|
37
|
+
favicon: metadataTextField(METADATA_LIMITS.favicon).optional(),
|
|
38
|
+
publishedAt: metadataTextField(METADATA_LIMITS.publishedAt).optional(),
|
|
39
|
+
modifiedAt: metadataTextField(METADATA_LIMITS.modifiedAt).optional(),
|
|
40
|
+
});
|
|
41
|
+
function compactDefined(value) {
|
|
42
|
+
const result = {};
|
|
43
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
44
|
+
if (entry !== undefined) {
|
|
45
|
+
result[key] = entry;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
export function normalizeExtractedMetadata(value) {
|
|
51
|
+
const parsed = normalizedMetadataSchema.safeParse(value);
|
|
52
|
+
if (!parsed.success)
|
|
53
|
+
return undefined;
|
|
54
|
+
const compacted = compactDefined(parsed.data);
|
|
55
|
+
return Object.keys(compacted).length > 0
|
|
56
|
+
? compacted
|
|
57
|
+
: undefined;
|
|
58
|
+
}
|
|
59
|
+
export function normalizePageTitle(value) {
|
|
60
|
+
return normalizeWithSchema(pageTitleSchema, value);
|
|
61
|
+
}
|
|
62
|
+
function normalizeString(value) {
|
|
63
|
+
return typeof value === 'string' ? value : undefined;
|
|
64
|
+
}
|
|
65
|
+
function normalizeBoolean(value) {
|
|
66
|
+
return typeof value === 'boolean' ? value : undefined;
|
|
67
|
+
}
|
|
68
|
+
export const cachedPayloadSchema = z
|
|
69
|
+
.object({
|
|
70
|
+
markdown: z
|
|
71
|
+
.unknown()
|
|
72
|
+
.transform((value) => normalizeString(value))
|
|
73
|
+
.optional(),
|
|
74
|
+
content: z
|
|
75
|
+
.unknown()
|
|
76
|
+
.transform((value) => normalizeString(value))
|
|
77
|
+
.optional(),
|
|
78
|
+
title: z
|
|
79
|
+
.unknown()
|
|
80
|
+
.transform((value) => normalizePageTitle(value))
|
|
81
|
+
.optional(),
|
|
82
|
+
metadata: z
|
|
83
|
+
.unknown()
|
|
84
|
+
.transform((value) => normalizeExtractedMetadata(value))
|
|
85
|
+
.optional(),
|
|
86
|
+
truncated: z
|
|
87
|
+
.unknown()
|
|
88
|
+
.transform((value) => normalizeBoolean(value))
|
|
89
|
+
.optional(),
|
|
90
|
+
})
|
|
91
|
+
.refine((value) => typeof value.markdown === 'string' || typeof value.content === 'string', { error: 'Missing markdown/content' });
|
|
92
|
+
export const fetchUrlInputSchema = z.strictObject({
|
|
93
|
+
url: z
|
|
94
|
+
.httpUrl()
|
|
95
|
+
.min(1)
|
|
96
|
+
.max(config.constants.maxUrlLength)
|
|
97
|
+
.describe(`Target URL. Max ${config.constants.maxUrlLength} chars.`),
|
|
98
|
+
skipNoiseRemoval: z
|
|
99
|
+
.boolean()
|
|
100
|
+
.optional()
|
|
101
|
+
.describe('Preserve navigation/footers (disable noise filtering).'),
|
|
102
|
+
forceRefresh: z
|
|
103
|
+
.boolean()
|
|
104
|
+
.optional()
|
|
105
|
+
.describe('Bypass cache and fetch fresh content.'),
|
|
106
|
+
maxInlineChars: z
|
|
107
|
+
.number()
|
|
108
|
+
.int()
|
|
109
|
+
.min(0)
|
|
110
|
+
.max(config.constants.maxHtmlSize)
|
|
111
|
+
.optional()
|
|
112
|
+
.describe(`Inline markdown limit (0-${config.constants.maxHtmlSize}, 0=unlimited). Lower of this or global limit applies.`),
|
|
113
|
+
});
|
|
114
|
+
export const fetchUrlOutputSchema = z.strictObject({
|
|
115
|
+
url: z.httpUrl().max(config.constants.maxUrlLength).describe('Fetched URL.'),
|
|
116
|
+
inputUrl: z
|
|
117
|
+
.httpUrl()
|
|
118
|
+
.max(config.constants.maxUrlLength)
|
|
119
|
+
.optional()
|
|
120
|
+
.describe('Original requested URL.'),
|
|
121
|
+
resolvedUrl: z
|
|
122
|
+
.httpUrl()
|
|
123
|
+
.max(config.constants.maxUrlLength)
|
|
124
|
+
.optional()
|
|
125
|
+
.describe('Final URL after raw-content transformations.'),
|
|
126
|
+
finalUrl: z
|
|
127
|
+
.httpUrl()
|
|
128
|
+
.max(config.constants.maxUrlLength)
|
|
129
|
+
.optional()
|
|
130
|
+
.describe('Final URL after HTTP redirects.'),
|
|
131
|
+
title: z.string().max(512).optional().describe('Page title.'),
|
|
132
|
+
metadata: extractedMetadataSchema
|
|
133
|
+
.optional()
|
|
134
|
+
.describe('Extracted page metadata.'),
|
|
135
|
+
markdown: (config.constants.maxInlineContentChars > 0
|
|
136
|
+
? z.string().max(config.constants.maxInlineContentChars)
|
|
137
|
+
: z.string())
|
|
138
|
+
.optional()
|
|
139
|
+
.describe('Extracted Markdown. May be truncated (check truncated field).'),
|
|
140
|
+
fromCache: z.boolean().optional().describe('True if served from cache.'),
|
|
141
|
+
fetchedAt: z.iso.datetime().optional().describe('ISO timestamp of fetch.'),
|
|
142
|
+
contentSize: z
|
|
143
|
+
.number()
|
|
144
|
+
.int()
|
|
145
|
+
.min(0)
|
|
146
|
+
.max(config.constants.maxHtmlSize * 4)
|
|
147
|
+
.optional()
|
|
148
|
+
.describe('Full markdown size before truncation.'),
|
|
149
|
+
truncated: z.boolean().optional().describe('True if markdown was truncated.'),
|
|
150
|
+
});
|
|
151
|
+
export function parseCachedPayload(raw) {
|
|
152
|
+
try {
|
|
153
|
+
const parsed = JSON.parse(raw);
|
|
154
|
+
const result = cachedPayloadSchema.safeParse(parsed);
|
|
155
|
+
if (!result.success) {
|
|
156
|
+
logWarn('Rejected invalid cached payload', {
|
|
157
|
+
issues: result.error.issues.map((issue) => ({
|
|
158
|
+
path: issue.path,
|
|
159
|
+
message: issue.message,
|
|
160
|
+
code: issue.code,
|
|
161
|
+
})),
|
|
162
|
+
});
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
return result.data;
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
export function resolveCachedPayloadContent(payload) {
|
|
172
|
+
return payload.markdown ?? payload.content ?? null;
|
|
173
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owner.d.ts","sourceRoot":"","sources":["../../src/tasks/owner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"owner.d.ts","sourceRoot":"","sources":["../../src/tasks/owner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAGvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAOhE,UAAU,YAAY;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,CAAC,YAAY,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1E;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,CAAC,YAAY,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1E;AAED;;sDAEsD;AACtD,KAAK,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI;KAChC,CAAC,IAAI,MAAM,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,SAAS,KAAK,GACnD,KAAK,GACL,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;CAClC,CAAC;AAEF,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAQ9D;AA2BD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAyB1E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,MAAM,CAMhE;AAED,wBAAgB,sBAAsB,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,eAAe,CAQ5E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAIpE;AAWD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAgB7E"}
|
package/dist/tasks/owner.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import { z } from 'zod';
|
|
2
3
|
import { isObject } from '../lib/utils.js';
|
|
3
4
|
export function compact(obj) {
|
|
4
5
|
const result = {};
|
|
@@ -71,20 +72,25 @@ export function resolveToolCallContext(extra) {
|
|
|
71
72
|
export function isServerResult(value) {
|
|
72
73
|
return (isObject(value) && Array.isArray(value.content));
|
|
73
74
|
}
|
|
75
|
+
const toolErrorContentSchema = z.strictObject({
|
|
76
|
+
error: z.string(),
|
|
77
|
+
});
|
|
78
|
+
const toolErrorBlockSchema = z.strictObject({
|
|
79
|
+
type: z.literal('text'),
|
|
80
|
+
text: z.string(),
|
|
81
|
+
});
|
|
74
82
|
export function tryReadToolStructuredError(value) {
|
|
75
83
|
if (!isObject(value))
|
|
76
84
|
return undefined;
|
|
77
85
|
const record = value;
|
|
78
86
|
if (!Array.isArray(record.content) || record.content.length === 0)
|
|
79
87
|
return undefined;
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
82
|
-
firstBlock['type'] !== 'text' ||
|
|
83
|
-
typeof firstBlock['text'] !== 'string')
|
|
88
|
+
const parsedBlock = toolErrorBlockSchema.safeParse(record.content[0]);
|
|
89
|
+
if (!parsedBlock.success)
|
|
84
90
|
return undefined;
|
|
85
91
|
try {
|
|
86
|
-
const parsed = JSON.parse(
|
|
87
|
-
return
|
|
92
|
+
const parsed = toolErrorContentSchema.safeParse(JSON.parse(parsedBlock.data.text));
|
|
93
|
+
return parsed.success ? parsed.data.error : undefined;
|
|
88
94
|
}
|
|
89
95
|
catch {
|
|
90
96
|
return undefined;
|
|
@@ -2,7 +2,7 @@ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
2
2
|
import type { ContentBlock } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { type ToolHandlerExtra } from '../lib/mcp-tools.js';
|
|
5
|
-
import { fetchUrlInputSchema } from '../schemas
|
|
5
|
+
import { fetchUrlInputSchema } from '../schemas.js';
|
|
6
6
|
type FetchUrlInput = z.infer<typeof fetchUrlInputSchema>;
|
|
7
7
|
type ToolContentBlockUnion = ContentBlock;
|
|
8
8
|
interface ToolResponseBase {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-url.d.ts","sourceRoot":"","sources":["../../src/tools/fetch-url.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,SAAS,EAEV,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EACV,YAAY,EAEb,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwBxB,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"fetch-url.d.ts","sourceRoot":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{ appendTruncationMarker, markdownTransform, parseCachedMarkdownResult, p
|
|
|
8
8
|
import { createProgressReporter, } from '../lib/mcp-tools.js';
|
|
9
9
|
import { isAbortError, isObject, toError } from '../lib/utils.js';
|
|
10
10
|
import { formatZodError } from '../lib/zod.js';
|
|
11
|
-
import { fetchUrlInputSchema } from '../schemas
|
|
12
|
-
import { fetchUrlOutputSchema } from '../schemas/outputs.js';
|
|
11
|
+
import { fetchUrlInputSchema, fetchUrlOutputSchema, normalizeExtractedMetadata, normalizePageTitle, } from '../schemas.js';
|
|
13
12
|
import { registerTaskCapableTool, unregisterTaskCapableTool, } from '../tasks/tool-registry.js';
|
|
14
13
|
export const FETCH_URL_TOOL_NAME = 'fetch-url';
|
|
15
14
|
const FETCH_URL_TOOL_DESCRIPTION = `
|
|
@@ -56,35 +55,20 @@ function truncateStr(value, max) {
|
|
|
56
55
|
return value;
|
|
57
56
|
return value.slice(0, max);
|
|
58
57
|
}
|
|
59
|
-
const METADATA_FIELD_LIMITS = {
|
|
60
|
-
title: 512,
|
|
61
|
-
description: 2048,
|
|
62
|
-
author: 512,
|
|
63
|
-
};
|
|
64
|
-
function truncateMetadata(metadata) {
|
|
65
|
-
const result = { ...metadata };
|
|
66
|
-
for (const [field, limit] of Object.entries(METADATA_FIELD_LIMITS)) {
|
|
67
|
-
const key = field;
|
|
68
|
-
const value = result[key];
|
|
69
|
-
if (typeof value === 'string' && value.length > limit) {
|
|
70
|
-
result[key] = value.slice(0, limit);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
58
|
function buildStructuredContent(pipeline, inlineResult, inputUrl) {
|
|
76
59
|
const truncated = inlineResult.truncated ?? pipeline.data.truncated;
|
|
77
60
|
const rawMarkdown = applyTruncationMarker(inlineResult.content, pipeline.data.truncated);
|
|
78
61
|
const maxChars = config.constants.maxInlineContentChars;
|
|
79
62
|
const markdown = maxChars > 0 ? truncateStr(rawMarkdown, maxChars) : rawMarkdown;
|
|
80
|
-
const
|
|
63
|
+
const metadata = normalizeExtractedMetadata(pipeline.data.metadata);
|
|
64
|
+
const title = normalizePageTitle(pipeline.data.title);
|
|
81
65
|
return {
|
|
82
66
|
url: pipeline.originalUrl ?? pipeline.url,
|
|
83
67
|
resolvedUrl: pipeline.url,
|
|
84
68
|
...(pipeline.finalUrl ? { finalUrl: pipeline.finalUrl } : {}),
|
|
85
69
|
inputUrl,
|
|
86
|
-
title
|
|
87
|
-
...(metadata ? { metadata
|
|
70
|
+
...(title ? { title } : {}),
|
|
71
|
+
...(metadata ? { metadata } : {}),
|
|
88
72
|
markdown,
|
|
89
73
|
fromCache: pipeline.fromCache,
|
|
90
74
|
fetchedAt: pipeline.fetchedAt,
|
|
@@ -107,7 +91,7 @@ function buildResponse(pipeline, inlineResult, inputUrl) {
|
|
|
107
91
|
if (!validation.success) {
|
|
108
92
|
logWarn('Tool output schema validation failed', {
|
|
109
93
|
url: inputUrl,
|
|
110
|
-
issues: validation.error
|
|
94
|
+
issues: formatZodError(validation.error),
|
|
111
95
|
});
|
|
112
96
|
// Omit structuredContent so the SDK does not receive data that fails its
|
|
113
97
|
// output schema validation. The client still gets the payload via content[0].text.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-pool.d.ts","sourceRoot":"","sources":["../../src/transform/worker-pool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"worker-pool.d.ts","sourceRoot":"","sources":["../../src/transform/worker-pool.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EACV,uBAAuB,EAGxB,MAAM,YAAY,CAAC;AAuJpB,UAAU,mBAAmB;IAC3B,SAAS,CACP,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QACP,eAAe,EAAE,OAAO,CAAC;QACzB,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;KAC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AAE,OAAO,CAAC;QAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GACA,OAAO,CAAC,uBAAuB,CAAC;IAoCnC,aAAa,IAAI,MAAM;IAKvB,gBAAgB,IAAI,MAAM;IAI1B,WAAW,IAAI,MAAM;IAIrB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAWpB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAiC5B,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,iBAAiB;IAoDzB,OAAO,CAAC,aAAa;IAsCrB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,gBAAgB;YAyBV,aAAa;IA2B3B,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,WAAW;IAmCnB,OAAO,CAAC,cAAc;IAuBtB,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,eAAe;IAsDvB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,QAAQ;IAWhB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,UAAU;IA2BlB,OAAO,CAAC,kBAAkB;IAe1B,OAAO,CAAC,iBAAiB;IAiFzB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,iBAAiB;CAW1B;AAMD,wBAAgB,qBAAqB,IAAI,UAAU,CAIlD;AAED,wBAAgB,kBAAkB,IAAI;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CAOP;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC,CAIxD"}
|
|
@@ -4,66 +4,53 @@ import { availableParallelism } from 'node:os';
|
|
|
4
4
|
import process from 'node:process';
|
|
5
5
|
import { isSharedArrayBuffer } from 'node:util/types';
|
|
6
6
|
import { isMainThread, parentPort, Worker, } from 'node:worker_threads';
|
|
7
|
+
import { z } from 'zod';
|
|
7
8
|
import { config } from '../lib/core.js';
|
|
8
9
|
import { logWarn } from '../lib/core.js';
|
|
9
10
|
import { createAbortError } from '../lib/utils.js';
|
|
10
11
|
import { FetchError, getErrorMessage } from '../lib/utils.js';
|
|
11
12
|
import { createUnrefTimeout } from '../lib/utils.js';
|
|
12
|
-
import {
|
|
13
|
+
import { normalizeExtractedMetadata } from '../schemas.js';
|
|
13
14
|
import { createTransformMessageHandler } from './shared.js';
|
|
14
15
|
import { transformHtmlToMarkdownInProcess } from './transform.js';
|
|
15
16
|
// Worker message validation
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!isObject(raw))
|
|
54
|
-
return false;
|
|
55
|
-
if (typeof raw['id'] !== 'string')
|
|
56
|
-
return false;
|
|
57
|
-
if (raw['type'] === 'result') {
|
|
58
|
-
return isWorkerResultPayload(raw['result']);
|
|
59
|
-
}
|
|
60
|
-
if (raw['type'] === 'error') {
|
|
61
|
-
return isWorkerErrorPayload(raw['error']);
|
|
62
|
-
}
|
|
63
|
-
if (raw['type'] === 'cancelled') {
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
return false;
|
|
17
|
+
const workerResultPayloadSchema = z.object({
|
|
18
|
+
markdown: z.string(),
|
|
19
|
+
title: z.string().optional(),
|
|
20
|
+
metadata: z
|
|
21
|
+
.unknown()
|
|
22
|
+
.transform((value) => normalizeExtractedMetadata(value))
|
|
23
|
+
.optional(),
|
|
24
|
+
truncated: z.boolean(),
|
|
25
|
+
});
|
|
26
|
+
const workerErrorPayloadSchema = z.strictObject({
|
|
27
|
+
name: z.string(),
|
|
28
|
+
message: z.string(),
|
|
29
|
+
url: z.string(),
|
|
30
|
+
statusCode: z.number().optional(),
|
|
31
|
+
details: z.record(z.string(), z.unknown()).optional(),
|
|
32
|
+
});
|
|
33
|
+
const workerResponseSchema = z.union([
|
|
34
|
+
z.strictObject({
|
|
35
|
+
type: z.literal('result'),
|
|
36
|
+
id: z.string(),
|
|
37
|
+
result: workerResultPayloadSchema,
|
|
38
|
+
}),
|
|
39
|
+
z.strictObject({
|
|
40
|
+
type: z.literal('error'),
|
|
41
|
+
id: z.string(),
|
|
42
|
+
error: workerErrorPayloadSchema,
|
|
43
|
+
}),
|
|
44
|
+
z.strictObject({
|
|
45
|
+
type: z.literal('cancelled'),
|
|
46
|
+
id: z.string(),
|
|
47
|
+
}),
|
|
48
|
+
]);
|
|
49
|
+
function parseWorkerResponse(raw) {
|
|
50
|
+
const parsed = workerResponseSchema.safeParse(raw);
|
|
51
|
+
return parsed.success
|
|
52
|
+
? parsed.data
|
|
53
|
+
: undefined;
|
|
67
54
|
}
|
|
68
55
|
function createTaskContext() {
|
|
69
56
|
const runWithStore = AsyncLocalStorage.snapshot();
|
|
@@ -380,9 +367,9 @@ class WorkerPool {
|
|
|
380
367
|
this.drainQueue();
|
|
381
368
|
}
|
|
382
369
|
onWorkerMessage(workerIndex, raw) {
|
|
383
|
-
|
|
370
|
+
const message = parseWorkerResponse(raw);
|
|
371
|
+
if (!message)
|
|
384
372
|
return;
|
|
385
|
-
const message = raw;
|
|
386
373
|
if (message.type === 'cancelled') {
|
|
387
374
|
this.resolveCancelAck(message.id);
|
|
388
375
|
return;
|
package/package.json
CHANGED
package/dist/schemas/cache.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const cachedPayloadSchema: z.ZodObject<{
|
|
3
|
-
markdown: z.ZodOptional<z.ZodString>;
|
|
4
|
-
content: z.ZodOptional<z.ZodString>;
|
|
5
|
-
title: z.ZodOptional<z.ZodString>;
|
|
6
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
7
|
-
title: z.ZodOptional<z.ZodString>;
|
|
8
|
-
description: z.ZodOptional<z.ZodString>;
|
|
9
|
-
author: z.ZodOptional<z.ZodString>;
|
|
10
|
-
image: z.ZodOptional<z.ZodString>;
|
|
11
|
-
favicon: z.ZodOptional<z.ZodString>;
|
|
12
|
-
publishedAt: z.ZodOptional<z.ZodString>;
|
|
13
|
-
modifiedAt: z.ZodOptional<z.ZodString>;
|
|
14
|
-
}, z.core.$strict>>;
|
|
15
|
-
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
-
}, z.core.$loose>;
|
|
17
|
-
export type CachedPayload = z.infer<typeof cachedPayloadSchema>;
|
|
18
|
-
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/schemas/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;iBAY7B,CAAC;AAEJ,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
package/dist/schemas/cache.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
const extractedMetadataSchema = z.strictObject({
|
|
3
|
-
title: z.string().optional(),
|
|
4
|
-
description: z.string().optional(),
|
|
5
|
-
author: z.string().optional(),
|
|
6
|
-
image: z.string().optional(),
|
|
7
|
-
favicon: z.string().optional(),
|
|
8
|
-
publishedAt: z.string().optional(),
|
|
9
|
-
modifiedAt: z.string().optional(),
|
|
10
|
-
});
|
|
11
|
-
export const cachedPayloadSchema = z
|
|
12
|
-
.looseObject({
|
|
13
|
-
markdown: z.string().optional(),
|
|
14
|
-
content: z.string().optional(),
|
|
15
|
-
title: z.string().optional(),
|
|
16
|
-
metadata: extractedMetadataSchema.optional(),
|
|
17
|
-
truncated: z.boolean().optional(),
|
|
18
|
-
})
|
|
19
|
-
.refine((value) => typeof value.markdown === 'string' || typeof value.content === 'string', { error: 'Missing markdown/content' });
|
package/dist/schemas/inputs.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const fetchUrlInputSchema: z.ZodObject<{
|
|
3
|
-
url: z.ZodURL;
|
|
4
|
-
skipNoiseRemoval: z.ZodOptional<z.ZodBoolean>;
|
|
5
|
-
forceRefresh: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
-
maxInlineChars: z.ZodOptional<z.ZodNumber>;
|
|
7
|
-
}, z.core.$strict>;
|
|
8
|
-
//# sourceMappingURL=inputs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../../src/schemas/inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,mBAAmB;;;;;kBAuB9B,CAAC"}
|
package/dist/schemas/inputs.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { config } from '../lib/core.js';
|
|
3
|
-
export const fetchUrlInputSchema = z.strictObject({
|
|
4
|
-
url: z
|
|
5
|
-
.httpUrl()
|
|
6
|
-
.min(1)
|
|
7
|
-
.max(config.constants.maxUrlLength)
|
|
8
|
-
.describe(`Target URL. Max ${config.constants.maxUrlLength} chars.`),
|
|
9
|
-
skipNoiseRemoval: z
|
|
10
|
-
.boolean()
|
|
11
|
-
.optional()
|
|
12
|
-
.describe('Preserve navigation/footers (disable noise filtering).'),
|
|
13
|
-
forceRefresh: z
|
|
14
|
-
.boolean()
|
|
15
|
-
.optional()
|
|
16
|
-
.describe('Bypass cache and fetch fresh content.'),
|
|
17
|
-
maxInlineChars: z
|
|
18
|
-
.number()
|
|
19
|
-
.int()
|
|
20
|
-
.min(0)
|
|
21
|
-
.max(config.constants.maxHtmlSize)
|
|
22
|
-
.optional()
|
|
23
|
-
.describe(`Inline markdown limit (0-${config.constants.maxHtmlSize}, 0=unlimited). Lower of this or global limit applies.`),
|
|
24
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const fetchUrlOutputSchema: z.ZodObject<{
|
|
3
|
-
url: z.ZodURL;
|
|
4
|
-
inputUrl: z.ZodOptional<z.ZodURL>;
|
|
5
|
-
resolvedUrl: z.ZodOptional<z.ZodURL>;
|
|
6
|
-
finalUrl: z.ZodOptional<z.ZodURL>;
|
|
7
|
-
title: z.ZodOptional<z.ZodString>;
|
|
8
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
9
|
-
title: z.ZodOptional<z.ZodString>;
|
|
10
|
-
description: z.ZodOptional<z.ZodString>;
|
|
11
|
-
author: z.ZodOptional<z.ZodString>;
|
|
12
|
-
image: z.ZodOptional<z.ZodString>;
|
|
13
|
-
favicon: z.ZodOptional<z.ZodString>;
|
|
14
|
-
publishedAt: z.ZodOptional<z.ZodString>;
|
|
15
|
-
modifiedAt: z.ZodOptional<z.ZodString>;
|
|
16
|
-
}, z.core.$strict>>;
|
|
17
|
-
markdown: z.ZodOptional<z.ZodString>;
|
|
18
|
-
fromCache: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
-
fetchedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
20
|
-
contentSize: z.ZodOptional<z.ZodNumber>;
|
|
21
|
-
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
-
}, z.core.$strict>;
|
|
23
|
-
//# sourceMappingURL=outputs.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outputs.d.ts","sourceRoot":"","sources":["../../src/schemas/outputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;kBAkE/B,CAAC"}
|
package/dist/schemas/outputs.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { config } from '../lib/core.js';
|
|
3
|
-
export const fetchUrlOutputSchema = z.strictObject({
|
|
4
|
-
url: z.httpUrl().max(config.constants.maxUrlLength).describe('Fetched URL.'),
|
|
5
|
-
inputUrl: z
|
|
6
|
-
.httpUrl()
|
|
7
|
-
.max(config.constants.maxUrlLength)
|
|
8
|
-
.optional()
|
|
9
|
-
.describe('Original requested URL.'),
|
|
10
|
-
resolvedUrl: z
|
|
11
|
-
.httpUrl()
|
|
12
|
-
.max(config.constants.maxUrlLength)
|
|
13
|
-
.optional()
|
|
14
|
-
.describe('Final URL after raw-content transformations.'),
|
|
15
|
-
finalUrl: z
|
|
16
|
-
.httpUrl()
|
|
17
|
-
.max(config.constants.maxUrlLength)
|
|
18
|
-
.optional()
|
|
19
|
-
.describe('Final URL after HTTP redirects.'),
|
|
20
|
-
title: z.string().max(512).optional().describe('Page title.'),
|
|
21
|
-
metadata: z
|
|
22
|
-
.strictObject({
|
|
23
|
-
title: z.string().max(512).optional().describe('Detected page title.'),
|
|
24
|
-
description: z
|
|
25
|
-
.string()
|
|
26
|
-
.max(2048)
|
|
27
|
-
.optional()
|
|
28
|
-
.describe('Detected page description.'),
|
|
29
|
-
author: z.string().max(512).optional().describe('Detected page author.'),
|
|
30
|
-
image: z
|
|
31
|
-
.string()
|
|
32
|
-
.max(config.constants.maxUrlLength)
|
|
33
|
-
.optional()
|
|
34
|
-
.describe('Detected page preview image URL.'),
|
|
35
|
-
favicon: z
|
|
36
|
-
.string()
|
|
37
|
-
.max(config.constants.maxUrlLength)
|
|
38
|
-
.optional()
|
|
39
|
-
.describe('Detected page favicon URL.'),
|
|
40
|
-
publishedAt: z
|
|
41
|
-
.string()
|
|
42
|
-
.max(64)
|
|
43
|
-
.optional()
|
|
44
|
-
.describe('Detected publication date.'),
|
|
45
|
-
modifiedAt: z
|
|
46
|
-
.string()
|
|
47
|
-
.max(64)
|
|
48
|
-
.optional()
|
|
49
|
-
.describe('Detected last modified date.'),
|
|
50
|
-
})
|
|
51
|
-
.optional()
|
|
52
|
-
.describe('Extracted page metadata.'),
|
|
53
|
-
markdown: (config.constants.maxInlineContentChars > 0
|
|
54
|
-
? z.string().max(config.constants.maxInlineContentChars)
|
|
55
|
-
: z.string())
|
|
56
|
-
.optional()
|
|
57
|
-
.describe('Extracted Markdown. May be truncated (check truncated field).'),
|
|
58
|
-
fromCache: z.boolean().optional().describe('True if served from cache.'),
|
|
59
|
-
fetchedAt: z.iso.datetime().optional().describe('ISO timestamp of fetch.'),
|
|
60
|
-
contentSize: z
|
|
61
|
-
.number()
|
|
62
|
-
.int()
|
|
63
|
-
.min(0)
|
|
64
|
-
.max(config.constants.maxHtmlSize * 4)
|
|
65
|
-
.optional()
|
|
66
|
-
.describe('Full markdown size before truncation.'),
|
|
67
|
-
truncated: z.boolean().optional().describe('True if markdown was truncated.'),
|
|
68
|
-
});
|