@remcp/runtime 0.2.152 → 0.2.154

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.
@@ -20,392 +20,9 @@ import {
20
20
  unavailable,
21
21
  } from './common.mjs';
22
22
 
23
- function xmlEscape(value) {
24
- return String(value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;');
25
- }
26
- function xmlUnescape(value) {
27
- return String(value).replace(/&lt;/g, '<').replace(/&gt;/g, '>').replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, '&');
28
- }
29
-
30
- const MAX_OOXML_ENTRIES = 10_000;
31
- const MAX_OOXML_UNCOMPRESSED_BYTES = 512 * 1024 * 1024;
32
- const MAX_DOCUMENT_BYTES = 128 * 1024 * 1024;
33
- const DOCUMENT_READ_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW || 0) | (constants.O_NONBLOCK || 0);
34
-
35
- function descriptorAnchorsAvailable() {
36
- return process.platform === 'linux' && Boolean(constants.O_NOFOLLOW) && Boolean(constants.O_DIRECTORY);
37
- }
38
-
39
- async function openDocumentSource(filePath) {
40
- if (!descriptorAnchorsAvailable()) {
41
- const handle = await open(filePath, DOCUMENT_READ_FLAGS);
42
- try {
43
- const info = await handle.stat();
44
- if (!info.isFile()) throw new Error('Document path must be a regular file');
45
- return { handle, close: () => handle.close() };
46
- } catch (error) {
47
- await handle.close().catch(() => {});
48
- throw error;
49
- }
50
- }
51
- const parent = await openDirectoryPath(path.dirname(filePath));
52
- let handle;
53
- try {
54
- handle = await open(path.join(parent.anchor, path.basename(filePath)), DOCUMENT_READ_FLAGS);
55
- const info = await handle.stat();
56
- if (!info.isFile()) throw new Error('Document path must be a regular file');
57
- return {
58
- handle,
59
- close: async () => {
60
- try { await handle.close(); }
61
- finally { await parent.close().catch(() => {}); }
62
- },
63
- };
64
- } catch (error) {
65
- if (handle) await handle.close().catch(() => {});
66
- await parent.close().catch(() => {});
67
- throw error;
68
- }
69
- }
70
-
71
- async function openDocumentDirectoryPath(directory, { create = false } = {}) {
72
- const opened = await openDirectoryPath(directory, { create });
73
- return { ...opened, descriptorBound:opened.anchor !== directory || process.platform === 'linux' };
74
- }
75
-
76
- async function createAnchoredTempDirectory(parent, prefix) {
77
- const directory = await openDocumentDirectoryPath(parent, { create:true });
78
- try {
79
- const childAnchor = directory.descriptorBound === false
80
- ? directory.anchor
81
- : directory.anchor.replace('/proc/self/fd/', `/proc/${process.pid}/fd/`);
82
- const directoryPath = await mkdtemp(path.join(childAnchor, prefix));
83
- return { path:directoryPath, close:directory.close };
84
- } catch (error) {
85
- await directory.close().catch(() => {});
86
- throw error;
87
- }
88
- }
89
-
90
- async function readBounded(handle, maximum, label) {
91
- const chunks = [];
92
- const buffer = Buffer.allocUnsafe(1024 * 1024);
93
- let offset = 0;
94
- for (;;) {
95
- const { bytesRead } = await handle.read(buffer, 0, buffer.length, offset);
96
- if (!bytesRead) break;
97
- if (!Number.isSafeInteger(offset + bytesRead) || offset + bytesRead > maximum) {
98
- throw new Error(`${label} exceeds the ${maximum}-byte safety limit`);
99
- }
100
- chunks.push(Buffer.from(buffer.subarray(0, bytesRead)));
101
- offset += bytesRead;
102
- }
103
- return Buffer.concat(chunks, offset);
104
- }
105
-
106
- async function readDocumentFile(filePath) {
107
- const opened = await openDocumentSource(filePath);
108
- try {
109
- const info = await opened.handle.stat();
110
- if (!info.isFile()) throw new Error('Document path must be a regular file');
111
- if (info.size > MAX_DOCUMENT_BYTES) throw new Error(`Document is too large (maximum ${MAX_DOCUMENT_BYTES} bytes)`);
112
- return await readBounded(opened.handle, MAX_DOCUMENT_BYTES, 'Document');
113
- } finally {
114
- await opened.close();
115
- }
116
- }
117
-
118
- async function copyRegularNoFollow(source, destination) {
119
- const opened = await openDocumentSource(source);
120
- try {
121
- const info = await opened.handle.stat();
122
- if (!info.isFile()) throw new Error('Document path must be a regular file');
123
- if (info.size > MAX_DOCUMENT_BYTES) throw new Error(`Document is too large (maximum ${MAX_DOCUMENT_BYTES} bytes)`);
124
- const destinationHandle = await open(destination, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | (constants.O_NOFOLLOW || 0), 0o600);
125
- try {
126
- const data = await readBounded(opened.handle, MAX_DOCUMENT_BYTES, 'Document');
127
- await destinationHandle.writeFile(data);
128
- } finally {
129
- await destinationHandle.close();
130
- }
131
- } finally {
132
- await opened.close();
133
- }
134
- }
135
-
136
- async function snapshotDocumentFile(filePath) {
137
- const dir = await tempDir('remcp-pdf-input-');
138
- const snapshot = path.join(dir, `input-${randomUUID()}.pdf`);
139
- try {
140
- await copyRegularNoFollow(filePath, snapshot);
141
- return { dir, path: snapshot };
142
- } catch (error) {
143
- await removeTemp(dir);
144
- throw error;
145
- }
146
- }
147
-
148
- async function assertSafeExtractedTree(root, state = { entries: 0 }) {
149
- const info = await lstat(root);
150
- if (info.isSymbolicLink()) throw new Error('OOXML archive contains a symbolic link');
151
- if (!info.isDirectory() && !info.isFile()) throw new Error('OOXML archive contains a special file');
152
- state.entries += 1;
153
- if (state.entries > MAX_OOXML_ENTRIES) throw new Error('OOXML archive has too many extracted entries');
154
- if (!info.isDirectory()) return;
155
- for (const entry of await readdir(root, { withFileTypes: true })) {
156
- await assertSafeExtractedTree(path.join(root, entry.name), state);
157
- }
158
- }
159
-
160
- function safePdfPattern(value, fallback) {
161
- const pattern = String(value || fallback);
162
- if (!pattern || pattern.length > 240 || pattern.includes('\0') || path.isAbsolute(pattern) || /[\\/]/.test(pattern) || pattern.split(/[\\/]/).includes('..')) {
163
- throw new Error('PDF split pattern must be a filename without path separators');
164
- }
165
- return pattern;
166
- }
167
-
168
- function safeArchiveEntry(name) {
169
- const normalized = String(name || '').replace(/\\/g, '/');
170
- if (!normalized || normalized.startsWith('/') || /^[A-Za-z]:\//.test(normalized)) return false;
171
- return !normalized.split('/').includes('..');
172
- }
173
-
174
- async function validateZipArchive(source) {
175
- if (process.platform === 'win32') {
176
- const script = `Add-Type -AssemblyName System.IO.Compression.FileSystem;$z=[IO.Compression.ZipFile]::OpenRead('${escapePowerShellSingle(source)}');try{$count=$z.Entries.Count;$total=0;foreach($e in $z.Entries){$n=$e.FullName.Replace('\\','/');if([IO.Path]::IsPathRooted($n) -or $n.StartsWith('/') -or ($n.Split('/') -contains '..')){throw ('unsafe archive path: '+$n)};$total += $e.Length};if($count -gt ${MAX_OOXML_ENTRIES}){throw 'too many archive entries'};if($total -gt ${MAX_OOXML_UNCOMPRESSED_BYTES}){throw 'archive expands beyond the OOXML limit'};[pscustomobject]@{count=$count;total=$total}|ConvertTo-Json -Compress}finally{$z.Dispose()}`;
177
- await runPowerShell(script, { label:'validate OOXML archive', timeout:30_000 });
178
- return;
179
- }
180
- if (!commandExists('unzip')) unavailable('OOXML document editing', 'unzip is required');
181
- const names = await runFile('unzip', ['-Z','-1',source], { label:'inspect OOXML archive', timeout:30_000, maxBuffer:16 * 1024 * 1024 });
182
- const entries = names.stdout.split(/\r?\n/).filter(Boolean);
183
- if (entries.length > MAX_OOXML_ENTRIES) throw new Error(`OOXML archive has too many entries (${entries.length}; max ${MAX_OOXML_ENTRIES})`);
184
- const unsafe = entries.find(name => !safeArchiveEntry(name));
185
- if (unsafe) throw new Error(`OOXML archive contains an unsafe path: ${unsafe}`);
186
- const details = await runFile('unzip', ['-Z','-v',source], { label:'inspect OOXML entry types', timeout:30_000, maxBuffer:16 * 1024 * 1024 });
187
- if (/symbolic link|Unix file attributes \([^)]*\b12\d{4}/i.test(details.stdout)) throw new Error('OOXML archive contains a symbolic link');
188
- const totals = await runFile('unzip', ['-Z','-t',source], { label:'inspect OOXML archive size', timeout:30_000 });
189
- const uncompressed = Number(totals.stdout.match(/(?:^|,\s)([0-9]+) bytes uncompressed/)?.[1] || 0);
190
- if (uncompressed > MAX_OOXML_UNCOMPRESSED_BYTES) throw new Error(`OOXML archive expands to ${uncompressed} bytes; max ${MAX_OOXML_UNCOMPRESSED_BYTES}`);
191
- }
192
-
193
- async function extractZip(source, destination) {
194
- const sourceDirectory = await tempDir('remcp-ooxml-source-');
195
- const sourceCopy = path.join(sourceDirectory, 'source.zip');
196
- try {
197
- await copyRegularNoFollow(source, sourceCopy);
198
- await validateZipArchive(sourceCopy);
199
- await mkdir(destination, { recursive:true });
200
- if (process.platform === 'win32') {
201
- await runPowerShell(`Add-Type -AssemblyName System.IO.Compression.FileSystem;[IO.Compression.ZipFile]::ExtractToDirectory('${escapePowerShellSingle(sourceCopy)}','${escapePowerShellSingle(destination)}')`, { label:'extract OOXML archive', timeout:30_000 });
202
- } else {
203
- if (!commandExists('unzip')) unavailable('OOXML document editing', 'unzip is required');
204
- await runFile('unzip', ['-qq',sourceCopy,'-d',destination], { label:'extract OOXML archive', timeout:30_000 });
205
- }
206
- await assertSafeExtractedTree(destination);
207
- } finally {
208
- await removeTemp(sourceDirectory);
209
- }
210
- }
211
-
212
- async function createZip(sourceDir, destination) {
213
- await rm(destination, { force:true }).catch(() => {});
214
- if (process.platform === 'win32') {
215
- await runPowerShell(`Add-Type -AssemblyName System.IO.Compression.FileSystem;[IO.Compression.ZipFile]::CreateFromDirectory('${escapePowerShellSingle(sourceDir)}','${escapePowerShellSingle(destination)}',[IO.Compression.CompressionLevel]::Optimal,$false)`, { label:'create OOXML archive', timeout:30_000 });
216
- return;
217
- }
218
- if (!commandExists('zip')) unavailable('OOXML document editing', 'zip is required');
219
- await runFile('zip', ['-qr',destination,'.'], { cwd:sourceDir, label:'create OOXML archive', timeout:30_000 });
220
- }
221
-
222
- async function commitDocumentOutput(staged, destination, { noReplace = false } = {}) {
223
- const parentDirectory = await openDocumentDirectoryPath(path.dirname(destination));
224
- const parentAnchor = parentDirectory.anchor;
225
- const destinationPath = path.join(parentAnchor, path.basename(destination));
226
- try {
227
- if (noReplace) {
228
- await link(staged, destinationPath);
229
- await unlink(staged);
230
- return;
231
- }
232
- try {
233
- await rename(staged, destinationPath);
234
- return;
235
- } catch (error) {
236
- if (!['EEXIST', 'EPERM', 'ENOTEMPTY'].includes(error?.code)) throw error;
237
- }
238
- const backup = path.join(parentAnchor, `.${path.basename(destination)}.remcp-old-${randomUUID()}`);
239
- let moved = false;
240
- try {
241
- await rename(destinationPath, backup);
242
- moved = true;
243
- await rename(staged, destinationPath);
244
- await rm(backup, { force: true }).catch(() => {});
245
- } catch (error) {
246
- if (moved && !await lstat(destinationPath).catch(() => null)) await rename(backup, destinationPath).catch(() => {});
247
- throw error;
248
- }
249
- } finally {
250
- await parentDirectory.close().catch(() => {});
251
- }
252
- }
253
-
254
- async function ensureCreateTargetIsNew(filePath) {
255
- try {
256
- await stat(filePath);
257
- } catch (error) {
258
- if (error?.code === 'ENOENT') return;
259
- throw error;
260
- }
261
- throw new Error(`Cannot create document because path already exists: ${filePath}`);
262
- }
263
-
264
- async function writeOoxmlPart(root, relative, content) {
265
- const target = path.join(root, ...relative.split('/'));
266
- await mkdir(path.dirname(target), { recursive:true });
267
- await writeFile(target, content, 'utf8');
268
- }
269
-
270
- function newWorksheetName(value) {
271
- const name = optionalString(value) || 'Sheet1';
272
- if (name.length > 31) throw new Error('Worksheet name must be 31 characters or fewer');
273
- if (/[\\/*?:\[\]]/.test(name) || name.startsWith("'") || name.endsWith("'")) {
274
- throw new Error('Worksheet name contains characters Excel does not allow');
275
- }
276
- return name;
277
- }
278
-
279
- async function createBlankXlsxTree(root, sheetName) {
280
- const name = newWorksheetName(sheetName);
281
- await writeOoxmlPart(root, '[Content_Types].xml', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/></Types>');
282
- await writeOoxmlPart(root, '_rels/.rels', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>');
283
- await writeOoxmlPart(root, 'xl/workbook.xml', `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets><sheet name="${xmlEscape(name)}" sheetId="1" r:id="rId1"/></sheets></workbook>`);
284
- await writeOoxmlPart(root, 'xl/_rels/workbook.xml.rels', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/></Relationships>');
285
- await writeOoxmlPart(root, 'xl/worksheets/sheet1.xml', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData></sheetData></worksheet>');
286
- return name;
287
- }
288
-
289
- async function createBlankDocxTree(root) {
290
- await writeOoxmlPart(root, '[Content_Types].xml', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/></Types>');
291
- await writeOoxmlPart(root, '_rels/.rels', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/></Relationships>');
292
- await writeOoxmlPart(root, 'word/document.xml', '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><w:sectPr><w:pgSz w:w="12240" w:h="15840"/><w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="708" w:footer="708" w:gutter="0"/></w:sectPr></w:body></w:document>');
293
- }
294
-
295
- function workbookSheetPath(workbookXml, relsXml, requestedName) {
296
- const sheets = [...workbookXml.matchAll(/<sheet\b[^>]*name="([^"]+)"[^>]*(?:r:id|id)="([^"]+)"[^>]*\/?>(?:<\/sheet>)?/g)].map(match => ({ name:xmlUnescape(match[1]), rid:match[2] }));
297
- const sheet = requestedName ? sheets.find(item => item.name.toLowerCase() === requestedName.toLowerCase()) : sheets[0];
298
- if (!sheet) throw new Error(requestedName ? `Worksheet not found: ${requestedName}` : 'Workbook contains no worksheets');
299
- const relationships = [...relsXml.matchAll(/<Relationship\b[^>]*Id="([^"]+)"[^>]*Target="([^"]+)"[^>]*\/?>/g)].map(match => ({ id:match[1], target:match[2] }));
300
- const rel = relationships.find(item => item.id === sheet.rid);
301
- if (!rel) throw new Error(`Relationship for worksheet ${sheet.name} was not found`);
302
- const target = rel.target.replace(/^\//, '').replace(/\\/g, '/');
303
- if (!safeArchiveEntry(target)) throw new Error(`Worksheet relationship contains an unsafe path: ${target}`);
304
- const relative = path.posix.normalize(target.startsWith('xl/') ? target : path.posix.join('xl', target));
305
- if (!relative.startsWith('xl/') || relative.split('/').includes('..')) throw new Error(`Worksheet relationship escapes the workbook: ${target}`);
306
- return { name:sheet.name, relative };
307
- }
308
-
309
- function readSharedStrings(xml) {
310
- if (!xml) return [];
311
- return [...xml.matchAll(/<si\b[^>]*>([\s\S]*?)<\/si>/g)].map(match => [...match[1].matchAll(/<t\b[^>]*>([\s\S]*?)<\/t>/g)].map(textMatch => xmlUnescape(textMatch[1])).join(''));
312
- }
313
-
314
- function readWorksheetCells(xml, sharedStrings, maxCells) {
315
- const cells = [];
316
- const pattern = /<c\b([^>]*)\br="([A-Z]+\d+)"([^>]*)>([\s\S]*?)<\/c>|<c\b([^>]*)\br="([A-Z]+\d+)"([^>]*)\/>/g;
317
- for (const match of xml.matchAll(pattern)) {
318
- if (cells.length >= maxCells) break;
319
- const attrs = `${match[1] || match[5] || ''}${match[3] || match[7] || ''}`;
320
- const ref = match[2] || match[6];
321
- const body = match[4] || '';
322
- const type = attrs.match(/\bt="([^"]+)"/)?.[1] || '';
323
- const formula = body.match(/<f\b[^>]*>([\s\S]*?)<\/f>/)?.[1];
324
- const raw = body.match(/<v\b[^>]*>([\s\S]*?)<\/v>/)?.[1] ?? '';
325
- let value;
326
- if (type === 's') value = sharedStrings[Number(raw)] ?? raw;
327
- else if (type === 'inlineStr') value = [...body.matchAll(/<t\b[^>]*>([\s\S]*?)<\/t>/g)].map(item => xmlUnescape(item[1])).join('');
328
- else if (type === 'b') value = raw === '1';
329
- else if (raw !== '' && Number.isFinite(Number(raw))) value = Number(raw);
330
- else value = xmlUnescape(raw);
331
- cells.push({ ref, value, ...(formula ? { formula:xmlUnescape(formula) } : {}) });
332
- }
333
- return cells;
334
- }
335
-
336
- async function readXlsx(filePath, args) {
337
- const dir = await tempDir('remcp-xlsx-read-');
338
- try {
339
- // extractZip already snapshots the user-approved source into a private temp file
340
- // before invoking unzip. A second snapshot here used to re-open ReMCP's own temp
341
- // path through allowedRoots, so read_document failed whenever confinement was on.
342
- await extractZip(filePath, dir);
343
- const workbook = await readFile(path.join(dir,'xl','workbook.xml'),'utf8');
344
- const rels = await readFile(path.join(dir,'xl','_rels','workbook.xml.rels'),'utf8');
345
- const sheet = workbookSheetPath(workbook, rels, optionalString(args.sheet));
346
- const worksheet = await readFile(path.join(dir,...sheet.relative.split('/')),'utf8');
347
- let shared = [];
348
- try { shared = readSharedStrings(await readFile(path.join(dir,'xl','sharedStrings.xml'),'utf8')); } catch {}
349
- const cells = readWorksheetCells(worksheet, shared, clamp(args.max_cells,5000,1,50_000));
350
- return { kind:'xlsx', sheet:sheet.name, count:cells.length, cells };
351
- } finally {
352
- await removeTemp(dir);
353
- }
354
- }
355
-
356
- async function readDocxDocument(filePath) {
357
- const dir = await tempDir('remcp-docx-read-');
358
- try {
359
- await extractZip(filePath, dir);
360
- let xml;
361
- try {
362
- xml = await readFile(path.join(dir, 'word', 'document.xml'), 'utf8');
363
- } catch (error) {
364
- if (error?.code === 'ENOENT') {
365
- throw new Error('This file is not a readable .docx (word/document.xml is missing)');
366
- }
367
- throw error;
368
- }
369
- return readDocxXmlText(xml);
370
- } finally {
371
- await removeTemp(dir);
372
- }
373
- }
374
-
375
- async function readPdfDocument(data) {
376
- try {
377
- return readPdfText(data);
378
- } catch (builtinError) {
379
- if (commandExists('pdftotext')) {
380
- const dir = await tempDir('remcp-pdf-read-');
381
- try {
382
- const snapshot = path.join(dir, 'input.pdf');
383
- await writeFile(snapshot, data, { mode: 0o600 });
384
- const extracted = await runFile('pdftotext', ['-enc','UTF-8',snapshot,'-'], {
385
- label:'PDF text extraction',
386
- timeout:60_000,
387
- allowFailure:true,
388
- });
389
- const fallbackText = String(extracted.stdout || '').replace(/\f/g, '\n').trim();
390
- if (extracted.code === 0 && fallbackText) return fallbackText;
391
- } finally {
392
- await removeTemp(dir);
393
- }
394
- }
395
- throw builtinError;
396
- }
397
- }
398
-
399
- export async function readDocument(args) {
400
- const filePath = await resolveSafePath(args.path,'path');
401
- const lower = filePath.toLowerCase();
402
- if (lower.endsWith('.docx')) return text(await readDocxDocument(filePath));
403
- if (lower.endsWith('.xlsx')) return jsonResult(await readXlsx(filePath,args));
404
- const data = await readDocumentFile(filePath);
405
- if (lower.endsWith('.pdf')) return text(await readPdfDocument(data));
406
- if (/\.(txt|md|csv|json|xml|yaml|yml)$/i.test(lower)) return text(data.toString('utf8'));
407
- throw new Error('read_document supports PDF, DOCX, XLSX, TXT, Markdown, CSV, JSON, XML, YAML');
408
- }
23
+ import { xmlEscape, xmlUnescape, descriptorAnchorsAvailable, openDocumentSource, openDocumentDirectoryPath, createAnchoredTempDirectory, readBounded, readDocumentFile, copyRegularNoFollow, snapshotDocumentFile, assertSafeExtractedTree, safePdfPattern, safeArchiveEntry, validateZipArchive, extractZip, createZip, commitDocumentOutput, ensureCreateTargetIsNew, writeOoxmlPart } from './documents-filesystem.mjs';
24
+ import { newWorksheetName, createBlankXlsxTree, createBlankDocxTree, workbookSheetPath, readSharedStrings, readWorksheetCells, readXlsx, readDocxDocument, readPdfDocument, readDocument } from './documents-reading.mjs';
25
+ export { readDocument };
409
26
 
410
27
  function cellXml(ref, value, formula) {
411
28
  if (formula != null) return `<c r="${ref}"><f>${xmlEscape(String(formula).replace(/^=/,''))}</f></c>`;