@shuji-bonji/pdf-reader-mcp 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/LICENSE +21 -0
- package/README.ja.md +190 -0
- package/README.md +206 -0
- package/dist/constants.d.ts +22 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +23 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/common.d.ts +14 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +26 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/schemas/tier1.d.ts +104 -0
- package/dist/schemas/tier1.d.ts.map +1 -0
- package/dist/schemas/tier1.js +77 -0
- package/dist/schemas/tier1.js.map +1 -0
- package/dist/schemas/tier2.d.ts +68 -0
- package/dist/schemas/tier2.d.ts.map +1 -0
- package/dist/schemas/tier2.js +42 -0
- package/dist/schemas/tier2.js.map +1 -0
- package/dist/schemas/tier3.d.ts +44 -0
- package/dist/schemas/tier3.d.ts.map +1 -0
- package/dist/schemas/tier3.js +28 -0
- package/dist/schemas/tier3.js.map +1 -0
- package/dist/services/pdfjs-service.d.ts +65 -0
- package/dist/services/pdfjs-service.d.ts.map +1 -0
- package/dist/services/pdfjs-service.js +520 -0
- package/dist/services/pdfjs-service.js.map +1 -0
- package/dist/services/pdflib-service.d.ts +35 -0
- package/dist/services/pdflib-service.d.ts.map +1 -0
- package/dist/services/pdflib-service.js +318 -0
- package/dist/services/pdflib-service.js.map +1 -0
- package/dist/services/url-fetcher.d.ts +8 -0
- package/dist/services/url-fetcher.d.ts.map +1 -0
- package/dist/services/url-fetcher.js +40 -0
- package/dist/services/url-fetcher.js.map +1 -0
- package/dist/services/validation-service.d.ts +49 -0
- package/dist/services/validation-service.d.ts.map +1 -0
- package/dist/services/validation-service.js +670 -0
- package/dist/services/validation-service.js.map +1 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +46 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/tier1/get-metadata.d.ts +6 -0
- package/dist/tools/tier1/get-metadata.d.ts.map +1 -0
- package/dist/tools/tier1/get-metadata.js +49 -0
- package/dist/tools/tier1/get-metadata.js.map +1 -0
- package/dist/tools/tier1/get-page-count.d.ts +6 -0
- package/dist/tools/tier1/get-page-count.d.ts.map +1 -0
- package/dist/tools/tier1/get-page-count.js +50 -0
- package/dist/tools/tier1/get-page-count.js.map +1 -0
- package/dist/tools/tier1/read-images.d.ts +6 -0
- package/dist/tools/tier1/read-images.d.ts.map +1 -0
- package/dist/tools/tier1/read-images.js +79 -0
- package/dist/tools/tier1/read-images.js.map +1 -0
- package/dist/tools/tier1/read-text.d.ts +6 -0
- package/dist/tools/tier1/read-text.d.ts.map +1 -0
- package/dist/tools/tier1/read-text.js +57 -0
- package/dist/tools/tier1/read-text.js.map +1 -0
- package/dist/tools/tier1/read-url.d.ts +6 -0
- package/dist/tools/tier1/read-url.d.ts.map +1 -0
- package/dist/tools/tier1/read-url.js +64 -0
- package/dist/tools/tier1/read-url.js.map +1 -0
- package/dist/tools/tier1/search-text.d.ts +6 -0
- package/dist/tools/tier1/search-text.d.ts.map +1 -0
- package/dist/tools/tier1/search-text.js +62 -0
- package/dist/tools/tier1/search-text.js.map +1 -0
- package/dist/tools/tier1/summarize.d.ts +6 -0
- package/dist/tools/tier1/summarize.d.ts.map +1 -0
- package/dist/tools/tier1/summarize.js +70 -0
- package/dist/tools/tier1/summarize.js.map +1 -0
- package/dist/tools/tier2/inspect-annotations.d.ts +6 -0
- package/dist/tools/tier2/inspect-annotations.d.ts.map +1 -0
- package/dist/tools/tier2/inspect-annotations.js +47 -0
- package/dist/tools/tier2/inspect-annotations.js.map +1 -0
- package/dist/tools/tier2/inspect-fonts.d.ts +6 -0
- package/dist/tools/tier2/inspect-fonts.d.ts.map +1 -0
- package/dist/tools/tier2/inspect-fonts.js +54 -0
- package/dist/tools/tier2/inspect-fonts.js.map +1 -0
- package/dist/tools/tier2/inspect-signatures.d.ts +6 -0
- package/dist/tools/tier2/inspect-signatures.d.ts.map +1 -0
- package/dist/tools/tier2/inspect-signatures.js +48 -0
- package/dist/tools/tier2/inspect-signatures.js.map +1 -0
- package/dist/tools/tier2/inspect-structure.d.ts +6 -0
- package/dist/tools/tier2/inspect-structure.d.ts.map +1 -0
- package/dist/tools/tier2/inspect-structure.js +46 -0
- package/dist/tools/tier2/inspect-structure.js.map +1 -0
- package/dist/tools/tier2/inspect-tags.d.ts +6 -0
- package/dist/tools/tier2/inspect-tags.d.ts.map +1 -0
- package/dist/tools/tier2/inspect-tags.js +46 -0
- package/dist/tools/tier2/inspect-tags.js.map +1 -0
- package/dist/tools/tier3/compare-structure.d.ts +6 -0
- package/dist/tools/tier3/compare-structure.d.ts.map +1 -0
- package/dist/tools/tier3/compare-structure.js +47 -0
- package/dist/tools/tier3/compare-structure.js.map +1 -0
- package/dist/tools/tier3/validate-metadata.d.ts +6 -0
- package/dist/tools/tier3/validate-metadata.d.ts.map +1 -0
- package/dist/tools/tier3/validate-metadata.js +57 -0
- package/dist/tools/tier3/validate-metadata.js.map +1 -0
- package/dist/tools/tier3/validate-tagged.d.ts +6 -0
- package/dist/tools/tier3/validate-tagged.d.ts.map +1 -0
- package/dist/tools/tier3/validate-tagged.js +56 -0
- package/dist/tools/tier3/validate-tagged.js.map +1 -0
- package/dist/types.d.ts +226 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/batch-processor.d.ts +60 -0
- package/dist/utils/batch-processor.d.ts.map +1 -0
- package/dist/utils/batch-processor.js +72 -0
- package/dist/utils/batch-processor.js.map +1 -0
- package/dist/utils/error-handler.d.ts +23 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +76 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/formatter.d.ts +64 -0
- package/dist/utils/formatter.d.ts.map +1 -0
- package/dist/utils/formatter.js +379 -0
- package/dist/utils/formatter.js.map +1 -0
- package/dist/utils/pdf-helpers.d.ts +22 -0
- package/dist/utils/pdf-helpers.d.ts.map +1 -0
- package/dist/utils/pdf-helpers.js +68 -0
- package/dist/utils/pdf-helpers.js.map +1 -0
- package/package.json +78 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pdf-reader-mcp shared type definitions
|
|
3
|
+
*/
|
|
4
|
+
/** Metadata extracted from a PDF document */
|
|
5
|
+
export interface PdfMetadata {
|
|
6
|
+
title: string | null;
|
|
7
|
+
author: string | null;
|
|
8
|
+
subject: string | null;
|
|
9
|
+
keywords: string | null;
|
|
10
|
+
creator: string | null;
|
|
11
|
+
producer: string | null;
|
|
12
|
+
creationDate: string | null;
|
|
13
|
+
modificationDate: string | null;
|
|
14
|
+
pageCount: number;
|
|
15
|
+
pdfVersion: string | null;
|
|
16
|
+
isLinearized: boolean;
|
|
17
|
+
isEncrypted: boolean;
|
|
18
|
+
isTagged: boolean;
|
|
19
|
+
hasSignatures: boolean;
|
|
20
|
+
fileSize: number;
|
|
21
|
+
}
|
|
22
|
+
/** A single page's extracted text */
|
|
23
|
+
export interface PageText {
|
|
24
|
+
page: number;
|
|
25
|
+
text: string;
|
|
26
|
+
}
|
|
27
|
+
/** A search match within a PDF */
|
|
28
|
+
export interface SearchMatch {
|
|
29
|
+
page: number;
|
|
30
|
+
lineIndex: number;
|
|
31
|
+
text: string;
|
|
32
|
+
contextBefore: string;
|
|
33
|
+
contextAfter: string;
|
|
34
|
+
}
|
|
35
|
+
/** Search results response */
|
|
36
|
+
export interface SearchResult {
|
|
37
|
+
query: string;
|
|
38
|
+
totalMatches: number;
|
|
39
|
+
matches: SearchMatch[];
|
|
40
|
+
truncated: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** An extracted image from a PDF page */
|
|
43
|
+
export interface ExtractedImage {
|
|
44
|
+
page: number;
|
|
45
|
+
index: number;
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
colorSpace: string;
|
|
49
|
+
bitsPerComponent: number;
|
|
50
|
+
dataBase64: string;
|
|
51
|
+
}
|
|
52
|
+
/** Result of image extraction including detected vs extracted counts */
|
|
53
|
+
export interface ImageExtractionResult {
|
|
54
|
+
images: ExtractedImage[];
|
|
55
|
+
detectedCount: number;
|
|
56
|
+
extractedCount: number;
|
|
57
|
+
skippedCount: number;
|
|
58
|
+
}
|
|
59
|
+
/** Summary report of a PDF document */
|
|
60
|
+
export interface PdfSummary {
|
|
61
|
+
filePath: string;
|
|
62
|
+
metadata: PdfMetadata;
|
|
63
|
+
textPreview: string;
|
|
64
|
+
imageCount: number;
|
|
65
|
+
hasText: boolean;
|
|
66
|
+
}
|
|
67
|
+
/** Catalog entry info */
|
|
68
|
+
export interface CatalogEntry {
|
|
69
|
+
key: string;
|
|
70
|
+
type: string;
|
|
71
|
+
value: string;
|
|
72
|
+
}
|
|
73
|
+
/** Page tree statistics */
|
|
74
|
+
export interface PageTreeInfo {
|
|
75
|
+
totalPages: number;
|
|
76
|
+
mediaBoxSamples: Array<{
|
|
77
|
+
page: number;
|
|
78
|
+
width: number;
|
|
79
|
+
height: number;
|
|
80
|
+
}>;
|
|
81
|
+
}
|
|
82
|
+
/** Object statistics */
|
|
83
|
+
export interface ObjectStats {
|
|
84
|
+
totalObjects: number;
|
|
85
|
+
streamCount: number;
|
|
86
|
+
byType: Record<string, number>;
|
|
87
|
+
}
|
|
88
|
+
/** inspect_structure output */
|
|
89
|
+
export interface StructureAnalysis {
|
|
90
|
+
catalog: CatalogEntry[];
|
|
91
|
+
pageTree: PageTreeInfo;
|
|
92
|
+
objectStats: ObjectStats;
|
|
93
|
+
isEncrypted: boolean;
|
|
94
|
+
pdfVersion: string | null;
|
|
95
|
+
}
|
|
96
|
+
/** Tag tree node */
|
|
97
|
+
export interface TagNode {
|
|
98
|
+
role: string;
|
|
99
|
+
children: TagNode[];
|
|
100
|
+
contentCount: number;
|
|
101
|
+
}
|
|
102
|
+
/** inspect_tags output */
|
|
103
|
+
export interface TagsAnalysis {
|
|
104
|
+
isTagged: boolean;
|
|
105
|
+
rootTag: TagNode | null;
|
|
106
|
+
maxDepth: number;
|
|
107
|
+
totalElements: number;
|
|
108
|
+
roleCounts: Record<string, number>;
|
|
109
|
+
}
|
|
110
|
+
/** Font information */
|
|
111
|
+
export interface FontInfo {
|
|
112
|
+
name: string;
|
|
113
|
+
type: string;
|
|
114
|
+
encoding: string | null;
|
|
115
|
+
isEmbedded: boolean;
|
|
116
|
+
isSubset: boolean;
|
|
117
|
+
pagesUsed: number[];
|
|
118
|
+
}
|
|
119
|
+
/** inspect_fonts output */
|
|
120
|
+
export interface FontsAnalysis {
|
|
121
|
+
fonts: FontInfo[];
|
|
122
|
+
totalFontCount: number;
|
|
123
|
+
embeddedCount: number;
|
|
124
|
+
subsetCount: number;
|
|
125
|
+
pagesScanned: number;
|
|
126
|
+
}
|
|
127
|
+
/** Annotation information */
|
|
128
|
+
export interface AnnotationInfo {
|
|
129
|
+
subtype: string;
|
|
130
|
+
page: number;
|
|
131
|
+
rect: number[] | null;
|
|
132
|
+
contents: string | null;
|
|
133
|
+
author: string | null;
|
|
134
|
+
modificationDate: string | null;
|
|
135
|
+
hasAppearance: boolean;
|
|
136
|
+
}
|
|
137
|
+
/** inspect_annotations output */
|
|
138
|
+
export interface AnnotationsAnalysis {
|
|
139
|
+
totalAnnotations: number;
|
|
140
|
+
bySubtype: Record<string, number>;
|
|
141
|
+
byPage: Record<number, number>;
|
|
142
|
+
annotations: AnnotationInfo[];
|
|
143
|
+
hasLinks: boolean;
|
|
144
|
+
hasForms: boolean;
|
|
145
|
+
hasMarkup: boolean;
|
|
146
|
+
}
|
|
147
|
+
/** Signature field information */
|
|
148
|
+
export interface SignatureFieldInfo {
|
|
149
|
+
fieldName: string;
|
|
150
|
+
isSigned: boolean;
|
|
151
|
+
signerName: string | null;
|
|
152
|
+
reason: string | null;
|
|
153
|
+
location: string | null;
|
|
154
|
+
contactInfo: string | null;
|
|
155
|
+
signingTime: string | null;
|
|
156
|
+
filter: string | null;
|
|
157
|
+
subFilter: string | null;
|
|
158
|
+
}
|
|
159
|
+
/** inspect_signatures output */
|
|
160
|
+
export interface SignaturesAnalysis {
|
|
161
|
+
totalFields: number;
|
|
162
|
+
signedCount: number;
|
|
163
|
+
unsignedCount: number;
|
|
164
|
+
fields: SignatureFieldInfo[];
|
|
165
|
+
note: string;
|
|
166
|
+
}
|
|
167
|
+
/** Severity level for validation issues */
|
|
168
|
+
export type ValidationSeverity = 'error' | 'warning' | 'info';
|
|
169
|
+
/** A single validation issue */
|
|
170
|
+
export interface ValidationIssue {
|
|
171
|
+
severity: ValidationSeverity;
|
|
172
|
+
code: string;
|
|
173
|
+
message: string;
|
|
174
|
+
details?: string;
|
|
175
|
+
}
|
|
176
|
+
/** validate_tagged output */
|
|
177
|
+
export interface TaggedValidation {
|
|
178
|
+
isTagged: boolean;
|
|
179
|
+
totalChecks: number;
|
|
180
|
+
passed: number;
|
|
181
|
+
failed: number;
|
|
182
|
+
warnings: number;
|
|
183
|
+
issues: ValidationIssue[];
|
|
184
|
+
summary: string;
|
|
185
|
+
}
|
|
186
|
+
/** validate_metadata output */
|
|
187
|
+
export interface MetadataValidation {
|
|
188
|
+
totalChecks: number;
|
|
189
|
+
passed: number;
|
|
190
|
+
failed: number;
|
|
191
|
+
warnings: number;
|
|
192
|
+
issues: ValidationIssue[];
|
|
193
|
+
metadata: {
|
|
194
|
+
hasTitle: boolean;
|
|
195
|
+
hasAuthor: boolean;
|
|
196
|
+
hasSubject: boolean;
|
|
197
|
+
hasKeywords: boolean;
|
|
198
|
+
hasCreator: boolean;
|
|
199
|
+
hasProducer: boolean;
|
|
200
|
+
hasCreationDate: boolean;
|
|
201
|
+
hasModificationDate: boolean;
|
|
202
|
+
pdfVersion: string | null;
|
|
203
|
+
isTagged: boolean;
|
|
204
|
+
};
|
|
205
|
+
summary: string;
|
|
206
|
+
}
|
|
207
|
+
/** Diff entry for structure comparison */
|
|
208
|
+
export interface StructureDiffEntry {
|
|
209
|
+
property: string;
|
|
210
|
+
file1Value: string;
|
|
211
|
+
file2Value: string;
|
|
212
|
+
status: 'match' | 'differ';
|
|
213
|
+
}
|
|
214
|
+
/** compare_structure output */
|
|
215
|
+
export interface StructureComparison {
|
|
216
|
+
file1: string;
|
|
217
|
+
file2: string;
|
|
218
|
+
diffs: StructureDiffEntry[];
|
|
219
|
+
fontComparison: {
|
|
220
|
+
onlyInFile1: string[];
|
|
221
|
+
onlyInFile2: string[];
|
|
222
|
+
inBoth: string[];
|
|
223
|
+
};
|
|
224
|
+
summary: string;
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,6CAA6C;AAC7C,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,C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mBAAmB,EAAE,OAAO,CAAC;QAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,QAAQ,EAAE,OAAO,CAAC;KACnB,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC5B;AAED,+BAA+B;AAC/B,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,cAAc,EAAE;QACd,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,MAAM,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch processing utility for large PDFs.
|
|
3
|
+
*
|
|
4
|
+
* Processes pages in configurable batches to balance parallelism
|
|
5
|
+
* with memory usage. Within each batch, pages are processed in
|
|
6
|
+
* parallel using Promise.all. Batches run sequentially to avoid
|
|
7
|
+
* excessive memory consumption on large documents.
|
|
8
|
+
*/
|
|
9
|
+
/** Default batch size — balances parallelism and memory */
|
|
10
|
+
export declare const DEFAULT_BATCH_SIZE = 10;
|
|
11
|
+
/**
|
|
12
|
+
* Process an array of items in parallel batches.
|
|
13
|
+
*
|
|
14
|
+
* @param items Array of items to process (e.g., page numbers).
|
|
15
|
+
* @param processor Async function that processes a single item and returns a result.
|
|
16
|
+
* @param batchSize Number of items to process concurrently in each batch.
|
|
17
|
+
* @returns Array of results in the same order as the input items.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const pageTexts = await processInBatches(
|
|
22
|
+
* [1, 2, 3, ..., 200],
|
|
23
|
+
* async (pageNum) => {
|
|
24
|
+
* const page = await doc.getPage(pageNum);
|
|
25
|
+
* return extractPageText(page);
|
|
26
|
+
* },
|
|
27
|
+
* 10, // 10 pages at a time
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function processInBatches<T, R>(items: T[], processor: (item: T) => Promise<R>, batchSize?: number): Promise<R[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Process items in parallel batches and reduce into a single value.
|
|
34
|
+
*
|
|
35
|
+
* Useful when each item produces a partial result that must be merged
|
|
36
|
+
* (e.g., per-page image counts summed into a total).
|
|
37
|
+
*
|
|
38
|
+
* @param items Array of items to process.
|
|
39
|
+
* @param processor Async function that processes a single item.
|
|
40
|
+
* @param reducer Function that merges two results into one.
|
|
41
|
+
* @param initial Initial value for the reduction.
|
|
42
|
+
* @param batchSize Number of items to process concurrently in each batch.
|
|
43
|
+
* @returns The fully reduced result.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const totalImages = await processAndReduce(
|
|
48
|
+
* pageNumbers,
|
|
49
|
+
* async (pageNum) => {
|
|
50
|
+
* const page = await doc.getPage(pageNum);
|
|
51
|
+
* const ops = await page.getOperatorList();
|
|
52
|
+
* return ops.fnArray.filter(op => op === OPS.paintImageXObject).length;
|
|
53
|
+
* },
|
|
54
|
+
* (sum, count) => sum + count,
|
|
55
|
+
* 0,
|
|
56
|
+
* );
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare function processAndReduce<T, R>(items: T[], processor: (item: T) => Promise<R>, reducer: (acc: R, current: R) => R, initial: R, batchSize?: number): Promise<R>;
|
|
60
|
+
//# sourceMappingURL=batch-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-processor.d.ts","sourceRoot":"","sources":["../../src/utils/batch-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2DAA2D;AAC3D,eAAO,MAAM,kBAAkB,KAAK,CAAC;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EACzC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAClC,SAAS,GAAE,MAA2B,GACrC,OAAO,CAAC,CAAC,EAAE,CAAC,CAWd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EACzC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAClC,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,EAClC,OAAO,EAAE,CAAC,EACV,SAAS,GAAE,MAA2B,GACrC,OAAO,CAAC,CAAC,CAAC,CAGZ"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch processing utility for large PDFs.
|
|
3
|
+
*
|
|
4
|
+
* Processes pages in configurable batches to balance parallelism
|
|
5
|
+
* with memory usage. Within each batch, pages are processed in
|
|
6
|
+
* parallel using Promise.all. Batches run sequentially to avoid
|
|
7
|
+
* excessive memory consumption on large documents.
|
|
8
|
+
*/
|
|
9
|
+
/** Default batch size — balances parallelism and memory */
|
|
10
|
+
export const DEFAULT_BATCH_SIZE = 10;
|
|
11
|
+
/**
|
|
12
|
+
* Process an array of items in parallel batches.
|
|
13
|
+
*
|
|
14
|
+
* @param items Array of items to process (e.g., page numbers).
|
|
15
|
+
* @param processor Async function that processes a single item and returns a result.
|
|
16
|
+
* @param batchSize Number of items to process concurrently in each batch.
|
|
17
|
+
* @returns Array of results in the same order as the input items.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const pageTexts = await processInBatches(
|
|
22
|
+
* [1, 2, 3, ..., 200],
|
|
23
|
+
* async (pageNum) => {
|
|
24
|
+
* const page = await doc.getPage(pageNum);
|
|
25
|
+
* return extractPageText(page);
|
|
26
|
+
* },
|
|
27
|
+
* 10, // 10 pages at a time
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export async function processInBatches(items, processor, batchSize = DEFAULT_BATCH_SIZE) {
|
|
32
|
+
const results = [];
|
|
33
|
+
const effectiveBatchSize = Math.max(1, batchSize);
|
|
34
|
+
for (let i = 0; i < items.length; i += effectiveBatchSize) {
|
|
35
|
+
const batch = items.slice(i, i + effectiveBatchSize);
|
|
36
|
+
const batchResults = await Promise.all(batch.map(processor));
|
|
37
|
+
results.push(...batchResults);
|
|
38
|
+
}
|
|
39
|
+
return results;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Process items in parallel batches and reduce into a single value.
|
|
43
|
+
*
|
|
44
|
+
* Useful when each item produces a partial result that must be merged
|
|
45
|
+
* (e.g., per-page image counts summed into a total).
|
|
46
|
+
*
|
|
47
|
+
* @param items Array of items to process.
|
|
48
|
+
* @param processor Async function that processes a single item.
|
|
49
|
+
* @param reducer Function that merges two results into one.
|
|
50
|
+
* @param initial Initial value for the reduction.
|
|
51
|
+
* @param batchSize Number of items to process concurrently in each batch.
|
|
52
|
+
* @returns The fully reduced result.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const totalImages = await processAndReduce(
|
|
57
|
+
* pageNumbers,
|
|
58
|
+
* async (pageNum) => {
|
|
59
|
+
* const page = await doc.getPage(pageNum);
|
|
60
|
+
* const ops = await page.getOperatorList();
|
|
61
|
+
* return ops.fnArray.filter(op => op === OPS.paintImageXObject).length;
|
|
62
|
+
* },
|
|
63
|
+
* (sum, count) => sum + count,
|
|
64
|
+
* 0,
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export async function processAndReduce(items, processor, reducer, initial, batchSize = DEFAULT_BATCH_SIZE) {
|
|
69
|
+
const results = await processInBatches(items, processor, batchSize);
|
|
70
|
+
return results.reduce(reducer, initial);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=batch-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-processor.js","sourceRoot":"","sources":["../../src/utils/batch-processor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2DAA2D;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAU,EACV,SAAkC,EAClC,YAAoB,kBAAkB;IAEtC,MAAM,OAAO,GAAQ,EAAE,CAAC;IACxB,MAAM,kBAAkB,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAElD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,kBAAkB,EAAE,CAAC;QAC1D,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC;QACrD,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;QAC7D,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,KAAU,EACV,SAAkC,EAClC,OAAkC,EAClC,OAAU,EACV,YAAoB,kBAAkB;IAEtC,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACpE,OAAO,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified error handling for pdf-reader-mcp
|
|
3
|
+
*/
|
|
4
|
+
export declare class PdfReaderError extends Error {
|
|
5
|
+
readonly code: string;
|
|
6
|
+
readonly suggestion?: string | undefined;
|
|
7
|
+
constructor(message: string, code: string, suggestion?: string | undefined);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Handle errors and return user-friendly messages with actionable suggestions.
|
|
11
|
+
*/
|
|
12
|
+
export declare function handleError(error: unknown): string;
|
|
13
|
+
/**
|
|
14
|
+
* Validate that a file path points to a PDF.
|
|
15
|
+
*
|
|
16
|
+
* Security checks:
|
|
17
|
+
* - Path must be non-empty
|
|
18
|
+
* - Path must be absolute (prevents relative path traversal)
|
|
19
|
+
* - Path must not contain `..` segments after normalization
|
|
20
|
+
* - Path must have a `.pdf` extension
|
|
21
|
+
*/
|
|
22
|
+
export declare function validatePdfPath(filePath: string): void;
|
|
23
|
+
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,qBAAa,cAAe,SAAQ,KAAK;aAGrB,IAAI,EAAE,MAAM;aACZ,UAAU,CAAC,EAAE,MAAM;gBAFnC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,YAAA;CAKtC;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAyClD;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAiCtD"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified error handling for pdf-reader-mcp
|
|
3
|
+
*/
|
|
4
|
+
import { isAbsolute, normalize } from 'node:path';
|
|
5
|
+
export class PdfReaderError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
suggestion;
|
|
8
|
+
constructor(message, code, suggestion) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.suggestion = suggestion;
|
|
12
|
+
this.name = 'PdfReaderError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Handle errors and return user-friendly messages with actionable suggestions.
|
|
17
|
+
*/
|
|
18
|
+
export function handleError(error) {
|
|
19
|
+
if (error instanceof PdfReaderError) {
|
|
20
|
+
let msg = `Error: ${error.message}`;
|
|
21
|
+
if (error.suggestion) {
|
|
22
|
+
msg += `\n\nSuggestion: ${error.suggestion}`;
|
|
23
|
+
}
|
|
24
|
+
return msg;
|
|
25
|
+
}
|
|
26
|
+
if (error instanceof Error) {
|
|
27
|
+
const message = error.message;
|
|
28
|
+
// File not found
|
|
29
|
+
if (message.includes('ENOENT') || message.includes('no such file')) {
|
|
30
|
+
return 'Error: File not found. Please check the file path is correct and the file exists.';
|
|
31
|
+
}
|
|
32
|
+
// Permission denied
|
|
33
|
+
if (message.includes('EACCES') || message.includes('permission denied')) {
|
|
34
|
+
return 'Error: Permission denied. Please check file permissions.';
|
|
35
|
+
}
|
|
36
|
+
// Invalid PDF
|
|
37
|
+
if (message.includes('Invalid PDF') || message.includes('PDF header not found')) {
|
|
38
|
+
return 'Error: The file does not appear to be a valid PDF. Please check the file is not corrupted.';
|
|
39
|
+
}
|
|
40
|
+
// Encrypted PDF
|
|
41
|
+
if (message.includes('password') || message.includes('encrypted')) {
|
|
42
|
+
return 'Error: This PDF is password-protected. Encrypted PDFs are not currently supported.';
|
|
43
|
+
}
|
|
44
|
+
// File too large
|
|
45
|
+
if (message.includes('too large') || message.includes('MAX_FILE_SIZE')) {
|
|
46
|
+
return 'Error: File exceeds the 50MB size limit. Try splitting the PDF into smaller parts.';
|
|
47
|
+
}
|
|
48
|
+
return `Error: ${message}`;
|
|
49
|
+
}
|
|
50
|
+
return `Error: An unexpected error occurred: ${String(error)}`;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Validate that a file path points to a PDF.
|
|
54
|
+
*
|
|
55
|
+
* Security checks:
|
|
56
|
+
* - Path must be non-empty
|
|
57
|
+
* - Path must be absolute (prevents relative path traversal)
|
|
58
|
+
* - Path must not contain `..` segments after normalization
|
|
59
|
+
* - Path must have a `.pdf` extension
|
|
60
|
+
*/
|
|
61
|
+
export function validatePdfPath(filePath) {
|
|
62
|
+
if (!filePath) {
|
|
63
|
+
throw new PdfReaderError('File path is required.', 'MISSING_PATH', 'Provide a valid file path to a PDF document.');
|
|
64
|
+
}
|
|
65
|
+
if (!isAbsolute(filePath)) {
|
|
66
|
+
throw new PdfReaderError('File path must be absolute.', 'RELATIVE_PATH', 'Provide an absolute file path (e.g., /home/user/document.pdf).');
|
|
67
|
+
}
|
|
68
|
+
const normalized = normalize(filePath);
|
|
69
|
+
if (normalized.includes('..')) {
|
|
70
|
+
throw new PdfReaderError('Path traversal is not allowed.', 'PATH_TRAVERSAL', 'Provide a direct absolute path without ".." segments.');
|
|
71
|
+
}
|
|
72
|
+
if (!normalized.toLowerCase().endsWith('.pdf')) {
|
|
73
|
+
throw new PdfReaderError(`Expected a .pdf file, got: ${filePath}`, 'INVALID_EXTENSION', 'Ensure the file has a .pdf extension.');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@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 -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response formatting utilities for Markdown and JSON output.
|
|
3
|
+
*/
|
|
4
|
+
import type { AnnotationsAnalysis, FontsAnalysis, MetadataValidation, PageText, PdfMetadata, PdfSummary, SearchResult, SignaturesAnalysis, StructureAnalysis, StructureComparison, TaggedValidation, TagsAnalysis } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Truncate text to CHARACTER_LIMIT with a notice.
|
|
7
|
+
*/
|
|
8
|
+
export declare function truncateIfNeeded(text: string): {
|
|
9
|
+
text: string;
|
|
10
|
+
truncated: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Format metadata as Markdown.
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatMetadataMarkdown(meta: PdfMetadata): string;
|
|
16
|
+
/**
|
|
17
|
+
* Format page texts as Markdown.
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatPageTextsMarkdown(pages: PageText[]): string;
|
|
20
|
+
/**
|
|
21
|
+
* Format search results as Markdown.
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatSearchResultMarkdown(result: SearchResult): string;
|
|
24
|
+
/**
|
|
25
|
+
* Format summary as Markdown.
|
|
26
|
+
*/
|
|
27
|
+
export declare function formatSummaryMarkdown(summary: PdfSummary): string;
|
|
28
|
+
/**
|
|
29
|
+
* Format structure analysis as Markdown.
|
|
30
|
+
*/
|
|
31
|
+
export declare function formatStructureMarkdown(analysis: StructureAnalysis): string;
|
|
32
|
+
/**
|
|
33
|
+
* Format tags analysis as Markdown.
|
|
34
|
+
*/
|
|
35
|
+
export declare function formatTagsMarkdown(analysis: TagsAnalysis): string;
|
|
36
|
+
/**
|
|
37
|
+
* Format fonts analysis as Markdown.
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatFontsMarkdown(analysis: FontsAnalysis): string;
|
|
40
|
+
/**
|
|
41
|
+
* Format annotations analysis as Markdown.
|
|
42
|
+
*/
|
|
43
|
+
export declare function formatAnnotationsMarkdown(analysis: AnnotationsAnalysis): string;
|
|
44
|
+
/**
|
|
45
|
+
* Format signatures analysis as Markdown.
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatSignaturesMarkdown(analysis: SignaturesAnalysis): string;
|
|
48
|
+
/**
|
|
49
|
+
* Format file size in human-readable form.
|
|
50
|
+
*/
|
|
51
|
+
export declare function formatFileSize(bytes: number): string;
|
|
52
|
+
/**
|
|
53
|
+
* Format tagged validation results as Markdown.
|
|
54
|
+
*/
|
|
55
|
+
export declare function formatTaggedValidationMarkdown(result: TaggedValidation): string;
|
|
56
|
+
/**
|
|
57
|
+
* Format metadata validation results as Markdown.
|
|
58
|
+
*/
|
|
59
|
+
export declare function formatMetadataValidationMarkdown(result: MetadataValidation): string;
|
|
60
|
+
/**
|
|
61
|
+
* Format structure comparison results as Markdown.
|
|
62
|
+
*/
|
|
63
|
+
export declare function formatCompareStructureMarkdown(result: StructureComparison): string;
|
|
64
|
+
//# sourceMappingURL=formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../../src/utils/formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EAEnB,gBAAgB,EAChB,YAAY,EACb,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAWnF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CA6BhE;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM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