@cyanheads/mcp-ts-core 0.11.1 → 0.11.3
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/AGENTS.md +14 -10
- package/CLAUDE.md +14 -10
- package/README.md +3 -3
- package/biome.json +1 -1
- package/changelog/0.11.x/0.11.2.md +98 -0
- package/changelog/0.11.x/0.11.3.md +49 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +3 -13
- package/dist/config/index.js.map +1 -1
- package/dist/config/logLevelAlias.d.ts +15 -0
- package/dist/config/logLevelAlias.d.ts.map +1 -0
- package/dist/config/logLevelAlias.js +30 -0
- package/dist/config/logLevelAlias.js.map +1 -0
- package/dist/core/app.d.ts +37 -14
- package/dist/core/app.d.ts.map +1 -1
- package/dist/core/app.js +56 -23
- package/dist/core/app.js.map +1 -1
- package/dist/core/context.d.ts +10 -0
- package/dist/core/context.d.ts.map +1 -1
- package/dist/core/context.js +10 -1
- package/dist/core/context.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/worker.d.ts.map +1 -1
- package/dist/core/worker.js +35 -18
- package/dist/core/worker.js.map +1 -1
- package/dist/logs/combined.log +16 -8
- package/dist/logs/error.log +12 -4
- package/dist/mcp-server/elicitation.d.ts +64 -0
- package/dist/mcp-server/elicitation.d.ts.map +1 -0
- package/dist/mcp-server/elicitation.js +81 -0
- package/dist/mcp-server/elicitation.js.map +1 -0
- package/dist/mcp-server/protocolSession.d.ts +34 -0
- package/dist/mcp-server/protocolSession.d.ts.map +1 -0
- package/dist/mcp-server/protocolSession.js +13 -0
- package/dist/mcp-server/protocolSession.js.map +1 -0
- package/dist/mcp-server/resources/resource-registration.d.ts +2 -1
- package/dist/mcp-server/resources/resource-registration.d.ts.map +1 -1
- package/dist/mcp-server/resources/resource-registration.js +6 -2
- package/dist/mcp-server/resources/resource-registration.js.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts +7 -12
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js +24 -31
- package/dist/mcp-server/resources/utils/resourceHandlerFactory.js.map +1 -1
- package/dist/mcp-server/server.d.ts +3 -0
- package/dist/mcp-server/server.d.ts.map +1 -1
- package/dist/mcp-server/server.js +12 -2
- package/dist/mcp-server/server.js.map +1 -1
- package/dist/mcp-server/tools/tool-registration.d.ts +2 -1
- package/dist/mcp-server/tools/tool-registration.d.ts.map +1 -1
- package/dist/mcp-server/tools/tool-registration.js +6 -2
- package/dist/mcp-server/tools/tool-registration.js.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts +7 -13
- package/dist/mcp-server/tools/utils/toolHandlerFactory.d.ts.map +1 -1
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js +11 -44
- package/dist/mcp-server/tools/utils/toolHandlerFactory.js.map +1 -1
- package/dist/mcp-server/transports/http/httpErrorHandler.js +1 -1
- package/dist/mcp-server/transports/http/httpErrorHandler.js.map +1 -1
- package/dist/mcp-server/transports/http/httpServer.d.ts +2 -2
- package/dist/mcp-server/transports/http/httpServer.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/httpServer.js.map +1 -1
- package/dist/mcp-server/transports/http/httpTransport.d.ts +2 -2
- package/dist/mcp-server/transports/http/httpTransport.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/httpTransport.js +113 -55
- package/dist/mcp-server/transports/http/httpTransport.js.map +1 -1
- package/dist/mcp-server/transports/http/sessionStore.d.ts +17 -0
- package/dist/mcp-server/transports/http/sessionStore.d.ts.map +1 -1
- package/dist/mcp-server/transports/http/sessionStore.js +71 -0
- package/dist/mcp-server/transports/http/sessionStore.js.map +1 -1
- package/dist/mcp-server/transports/manager.d.ts +2 -6
- package/dist/mcp-server/transports/manager.d.ts.map +1 -1
- package/dist/mcp-server/transports/manager.js +4 -0
- package/dist/mcp-server/transports/manager.js.map +1 -1
- package/dist/services/canvas/core/CanvasRegistry.d.ts +2 -2
- package/dist/services/canvas/core/CanvasRegistry.d.ts.map +1 -1
- package/dist/services/canvas/core/CanvasRegistry.js +14 -3
- package/dist/services/canvas/core/CanvasRegistry.js.map +1 -1
- package/dist/services/canvas/core/DataCanvas.d.ts +1 -1
- package/dist/services/canvas/core/DataCanvas.d.ts.map +1 -1
- package/dist/services/canvas/core/DataCanvas.js +2 -2
- package/dist/services/canvas/core/DataCanvas.js.map +1 -1
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.d.ts.map +1 -1
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.js +11 -3
- package/dist/services/canvas/providers/duckdb/DuckdbProvider.js.map +1 -1
- package/dist/services/canvas/providers/duckdb/exportWriter.d.ts.map +1 -1
- package/dist/services/canvas/providers/duckdb/exportWriter.js +23 -2
- package/dist/services/canvas/providers/duckdb/exportWriter.js.map +1 -1
- package/dist/services/mirror/core/defineMirror.d.ts.map +1 -1
- package/dist/services/mirror/core/defineMirror.js +18 -7
- package/dist/services/mirror/core/defineMirror.js.map +1 -1
- package/dist/services/mirror/core/runner.d.ts.map +1 -1
- package/dist/services/mirror/core/runner.js +3 -0
- package/dist/services/mirror/core/runner.js.map +1 -1
- package/dist/services/mirror/index.d.ts +1 -1
- package/dist/services/mirror/index.d.ts.map +1 -1
- package/dist/services/mirror/index.js.map +1 -1
- package/dist/services/mirror/sqlite/sqliteMirrorStore.d.ts +20 -0
- package/dist/services/mirror/sqlite/sqliteMirrorStore.d.ts.map +1 -1
- package/dist/services/mirror/sqlite/sqliteMirrorStore.js +92 -8
- package/dist/services/mirror/sqlite/sqliteMirrorStore.js.map +1 -1
- package/dist/storage/core/StorageService.d.ts.map +1 -1
- package/dist/storage/core/StorageService.js +4 -1
- package/dist/storage/core/StorageService.js.map +1 -1
- package/dist/storage/core/storageValidation.d.ts +8 -0
- package/dist/storage/core/storageValidation.d.ts.map +1 -1
- package/dist/storage/core/storageValidation.js +22 -0
- package/dist/storage/core/storageValidation.js.map +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.d.ts +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.d.ts.map +1 -1
- package/dist/storage/providers/inMemory/inMemoryProvider.js +67 -25
- package/dist/storage/providers/inMemory/inMemoryProvider.js.map +1 -1
- package/dist/testing/fuzz.d.ts.map +1 -1
- package/dist/testing/fuzz.js +33 -14
- package/dist/testing/fuzz.js.map +1 -1
- package/dist/testing/index.d.ts +45 -13
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +29 -76
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/vitest.d.ts +12 -3
- package/dist/testing/vitest.d.ts.map +1 -1
- package/dist/testing/vitest.js +3 -0
- package/dist/testing/vitest.js.map +1 -1
- package/dist/utils/formatting/diffFormatter.d.ts +5 -5
- package/dist/utils/formatting/diffFormatter.d.ts.map +1 -1
- package/dist/utils/formatting/diffFormatter.js +1 -1
- package/dist/utils/formatting/diffFormatter.js.map +1 -1
- package/dist/utils/formatting/tableFormatter.d.ts +3 -3
- package/dist/utils/formatting/tableFormatter.d.ts.map +1 -1
- package/dist/utils/formatting/tableFormatter.js +1 -1
- package/dist/utils/formatting/tableFormatter.js.map +1 -1
- package/dist/utils/formatting/treeFormatter.d.ts +3 -3
- package/dist/utils/formatting/treeFormatter.d.ts.map +1 -1
- package/dist/utils/formatting/treeFormatter.js +1 -1
- package/dist/utils/formatting/treeFormatter.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/metrics/tokenCounter.d.ts +3 -3
- package/dist/utils/metrics/tokenCounter.d.ts.map +1 -1
- package/dist/utils/metrics/tokenCounter.js.map +1 -1
- package/dist/utils/network/fetchWithTimeout.d.ts +50 -21
- package/dist/utils/network/fetchWithTimeout.d.ts.map +1 -1
- package/dist/utils/network/fetchWithTimeout.js +299 -90
- package/dist/utils/network/fetchWithTimeout.js.map +1 -1
- package/dist/utils/network/httpError.d.ts.map +1 -1
- package/dist/utils/network/httpError.js +2 -2
- package/dist/utils/network/httpError.js.map +1 -1
- package/dist/utils/network/responseBody.d.ts +35 -0
- package/dist/utils/network/responseBody.d.ts.map +1 -0
- package/dist/utils/network/responseBody.js +104 -0
- package/dist/utils/network/responseBody.js.map +1 -0
- package/dist/utils/network/retry.d.ts +2 -2
- package/dist/utils/network/retry.d.ts.map +1 -1
- package/dist/utils/pagination/pagination.d.ts +3 -3
- package/dist/utils/pagination/pagination.d.ts.map +1 -1
- package/dist/utils/pagination/pagination.js.map +1 -1
- package/dist/utils/parsing/csvParser.d.ts +2 -2
- package/dist/utils/parsing/csvParser.d.ts.map +1 -1
- package/dist/utils/parsing/csvParser.js +1 -1
- package/dist/utils/parsing/csvParser.js.map +1 -1
- package/dist/utils/parsing/dateParser.d.ts +11 -7
- package/dist/utils/parsing/dateParser.d.ts.map +1 -1
- package/dist/utils/parsing/dateParser.js +8 -4
- package/dist/utils/parsing/dateParser.js.map +1 -1
- package/dist/utils/parsing/frontmatterParser.d.ts +6 -3
- package/dist/utils/parsing/frontmatterParser.d.ts.map +1 -1
- package/dist/utils/parsing/frontmatterParser.js +9 -9
- package/dist/utils/parsing/frontmatterParser.js.map +1 -1
- package/dist/utils/parsing/htmlExtractor.d.ts +8 -3
- package/dist/utils/parsing/htmlExtractor.d.ts.map +1 -1
- package/dist/utils/parsing/htmlExtractor.js +7 -7
- package/dist/utils/parsing/htmlExtractor.js.map +1 -1
- package/dist/utils/parsing/index.d.ts +1 -0
- package/dist/utils/parsing/index.d.ts.map +1 -1
- package/dist/utils/parsing/index.js +1 -0
- package/dist/utils/parsing/index.js.map +1 -1
- package/dist/utils/parsing/inputBudget.d.ts +35 -0
- package/dist/utils/parsing/inputBudget.d.ts.map +1 -0
- package/dist/utils/parsing/inputBudget.js +79 -0
- package/dist/utils/parsing/inputBudget.js.map +1 -0
- package/dist/utils/parsing/jsonParser.d.ts +6 -3
- package/dist/utils/parsing/jsonParser.d.ts.map +1 -1
- package/dist/utils/parsing/jsonParser.js +8 -8
- package/dist/utils/parsing/jsonParser.js.map +1 -1
- package/dist/utils/parsing/pdfParser.d.ts +41 -19
- package/dist/utils/parsing/pdfParser.d.ts.map +1 -1
- package/dist/utils/parsing/pdfParser.js +86 -60
- package/dist/utils/parsing/pdfParser.js.map +1 -1
- package/dist/utils/parsing/xmlParser.d.ts +4 -2
- package/dist/utils/parsing/xmlParser.d.ts.map +1 -1
- package/dist/utils/parsing/xmlParser.js +6 -7
- package/dist/utils/parsing/xmlParser.js.map +1 -1
- package/dist/utils/parsing/yamlParser.d.ts +4 -2
- package/dist/utils/parsing/yamlParser.d.ts.map +1 -1
- package/dist/utils/parsing/yamlParser.js +6 -7
- package/dist/utils/parsing/yamlParser.js.map +1 -1
- package/dist/utils/security/rateLimiter.d.ts +2 -2
- package/dist/utils/security/rateLimiter.d.ts.map +1 -1
- package/dist/utils/security/rateLimiter.js +1 -1
- package/dist/utils/security/rateLimiter.js.map +1 -1
- package/dist/utils/telemetry/trace.d.ts +3 -3
- package/dist/utils/telemetry/trace.d.ts.map +1 -1
- package/dist/utils/telemetry/trace.js.map +1 -1
- package/package.json +17 -15
- package/skills/add-test/SKILL.md +2 -2
- package/skills/api-auth/SKILL.md +5 -5
- package/skills/api-context/SKILL.md +13 -12
- package/skills/api-testing/SKILL.md +29 -10
- package/skills/api-utils/SKILL.md +4 -2
- package/skills/api-utils/references/parsing.md +3 -2
- package/skills/git-wrapup/SKILL.md +22 -1
- package/templates/AGENTS.md +1 -1
- package/templates/CLAUDE.md +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Bounded response-body reader for error diagnostics.
|
|
3
|
+
* @module src/utils/network/responseBody
|
|
4
|
+
*/
|
|
5
|
+
/** Options for {@link readBoundedResponseText}. */
|
|
6
|
+
export interface BoundedReadOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Hard ceiling on the bytes pulled off the wire. Defaults to `maxBytes`, which
|
|
9
|
+
* keeps the capture head-only: the reader stops as soon as the budget is
|
|
10
|
+
* exceeded and never sees the end of the document.
|
|
11
|
+
*
|
|
12
|
+
* Raising it above `maxBytes` lets the reader reach the end of a document it
|
|
13
|
+
* is not going to keep whole. A body that finishes within the ceiling is then
|
|
14
|
+
* captured as head + tail around an elision marker, so a diagnostic sitting
|
|
15
|
+
* behind a boilerplate preamble (doctype, stylesheet link, page header)
|
|
16
|
+
* survives the cap. A body still streaming at the ceiling falls back to
|
|
17
|
+
* head-only, because its real tail was never read.
|
|
18
|
+
*/
|
|
19
|
+
scanBytes?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Reads a response body under a byte budget and returns display-ready
|
|
23
|
+
* diagnostic text — elision markers included, so callers append nothing.
|
|
24
|
+
* At most `maxBytes` of body content is retained; the stream is cancelled once
|
|
25
|
+
* the scan ceiling is passed.
|
|
26
|
+
*
|
|
27
|
+
* This is intentionally destructive: callers use it only for responses that
|
|
28
|
+
* will be converted into an error.
|
|
29
|
+
*
|
|
30
|
+
* @param response - The response whose body is captured (consumed).
|
|
31
|
+
* @param maxBytes - Body bytes retained in the returned text.
|
|
32
|
+
* @param options - See {@link BoundedReadOptions.scanBytes} for head+tail capture.
|
|
33
|
+
*/
|
|
34
|
+
export declare function readBoundedResponseText(response: Response, maxBytes: number, options?: BoundedReadOptions): Promise<string>;
|
|
35
|
+
//# sourceMappingURL=responseBody.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseBody.d.ts","sourceRoot":"","sources":["../../../src/utils/network/responseBody.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,mDAAmD;AACnD,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAsCD;;;;;;;;;;;;GAYG;AACH,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,MAAM,CAAC,CAsDjB"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Bounded response-body reader for error diagnostics.
|
|
3
|
+
* @module src/utils/network/responseBody
|
|
4
|
+
*/
|
|
5
|
+
/** Share of the capture budget spent on the head of an over-budget body. */
|
|
6
|
+
const HEAD_SHARE = 0.4;
|
|
7
|
+
function decodeUtf8Prefix(bytes) {
|
|
8
|
+
// A byte cap can split the final UTF-8 code point. Trim at most the maximum
|
|
9
|
+
// UTF-8 continuation width so a valid body never grows a replacement marker
|
|
10
|
+
// beyond the requested diagnostic budget.
|
|
11
|
+
const minimum = Math.max(0, bytes.byteLength - 3);
|
|
12
|
+
for (let end = bytes.byteLength; end >= minimum; end -= 1) {
|
|
13
|
+
try {
|
|
14
|
+
return new TextDecoder('utf-8', { fatal: true, ignoreBOM: false }).decode(bytes.subarray(0, end));
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Try the preceding byte boundary.
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return new TextDecoder().decode(bytes);
|
|
21
|
+
}
|
|
22
|
+
/** Mirror of {@link decodeUtf8Prefix} for a slice taken from the end of a body. */
|
|
23
|
+
function decodeUtf8Suffix(bytes) {
|
|
24
|
+
const maximum = Math.min(3, bytes.byteLength);
|
|
25
|
+
for (let start = 0; start <= maximum; start += 1) {
|
|
26
|
+
try {
|
|
27
|
+
return new TextDecoder('utf-8', { fatal: true, ignoreBOM: false }).decode(bytes.subarray(start));
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Drop the leading continuation byte and try the next boundary.
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return new TextDecoder().decode(bytes);
|
|
34
|
+
}
|
|
35
|
+
function positiveOrZero(value) {
|
|
36
|
+
return value !== undefined && Number.isSafeInteger(value) && value > 0 ? value : 0;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reads a response body under a byte budget and returns display-ready
|
|
40
|
+
* diagnostic text — elision markers included, so callers append nothing.
|
|
41
|
+
* At most `maxBytes` of body content is retained; the stream is cancelled once
|
|
42
|
+
* the scan ceiling is passed.
|
|
43
|
+
*
|
|
44
|
+
* This is intentionally destructive: callers use it only for responses that
|
|
45
|
+
* will be converted into an error.
|
|
46
|
+
*
|
|
47
|
+
* @param response - The response whose body is captured (consumed).
|
|
48
|
+
* @param maxBytes - Body bytes retained in the returned text.
|
|
49
|
+
* @param options - See {@link BoundedReadOptions.scanBytes} for head+tail capture.
|
|
50
|
+
*/
|
|
51
|
+
export async function readBoundedResponseText(response, maxBytes, options = {}) {
|
|
52
|
+
const limit = positiveOrZero(maxBytes);
|
|
53
|
+
const scan = Math.max(limit, positiveOrZero(options.scanBytes));
|
|
54
|
+
if (!response.body) {
|
|
55
|
+
return await response.text();
|
|
56
|
+
}
|
|
57
|
+
const reader = response.body.getReader();
|
|
58
|
+
const chunks = [];
|
|
59
|
+
// Keep reading until the ceiling is exceeded, not merely reached, so a body of
|
|
60
|
+
// exactly `scan` bytes is known to be whole rather than assumed truncated.
|
|
61
|
+
let read = 0;
|
|
62
|
+
while (read <= scan) {
|
|
63
|
+
const { done, value } = await reader.read();
|
|
64
|
+
if (done)
|
|
65
|
+
break;
|
|
66
|
+
chunks.push(value);
|
|
67
|
+
read += value.byteLength;
|
|
68
|
+
}
|
|
69
|
+
const stillStreaming = read > scan;
|
|
70
|
+
if (stillStreaming) {
|
|
71
|
+
try {
|
|
72
|
+
await reader.cancel('Response body diagnostic limit reached');
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// The bounded capture remains valid if the producer rejects cancellation.
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const captured = Math.min(read, scan);
|
|
79
|
+
const bytes = new Uint8Array(captured);
|
|
80
|
+
let offset = 0;
|
|
81
|
+
for (const chunk of chunks) {
|
|
82
|
+
if (offset >= captured)
|
|
83
|
+
break;
|
|
84
|
+
const accepted = chunk.subarray(0, captured - offset);
|
|
85
|
+
bytes.set(accepted, offset);
|
|
86
|
+
offset += accepted.byteLength;
|
|
87
|
+
}
|
|
88
|
+
if (read <= limit)
|
|
89
|
+
return decodeUtf8Prefix(bytes);
|
|
90
|
+
// The tail was never read — keep the head and say so.
|
|
91
|
+
if (stillStreaming)
|
|
92
|
+
return `${decodeUtf8Prefix(bytes.subarray(0, limit))}…`;
|
|
93
|
+
// The whole document was read and is over budget: keep both ends, since the
|
|
94
|
+
// opening bytes are the least informative part of a wrapped error document.
|
|
95
|
+
const head = Math.floor(limit * HEAD_SHARE);
|
|
96
|
+
const tail = limit - head;
|
|
97
|
+
const elided = captured - limit;
|
|
98
|
+
return [
|
|
99
|
+
decodeUtf8Prefix(bytes.subarray(0, head)),
|
|
100
|
+
`…[${elided} byte${elided === 1 ? '' : 's'} elided]…`,
|
|
101
|
+
decodeUtf8Suffix(bytes.subarray(captured - tail)),
|
|
102
|
+
].join('');
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=responseBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseBody.js","sourceRoot":"","sources":["../../../src/utils/network/responseBody.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4EAA4E;AAC5E,MAAM,UAAU,GAAG,GAAG,CAAC;AAmBvB,SAAS,gBAAgB,CAAC,KAAiB;IACzC,4EAA4E;IAC5E,4EAA4E;IAC5E,0CAA0C;IAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;IAClD,KAAK,IAAI,GAAG,GAAG,KAAK,CAAC,UAAU,EAAE,GAAG,IAAI,OAAO,EAAE,GAAG,IAAI,CAAC,E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,CAAC,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC;QACtD,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC5B,MAAM,IAAI,QAAQ,CAAC,UAAU,CAAC;IAChC,CAAC;IAED,IAAI,IAAI,IAAI,KAAK;QAAE,OAAO,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAElD,sDAAsD;IACtD,IAAI,cAAc;QAAE,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC;IAE5E,4EAA4E;IAC5E,4EAA4E;IAC5E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC;IAC1B,MAAM,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IAChC,OAAO;QACL,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACzC,KAAK,MAAM,QAAQ,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,WAAW;QACrD,gBAAgB,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;KAClD,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACb,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RequestContext } from '../../utils/internal/requestContext.js';
|
|
1
|
+
import type { RequestContext, RequestContextLike } from '../../utils/internal/requestContext.js';
|
|
2
2
|
/** Configuration for {@link withRetry}. */
|
|
3
3
|
export interface RetryOptions {
|
|
4
4
|
/**
|
|
@@ -17,7 +17,7 @@ export interface RetryOptions {
|
|
|
17
17
|
* safe — the logger strips non-serializable fields (`signal`, `log`,
|
|
18
18
|
* `state`, protocol method handles) before pino sees them.
|
|
19
19
|
*/
|
|
20
|
-
context?: RequestContext;
|
|
20
|
+
context?: RequestContextLike | RequestContext;
|
|
21
21
|
/**
|
|
22
22
|
* Custom predicate to determine if an error is transient and should be
|
|
23
23
|
* retried. When provided, this **replaces** the default predicate entirely
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../src/utils/network/retry.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../../src/utils/network/retry.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAY7F,2CAA2C;AAC3C,MAAM,WAAW,YAAY;IAC3B;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,CAAC;IAE9C;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IAE1C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AA8GD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAgE/F"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @see {@link https://modelcontextprotocol.io/specification/2025-06-18/utils/pagination | MCP Pagination Spec}
|
|
12
12
|
* @module src/utils/pagination/pagination
|
|
13
13
|
*/
|
|
14
|
-
import type { RequestContext } from '../../utils/internal/requestContext.js';
|
|
14
|
+
import type { RequestContext, RequestContextLike } from '../../utils/internal/requestContext.js';
|
|
15
15
|
/**
|
|
16
16
|
* Generic pagination state that can be encoded into a cursor.
|
|
17
17
|
* Implementations can extend this with additional fields as needed.
|
|
@@ -72,7 +72,7 @@ export declare function encodeCursor(state: PaginationState): string;
|
|
|
72
72
|
* const state = decodeCursor(req.params.cursor, ctx);
|
|
73
73
|
* // state.offset and state.limit are safe to use directly
|
|
74
74
|
*/
|
|
75
|
-
export declare function decodeCursor(cursor: string, context: RequestContext): PaginationState;
|
|
75
|
+
export declare function decodeCursor(cursor: string, context: RequestContextLike | RequestContext): PaginationState;
|
|
76
76
|
/**
|
|
77
77
|
* Extracts the cursor parameter from an MCP request's params object.
|
|
78
78
|
* Checks `params.cursor` first, then falls back to `params._meta.cursor`,
|
|
@@ -130,7 +130,7 @@ export declare function extractCursor(params?: {
|
|
|
130
130
|
* const page3 = paginateArray(allItems, page2.nextCursor, 2, 100, ctx);
|
|
131
131
|
* // => { items: ['e'], totalCount: 5 } (no nextCursor)
|
|
132
132
|
*/
|
|
133
|
-
export declare function paginateArray<T>(items: T[], cursorStr: string | undefined, defaultPageSize: number, maxPageSize: number, context: RequestContext): PaginatedResult<T>;
|
|
133
|
+
export declare function paginateArray<T>(items: T[], cursorStr: string | undefined, defaultPageSize: number, maxPageSize: number, context: RequestContextLike | RequestContext): PaginatedResult<T>;
|
|
134
134
|
/**
|
|
135
135
|
* Default pagination configuration values used by {@link paginateArray} callers.
|
|
136
136
|
* These serve as sensible defaults; individual call sites may pass different values
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/utils/pagination/pagination.ts"],"names":[],"mappings":"AAAA;;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CAAC;QAC/C,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QACtB,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,wBAAwB;IACtE,CAAC;IAED,kBAAkB;IAClB,IAAI,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QAC3B,OAAO;YACL,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,KAAK,CAAC,MAAM;SACzB,CAAC;IACJ,CAAC;IAED,eAAe;IACf,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;IAE9C,kEAAkE;IAClE,MAAM,MAAM,GAAuB;QACjC,KAAK,EAAE,SAAS;QAChB,UAAU,EAAE,KAAK,CAAC,MAAM;KACzB,CAAC;IAEF,4CAA4C;IAC5C,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,CAAC,UAAU,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,uCAAuC;IACvC,iBAAiB,EAAE,EAAE;IACrB,qCAAqC;IACrC,aAAa,EAAE,IAAI;IACnB,qCAAqC;IACrC,aAAa,EAAE,CAAC;CACR,CAAC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @module src/utils/parsing/csvParser
|
|
9
9
|
*/
|
|
10
10
|
import type Papa from 'papaparse';
|
|
11
|
-
import { type RequestContext } from '../../utils/internal/requestContext.js';
|
|
11
|
+
import { type RequestContext, type RequestContextLike } from '../../utils/internal/requestContext.js';
|
|
12
12
|
/**
|
|
13
13
|
* Utility class for parsing CSV strings.
|
|
14
14
|
*
|
|
@@ -54,7 +54,7 @@ export declare class CsvParser {
|
|
|
54
54
|
* console.log(fromLlm.data[0]); // { a: '1', b: '2' }
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
|
-
parse<T = unknown>(csvString: string, options?: Papa.ParseConfig, context?: RequestContext): Promise<Papa.ParseResult<T>>;
|
|
57
|
+
parse<T = unknown>(csvString: string, options?: Papa.ParseConfig, context?: RequestContextLike | RequestContext): Promise<Papa.ParseResult<T>>;
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Singleton instance of {@link CsvParser}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csvParser.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/csvParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAKlC,OAAO,
|
|
1
|
+
{"version":3,"file":"csvParser.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/csvParser.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAKlC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EAExB,MAAM,oCAAoC,CAAC;AAkB5C;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,KAAK,CAAC,CAAC,GAAG,OAAO,EACrB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAC1B,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,GAC5C,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CA4D9B;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,SAAS,WAAkB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { validationError } from '../../types-global/errors.js';
|
|
2
2
|
import { lazyImport } from '../../utils/internal/lazyImport.js';
|
|
3
3
|
import { logger } from '../../utils/internal/logger.js';
|
|
4
|
-
import { requestContextService } from '../../utils/internal/requestContext.js';
|
|
4
|
+
import { requestContextService, } from '../../utils/internal/requestContext.js';
|
|
5
5
|
import { thinkBlockRegex } from './thinkBlock.js';
|
|
6
6
|
const importPapa = lazyImport(() => import('papaparse'), 'Install "papaparse" to use CSV parsing: bun add papaparse');
|
|
7
7
|
let _papa;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csvParser.js","sourceRoot":"","sources":["../../../src/utils/parsing/csvParser.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"csvParser.js","sourceRoot":"","sources":["../../../src/utils/parsing/csvParser.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAGL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,UAAU,GAAG,UAAU,CAC3B,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,EACzB,2DAA2D,CAC5D,CAAC;AAEF,IAAI,KAA8B,CAAC;AACnC,KAAK,UAAU,OAAO;IACpB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,GAAG,GAAG,MAAM,UAAU,EAAE,CAAC;QAC/B,qDAAqD;QACrD,KAAK,GAAG,CA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,CAAC;QAErD,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,eAAe,GACnB,OAAO;gBACP,qBAAqB,CAAC,oBAAoB,CAAC;oBACzC,SAAS,EAAE,sBAAsB;iBAClC,CAAC,CAAC;YACL,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE;gBAC3C,GAAG,eAAe;gBAClB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,gBAAgB,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;aAClD,CAAC,CAAC;YAEH,MAAM,eAAe,CACnB,wBAAwB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EACxE;gBACE,GAAG,OAAO;gBACV,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,qBAAqB,EACnB,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9E,CACF,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module src/utils/parsing/dateParser
|
|
5
5
|
*/
|
|
6
6
|
import type * as chrono from 'chrono-node';
|
|
7
|
-
import type { RequestContext } from '../../utils/internal/requestContext.js';
|
|
7
|
+
import type { RequestContext, RequestContextLike } from '../../utils/internal/requestContext.js';
|
|
8
8
|
/**
|
|
9
9
|
* Parses a natural language date string into a JavaScript `Date` object.
|
|
10
10
|
*
|
|
@@ -16,13 +16,14 @@ import type { RequestContext } from '../../utils/internal/requestContext.js';
|
|
|
16
16
|
* (`bun add chrono-node`).
|
|
17
17
|
*
|
|
18
18
|
* @param text - The natural language date string to parse (e.g. `"next Friday at 3pm"`).
|
|
19
|
-
* @param context -
|
|
19
|
+
* @param context - Context for correlated logging and error metadata. The handler
|
|
20
|
+
* `Context` is accepted directly.
|
|
20
21
|
* @param refDate - Reference date for relative expressions. Defaults to the current date/time.
|
|
21
22
|
* @returns A `Date` object if a date was found, or `null` if parsing yields no result.
|
|
22
23
|
* @throws {McpError} With `ConfigurationError` if `chrono-node` is not installed.
|
|
23
24
|
* @throws {McpError} With `ParseError` if an unexpected error occurs during parsing.
|
|
24
25
|
*/
|
|
25
|
-
export declare function parseDateString(text: string, context: RequestContext, refDate?: Date): Promise<Date | null>;
|
|
26
|
+
export declare function parseDateString(text: string, context: RequestContextLike | RequestContext, refDate?: Date): Promise<Date | null>;
|
|
26
27
|
/**
|
|
27
28
|
* Parses a natural language date string and returns detailed `chrono-node` results.
|
|
28
29
|
*
|
|
@@ -38,14 +39,15 @@ export declare function parseDateString(text: string, context: RequestContext, r
|
|
|
38
39
|
* (`bun add chrono-node`).
|
|
39
40
|
*
|
|
40
41
|
* @param text - The natural language date string to parse.
|
|
41
|
-
* @param context -
|
|
42
|
+
* @param context - Context for correlated logging and error metadata. The handler
|
|
43
|
+
* `Context` is accepted directly.
|
|
42
44
|
* @param refDate - Reference date for relative expressions. Defaults to the current date/time.
|
|
43
45
|
* @returns An array of `chrono.ParsedResult` objects — one per date expression found.
|
|
44
46
|
* Empty array if no dates are present in the text.
|
|
45
47
|
* @throws {McpError} With `ConfigurationError` if `chrono-node` is not installed.
|
|
46
48
|
* @throws {McpError} With `ParseError` if an unexpected error occurs during parsing.
|
|
47
49
|
*/
|
|
48
|
-
export declare function parseDateStringDetailed(text: string, context: RequestContext, refDate?: Date): Promise<chrono.ParsedResult[]>;
|
|
50
|
+
export declare function parseDateStringDetailed(text: string, context: RequestContextLike | RequestContext, refDate?: Date): Promise<chrono.ParsedResult[]>;
|
|
49
51
|
/**
|
|
50
52
|
* Singleton object providing natural language date parsing via `chrono-node`.
|
|
51
53
|
*
|
|
@@ -79,7 +81,8 @@ export declare const dateParser: {
|
|
|
79
81
|
* Async due to lazy loading of `chrono-node` (`bun add chrono-node`).
|
|
80
82
|
*
|
|
81
83
|
* @param text - The natural language date string to parse.
|
|
82
|
-
* @param context -
|
|
84
|
+
* @param context - Context for correlated logging and error metadata. The handler
|
|
85
|
+
* `Context` is accepted directly.
|
|
83
86
|
* @param refDate - Reference date for relative expressions. Defaults to now.
|
|
84
87
|
* @returns An array of `chrono.ParsedResult` objects; empty if no dates found.
|
|
85
88
|
* @throws {McpError} With `ConfigurationError` if `chrono-node` is not installed.
|
|
@@ -92,7 +95,8 @@ export declare const dateParser: {
|
|
|
92
95
|
* Async due to lazy loading of `chrono-node` (`bun add chrono-node`).
|
|
93
96
|
*
|
|
94
97
|
* @param text - The natural language date string to parse.
|
|
95
|
-
* @param context -
|
|
98
|
+
* @param context - Context for correlated logging and error metadata. The handler
|
|
99
|
+
* `Context` is accepted directly.
|
|
96
100
|
* @param refDate - Reference date for relative expressions. Defaults to now.
|
|
97
101
|
* @returns A `Date` if a date expression was found, or `null` if none was recognized.
|
|
98
102
|
* @throws {McpError} With `ConfigurationError` if `chrono-node` is not installed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateParser.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/dateParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAC;AAM3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"dateParser.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/dateParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,KAAK,MAAM,MAAM,aAAa,CAAC;AAM3C,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAO7F;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,kBAAkB,GAAG,cAAc,EAC5C,OAAO,CAAC,EAAE,IAAI,GACb,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CA4BtB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,kBAAkB,GAAG,cAAc,EAC5C,OAAO,CAAC,EAAE,IAAI,GACb,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAuBhC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,UAAU;IACrB;;;;;;;;;;;;;OAaG;IACH,KAAK;IACL;;;;;;;;;;;;OAYG;IACH,SAAS;CACV,CAAC"}
|
|
@@ -14,7 +14,8 @@ const getChrono = lazyImport(() => import('chrono-node'), 'Install "chrono-node"
|
|
|
14
14
|
* (`bun add chrono-node`).
|
|
15
15
|
*
|
|
16
16
|
* @param text - The natural language date string to parse (e.g. `"next Friday at 3pm"`).
|
|
17
|
-
* @param context -
|
|
17
|
+
* @param context - Context for correlated logging and error metadata. The handler
|
|
18
|
+
* `Context` is accepted directly.
|
|
18
19
|
* @param refDate - Reference date for relative expressions. Defaults to the current date/time.
|
|
19
20
|
* @returns A `Date` object if a date was found, or `null` if parsing yields no result.
|
|
20
21
|
* @throws {McpError} With `ConfigurationError` if `chrono-node` is not installed.
|
|
@@ -60,7 +61,8 @@ export async function parseDateString(text, context, refDate) {
|
|
|
60
61
|
* (`bun add chrono-node`).
|
|
61
62
|
*
|
|
62
63
|
* @param text - The natural language date string to parse.
|
|
63
|
-
* @param context -
|
|
64
|
+
* @param context - Context for correlated logging and error metadata. The handler
|
|
65
|
+
* `Context` is accepted directly.
|
|
64
66
|
* @param refDate - Reference date for relative expressions. Defaults to the current date/time.
|
|
65
67
|
* @returns An array of `chrono.ParsedResult` objects — one per date expression found.
|
|
66
68
|
* Empty array if no dates are present in the text.
|
|
@@ -116,7 +118,8 @@ export const dateParser = {
|
|
|
116
118
|
* Async due to lazy loading of `chrono-node` (`bun add chrono-node`).
|
|
117
119
|
*
|
|
118
120
|
* @param text - The natural language date string to parse.
|
|
119
|
-
* @param context -
|
|
121
|
+
* @param context - Context for correlated logging and error metadata. The handler
|
|
122
|
+
* `Context` is accepted directly.
|
|
120
123
|
* @param refDate - Reference date for relative expressions. Defaults to now.
|
|
121
124
|
* @returns An array of `chrono.ParsedResult` objects; empty if no dates found.
|
|
122
125
|
* @throws {McpError} With `ConfigurationError` if `chrono-node` is not installed.
|
|
@@ -129,7 +132,8 @@ export const dateParser = {
|
|
|
129
132
|
* Async due to lazy loading of `chrono-node` (`bun add chrono-node`).
|
|
130
133
|
*
|
|
131
134
|
* @param text - The natural language date string to parse.
|
|
132
|
-
* @param context -
|
|
135
|
+
* @param context - Context for correlated logging and error metadata. The handler
|
|
136
|
+
* `Context` is accepted directly.
|
|
133
137
|
* @param refDate - Reference date for relative expressions. Defaults to now.
|
|
134
138
|
* @returns A `Date` if a date expression was found, or `null` if none was recognized.
|
|
135
139
|
* @throws {McpError} With `ConfigurationError` if `chrono-node` is not installed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateParser.js","sourceRoot":"","sources":["../../../src/utils/parsing/dateParser.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGpD,MAAM,SAAS,GAAG,UAAU,CAC1B,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,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;;;;;OAYG;IACH,SAAS,EAAE,eAAe;CAC3B,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type RequestContext } from '../../utils/internal/requestContext.js';
|
|
1
|
+
import { type RequestContext, type RequestContextLike } from '../../utils/internal/requestContext.js';
|
|
2
|
+
import { type ParserInputBudgetOptions } from './inputBudget.js';
|
|
2
3
|
/**
|
|
3
4
|
* Result of parsing markdown with frontmatter.
|
|
4
5
|
* @template T The expected type of the parsed frontmatter object.
|
|
@@ -35,7 +36,9 @@ export declare class FrontmatterParser {
|
|
|
35
36
|
*
|
|
36
37
|
* @template T - The expected shape of the parsed frontmatter object. Defaults to `unknown`.
|
|
37
38
|
* @param markdown - The markdown string that may contain a frontmatter block.
|
|
38
|
-
* @param context - Optional
|
|
39
|
+
* @param context - Optional context for correlated logging. The handler `Context`
|
|
40
|
+
* is accepted directly.
|
|
41
|
+
* @param budget - Optional UTF-8 byte budget for the input. Unbounded when omitted.
|
|
39
42
|
* @returns A {@link FrontmatterResult} with `frontmatter`, `content`, and `hasFrontmatter`.
|
|
40
43
|
* @throws {McpError} With code `ValidationError` if the YAML content is present but malformed.
|
|
41
44
|
* @example
|
|
@@ -49,7 +52,7 @@ export declare class FrontmatterParser {
|
|
|
49
52
|
* // result.hasFrontmatter → true
|
|
50
53
|
* ```
|
|
51
54
|
*/
|
|
52
|
-
parse<T = unknown>(markdown: string, context?: RequestContext): Promise<FrontmatterResult<T>>;
|
|
55
|
+
parse<T = unknown>(markdown: string, context?: RequestContextLike | RequestContext, budget?: ParserInputBudgetOptions): Promise<FrontmatterResult<T>>;
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
58
|
* Singleton instance of {@link FrontmatterParser}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatterParser.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/frontmatterParser.ts"],"names":[],"mappings":"AAQA,OAAO,
|
|
1
|
+
{"version":3,"file":"frontmatterParser.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/frontmatterParser.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EAExB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAyB,KAAK,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAYxF;;;GAGG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO;IAC5C;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,WAAW,EAAE,CAAC,CAAC;IACf;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,KAAK,CAAC,CAAC,GAAG,OAAO,EACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,EAC7C,MAAM,CAAC,EAAE,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CA2F/B;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,iBAAiB,mBAA0B,CAAC"}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { McpError, validationError } from '../../types-global/errors.js';
|
|
8
8
|
import { logger } from '../../utils/internal/logger.js';
|
|
9
|
-
import { requestContextService } from '../../utils/internal/requestContext.js';
|
|
9
|
+
import { requestContextService, } from '../../utils/internal/requestContext.js';
|
|
10
|
+
import { assertTextInputBudget } from './inputBudget.js';
|
|
10
11
|
import { yamlParser } from './yamlParser.js';
|
|
11
12
|
/**
|
|
12
13
|
* Regular expression to extract frontmatter from markdown.
|
|
@@ -33,7 +34,9 @@ export class FrontmatterParser {
|
|
|
33
34
|
*
|
|
34
35
|
* @template T - The expected shape of the parsed frontmatter object. Defaults to `unknown`.
|
|
35
36
|
* @param markdown - The markdown string that may contain a frontmatter block.
|
|
36
|
-
* @param context - Optional
|
|
37
|
+
* @param context - Optional context for correlated logging. The handler `Context`
|
|
38
|
+
* is accepted directly.
|
|
39
|
+
* @param budget - Optional UTF-8 byte budget for the input. Unbounded when omitted.
|
|
37
40
|
* @returns A {@link FrontmatterResult} with `frontmatter`, `content`, and `hasFrontmatter`.
|
|
38
41
|
* @throws {McpError} With code `ValidationError` if the YAML content is present but malformed.
|
|
39
42
|
* @example
|
|
@@ -47,7 +50,8 @@ export class FrontmatterParser {
|
|
|
47
50
|
* // result.hasFrontmatter → true
|
|
48
51
|
* ```
|
|
49
52
|
*/
|
|
50
|
-
async parse(markdown, context) {
|
|
53
|
+
async parse(markdown, context, budget) {
|
|
54
|
+
assertTextInputBudget(markdown, budget);
|
|
51
55
|
const match = markdown.match(frontmatterRegex);
|
|
52
56
|
if (!match) {
|
|
53
57
|
// No frontmatter found - return original content
|
|
@@ -85,7 +89,7 @@ export class FrontmatterParser {
|
|
|
85
89
|
}
|
|
86
90
|
try {
|
|
87
91
|
// Use existing yamlParser for parsing (handles <think> blocks too)
|
|
88
|
-
const parsedFrontmatter = await yamlParser.parse(yamlContent, context);
|
|
92
|
+
const parsedFrontmatter = await yamlParser.parse(yamlContent, context, budget);
|
|
89
93
|
logger.debug('Frontmatter parsed successfully.', {
|
|
90
94
|
...logContext,
|
|
91
95
|
frontmatterKeys: parsedFrontmatter &&
|
|
@@ -115,11 +119,7 @@ export class FrontmatterParser {
|
|
|
115
119
|
if (error instanceof McpError) {
|
|
116
120
|
throw error;
|
|
117
121
|
}
|
|
118
|
-
throw validationError(`Failed to parse frontmatter: ${error.message}`, {
|
|
119
|
-
...context,
|
|
120
|
-
yamlContentSample: yamlContent.substring(0, 200) + (yamlContent.length > 200 ? '...' : ''),
|
|
121
|
-
rawError: error instanceof Error ? error.stack : String(error),
|
|
122
|
-
});
|
|
122
|
+
throw validationError(`Failed to parse frontmatter content: ${error.message}`, { reason: 'frontmatter_parse_failed' }, { cause: error });
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatterParser.js","sourceRoot":"","sources":["../../../src/utils/parsing/frontmatterParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"frontmatterParser.js","sourceRoot":"","sources":["../../../src/utils/parsing/frontmatterParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAGL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAiC,MAAM,kBAAkB,CAAC;AACxF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,uCAAuC,CAAC;AAsBjE;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,KAAK,CAAC,KAAK,CACT,QAAgB,EAChB,OAA6C,EAC7C,MAAiC;QAEjC,qBAAqB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAExC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAE/C,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,iDAAiD;YACjD,MAAM,UAAU,GACd,OAAO;gBACP,qBAAqB,CAAC,oBAAoB,CAAC;oBACzC,SAAS,EAAE,iCAAiC;iBAC7C,CAAC,CAAC;YACL,MAAM,CAAC,KAAK,CAAC,sCAAsC,E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L,WAAW,EAAE,iBAAiB;gBAC9B,OAAO,EAAE,eAAe;gBACxB,cAAc,EAAE,IAAI;aACrB,CAAC;QACJ,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5D,MAAM,eAAe,GACnB,OAAO;gBACP,qBAAqB,CAAC,oBAAoB,CAAC;oBACzC,SAAS,EAAE,8BAA8B;iBAC1C,CAAC,CAAC;YAEL,MAAM,CAAC,KAAK,CAAC,2CAA2C,EAAE;gBACxD,GAAG,eAAe;gBAClB,YAAY,EAAE,KAAK,CAAC,OAAO;gBAC3B,iBAAiB,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;aACjD,CAAC,CAAC;YAEH,sDAAsD;YACtD,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;gBAC9B,MAAM,KAAK,CAAC;YACd,CAAC;YAED,MAAM,eAAe,CACnB,wCAAwC,KAAK,CAAC,OAAO,EAAE,EACvD,EAAE,MAAM,EAAE,0BAA0B,EAAE,EACtC,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type RequestContext } from '../../utils/internal/requestContext.js';
|
|
1
|
+
import { type RequestContext, type RequestContextLike } from '../../utils/internal/requestContext.js';
|
|
2
2
|
/**
|
|
3
3
|
* Options for HTML article extraction.
|
|
4
4
|
*/
|
|
@@ -25,6 +25,10 @@ export interface ExtractArticleOptions {
|
|
|
25
25
|
* `'en'`, `'fr'`, `'ja'`).
|
|
26
26
|
*/
|
|
27
27
|
language?: string;
|
|
28
|
+
/**
|
|
29
|
+
* UTF-8 input budget in bytes. Unbounded when omitted.
|
|
30
|
+
*/
|
|
31
|
+
maxBytes?: number;
|
|
28
32
|
/**
|
|
29
33
|
* Strip all images from the extracted content. Defaults to `false`.
|
|
30
34
|
*/
|
|
@@ -99,7 +103,8 @@ export declare class HtmlExtractor {
|
|
|
99
103
|
*
|
|
100
104
|
* @param html - Raw HTML string to extract from.
|
|
101
105
|
* @param options - Optional extraction options (format, URL, content selector, etc.).
|
|
102
|
-
* @param context - Optional
|
|
106
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
107
|
+
* handler `Context` is accepted directly.
|
|
103
108
|
* @returns Extracted content and metadata. Only `content` is guaranteed to
|
|
104
109
|
* be present; all other fields are best-effort.
|
|
105
110
|
* @throws {McpError} With `ConfigurationError` if `defuddle` or `linkedom` is not installed.
|
|
@@ -120,7 +125,7 @@ export declare class HtmlExtractor {
|
|
|
120
125
|
* console.log(result.content);
|
|
121
126
|
* ```
|
|
122
127
|
*/
|
|
123
|
-
extract(html: string, options?: ExtractArticleOptions, context?: RequestContext): Promise<ExtractArticleResult>;
|
|
128
|
+
extract(html: string, options?: ExtractArticleOptions, context?: RequestContextLike | RequestContext): Promise<ExtractArticleResult>;
|
|
124
129
|
}
|
|
125
130
|
/**
|
|
126
131
|
* Singleton instance of {@link HtmlExtractor}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlExtractor.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/htmlExtractor.ts"],"names":[],"mappings":"AAgCA,OAAO,
|
|
1
|
+
{"version":3,"file":"htmlExtractor.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/htmlExtractor.ts"],"names":[],"mappings":"AAgCA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EAExB,MAAM,oCAAoC,CAAC;AAsC5C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OA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xB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,qBAAqB,EAC/B,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,GAC5C,OAAO,CAAC,oBAAoB,CAAC,CA6E/B;CACF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,aAAa,eAAsB,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { McpError, validationError } from '../../types-global/errors.js';
|
|
2
2
|
import { lazyImport } from '../../utils/internal/lazyImport.js';
|
|
3
3
|
import { logger } from '../../utils/internal/logger.js';
|
|
4
|
-
import { requestContextService } from '../../utils/internal/requestContext.js';
|
|
4
|
+
import { requestContextService, } from '../../utils/internal/requestContext.js';
|
|
5
|
+
import { assertTextInputBudget } from './inputBudget.js';
|
|
5
6
|
const getDefuddle = lazyImport(() => import('defuddle/node'), 'Install "defuddle" to use HTML article extraction: bun add defuddle linkedom');
|
|
6
7
|
const getLinkedom = lazyImport(() => import('linkedom'), 'Install "linkedom" to use HTML article extraction: bun add defuddle linkedom');
|
|
7
8
|
/** Flattens defuddle's `MetaTagItem[]` into a `Record<string, string>` keyed
|
|
@@ -42,7 +43,8 @@ export class HtmlExtractor {
|
|
|
42
43
|
*
|
|
43
44
|
* @param html - Raw HTML string to extract from.
|
|
44
45
|
* @param options - Optional extraction options (format, URL, content selector, etc.).
|
|
45
|
-
* @param context - Optional
|
|
46
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
47
|
+
* handler `Context` is accepted directly.
|
|
46
48
|
* @returns Extracted content and metadata. Only `content` is guaranteed to
|
|
47
49
|
* be present; all other fields are best-effort.
|
|
48
50
|
* @throws {McpError} With `ConfigurationError` if `defuddle` or `linkedom` is not installed.
|
|
@@ -64,6 +66,7 @@ export class HtmlExtractor {
|
|
|
64
66
|
* ```
|
|
65
67
|
*/
|
|
66
68
|
async extract(html, options, context) {
|
|
69
|
+
const byteLength = assertTextInputBudget(html, options);
|
|
67
70
|
const logContext = context ??
|
|
68
71
|
requestContextService.createRequestContext({
|
|
69
72
|
operation: 'HtmlExtractor.extract',
|
|
@@ -88,7 +91,7 @@ export class HtmlExtractor {
|
|
|
88
91
|
};
|
|
89
92
|
logger.debug('Extracting article content from HTML.', {
|
|
90
93
|
...logContext,
|
|
91
|
-
byteLength
|
|
94
|
+
byteLength,
|
|
92
95
|
format,
|
|
93
96
|
hasUrl: Boolean(options?.url),
|
|
94
97
|
hasContentSelector: Boolean(options?.contentSelector),
|
|
@@ -140,10 +143,7 @@ export class HtmlExtractor {
|
|
|
140
143
|
...logContext,
|
|
141
144
|
errorDetails: error.message,
|
|
142
145
|
});
|
|
143
|
-
throw validationError(`Failed to extract article from HTML: ${error.message}`, {
|
|
144
|
-
...context,
|
|
145
|
-
rawError: error.stack ?? String(error),
|
|
146
|
-
});
|
|
146
|
+
throw validationError(`Failed to extract article from HTML: ${error.message}`, { reason: 'html_extract_failed' }, { cause: error });
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
}
|