@j0hanz/fetch-url-mcp 1.6.0 → 1.7.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 +507 -403
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/http/auth.d.ts +12 -0
- package/dist/http/auth.d.ts.map +1 -0
- package/dist/http/auth.js +85 -6
- package/dist/http/health.d.ts +1 -0
- package/dist/http/health.d.ts.map +1 -0
- package/dist/http/helpers.d.ts +1 -0
- package/dist/http/helpers.d.ts.map +1 -0
- package/dist/http/native.d.ts +1 -0
- package/dist/http/native.d.ts.map +1 -0
- package/dist/http/native.js +80 -63
- package/dist/http/rate-limit.d.ts +1 -0
- package/dist/http/rate-limit.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/content.d.ts +3 -0
- package/dist/lib/content.d.ts.map +1 -0
- package/dist/lib/content.js +16 -11
- package/dist/lib/core.d.ts +6 -8
- package/dist/lib/core.d.ts.map +1 -0
- package/dist/lib/core.js +111 -97
- package/dist/lib/fetch-pipeline.d.ts +1 -1
- package/dist/lib/fetch-pipeline.d.ts.map +1 -0
- package/dist/lib/fetch-pipeline.js +54 -44
- package/dist/lib/http.d.ts +1 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/lib/mcp-tools.d.ts +45 -7
- package/dist/lib/mcp-tools.d.ts.map +1 -0
- package/dist/lib/mcp-tools.js +37 -6
- package/dist/lib/net-utils.d.ts +1 -0
- package/dist/lib/net-utils.d.ts.map +1 -0
- package/dist/lib/progress.d.ts +1 -0
- package/dist/lib/progress.d.ts.map +1 -0
- package/dist/lib/task-handlers.d.ts +9 -1
- package/dist/lib/task-handlers.d.ts.map +1 -0
- package/dist/lib/task-handlers.js +30 -38
- package/dist/lib/types.d.ts +4 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +12 -1
- package/dist/lib/url.d.ts +3 -0
- package/dist/lib/url.d.ts.map +1 -0
- package/dist/lib/url.js +78 -151
- package/dist/lib/utils.d.ts +2 -2
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +60 -94
- package/dist/lib/zod.d.ts +3 -0
- package/dist/lib/zod.d.ts.map +1 -0
- package/dist/lib/zod.js +33 -0
- package/dist/prompts/index.d.ts +2 -1
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +2 -13
- package/dist/resources/index.d.ts +2 -1
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +5 -19
- package/dist/resources/instructions.d.ts +1 -0
- package/dist/resources/instructions.d.ts.map +1 -0
- package/dist/resources/instructions.js +2 -0
- package/dist/schemas/cache.d.ts +18 -0
- package/dist/schemas/cache.d.ts.map +1 -0
- package/dist/schemas/cache.js +19 -0
- package/dist/schemas/inputs.d.ts +1 -0
- package/dist/schemas/inputs.d.ts.map +1 -0
- package/dist/schemas/outputs.d.ts +6 -5
- package/dist/schemas/outputs.d.ts.map +1 -0
- package/dist/schemas/outputs.js +5 -9
- package/dist/server.d.ts +1 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +9 -7
- package/dist/tasks/execution.d.ts +1 -0
- package/dist/tasks/execution.d.ts.map +1 -0
- package/dist/tasks/execution.js +3 -21
- package/dist/tasks/manager.d.ts +2 -6
- package/dist/tasks/manager.d.ts.map +1 -0
- package/dist/tasks/manager.js +2 -4
- package/dist/tasks/owner.d.ts +1 -0
- package/dist/tasks/owner.d.ts.map +1 -0
- package/dist/tasks/tool-registry.d.ts +2 -0
- package/dist/tasks/tool-registry.d.ts.map +1 -0
- package/dist/tasks/tool-registry.js +3 -0
- package/dist/tools/fetch-url.d.ts +4 -6
- package/dist/tools/fetch-url.d.ts.map +1 -0
- package/dist/tools/fetch-url.js +61 -59
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/transform/html-translators.d.ts +1 -0
- package/dist/transform/html-translators.d.ts.map +1 -0
- package/dist/transform/html-translators.js +5 -2
- package/dist/transform/metadata.d.ts +1 -0
- package/dist/transform/metadata.d.ts.map +1 -0
- package/dist/transform/metadata.js +1 -0
- package/dist/transform/{workers/shared.d.ts → shared.d.ts} +2 -1
- package/dist/transform/shared.d.ts.map +1 -0
- package/dist/transform/{workers/shared.js → shared.js} +1 -1
- package/dist/transform/transform.d.ts +1 -0
- package/dist/transform/transform.d.ts.map +1 -0
- package/dist/transform/transform.js +21 -14
- package/dist/transform/types.d.ts +1 -4
- package/dist/transform/types.d.ts.map +1 -0
- package/dist/transform/worker-pool.d.ts +3 -18
- package/dist/transform/worker-pool.d.ts.map +1 -0
- package/dist/transform/worker-pool.js +51 -167
- package/package.json +9 -6
- package/dist/transform/workers/transform-child.d.ts +0 -1
- package/dist/transform/workers/transform-child.js +0 -15
- package/dist/transform/workers/transform-worker.d.ts +0 -1
- package/dist/transform/workers/transform-worker.js +0 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAwBA,wBAAgB,cAAc,CAC5B,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,IAAI,CAeN;AACD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAKvE;AAsBD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAcjE;AAeD,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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S,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IACzC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,YAAY,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5C;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -50,25 +50,19 @@ function assertAllowedAlgorithm(algorithm) {
|
|
|
50
50
|
throw new Error(`Hash algorithm not allowed: ${algorithm}`);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
function padBuffer(buffer, length) {
|
|
54
|
-
const padded = Buffer.alloc(length);
|
|
55
|
-
buffer.copy(padded);
|
|
56
|
-
return padded;
|
|
57
|
-
}
|
|
58
|
-
function equalWithPadding(aBuffer, bBuffer, paddedLength) {
|
|
59
|
-
const paddedA = padBuffer(aBuffer, paddedLength);
|
|
60
|
-
const paddedB = padBuffer(bBuffer, paddedLength);
|
|
61
|
-
return timingSafeEqual(paddedA, paddedB) && aBuffer.length === bBuffer.length;
|
|
62
|
-
}
|
|
63
53
|
export function timingSafeEqualUtf8(a, b) {
|
|
64
54
|
const aBuffer = Buffer.from(a, 'utf8');
|
|
65
55
|
const bBuffer = Buffer.from(b, 'utf8');
|
|
66
56
|
if (aBuffer.length === bBuffer.length) {
|
|
67
57
|
return timingSafeEqual(aBuffer, bBuffer);
|
|
68
58
|
}
|
|
69
|
-
//
|
|
59
|
+
// If lengths differ, compare against a buffer of the same length filled with zeros.
|
|
70
60
|
const maxLength = Math.max(aBuffer.length, bBuffer.length);
|
|
71
|
-
|
|
61
|
+
const paddedA = Buffer.alloc(maxLength);
|
|
62
|
+
aBuffer.copy(paddedA);
|
|
63
|
+
const paddedB = Buffer.alloc(maxLength);
|
|
64
|
+
bBuffer.copy(paddedB);
|
|
65
|
+
return timingSafeEqual(paddedA, paddedB) && aBuffer.length === bBuffer.length;
|
|
72
66
|
}
|
|
73
67
|
function hashHex(algorithm, input) {
|
|
74
68
|
assertAllowedAlgorithm(algorithm);
|
|
@@ -96,36 +90,26 @@ export class FetchError extends Error {
|
|
|
96
90
|
this.url = url;
|
|
97
91
|
this.name = 'FetchError';
|
|
98
92
|
this.statusCode = httpStatus ?? DEFAULT_HTTP_STATUS;
|
|
99
|
-
this.code = httpStatus ? `HTTP_${httpStatus}` : 'FETCH_ERROR';
|
|
100
93
|
this.details = Object.freeze({ url, httpStatus, ...details });
|
|
101
|
-
|
|
94
|
+
const explicitCode = this.details['code'];
|
|
95
|
+
this.code =
|
|
96
|
+
typeof explicitCode === 'string'
|
|
97
|
+
? explicitCode
|
|
98
|
+
: httpStatus
|
|
99
|
+
? `HTTP_${httpStatus}`
|
|
100
|
+
: 'FETCH_ERROR';
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
export function getErrorMessage(error) {
|
|
105
104
|
if (isError(error))
|
|
106
105
|
return error.message;
|
|
107
|
-
if (
|
|
106
|
+
if (typeof error === 'string' && error.length > 0)
|
|
108
107
|
return error;
|
|
109
|
-
if (
|
|
108
|
+
if (isObject(error) &&
|
|
109
|
+
typeof error.message === 'string' &&
|
|
110
|
+
error.message.length > 0) {
|
|
110
111
|
return error.message;
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
export function toError(error) {
|
|
114
|
-
return isError(error) ? error : new Error(getErrorMessage(error));
|
|
115
|
-
}
|
|
116
|
-
export function isAbortError(error) {
|
|
117
|
-
return isError(error) && error.name === 'AbortError';
|
|
118
|
-
}
|
|
119
|
-
function isNonEmptyString(value) {
|
|
120
|
-
return typeof value === 'string' && value.length > 0;
|
|
121
|
-
}
|
|
122
|
-
function isErrorWithMessage(error) {
|
|
123
|
-
if (!isObject(error))
|
|
124
|
-
return false;
|
|
125
|
-
const { message } = error;
|
|
126
|
-
return typeof message === 'string' && message.length > 0;
|
|
127
|
-
}
|
|
128
|
-
function formatUnknownError(error) {
|
|
112
|
+
}
|
|
129
113
|
if (error === null || error === undefined)
|
|
130
114
|
return UNKNOWN_ERROR_MESSAGE;
|
|
131
115
|
try {
|
|
@@ -141,6 +125,12 @@ function formatUnknownError(error) {
|
|
|
141
125
|
return UNKNOWN_ERROR_MESSAGE;
|
|
142
126
|
}
|
|
143
127
|
}
|
|
128
|
+
export function toError(error) {
|
|
129
|
+
return isError(error) ? error : new Error(getErrorMessage(error));
|
|
130
|
+
}
|
|
131
|
+
export function isAbortError(error) {
|
|
132
|
+
return isError(error) && error.name === 'AbortError';
|
|
133
|
+
}
|
|
144
134
|
export function createErrorWithCode(message, code, options) {
|
|
145
135
|
const error = new Error(message, options);
|
|
146
136
|
return Object.assign(error, { code });
|
|
@@ -153,74 +143,50 @@ export function isSystemError(error) {
|
|
|
153
143
|
const { code } = error;
|
|
154
144
|
return typeof code === 'string';
|
|
155
145
|
}
|
|
156
|
-
export const RESOURCE_NOT_FOUND_ERROR_CODE = -32002;
|
|
157
146
|
const MAX_DEPTH = 20;
|
|
158
|
-
const MAX_DEPTH_ERROR = `stableStringify: Max depth (${MAX_DEPTH}) exceeded`;
|
|
159
147
|
const CIRCULAR_ERROR = 'stableStringify: Circular reference detected';
|
|
160
|
-
function
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
function processValue(obj, depth, seen) {
|
|
169
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
170
|
-
return obj;
|
|
171
|
-
}
|
|
172
|
-
// Depth guard
|
|
173
|
-
if (depth > MAX_DEPTH) {
|
|
174
|
-
throw new Error(MAX_DEPTH_ERROR);
|
|
175
|
-
}
|
|
176
|
-
// Cycle detection (track active recursion stack only).
|
|
177
|
-
if (seen.has(obj)) {
|
|
178
|
-
throw new Error(CIRCULAR_ERROR);
|
|
179
|
-
}
|
|
180
|
-
seen.add(obj);
|
|
181
|
-
try {
|
|
182
|
-
if (Array.isArray(obj)) {
|
|
183
|
-
return obj.map((item) => processValue(item, depth + 1, seen));
|
|
148
|
+
export function stableStringify(obj) {
|
|
149
|
+
const seen = new WeakSet();
|
|
150
|
+
const process = (value, depth) => {
|
|
151
|
+
if (typeof value !== 'object' || value === null)
|
|
152
|
+
return value;
|
|
153
|
+
if (depth > MAX_DEPTH) {
|
|
154
|
+
throw new Error(`stableStringify: Max depth (${MAX_DEPTH}) exceeded`);
|
|
184
155
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const sortedObj = {};
|
|
188
|
-
for (const key of keys) {
|
|
189
|
-
sortedObj[key] = processValue(record[key], depth + 1, seen);
|
|
156
|
+
if (seen.has(value)) {
|
|
157
|
+
throw new Error(CIRCULAR_ERROR);
|
|
190
158
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
159
|
+
seen.add(value);
|
|
160
|
+
try {
|
|
161
|
+
if (Array.isArray(value)) {
|
|
162
|
+
return value.map((item) => process(item, depth + 1));
|
|
163
|
+
}
|
|
164
|
+
const record = value;
|
|
165
|
+
const sorted = {};
|
|
166
|
+
for (const key of Object.keys(record).sort()) {
|
|
167
|
+
sorted[key] = process(record[key], depth + 1);
|
|
168
|
+
}
|
|
169
|
+
return sorted;
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
seen.delete(value);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
return JSON.stringify(process(obj, 0));
|
|
200
176
|
}
|
|
201
177
|
const DROP_LOG_INTERVAL_MS = 10_000;
|
|
202
|
-
function setIfDefined(value, setter) {
|
|
203
|
-
if (value === undefined)
|
|
204
|
-
return;
|
|
205
|
-
setter(value);
|
|
206
|
-
}
|
|
207
|
-
function assignServerValue(server, key, value) {
|
|
208
|
-
setIfDefined(value, (resolved) => {
|
|
209
|
-
server[key] = resolved;
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
178
|
export function applyHttpServerTuning(server) {
|
|
213
179
|
const { headersTimeoutMs, requestTimeoutMs, keepAliveTimeoutMs, keepAliveTimeoutBufferMs, maxHeadersCount, maxConnections, } = config.server.http;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
180
|
+
if (headersTimeoutMs !== undefined)
|
|
181
|
+
server.headersTimeout = headersTimeoutMs;
|
|
182
|
+
if (requestTimeoutMs !== undefined)
|
|
183
|
+
server.requestTimeout = requestTimeoutMs;
|
|
184
|
+
if (keepAliveTimeoutMs !== undefined)
|
|
185
|
+
server.keepAliveTimeout = keepAliveTimeoutMs;
|
|
186
|
+
if (keepAliveTimeoutBufferMs !== undefined)
|
|
187
|
+
server.keepAliveTimeoutBuffer = keepAliveTimeoutBufferMs;
|
|
188
|
+
if (maxHeadersCount !== undefined)
|
|
189
|
+
server.maxHeadersCount = maxHeadersCount;
|
|
224
190
|
if (typeof maxConnections === 'number' && maxConnections > 0) {
|
|
225
191
|
server.maxConnections = maxConnections;
|
|
226
192
|
if (typeof server.on === 'function') {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/lib/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAyBxB,wBAAgB,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,QAAQ,GAAG,MAAM,CAWxD"}
|
package/dist/lib/zod.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
function formatPathSegment(segment) {
|
|
3
|
+
if (typeof segment === 'number')
|
|
4
|
+
return `[${segment}]`;
|
|
5
|
+
if (typeof segment === 'string')
|
|
6
|
+
return segment;
|
|
7
|
+
return segment.description ?? '<symbol>';
|
|
8
|
+
}
|
|
9
|
+
function formatIssuePath(path) {
|
|
10
|
+
if (path.length === 0)
|
|
11
|
+
return '';
|
|
12
|
+
let result = '';
|
|
13
|
+
for (const segment of path) {
|
|
14
|
+
if (typeof segment === 'number') {
|
|
15
|
+
result += formatPathSegment(segment);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
const normalized = formatPathSegment(segment);
|
|
19
|
+
result += result ? `.${normalized}` : normalized;
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
export function formatZodError(error) {
|
|
24
|
+
const parts = error.issues.map((issue) => {
|
|
25
|
+
const path = formatIssuePath(issue.path);
|
|
26
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
27
|
+
});
|
|
28
|
+
const unique = [...new Set(parts.filter((value) => value.trim().length > 0))];
|
|
29
|
+
if (unique.length > 0)
|
|
30
|
+
return unique.join('; ');
|
|
31
|
+
const pretty = z.prettifyError(error).replace(/\s+/g, ' ').trim();
|
|
32
|
+
return pretty || 'Invalid input';
|
|
33
|
+
}
|
package/dist/prompts/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type IconInfo } from '../lib/types.js';
|
|
3
3
|
export declare function registerGetHelpPrompt(server: McpServer, instructions: string, iconInfo?: IconInfo): void;
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEpE,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,CAAC,EAAE,QAAQ,GAClB,IAAI,CAwBN"}
|
package/dist/prompts/index.js
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
return iconInfo
|
|
3
|
-
? {
|
|
4
|
-
icons: [
|
|
5
|
-
{
|
|
6
|
-
src: iconInfo.src,
|
|
7
|
-
mimeType: iconInfo.mimeType,
|
|
8
|
-
},
|
|
9
|
-
],
|
|
10
|
-
}
|
|
11
|
-
: {};
|
|
12
|
-
}
|
|
1
|
+
import { buildOptionalIcons } from '../lib/types.js';
|
|
13
2
|
export function registerGetHelpPrompt(server, instructions, iconInfo) {
|
|
14
3
|
const description = 'Return Fetch URL server instructions: workflows, cache usage, task mode, and error handling.';
|
|
15
4
|
server.registerPrompt('get-help', {
|
|
16
5
|
title: 'Get Help',
|
|
17
6
|
description,
|
|
18
|
-
...
|
|
7
|
+
...buildOptionalIcons(iconInfo),
|
|
19
8
|
}, () => ({
|
|
20
9
|
description,
|
|
21
10
|
messages: [
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type IconInfo } from '../lib/types.js';
|
|
3
3
|
export declare function registerInstructionResource(server: McpServer, instructions: string, iconInfo?: IconInfo): void;
|
|
4
4
|
export declare function registerCacheResourceTemplate(server: McpServer, iconInfo?: IconInfo): void;
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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;AAoBjD,OAAO,EAAsB,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAgXpE,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
|
@@ -3,8 +3,9 @@ import { ErrorCode, McpError, SubscribeRequestSchema, UnsubscribeRequestSchema,
|
|
|
3
3
|
import { get as getCacheEntry, getEntryMeta, keys as listCacheKeys, onCacheUpdate, parseCachedPayload, parseCacheKey, resolveCachedPayloadContent, } from '../lib/core.js';
|
|
4
4
|
import { logWarn } from '../lib/core.js';
|
|
5
5
|
import { registerServerLifecycleCleanup } from '../lib/mcp-tools.js';
|
|
6
|
-
import {
|
|
6
|
+
import { buildOptionalIcons } from '../lib/types.js';
|
|
7
7
|
import { isObject } from '../lib/utils.js';
|
|
8
|
+
const RESOURCE_NOT_FOUND_ERROR_CODE = -32002;
|
|
8
9
|
const CACHE_RESOURCE_TEMPLATE_URI = 'internal://cache/{namespace}/{hash}';
|
|
9
10
|
const CACHE_RESOURCE_PREFIX = 'internal://cache/';
|
|
10
11
|
const CACHE_NAMESPACE_PATTERN = /^[a-z0-9_-]{1,64}$/i;
|
|
@@ -18,18 +19,6 @@ function sortAndLimitValues(values) {
|
|
|
18
19
|
.sort((left, right) => left.localeCompare(right))
|
|
19
20
|
.slice(0, MAX_COMPLETION_VALUES);
|
|
20
21
|
}
|
|
21
|
-
function buildOptionalIcons(iconInfo) {
|
|
22
|
-
if (!iconInfo)
|
|
23
|
-
return {};
|
|
24
|
-
return {
|
|
25
|
-
icons: [
|
|
26
|
-
{
|
|
27
|
-
src: iconInfo.src,
|
|
28
|
-
mimeType: iconInfo.mimeType,
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
22
|
function isValidCacheResourceParts(parts) {
|
|
34
23
|
return (CACHE_NAMESPACE_PATTERN.test(parts.namespace) &&
|
|
35
24
|
CACHE_HASH_PATTERN.test(parts.hash));
|
|
@@ -194,14 +183,11 @@ function normalizeSubscriptionUri(uri) {
|
|
|
194
183
|
return toCacheResourceUri(cacheParts);
|
|
195
184
|
return parsedUri.href;
|
|
196
185
|
}
|
|
197
|
-
|
|
198
|
-
// redundant Subscribe/Unsubscribe handlers and create a second onCacheUpdate
|
|
199
|
-
// listener, causing duplicate notifications.
|
|
200
|
-
let cacheNotificationsRegistered = false;
|
|
186
|
+
const cacheNotificationServers = new WeakSet();
|
|
201
187
|
function registerCacheResourceNotifications(server) {
|
|
202
|
-
if (
|
|
188
|
+
if (cacheNotificationServers.has(server))
|
|
203
189
|
return;
|
|
204
|
-
|
|
190
|
+
cacheNotificationServers.add(server);
|
|
205
191
|
const subscribedResourceUris = new Set();
|
|
206
192
|
const setSubscription = (uri, subscribed) => {
|
|
207
193
|
const normalized = normalizeSubscriptionUri(uri);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../../src/resources/instructions.ts"],"names":[],"mappings":"AAIA,wBAAgB,uBAAuB,IAAI,MAAM,CA2ChD"}
|
|
@@ -10,7 +10,9 @@ export function buildServerInstructions() {
|
|
|
10
10
|
<capabilities>
|
|
11
11
|
- Tools: \`${FETCH_URL_TOOL_NAME}\` (READ-ONLY).
|
|
12
12
|
- Resources: \`internal://instructions\` (server usage guidance).
|
|
13
|
+
- Resource templates: \`internal://cache/{namespace}/{hash}\` (cached markdown entries).
|
|
13
14
|
- Prompts: \`get-help\` (returns these instructions).
|
|
15
|
+
- Completions: resource-template argument completion for cache entries.
|
|
14
16
|
</capabilities>
|
|
15
17
|
|
|
16
18
|
<workflows>
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
CHANGED
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const fetchUrlOutputSchema: z.ZodObject<{
|
|
3
|
-
url: z.
|
|
4
|
-
inputUrl: z.ZodOptional<z.
|
|
5
|
-
resolvedUrl: z.ZodOptional<z.
|
|
6
|
-
finalUrl: z.ZodOptional<z.
|
|
3
|
+
url: z.ZodURL;
|
|
4
|
+
inputUrl: z.ZodOptional<z.ZodURL>;
|
|
5
|
+
resolvedUrl: z.ZodOptional<z.ZodURL>;
|
|
6
|
+
finalUrl: z.ZodOptional<z.ZodURL>;
|
|
7
7
|
title: z.ZodOptional<z.ZodString>;
|
|
8
8
|
metadata: z.ZodOptional<z.ZodObject<{
|
|
9
9
|
title: z.ZodOptional<z.ZodString>;
|
|
@@ -16,7 +16,8 @@ export declare const fetchUrlOutputSchema: z.ZodObject<{
|
|
|
16
16
|
}, z.core.$strict>>;
|
|
17
17
|
markdown: z.ZodOptional<z.ZodString>;
|
|
18
18
|
fromCache: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
-
fetchedAt: z.ZodOptional<z.
|
|
19
|
+
fetchedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
20
20
|
contentSize: z.ZodOptional<z.ZodNumber>;
|
|
21
21
|
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
22
22
|
}, z.core.$strict>;
|
|
23
|
+
//# sourceMappingURL=outputs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { config } from '../lib/core.js';
|
|
3
3
|
export const fetchUrlOutputSchema = z.strictObject({
|
|
4
|
-
url: z
|
|
5
|
-
.string()
|
|
6
|
-
.min(1)
|
|
7
|
-
.max(config.constants.maxUrlLength)
|
|
8
|
-
.describe('Fetched URL.'),
|
|
4
|
+
url: z.httpUrl().max(config.constants.maxUrlLength).describe('Fetched URL.'),
|
|
9
5
|
inputUrl: z
|
|
10
|
-
.
|
|
6
|
+
.httpUrl()
|
|
11
7
|
.max(config.constants.maxUrlLength)
|
|
12
8
|
.optional()
|
|
13
9
|
.describe('Original requested URL.'),
|
|
14
10
|
resolvedUrl: z
|
|
15
|
-
.
|
|
11
|
+
.httpUrl()
|
|
16
12
|
.max(config.constants.maxUrlLength)
|
|
17
13
|
.optional()
|
|
18
14
|
.describe('Final URL after raw-content transformations.'),
|
|
19
15
|
finalUrl: z
|
|
20
|
-
.
|
|
16
|
+
.httpUrl()
|
|
21
17
|
.max(config.constants.maxUrlLength)
|
|
22
18
|
.optional()
|
|
23
19
|
.describe('Final URL after HTTP redirects.'),
|
|
@@ -60,7 +56,7 @@ export const fetchUrlOutputSchema = z.strictObject({
|
|
|
60
56
|
.optional()
|
|
61
57
|
.describe('Extracted Markdown. May be truncated (check truncated field).'),
|
|
62
58
|
fromCache: z.boolean().optional().describe('True if served from cache.'),
|
|
63
|
-
fetchedAt: z.
|
|
59
|
+
fetchedAt: z.iso.datetime().optional().describe('ISO timestamp of fetch.'),
|
|
64
60
|
contentSize: z
|
|
65
61
|
.number()
|
|
66
62
|
.int()
|
package/dist/server.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
2
2
|
export declare function createMcpServer(): Promise<McpServer>;
|
|
3
3
|
export declare function createMcpServerForHttpSession(): Promise<McpServer>;
|
|
4
4
|
export declare function startStdioServer(): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAkGpE,wBAAsB,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAE1D;AA8CD,wBAAsB,6BAA6B,IAAI,OAAO,CAAC,SAAS,CAAC,CAExE;AAkFD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAMtD"}
|
package/dist/server.js
CHANGED
|
@@ -4,11 +4,11 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
4
4
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
5
|
import { SetLevelRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import { config } from './lib/core.js';
|
|
7
|
-
import { logError, logInfo, setLogLevel, setMcpServer } from './lib/core.js';
|
|
7
|
+
import { getSessionId, logError, logInfo, setLogLevel, setMcpServer, } from './lib/core.js';
|
|
8
8
|
import { abortAllTaskExecutions, registerTaskHandlers, } from './lib/mcp-tools.js';
|
|
9
9
|
import { toError } from './lib/utils.js';
|
|
10
10
|
import { registerGetHelpPrompt } from './prompts/index.js';
|
|
11
|
-
import { registerInstructionResource } from './resources/index.js';
|
|
11
|
+
import { registerCacheResourceTemplate, registerInstructionResource, } from './resources/index.js';
|
|
12
12
|
import { buildServerInstructions } from './resources/instructions.js';
|
|
13
13
|
import { registerAllTools } from './tools/index.js';
|
|
14
14
|
import { shutdownTransformWorkerPool } from './transform/transform.js';
|
|
@@ -33,8 +33,10 @@ async function getLocalIconInfo() {
|
|
|
33
33
|
const serverInstructions = buildServerInstructions();
|
|
34
34
|
function createServerCapabilities() {
|
|
35
35
|
return {
|
|
36
|
+
completions: {},
|
|
36
37
|
logging: {},
|
|
37
38
|
resources: { subscribe: true, listChanged: true },
|
|
39
|
+
// SDK auto-adds listChanged to tools capability at runtime.
|
|
38
40
|
tools: {},
|
|
39
41
|
prompts: {},
|
|
40
42
|
tasks: {
|
|
@@ -84,10 +86,10 @@ async function createMcpServerWithOptions(options) {
|
|
|
84
86
|
registerAllTools(server);
|
|
85
87
|
registerGetHelpPrompt(server, serverInstructions, localIcon);
|
|
86
88
|
registerInstructionResource(server, serverInstructions, localIcon);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
registerCacheResourceTemplate(server, localIcon);
|
|
90
|
+
registerTaskHandlers(server, {
|
|
91
|
+
requireInterception: config.tasks.requireInterception,
|
|
92
|
+
});
|
|
91
93
|
registerLoggingSetLevelHandler(server);
|
|
92
94
|
attachServerErrorHandler(server);
|
|
93
95
|
return server;
|
|
@@ -97,7 +99,7 @@ export async function createMcpServerForHttpSession() {
|
|
|
97
99
|
}
|
|
98
100
|
function registerLoggingSetLevelHandler(server) {
|
|
99
101
|
server.server.setRequestHandler(SetLevelRequestSchema, (request) => {
|
|
100
|
-
setLogLevel(request.params.level);
|
|
102
|
+
setLogLevel(request.params.level, getSessionId());
|
|
101
103
|
return {};
|
|
102
104
|
});
|
|
103
105
|
}
|
|
@@ -39,3 +39,4 @@ export declare function emitTaskStatusNotification(server: McpServer, task: Task
|
|
|
39
39
|
export declare function throwTaskNotFound(): never;
|
|
40
40
|
export declare function handleToolCallRequest(server: McpServer, request: ExtendedCallToolRequest, context: ToolCallContext): Promise<ServerResult>;
|
|
41
41
|
export {};
|
|
42
|
+
//# sourceMappingURL=execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution.d.ts","sourceRoot":"","sources":["../../src/tasks/execution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,oCAAoC,CAAC;AAW5C,OAAO,EACL,KAAK,gBAAgB,EAErB,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,YAAY,CAAC;AAapB,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;QAChD,IAAI,CAAC,EACD;YACE,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;SAC1B,GACD,SAAS,CAAC;QACd,KAAK,CAAC,EACF;YACE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;YAC5C,sCAAsC,CAAC,EACnC;gBAAE,MAAM,EAAE,MAAM,CAAA;aAAE,GAClB,SAAS,CAAC;YACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;SACxB,GACD,SAAS,CAAC;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAyBD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAKvD;AAMD,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,aAAa,SAA4D,GACxE,MAAM,CASR;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AAgBD,KAAK,WAAW,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAE5C,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,WAAW,CAUd;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,GACb,YAAY,CAYd;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,GACd,IAAI,CAmBN;AAoBD,wBAAgB,iBAAiB,IAAI,KAAK,CAEzC;AAiND,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC,CAYvB"}
|
package/dist/tasks/execution.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ErrorCode, McpError, } from '@modelcontextprotocol/sdk/types.js';
|
|
2
2
|
import { config } from '../lib/core.js';
|
|
3
3
|
import { logWarn, runWithRequestContext } from '../lib/core.js';
|
|
4
|
-
import { getErrorMessage
|
|
4
|
+
import { getErrorMessage } from '../lib/utils.js';
|
|
5
5
|
import { isObject } from '../lib/utils.js';
|
|
6
6
|
import { taskManager, } from './manager.js';
|
|
7
7
|
import { compact, tryReadToolStructuredError, } from './owner.js';
|
|
8
8
|
import { getTaskCapableTool, hasTaskCapableTool, } from './tool-registry.js';
|
|
9
|
-
const TASK_NOT_FOUND_ERROR_CODE =
|
|
9
|
+
const TASK_NOT_FOUND_ERROR_CODE = ErrorCode.InvalidParams;
|
|
10
10
|
/* -------------------------------------------------------------------------------------------------
|
|
11
11
|
* Abort-controller management for in-flight task executions
|
|
12
12
|
* ------------------------------------------------------------------------------------------------- */
|
|
@@ -59,11 +59,6 @@ export function toTaskSummary(task) {
|
|
|
59
59
|
lastUpdatedAt: task.lastUpdatedAt,
|
|
60
60
|
ttl: task.ttl,
|
|
61
61
|
pollInterval: task.pollInterval,
|
|
62
|
-
_meta: {
|
|
63
|
-
'io.modelcontextprotocol/related-task': {
|
|
64
|
-
taskId: task.taskId,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
62
|
};
|
|
68
63
|
}
|
|
69
64
|
export function withRelatedTaskMeta(result, taskId) {
|
|
@@ -139,20 +134,7 @@ function buildRelatedTaskMeta(taskId, meta) {
|
|
|
139
134
|
};
|
|
140
135
|
}
|
|
141
136
|
function buildCreateTaskResult(task) {
|
|
142
|
-
return {
|
|
143
|
-
task,
|
|
144
|
-
_meta: {
|
|
145
|
-
'io.modelcontextprotocol/related-task': {
|
|
146
|
-
taskId: task.taskId,
|
|
147
|
-
status: task.status,
|
|
148
|
-
...(task.statusMessage ? { statusMessage: task.statusMessage } : {}),
|
|
149
|
-
createdAt: task.createdAt,
|
|
150
|
-
lastUpdatedAt: task.lastUpdatedAt,
|
|
151
|
-
ttl: task.ttl,
|
|
152
|
-
pollInterval: task.pollInterval,
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
};
|
|
137
|
+
return { task };
|
|
156
138
|
}
|
|
157
139
|
/* -------------------------------------------------------------------------------------------------
|
|
158
140
|
* Execution pipeline
|
package/dist/tasks/manager.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ interface CreateTaskOptions {
|
|
|
20
20
|
ttl?: number;
|
|
21
21
|
}
|
|
22
22
|
export interface CreateTaskResult {
|
|
23
|
+
[key: string]: unknown;
|
|
23
24
|
task: {
|
|
24
25
|
taskId: string;
|
|
25
26
|
status: TaskStatus;
|
|
@@ -28,13 +29,7 @@ export interface CreateTaskResult {
|
|
|
28
29
|
lastUpdatedAt: string;
|
|
29
30
|
ttl: number;
|
|
30
31
|
pollInterval: number;
|
|
31
|
-
_meta?: {
|
|
32
|
-
'io.modelcontextprotocol/related-task': {
|
|
33
|
-
taskId: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
32
|
};
|
|
37
|
-
_meta?: Record<string, unknown>;
|
|
38
33
|
}
|
|
39
34
|
declare class TaskManager {
|
|
40
35
|
private tasks;
|
|
@@ -81,3 +76,4 @@ declare class TaskManager {
|
|
|
81
76
|
}
|
|
82
77
|
export declare const taskManager: TaskManager;
|
|
83
78
|
export {};
|
|
79
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/tasks/manager.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,gBAAgB,GAChB,WAAW,GACX,QAAQ,GACR,WAAW,CAAC;AAEhB,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAOD,UAAU,iB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