@tiwater/office-mcp 0.17.26 → 0.17.28
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
|
@@ -179,6 +179,10 @@ function docxInspectionOutput(tool) {
|
|
|
179
179
|
rowCount: z.number().int().nonnegative(),
|
|
180
180
|
columnCount: z.number().int().nonnegative(),
|
|
181
181
|
textPreview: z.string().max(240),
|
|
182
|
+
contextBefore: z.array(z.object({
|
|
183
|
+
ref: z.string().regex(/^dox1_[0-9a-f]{64}$/),
|
|
184
|
+
textPreview: z.string().min(1).max(240),
|
|
185
|
+
}).strict()).max(3),
|
|
182
186
|
}).strict()),
|
|
183
187
|
openingParagraphs: z.array(z.object({
|
|
184
188
|
ref: z.string().regex(/^dox1_[0-9a-f]{64}$/),
|
|
@@ -248,7 +252,7 @@ const docxReadObjectOutput = artifactOutput('docx_read_object').extend({
|
|
|
248
252
|
const tools = [
|
|
249
253
|
{
|
|
250
254
|
name: 'docx_inspect',
|
|
251
|
-
description: 'Inspect one current DOCX. The response returns its revision, every table identity with shape
|
|
255
|
+
description: 'Inspect one current DOCX. The response returns its revision, every table identity with shape, short text preview, and up to three immediately preceding non-empty body paragraphs, plus up to six opening non-empty body paragraphs. Reuse those native refs directly; use docx_find_literal only for text not exposed here and docx_list_objects only for container children. The complete inspection remains in the evidence artifact.',
|
|
252
256
|
inputSchema: inputContract('docx_inspect'),
|
|
253
257
|
outputSchema: docxInspectionOutput('docx_inspect'),
|
|
254
258
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
@@ -524,16 +528,33 @@ function compactDocxInspection(report) {
|
|
|
524
528
|
ref: item.objectRef,
|
|
525
529
|
textPreview: item.text.trim().replace(/\s+/gu, ' ').slice(0, 240),
|
|
526
530
|
}));
|
|
531
|
+
const tableContexts = new Map();
|
|
532
|
+
let precedingParagraphs = [];
|
|
533
|
+
for (const item of report.flow) {
|
|
534
|
+
if (item?.type === 'paragraph' && /^dox1_[0-9a-f]{64}$/u.test(item.objectRef)
|
|
535
|
+
&& typeof item.text === 'string' && item.text.trim()) {
|
|
536
|
+
precedingParagraphs.push({
|
|
537
|
+
ref: item.objectRef,
|
|
538
|
+
textPreview: item.text.trim().replace(/\s+/gu, ' ').slice(0, 240),
|
|
539
|
+
});
|
|
540
|
+
precedingParagraphs = precedingParagraphs.slice(-3);
|
|
541
|
+
}
|
|
542
|
+
if (item?.type === 'table' && Number.isInteger(item.tableIndex)) {
|
|
543
|
+
tableContexts.set(item.tableIndex, precedingParagraphs);
|
|
544
|
+
precedingParagraphs = [];
|
|
545
|
+
}
|
|
546
|
+
}
|
|
527
547
|
return {
|
|
528
548
|
revision: report.tables.revision,
|
|
529
549
|
summary: {
|
|
530
550
|
tableCount: report.tables.tables.length,
|
|
531
|
-
tables: report.tables.tables.map(table => ({
|
|
551
|
+
tables: report.tables.tables.map((table, tableIndex) => ({
|
|
532
552
|
ref: table.ref,
|
|
533
553
|
parentRef: table.parentRef,
|
|
534
554
|
rowCount: table.rowCount,
|
|
535
555
|
columnCount: table.columnCount,
|
|
536
556
|
textPreview: String(table.textPreview ?? '').trim().replace(/\s+/gu, ' ').slice(0, 240),
|
|
557
|
+
contextBefore: tableContexts.get(tableIndex) ?? [],
|
|
537
558
|
})),
|
|
538
559
|
openingParagraphs,
|
|
539
560
|
},
|