@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlExtractor.js","sourceRoot":"","sources":["../../../src/utils/parsing/htmlExtractor.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,0BAA0B,CA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AK,EAAE,CACjB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -8,6 +8,7 @@ export { CsvParser, csvParser } from './csvParser.js';
|
|
|
8
8
|
export { dateParser, parseDateString, parseDateStringDetailed } from './dateParser.js';
|
|
9
9
|
export { FrontmatterParser, type FrontmatterResult, frontmatterParser, } from './frontmatterParser.js';
|
|
10
10
|
export { type ExtractArticleOptions, type ExtractArticleResult, HtmlExtractor, htmlExtractor, } from './htmlExtractor.js';
|
|
11
|
+
export { DEFAULT_BINARY_PARSER_MAX_BYTES, DEFAULT_TEXT_PARSER_MAX_BYTES, type ParserInputBudgetOptions, } from './inputBudget.js';
|
|
11
12
|
export { Allow, JsonParser, jsonParser } from './jsonParser.js';
|
|
12
13
|
export { type AddPageOptions, type DrawImageOptions, type DrawTextOptions, type EmbedImageOptions, type ExtractTextOptions, type ExtractTextResult, type FillFormOptions, type PageRange, type PdfMetadata, PdfParser, pdfParser, type SetMetadataOptions, } from './pdfParser.js';
|
|
13
14
|
export { thinkBlockRegex } from './thinkBlock.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EACL,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,aAAa,EACb,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,UA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d,KAAK,WAAW,EAChB,SAAS,EACT,SAAS,EACT,KAAK,kBAAkB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -8,6 +8,7 @@ export { CsvParser, csvParser } from './csvParser.js';
|
|
|
8
8
|
export { dateParser, parseDateString, parseDateStringDetailed } from './dateParser.js';
|
|
9
9
|
export { FrontmatterParser, frontmatterParser, } from './frontmatterParser.js';
|
|
10
10
|
export { HtmlExtractor, htmlExtractor, } from './htmlExtractor.js';
|
|
11
|
+
export { DEFAULT_BINARY_PARSER_MAX_BYTES, DEFAULT_TEXT_PARSER_MAX_BYTES, } from './inputBudget.js';
|
|
11
12
|
export { Allow, JsonParser, jsonParser } from './jsonParser.js';
|
|
12
13
|
export { PdfParser, pdfParser, } from './pdfParser.js';
|
|
13
14
|
export { thinkBlockRegex } from './thinkBlock.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/parsing/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EACL,iBAAiB,EAEjB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,aAAa,EACb,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAUL,SAAS,EACT,SAAS,GAEV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/parsing/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EACL,iBAAiB,EAEjB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,aAAa,EACb,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,+BAA+B,EAC/B,6BAA6B,GAE9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAUL,SAAS,EACT,SAAS,GAEV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Opt-in input byte budgets shared by the parsing utilities. A
|
|
3
|
+
* parser is unbounded unless its caller supplies `maxBytes`: the input is
|
|
4
|
+
* already resident in memory by the time a parser sees it, so a budget is a
|
|
5
|
+
* caller's work-shaping knob rather than a trust boundary.
|
|
6
|
+
* @module src/utils/parsing/inputBudget
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Suggested UTF-8 input budget for text parsers (1 MiB). Not applied unless a
|
|
10
|
+
* caller passes it as `maxBytes`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_TEXT_PARSER_MAX_BYTES: number;
|
|
13
|
+
/**
|
|
14
|
+
* Suggested input budget for binary parsers (25 MiB). Not applied unless a
|
|
15
|
+
* caller passes it as `maxBytes`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_BINARY_PARSER_MAX_BYTES: number;
|
|
18
|
+
/**
|
|
19
|
+
* Caller override for a parser's input budget. Omit `maxBytes` for no bound;
|
|
20
|
+
* {@link DEFAULT_TEXT_PARSER_MAX_BYTES} and
|
|
21
|
+
* {@link DEFAULT_BINARY_PARSER_MAX_BYTES} are starting points for a caller that
|
|
22
|
+
* wants one.
|
|
23
|
+
*/
|
|
24
|
+
export interface ParserInputBudgetOptions {
|
|
25
|
+
maxBytes?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Return the UTF-8 byte length without allocating a second copy of the input. */
|
|
28
|
+
export declare function utf8ByteLength(input: string): number;
|
|
29
|
+
/** Assert a text input fits any budget the caller declared. Returns its UTF-8 byte length. */
|
|
30
|
+
export declare function assertTextInputBudget(input: string, options?: ParserInputBudgetOptions): number;
|
|
31
|
+
/** Assert a binary input fits any budget the caller declared. Returns its byte length. */
|
|
32
|
+
export declare function assertBinaryInputBudget(input: Uint8Array | ArrayBuffer, options?: ParserInputBudgetOptions): number;
|
|
33
|
+
/** Assert a set of binary inputs fits one shared budget. Returns their combined byte length. */
|
|
34
|
+
export declare function assertBinaryInputsBudget(inputs: readonly (Uint8Array | ArrayBuffer)[], options?: ParserInputBudgetOptions): number;
|
|
35
|
+
//# sourceMappingURL=inputBudget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputBudget.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/inputBudget.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;GAGG;AACH,eAAO,MAAM,6BAA6B,QAAc,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,+BAA+B,QAAmB,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAeD,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAyBpD;AAcD,8FAA8F;AAC9F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,GAAG,MAAM,CAE/F;AAED,0FAA0F;AAC1F,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,UAAU,GAAG,WAAW,EAC/B,OAAO,CAAC,EAAE,wBAAwB,GACjC,MAAM,CAER;AAED,gGAAgG;AAChG,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,CAAC,UAAU,GAAG,WAAW,CAAC,EAAE,EAC7C,OAAO,CAAC,EAAE,wBAAwB,GACjC,MAAM,CAGR"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Opt-in input byte budgets shared by the parsing utilities. A
|
|
3
|
+
* parser is unbounded unless its caller supplies `maxBytes`: the input is
|
|
4
|
+
* already resident in memory by the time a parser sees it, so a budget is a
|
|
5
|
+
* caller's work-shaping knob rather than a trust boundary.
|
|
6
|
+
* @module src/utils/parsing/inputBudget
|
|
7
|
+
*/
|
|
8
|
+
import { validationError } from '../../types-global/errors.js';
|
|
9
|
+
/**
|
|
10
|
+
* Suggested UTF-8 input budget for text parsers (1 MiB). Not applied unless a
|
|
11
|
+
* caller passes it as `maxBytes`.
|
|
12
|
+
*/
|
|
13
|
+
export const DEFAULT_TEXT_PARSER_MAX_BYTES = 1024 * 1024;
|
|
14
|
+
/**
|
|
15
|
+
* Suggested input budget for binary parsers (25 MiB). Not applied unless a
|
|
16
|
+
* caller passes it as `maxBytes`.
|
|
17
|
+
*/
|
|
18
|
+
export const DEFAULT_BINARY_PARSER_MAX_BYTES = 25 * 1024 * 1024;
|
|
19
|
+
function resolveLimit(options) {
|
|
20
|
+
const requested = options?.maxBytes;
|
|
21
|
+
if (requested === undefined)
|
|
22
|
+
return;
|
|
23
|
+
if (!Number.isSafeInteger(requested) || requested < 1) {
|
|
24
|
+
throw validationError('Parser input byte limit must be a positive safe integer.', {
|
|
25
|
+
reason: 'parser_input_limit_invalid',
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return requested;
|
|
29
|
+
}
|
|
30
|
+
/** Return the UTF-8 byte length without allocating a second copy of the input. */
|
|
31
|
+
export function utf8ByteLength(input) {
|
|
32
|
+
let bytes = 0;
|
|
33
|
+
for (let index = 0; index < input.length; index += 1) {
|
|
34
|
+
const codeUnit = input.charCodeAt(index);
|
|
35
|
+
if (codeUnit <= 0x7f) {
|
|
36
|
+
bytes += 1;
|
|
37
|
+
}
|
|
38
|
+
else if (codeUnit <= 0x7ff) {
|
|
39
|
+
bytes += 2;
|
|
40
|
+
}
|
|
41
|
+
else if (codeUnit >= 0xd800 &&
|
|
42
|
+
codeUnit <= 0xdbff &&
|
|
43
|
+
index + 1 < input.length &&
|
|
44
|
+
input.charCodeAt(index + 1) >= 0xdc00 &&
|
|
45
|
+
input.charCodeAt(index + 1) <= 0xdfff) {
|
|
46
|
+
bytes += 4;
|
|
47
|
+
index += 1;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// BMP characters and unpaired surrogates both encode as three bytes.
|
|
51
|
+
bytes += 3;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return bytes;
|
|
55
|
+
}
|
|
56
|
+
function assertWithinLimit(sizeBytes, limitBytes) {
|
|
57
|
+
if (limitBytes !== undefined && sizeBytes > limitBytes) {
|
|
58
|
+
throw validationError('Parser input exceeds the maximum allowed byte size.', {
|
|
59
|
+
reason: 'parser_input_too_large',
|
|
60
|
+
sizeBytes,
|
|
61
|
+
limitBytes,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return sizeBytes;
|
|
65
|
+
}
|
|
66
|
+
/** Assert a text input fits any budget the caller declared. Returns its UTF-8 byte length. */
|
|
67
|
+
export function assertTextInputBudget(input, options) {
|
|
68
|
+
return assertWithinLimit(utf8ByteLength(input), resolveLimit(options));
|
|
69
|
+
}
|
|
70
|
+
/** Assert a binary input fits any budget the caller declared. Returns its byte length. */
|
|
71
|
+
export function assertBinaryInputBudget(input, options) {
|
|
72
|
+
return assertWithinLimit(input.byteLength, resolveLimit(options));
|
|
73
|
+
}
|
|
74
|
+
/** Assert a set of binary inputs fits one shared budget. Returns their combined byte length. */
|
|
75
|
+
export function assertBinaryInputsBudget(inputs, options) {
|
|
76
|
+
const sizeBytes = inputs.reduce((total, input) => total + input.byteLength, 0);
|
|
77
|
+
return assertWithinLimit(sizeBytes, resolveLimit(options));
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=inputBudget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputBudget.js","sourceRoot":"","sources":["../../../src/utils/parsing/inputBudget.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,GAAG,IAAI,CAAC;AAEzD;;;GAGG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAYhE,SAAS,YAAY,CAAC,OAA6C;IACjE,MAAM,SAAS,GAAG,OAAO,EAAE,QAAQ,CAAC;IACpC,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO;IAEpC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QACtD,MAAM,eAAe,CAAC,0DAA0D,EAAE;YAChF,MAAM,EAAE,4BAA4B;SACrC,CAAC,CAAC;IACL,CAAC;IAED,OAA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AiB,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AACzE,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,uBAAuB,CACrC,KAA+B,EAC/B,OAAkC;IAElC,OAAO,iBAAiB,CAAC,KAAK,CAAC,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,wBAAwB,CACtC,MAA6C,EAC7C,OAAkC;IAElC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAC/E,OAAO,iBAAiB,CAAC,SAAS,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AAC7D,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
|
* Bit flags specifying which partial JSON types are permissible during parsing.
|
|
4
5
|
* Mirrors `partial-json`'s `Allow` constants. Combine flags with bitwise OR
|
|
@@ -67,7 +68,9 @@ export declare class JsonParser {
|
|
|
67
68
|
* and/or be a partial (incomplete) JSON value.
|
|
68
69
|
* @param allowPartial - Bitwise OR combination of `Allow` flags controlling which
|
|
69
70
|
* partial JSON types are accepted. Defaults to `Allow.ALL`.
|
|
70
|
-
* @param context - Optional
|
|
71
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
72
|
+
* handler `Context` is accepted directly.
|
|
73
|
+
* @param budget - Optional UTF-8 byte budget for the input. Unbounded when omitted.
|
|
71
74
|
* @returns The parsed JavaScript value cast to `T`.
|
|
72
75
|
* @throws {McpError} With `ValidationError` if the string is empty after stripping the
|
|
73
76
|
* `<think>` block and trimming, or if `partial-json` fails to parse the content.
|
|
@@ -86,7 +89,7 @@ export declare class JsonParser {
|
|
|
86
89
|
* console.log(result); // { items: [1, 2] }
|
|
87
90
|
* ```
|
|
88
91
|
*/
|
|
89
|
-
parse<T = unknown>(jsonString: string, allowPartial?: number, context?: RequestContext): Promise<T>;
|
|
92
|
+
parse<T = unknown>(jsonString: string, allowPartial?: number, context?: RequestContextLike | RequestContext, budget?: ParserInputBudgetOptions): Promise<T>;
|
|
90
93
|
}
|
|
91
94
|
/**
|
|
92
95
|
* Singleton instance of `JsonParser`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonParser.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/jsonParser.ts"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"jsonParser.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/jsonParser.ts"],"names":[],"mappings":"AASA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EAExB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAyB,KAAK,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAQxF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK;IAChB,6BAA6B;aAC7B,GAAG,EAAE,CAAG;IACR,6BAA6B;aAC7B,GAAG,EAAE,CAAG;IACR,4BAA4B;aAC5B,GAAG,EAAE,CAAG;IACR,6BAA6B;aAC7B,GAAG,EAAE,CAAG;IACR,iCAAiC;aACjC,IAAI,EAAE,EAAI;IACV,8BAA8B;aAC9B,IAAI,EAAE,EAAI;IACV,wBAAwB;aACxB,GAAG,EAAE,EAAI;IACT,+BAA+B;aAC/B,QAAQ,EAAE,GAAI;IACd,+BAA+B;aAC/B,SAAS,EAAE,GAAK;IAChB,0EAA0E;aAC1E,GAAG;IACH,sEAAsE;aACtE,OAAO;IACP,8EAA8E;aAC9E,IAAI;IACJ,8CAA8C;aAC9C,UAAU;IACV,+BAA+B;aAC/B,GAAG;CACK,CAAC;AAEX;;;;;;;GAOG;AACH,qBAAa,UAAU;IACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,KAAK,CAAC,CAAC,GAAG,OAAO,EACrB,UAAU,EAAE,MAAM,EAClB,YAAY,GAAE,MAAkB,EAChC,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,EAC7C,MAAM,CAAC,EAAE,wBAAwB,GAChC,OAAO,CAAC,CAAC,CAAC,CAyDZ;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,UAAU,YAAmB,CAAC"}
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
import { validationError } from '../../types-global/errors.js';
|
|
8
8
|
import { lazyImport } from '../../utils/internal/lazyImport.js';
|
|
9
9
|
import { logger } from '../../utils/internal/logger.js';
|
|
10
|
-
import { requestContextService } from '../../utils/internal/requestContext.js';
|
|
10
|
+
import { requestContextService, } from '../../utils/internal/requestContext.js';
|
|
11
|
+
import { assertTextInputBudget } from './inputBudget.js';
|
|
11
12
|
import { thinkBlockRegex } from './thinkBlock.js';
|
|
12
13
|
const getPartialJson = lazyImport(() => import('partial-json'), 'Install "partial-json" to use partial JSON parsing: bun add partial-json');
|
|
13
14
|
/**
|
|
@@ -78,7 +79,9 @@ export class JsonParser {
|
|
|
78
79
|
* and/or be a partial (incomplete) JSON value.
|
|
79
80
|
* @param allowPartial - Bitwise OR combination of `Allow` flags controlling which
|
|
80
81
|
* partial JSON types are accepted. Defaults to `Allow.ALL`.
|
|
81
|
-
* @param context - Optional
|
|
82
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
83
|
+
* handler `Context` is accepted directly.
|
|
84
|
+
* @param budget - Optional UTF-8 byte budget for the input. Unbounded when omitted.
|
|
82
85
|
* @returns The parsed JavaScript value cast to `T`.
|
|
83
86
|
* @throws {McpError} With `ValidationError` if the string is empty after stripping the
|
|
84
87
|
* `<think>` block and trimming, or if `partial-json` fails to parse the content.
|
|
@@ -97,7 +100,8 @@ export class JsonParser {
|
|
|
97
100
|
* console.log(result); // { items: [1, 2] }
|
|
98
101
|
* ```
|
|
99
102
|
*/
|
|
100
|
-
async parse(jsonString, allowPartial = Allow.ALL, context) {
|
|
103
|
+
async parse(jsonString, allowPartial = Allow.ALL, context, budget) {
|
|
104
|
+
assertTextInputBudget(jsonString, budget);
|
|
101
105
|
let stringToParse = jsonString;
|
|
102
106
|
const match = jsonString.match(thinkBlockRegex);
|
|
103
107
|
if (match) {
|
|
@@ -137,11 +141,7 @@ export class JsonParser {
|
|
|
137
141
|
errorDetails: error.message,
|
|
138
142
|
contentAttempted: stringToParse.substring(0, 200),
|
|
139
143
|
});
|
|
140
|
-
throw validationError(`Failed to parse JSON: ${error.message}`, {
|
|
141
|
-
...context,
|
|
142
|
-
originalContentSample: stringToParse.substring(0, 200) + (stringToParse.length > 200 ? '...' : ''),
|
|
143
|
-
rawError: error instanceof Error ? error.stack : String(error),
|
|
144
|
-
});
|
|
144
|
+
throw validationError(`Failed to parse JSON content: ${error.message}`, { reason: 'json_parse_failed' }, { cause: error });
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonParser.js","sourceRoot":"","sources":["../../../src/utils/parsing/jsonParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,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":"jsonParser.js","sourceRoot":"","sources":["../../../src/utils/parsing/jsonParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO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AAC;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,uBAAuB;iBACnC,CAAC,CAAC;YACL,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE;gBAC5C,GAAG,eAAe;gBAClB,YAAY,EAAE,KAAK,CAAC,OAAO;gBAC3B,gBAAgB,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC;aAClD,CAAC,CAAC;YAEH,MAAM,eAAe,CACnB,iCAAiC,KAAK,CAAC,OAAO,EAAE,EAChD,EAAE,MAAM,EAAE,mBAAmB,EAAE,EAC/B,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* @module src/utils/parsing/pdfParser
|
|
6
6
|
*/
|
|
7
7
|
import type { PDFDocument, PDFFont, PDFImage, PDFPage, RGB } from 'pdf-lib';
|
|
8
|
-
import { type RequestContext } from '../../utils/internal/requestContext.js';
|
|
8
|
+
import { type RequestContext, type RequestContextLike } from '../../utils/internal/requestContext.js';
|
|
9
|
+
import { type ParserInputBudgetOptions } from './inputBudget.js';
|
|
9
10
|
/**
|
|
10
11
|
* Options for adding a new page to a PDF document.
|
|
11
12
|
*/
|
|
@@ -73,6 +74,8 @@ export interface EmbedImageOptions {
|
|
|
73
74
|
* Image data as Uint8Array or ArrayBuffer.
|
|
74
75
|
*/
|
|
75
76
|
imageBytes: Uint8Array | ArrayBuffer;
|
|
77
|
+
/** Input budget in bytes. Unbounded when omitted. */
|
|
78
|
+
maxBytes?: number;
|
|
76
79
|
}
|
|
77
80
|
/**
|
|
78
81
|
* Options for drawing an embedded image on a page.
|
|
@@ -208,6 +211,13 @@ export interface FillFormOptions {
|
|
|
208
211
|
* Options for extracting text from a PDF document.
|
|
209
212
|
*/
|
|
210
213
|
export interface ExtractTextOptions {
|
|
214
|
+
/** Input budget in bytes. Unbounded when omitted. */
|
|
215
|
+
maxBytes?: number;
|
|
216
|
+
/**
|
|
217
|
+
* Ceiling in pixels on a single decoded image, forwarded to pdf.js as
|
|
218
|
+
* `maxImageSize`. Unbounded when omitted, matching pdf.js's own default.
|
|
219
|
+
*/
|
|
220
|
+
maxImageSize?: number;
|
|
211
221
|
/**
|
|
212
222
|
* Whether to merge all pages into a single string.
|
|
213
223
|
* If true, returns text as a single string.
|
|
@@ -245,7 +255,8 @@ export declare class PdfParser {
|
|
|
245
255
|
*
|
|
246
256
|
* Async due to lazy loading of the `pdf-lib` peer dependency (`bun add pdf-lib`).
|
|
247
257
|
*
|
|
248
|
-
* @param context - Optional
|
|
258
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
259
|
+
* handler `Context` is accepted directly.
|
|
249
260
|
* @returns A new empty `PDFDocument` instance.
|
|
250
261
|
* @throws {McpError} With `ConfigurationError` if `pdf-lib` is not installed.
|
|
251
262
|
* @throws {McpError} With `InternalError` if document creation fails.
|
|
@@ -255,14 +266,16 @@ export declare class PdfParser {
|
|
|
255
266
|
* const page = pdfParser.addPage(doc);
|
|
256
267
|
* ```
|
|
257
268
|
*/
|
|
258
|
-
createDocument(context?: RequestContext): Promise<PDFDocument>;
|
|
269
|
+
createDocument(context?: RequestContextLike | RequestContext): Promise<PDFDocument>;
|
|
259
270
|
/**
|
|
260
271
|
* Loads an existing PDF document from raw bytes.
|
|
261
272
|
*
|
|
262
273
|
* Async due to lazy loading of the `pdf-lib` peer dependency (`bun add pdf-lib`).
|
|
263
274
|
*
|
|
264
275
|
* @param pdfBytes - The PDF file contents as `Uint8Array` or `ArrayBuffer`.
|
|
265
|
-
* @param context - Optional
|
|
276
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
277
|
+
* handler `Context` is accepted directly.
|
|
278
|
+
* @param budget - Optional byte budget for the input. Unbounded when omitted.
|
|
266
279
|
* @returns The loaded `PDFDocument` instance.
|
|
267
280
|
* @throws {McpError} With `ConfigurationError` if `pdf-lib` is not installed.
|
|
268
281
|
* @throws {McpError} With `ValidationError` if the bytes are not a valid PDF.
|
|
@@ -273,7 +286,7 @@ export declare class PdfParser {
|
|
|
273
286
|
* const doc = await pdfParser.loadDocument(pdfBytes);
|
|
274
287
|
* ```
|
|
275
288
|
*/
|
|
276
|
-
loadDocument(pdfBytes: Uint8Array | ArrayBuffer, context?: RequestContext): Promise<PDFDocument>;
|
|
289
|
+
loadDocument(pdfBytes: Uint8Array | ArrayBuffer, context?: RequestContextLike | RequestContext, budget?: ParserInputBudgetOptions): Promise<PDFDocument>;
|
|
277
290
|
/**
|
|
278
291
|
* Adds a new blank page to a PDF document.
|
|
279
292
|
*
|
|
@@ -297,7 +310,8 @@ export declare class PdfParser {
|
|
|
297
310
|
*
|
|
298
311
|
* @param doc - The `PDFDocument` to embed the font into.
|
|
299
312
|
* @param fontName - A `StandardFonts` key. Defaults to `'Helvetica'`.
|
|
300
|
-
* @param context - Optional
|
|
313
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
314
|
+
* handler `Context` is accepted directly.
|
|
301
315
|
* @returns The embedded `PDFFont` ready to pass to `drawText`.
|
|
302
316
|
* @throws {McpError} With `ConfigurationError` if `pdf-lib` is not installed.
|
|
303
317
|
* @throws {McpError} With `InternalError` if the font name is invalid or embedding fails.
|
|
@@ -306,7 +320,7 @@ export declare class PdfParser {
|
|
|
306
320
|
* const font = await pdfParser.embedFont(doc, 'TimesRoman');
|
|
307
321
|
* ```
|
|
308
322
|
*/
|
|
309
|
-
embedFont(doc: PDFDocument, fontName?: string, context?: RequestContext): Promise<PDFFont>;
|
|
323
|
+
embedFont(doc: PDFDocument, fontName?: string, context?: RequestContextLike | RequestContext): Promise<PDFFont>;
|
|
310
324
|
/**
|
|
311
325
|
* Embeds a PNG or JPEG image into a PDF document for later rendering.
|
|
312
326
|
*
|
|
@@ -315,7 +329,8 @@ export declare class PdfParser {
|
|
|
315
329
|
*
|
|
316
330
|
* @param doc - The `PDFDocument` to embed the image into.
|
|
317
331
|
* @param options - Image bytes and format (`'png'` or `'jpg'`).
|
|
318
|
-
* @param context - Optional
|
|
332
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
333
|
+
* handler `Context` is accepted directly.
|
|
319
334
|
* @returns The embedded `PDFImage`, usable as the `image` option in `drawImage`.
|
|
320
335
|
* @throws {McpError} With `ConfigurationError` if `pdf-lib` is not installed.
|
|
321
336
|
* @throws {McpError} With `InternalError` if the image data is invalid or embedding fails.
|
|
@@ -327,7 +342,7 @@ export declare class PdfParser {
|
|
|
327
342
|
* pdfParser.drawImage(page, { image, x: 50, y: 700, width: 100, height: 50 });
|
|
328
343
|
* ```
|
|
329
344
|
*/
|
|
330
|
-
embedImage(doc: PDFDocument, options: EmbedImageOptions, context?: RequestContext): Promise<PDFImage>;
|
|
345
|
+
embedImage(doc: PDFDocument, options: EmbedImageOptions, context?: RequestContextLike | RequestContext): Promise<PDFImage>;
|
|
331
346
|
/**
|
|
332
347
|
* Draws text on a PDF page with optional font, size, color, rotation, and word-wrap.
|
|
333
348
|
*
|
|
@@ -385,7 +400,9 @@ export declare class PdfParser {
|
|
|
385
400
|
* `pdf-lib` (`bun add pdf-lib`).
|
|
386
401
|
*
|
|
387
402
|
* @param pdfBytesArray - Source PDF files as `Uint8Array` or `ArrayBuffer` elements.
|
|
388
|
-
* @param context - Optional
|
|
403
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
404
|
+
* handler `Context` is accepted directly.
|
|
405
|
+
* @param budget - Optional aggregate byte budget across all inputs. Unbounded when omitted.
|
|
389
406
|
* @returns A new `PDFDocument` containing all pages from the input documents.
|
|
390
407
|
* @throws {McpError} With `ConfigurationError` if `pdf-lib` is not installed.
|
|
391
408
|
* @throws {McpError} With `InternalError` if any source PDF is invalid or merging fails.
|
|
@@ -398,7 +415,7 @@ export declare class PdfParser {
|
|
|
398
415
|
* const bytes = await pdfParser.saveDocument(merged);
|
|
399
416
|
* ```
|
|
400
417
|
*/
|
|
401
|
-
mergePdfs(pdfBytesArray: (Uint8Array | ArrayBuffer)[], context?: RequestContext): Promise<PDFDocument>;
|
|
418
|
+
mergePdfs(pdfBytesArray: (Uint8Array | ArrayBuffer)[], context?: RequestContextLike | RequestContext, budget?: ParserInputBudgetOptions): Promise<PDFDocument>;
|
|
402
419
|
/**
|
|
403
420
|
* Splits a PDF document into multiple new documents based on page ranges.
|
|
404
421
|
*
|
|
@@ -408,7 +425,9 @@ export declare class PdfParser {
|
|
|
408
425
|
*
|
|
409
426
|
* @param pdfBytes - The source PDF as `Uint8Array` or `ArrayBuffer`.
|
|
410
427
|
* @param ranges - Page ranges to extract; each produces one output document.
|
|
411
|
-
* @param context - Optional
|
|
428
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
429
|
+
* handler `Context` is accepted directly.
|
|
430
|
+
* @param budget - Optional byte budget for the input. Unbounded when omitted.
|
|
412
431
|
* @returns An array of new `PDFDocument` instances, one per range, in order.
|
|
413
432
|
* @throws {McpError} With `ConfigurationError` if `pdf-lib` is not installed.
|
|
414
433
|
* @throws {McpError} With `InternalError` if the source PDF is invalid or a page index is out of bounds.
|
|
@@ -422,7 +441,7 @@ export declare class PdfParser {
|
|
|
422
441
|
* ]);
|
|
423
442
|
* ```
|
|
424
443
|
*/
|
|
425
|
-
splitPdf(pdfBytes: Uint8Array | ArrayBuffer, ranges: PageRange[], context?: RequestContext): Promise<PDFDocument[]>;
|
|
444
|
+
splitPdf(pdfBytes: Uint8Array | ArrayBuffer, ranges: PageRange[], context?: RequestContextLike | RequestContext, budget?: ParserInputBudgetOptions): Promise<PDFDocument[]>;
|
|
426
445
|
/**
|
|
427
446
|
* Fills form fields in a PDF document.
|
|
428
447
|
*
|
|
@@ -433,7 +452,8 @@ export declare class PdfParser {
|
|
|
433
452
|
*
|
|
434
453
|
* @param doc - The `PDFDocument` containing the AcroForm.
|
|
435
454
|
* @param options - Map of field names to values, plus optional `flatten` flag.
|
|
436
|
-
* @param context - Optional
|
|
455
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
456
|
+
* handler `Context` is accepted directly.
|
|
437
457
|
* @throws {McpError} With `InternalError` if the overall form operation fails.
|
|
438
458
|
* @example
|
|
439
459
|
* ```typescript
|
|
@@ -447,7 +467,7 @@ export declare class PdfParser {
|
|
|
447
467
|
* });
|
|
448
468
|
* ```
|
|
449
469
|
*/
|
|
450
|
-
fillForm(doc: PDFDocument, options: FillFormOptions, context?: RequestContext): void;
|
|
470
|
+
fillForm(doc: PDFDocument, options: FillFormOptions, context?: RequestContextLike | RequestContext): void;
|
|
451
471
|
/**
|
|
452
472
|
* Extracts metadata from a PDF document.
|
|
453
473
|
*
|
|
@@ -496,7 +516,8 @@ export declare class PdfParser {
|
|
|
496
516
|
* @param input - Raw PDF bytes (`Uint8Array` | `ArrayBuffer`) or a loaded `PDFDocument`.
|
|
497
517
|
* @param options - Optional extraction options. Set `mergePages: true` to get a
|
|
498
518
|
* single concatenated string instead of one string per page.
|
|
499
|
-
* @param context - Optional
|
|
519
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
520
|
+
* handler `Context` is accepted directly.
|
|
500
521
|
* @returns An `ExtractTextResult` with `totalPages` and `text` — a `string[]` (one
|
|
501
522
|
* per page) by default, or a single `string` when `mergePages` is `true`.
|
|
502
523
|
* @throws {McpError} With `ConfigurationError` if `unpdf` is not installed (or
|
|
@@ -513,7 +534,7 @@ export declare class PdfParser {
|
|
|
513
534
|
* const perPage = await pdfParser.extractText(doc);
|
|
514
535
|
* ```
|
|
515
536
|
*/
|
|
516
|
-
extractText(input: PDFDocument | Uint8Array | ArrayBuffer, options?: ExtractTextOptions, context?: RequestContext): Promise<ExtractTextResult>;
|
|
537
|
+
extractText(input: PDFDocument | Uint8Array | ArrayBuffer, options?: ExtractTextOptions, context?: RequestContextLike | RequestContext): Promise<ExtractTextResult>;
|
|
517
538
|
/**
|
|
518
539
|
* Serializes a PDF document to a `Uint8Array` for writing to disk or transmission.
|
|
519
540
|
*
|
|
@@ -521,7 +542,8 @@ export declare class PdfParser {
|
|
|
521
542
|
* compatible). Does not reload peer dependencies if already cached.
|
|
522
543
|
*
|
|
523
544
|
* @param doc - The `PDFDocument` to serialize.
|
|
524
|
-
* @param context - Optional
|
|
545
|
+
* @param context - Optional context for correlated logging and error metadata. The
|
|
546
|
+
* handler `Context` is accepted directly.
|
|
525
547
|
* @returns The complete PDF file as a `Uint8Array`.
|
|
526
548
|
* @throws {McpError} With `InternalError` if serialization fails.
|
|
527
549
|
* @example
|
|
@@ -531,7 +553,7 @@ export declare class PdfParser {
|
|
|
531
553
|
* await writeFile('output.pdf', pdfBytes);
|
|
532
554
|
* ```
|
|
533
555
|
*/
|
|
534
|
-
saveDocument(doc: PDFDocument, context?: RequestContext): Promise<Uint8Array>;
|
|
556
|
+
saveDocument(doc: PDFDocument, context?: RequestContextLike | RequestContext): Promise<Uint8Array>;
|
|
535
557
|
}
|
|
536
558
|
/**
|
|
537
559
|
* Singleton instance of `PdfParser`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pdfParser.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/pdfParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAK5E,OAAO,
|
|
1
|
+
{"version":3,"file":"pdfParser.d.ts","sourceRoot":"","sources":["../../../src/utils/parsing/pdfParser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,WAAW,EAA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