@tiwater/office-mcp 0.17.5 → 0.17.6
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/office/index.mjs
CHANGED
|
@@ -173,6 +173,7 @@ function docxInspectionOutput(tool) {
|
|
|
173
173
|
revision: docxRevision,
|
|
174
174
|
summary: z.object({
|
|
175
175
|
tableCount: z.number().int().nonnegative(),
|
|
176
|
+
openingText: z.array(z.string().min(1).max(240)).max(6),
|
|
176
177
|
}).strict(),
|
|
177
178
|
}).strict();
|
|
178
179
|
}
|
|
@@ -225,7 +226,7 @@ const docxReadObjectOutput = artifactOutput('docx_read_object').extend({
|
|
|
225
226
|
const tools = [
|
|
226
227
|
{
|
|
227
228
|
name: 'docx_inspect',
|
|
228
|
-
description: 'Inspect one current DOCX. The response returns its revision and
|
|
229
|
+
description: 'Inspect one current DOCX. The response returns its revision, table count, and a bounded sample of its opening non-empty paragraphs for document identification; use paged docx_find_literal or docx_list_objects to select native objects. The complete inspection remains in the evidence artifact.',
|
|
229
230
|
inputSchema: inputContract('docx_inspect'),
|
|
230
231
|
outputSchema: docxInspectionOutput('docx_inspect'),
|
|
231
232
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
@@ -489,10 +490,17 @@ function buildServer() {
|
|
|
489
490
|
}
|
|
490
491
|
|
|
491
492
|
function compactDocxInspection(report) {
|
|
492
|
-
if (!report?.revision || !Array.isArray(report.tables)) {
|
|
493
|
+
if (!report?.tables?.revision || !Array.isArray(report.tables.tables) || !Array.isArray(report.flow)) {
|
|
493
494
|
throw new Error('docx-table-inspection-result-invalid');
|
|
494
495
|
}
|
|
495
|
-
|
|
496
|
+
const openingText = report.flow
|
|
497
|
+
.filter(item => item?.type === 'paragraph' && typeof item.text === 'string' && item.text.trim())
|
|
498
|
+
.slice(0, 6)
|
|
499
|
+
.map(item => item.text.trim().replace(/\s+/gu, ' ').slice(0, 240));
|
|
500
|
+
return {
|
|
501
|
+
revision: report.tables.revision,
|
|
502
|
+
summary: { tableCount: report.tables.tables.length, openingText },
|
|
503
|
+
};
|
|
496
504
|
}
|
|
497
505
|
|
|
498
506
|
function compactDocxObjectIdentity(object) {
|
|
@@ -525,7 +533,7 @@ async function docxInspect(args) {
|
|
|
525
533
|
runtime: commandRuntime(result),
|
|
526
534
|
source: await fileArtifact(input),
|
|
527
535
|
artifact: await writeJsonArtifact(requireString(args.output, 'output'), result.json),
|
|
528
|
-
...compactDocxInspection(result.json
|
|
536
|
+
...compactDocxInspection(result.json),
|
|
529
537
|
};
|
|
530
538
|
}
|
|
531
539
|
|