@tiwater/office-mcp 0.18.11 → 0.18.12
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
|
@@ -311,7 +311,7 @@ const tools = [
|
|
|
311
311
|
},
|
|
312
312
|
{
|
|
313
313
|
name: 'docx_list_objects',
|
|
314
|
-
description: 'Page through mixed nearest-child OpenXML objects when document order or paragraph relationships are required. Continue with nextOffset and descend through a returned parent address. Do not use this tool to locate tables or read a whole document: use docx_table_index to locate tables, then docx_read_table for one selected table.',
|
|
314
|
+
description: 'Page through mixed nearest-child OpenXML objects when document order or paragraph relationships are required. The complete requested provider page is retained at output; the response returns a byte-bounded prefix. Continue with receipt.nextOffset and descend through a returned parent address. Do not use this tool to locate tables or read a whole document: use docx_table_index to locate tables, then docx_read_table for one selected table.',
|
|
315
315
|
inputSchema: inputContract('docx_list_objects'),
|
|
316
316
|
outputSchema: docxListObjectsOutput,
|
|
317
317
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
@@ -653,7 +653,28 @@ async function docxObservation(tool, args) {
|
|
|
653
653
|
artifact: await writeJsonArtifact(output, result.json),
|
|
654
654
|
};
|
|
655
655
|
if (tool === 'docx_list_objects') {
|
|
656
|
-
|
|
656
|
+
const totalCount = payload.receipt.totalCount;
|
|
657
|
+
const offset = Math.min(args.offset ?? 0, totalCount);
|
|
658
|
+
const objects = [];
|
|
659
|
+
for (const sourceObject of payload.objects.map(compactDocxObjectIdentity)) {
|
|
660
|
+
const candidate = [...objects, sourceObject];
|
|
661
|
+
if (objects.length > 0 && Buffer.byteLength(JSON.stringify(candidate)) > 6_500) break;
|
|
662
|
+
objects.push(sourceObject);
|
|
663
|
+
}
|
|
664
|
+
const nextOffset = offset + objects.length < totalCount ? offset + objects.length : null;
|
|
665
|
+
return {
|
|
666
|
+
...retained,
|
|
667
|
+
schema: payload.schema,
|
|
668
|
+
receipt: {
|
|
669
|
+
schema: 'tiwater.docx-observation-receipt/v1',
|
|
670
|
+
operation: 'list',
|
|
671
|
+
totalCount,
|
|
672
|
+
returnedCount: objects.length,
|
|
673
|
+
remaining: totalCount - offset - objects.length,
|
|
674
|
+
nextOffset,
|
|
675
|
+
},
|
|
676
|
+
objects,
|
|
677
|
+
};
|
|
657
678
|
}
|
|
658
679
|
if (tool === 'docx_table_index') {
|
|
659
680
|
const totalCount = payload.tables.length;
|