@tiwater/office-mcp 0.18.9 → 0.18.11
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.
|
@@ -17,6 +17,18 @@
|
|
|
17
17
|
"required": ["part", "path"],
|
|
18
18
|
"additionalProperties": false
|
|
19
19
|
},
|
|
20
|
+
"limit": {
|
|
21
|
+
"type": "integer",
|
|
22
|
+
"minimum": 1,
|
|
23
|
+
"maximum": 9007199254740991,
|
|
24
|
+
"description": "Maximum number of table rows requested in this response page. The provider may return fewer to keep the machine response bounded."
|
|
25
|
+
},
|
|
26
|
+
"offset": {
|
|
27
|
+
"type": "integer",
|
|
28
|
+
"minimum": 0,
|
|
29
|
+
"maximum": 9007199254740991,
|
|
30
|
+
"description": "Zero-based row offset. Continue from receipt.nextOffset until it is null."
|
|
31
|
+
},
|
|
20
32
|
"output": {
|
|
21
33
|
"type": "string",
|
|
22
34
|
"minLength": 1,
|
|
@@ -14,6 +14,18 @@
|
|
|
14
14
|
"minLength": 1,
|
|
15
15
|
"description": "New JSON artifact path for the complete table index.",
|
|
16
16
|
"x-tiwater-file-role": "write"
|
|
17
|
+
},
|
|
18
|
+
"limit": {
|
|
19
|
+
"type": "integer",
|
|
20
|
+
"minimum": 1,
|
|
21
|
+
"maximum": 1000,
|
|
22
|
+
"description": "Maximum number of table summaries requested in this response page. The provider may return fewer to keep the machine response bounded."
|
|
23
|
+
},
|
|
24
|
+
"offset": {
|
|
25
|
+
"type": "integer",
|
|
26
|
+
"minimum": 0,
|
|
27
|
+
"maximum": 9007199254740991,
|
|
28
|
+
"description": "Zero-based table offset. Continue from receipt.nextOffset until it is null."
|
|
17
29
|
}
|
|
18
30
|
},
|
|
19
31
|
"required": ["input", "output"],
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schema": "tiwater.office-provider-contract-manifest/v1",
|
|
3
3
|
"provider": {
|
|
4
4
|
"id": "@tiwater/office-mcp",
|
|
5
|
-
"version": "0.18.
|
|
5
|
+
"version": "0.18.11"
|
|
6
6
|
},
|
|
7
7
|
"tools": [
|
|
8
8
|
{
|
|
@@ -130,11 +130,11 @@
|
|
|
130
130
|
"name": "docx_read_table",
|
|
131
131
|
"providerContract": {
|
|
132
132
|
"source": "packages/docx-cli/contracts/mcp-input/docx_read_table.schema.json",
|
|
133
|
-
"sha256": "
|
|
133
|
+
"sha256": "c9c2bbab97bd58cb1426418f022f9c78be802eefb509e951fc4efa35e0096b63"
|
|
134
134
|
},
|
|
135
135
|
"inputContract": {
|
|
136
136
|
"path": "office/contracts/docx_read_table.schema.json",
|
|
137
|
-
"sha256": "
|
|
137
|
+
"sha256": "c9c2bbab97bd58cb1426418f022f9c78be802eefb509e951fc4efa35e0096b63"
|
|
138
138
|
}
|
|
139
139
|
},
|
|
140
140
|
{
|
|
@@ -207,11 +207,11 @@
|
|
|
207
207
|
"name": "docx_table_index",
|
|
208
208
|
"providerContract": {
|
|
209
209
|
"source": "packages/docx-cli/contracts/mcp-input/docx_table_index.schema.json",
|
|
210
|
-
"sha256": "
|
|
210
|
+
"sha256": "e10ea5780559f269b6fa193aadb0fc0793009e5e7a4047a7a46aa5621dfeaac1"
|
|
211
211
|
},
|
|
212
212
|
"inputContract": {
|
|
213
213
|
"path": "office/contracts/docx_table_index.schema.json",
|
|
214
|
-
"sha256": "
|
|
214
|
+
"sha256": "e10ea5780559f269b6fa193aadb0fc0793009e5e7a4047a7a46aa5621dfeaac1"
|
|
215
215
|
}
|
|
216
216
|
},
|
|
217
217
|
{
|
package/office/index.mjs
CHANGED
|
@@ -218,6 +218,13 @@ const docxListObjectsOutput = artifactOutput('docx_list_objects').extend({
|
|
|
218
218
|
|
|
219
219
|
const docxTableIndexOutput = artifactOutput('docx_table_index').extend({
|
|
220
220
|
schema: z.literal('tiwater.docx-table-index/v1'),
|
|
221
|
+
receipt: z.object({
|
|
222
|
+
schema: z.literal('tiwater.docx-table-index-receipt/v1'),
|
|
223
|
+
totalCount: z.number().int().nonnegative(),
|
|
224
|
+
returnedCount: z.number().int().nonnegative(),
|
|
225
|
+
remaining: z.number().int().nonnegative(),
|
|
226
|
+
nextOffset: z.number().int().nonnegative().nullable(),
|
|
227
|
+
}).strict(),
|
|
221
228
|
tables: z.array(z.object({
|
|
222
229
|
address: docxAddress,
|
|
223
230
|
parentAddress: docxAddress.nullable(),
|
|
@@ -240,6 +247,15 @@ const docxTableIndexOutput = artifactOutput('docx_table_index').extend({
|
|
|
240
247
|
|
|
241
248
|
const docxTableReadOutput = artifactOutput('docx_read_table').extend({
|
|
242
249
|
schema: z.literal('tiwater.docx-table-read/v1'),
|
|
250
|
+
receipt: z.object({
|
|
251
|
+
schema: z.literal('tiwater.docx-table-read-receipt/v1'),
|
|
252
|
+
totalRowCount: z.number().int().nonnegative(),
|
|
253
|
+
returnedRowCount: z.number().int().nonnegative(),
|
|
254
|
+
remaining: z.number().int().nonnegative(),
|
|
255
|
+
nextOffset: z.number().int().nonnegative().nullable(),
|
|
256
|
+
inlineTextNodesOmitted: z.literal(true),
|
|
257
|
+
narrowingRequired: z.boolean(),
|
|
258
|
+
}).strict(),
|
|
243
259
|
address: docxAddress,
|
|
244
260
|
rowCount: z.number().int().nonnegative(),
|
|
245
261
|
columnCount: z.number().int().nonnegative(),
|
|
@@ -274,7 +290,14 @@ const docxTableReadOutput = artifactOutput('docx_read_table').extend({
|
|
|
274
290
|
}).strict();
|
|
275
291
|
|
|
276
292
|
const docxReadObjectOutput = artifactOutput('docx_read_object').extend({
|
|
277
|
-
|
|
293
|
+
receipt: z.object({
|
|
294
|
+
schema: z.literal('tiwater.docx-read-object-receipt/v1'),
|
|
295
|
+
observationCount: z.number().int().positive(),
|
|
296
|
+
returnedCount: z.number().int().nonnegative(),
|
|
297
|
+
responseComplete: z.boolean(),
|
|
298
|
+
narrowingRequired: z.boolean(),
|
|
299
|
+
}).strict(),
|
|
300
|
+
observations: z.array(docxObservationNode),
|
|
278
301
|
}).strict();
|
|
279
302
|
|
|
280
303
|
const tools = [
|
|
@@ -296,7 +319,7 @@ const tools = [
|
|
|
296
319
|
},
|
|
297
320
|
{
|
|
298
321
|
name: 'docx_table_index',
|
|
299
|
-
description: 'Locate tables in one current DOCX.
|
|
322
|
+
description: 'Locate tables in one current DOCX. Writes the complete index to output and returns a bounded page containing table address, shape, short text preview, and nearest non-empty paragraphs. Continue with receipt.nextOffset, then call docx_read_table for one selected address. It does not return full cell content or decide table semantics.',
|
|
300
323
|
inputSchema: inputContract('docx_table_index'),
|
|
301
324
|
outputSchema: docxTableIndexOutput,
|
|
302
325
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
@@ -304,7 +327,7 @@ const tools = [
|
|
|
304
327
|
},
|
|
305
328
|
{
|
|
306
329
|
name: 'docx_read_object',
|
|
307
|
-
description: 'Read selected rows, cells, or paragraphs from one native DOCX
|
|
330
|
+
description: 'Read selected rows, cells, or paragraphs from one native DOCX and retain the complete result at output. The response returns compact requested descendants when bounded; if receipt.narrowingRequired is true, request fewer observed addresses or descendants. Use docx_read_table for a table.',
|
|
308
331
|
inputSchema: inputContract('docx_read_object'),
|
|
309
332
|
outputSchema: docxReadObjectOutput,
|
|
310
333
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
@@ -312,7 +335,7 @@ const tools = [
|
|
|
312
335
|
},
|
|
313
336
|
{
|
|
314
337
|
name: 'docx_read_table',
|
|
315
|
-
description: 'Read exactly one table selected from docx_table_index by native OpenXML address.
|
|
338
|
+
description: 'Read exactly one table selected from docx_table_index by native OpenXML address. Writes the complete table, including text nodes, to output and returns a bounded row page with cells, spans, vertical merges, paragraph text, and reusable addresses. Continue with receipt.nextOffset. If receipt.narrowingRequired is true, list rows under the same table and read smaller objects. It does not locate a table or decide business meaning.',
|
|
316
339
|
inputSchema: inputContract('docx_read_table'),
|
|
317
340
|
outputSchema: docxTableReadOutput,
|
|
318
341
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
@@ -632,7 +655,74 @@ async function docxObservation(tool, args) {
|
|
|
632
655
|
if (tool === 'docx_list_objects') {
|
|
633
656
|
return { ...retained, ...payload, objects: payload.objects.map(compactDocxObjectIdentity) };
|
|
634
657
|
}
|
|
635
|
-
if (tool === 'docx_table_index'
|
|
658
|
+
if (tool === 'docx_table_index') {
|
|
659
|
+
const totalCount = payload.tables.length;
|
|
660
|
+
const offset = Math.min(args.offset ?? 0, totalCount);
|
|
661
|
+
const requestedLimit = args.limit ?? totalCount;
|
|
662
|
+
const tables = [];
|
|
663
|
+
for (const table of payload.tables.slice(offset, offset + requestedLimit)) {
|
|
664
|
+
const candidate = [...tables, table];
|
|
665
|
+
if (tables.length > 0 && Buffer.byteLength(JSON.stringify(candidate)) > 7_000) break;
|
|
666
|
+
tables.push(table);
|
|
667
|
+
}
|
|
668
|
+
const nextOffset = offset + tables.length < totalCount ? offset + tables.length : null;
|
|
669
|
+
return {
|
|
670
|
+
...retained,
|
|
671
|
+
schema: payload.schema,
|
|
672
|
+
receipt: {
|
|
673
|
+
schema: 'tiwater.docx-table-index-receipt/v1',
|
|
674
|
+
totalCount,
|
|
675
|
+
returnedCount: tables.length,
|
|
676
|
+
remaining: totalCount - offset - tables.length,
|
|
677
|
+
nextOffset,
|
|
678
|
+
},
|
|
679
|
+
tables,
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
if (tool === 'docx_read_table') {
|
|
683
|
+
const totalRowCount = payload.rows.length;
|
|
684
|
+
const offset = Math.min(args.offset ?? 0, totalRowCount);
|
|
685
|
+
const requestedLimit = args.limit ?? totalRowCount;
|
|
686
|
+
const rows = [];
|
|
687
|
+
let narrowingRequired = false;
|
|
688
|
+
for (const sourceRow of payload.rows.slice(offset, offset + requestedLimit)) {
|
|
689
|
+
const row = {
|
|
690
|
+
...sourceRow,
|
|
691
|
+
cells: sourceRow.cells.map(cell => ({
|
|
692
|
+
...cell,
|
|
693
|
+
paragraphs: cell.paragraphs.map(paragraph => ({ ...paragraph, textNodes: [] })),
|
|
694
|
+
})),
|
|
695
|
+
};
|
|
696
|
+
const candidate = [...rows, row];
|
|
697
|
+
if (Buffer.byteLength(JSON.stringify(candidate)) > 6_500) {
|
|
698
|
+
narrowingRequired = rows.length === 0;
|
|
699
|
+
break;
|
|
700
|
+
}
|
|
701
|
+
rows.push(row);
|
|
702
|
+
}
|
|
703
|
+
const nextOffset = !narrowingRequired && offset + rows.length < totalRowCount
|
|
704
|
+
? offset + rows.length
|
|
705
|
+
: null;
|
|
706
|
+
return {
|
|
707
|
+
...retained,
|
|
708
|
+
schema: payload.schema,
|
|
709
|
+
address: payload.address,
|
|
710
|
+
rowCount: payload.rowCount,
|
|
711
|
+
columnCount: payload.columnCount,
|
|
712
|
+
precedingParagraph: payload.precedingParagraph,
|
|
713
|
+
followingParagraph: payload.followingParagraph,
|
|
714
|
+
receipt: {
|
|
715
|
+
schema: 'tiwater.docx-table-read-receipt/v1',
|
|
716
|
+
totalRowCount,
|
|
717
|
+
returnedRowCount: rows.length,
|
|
718
|
+
remaining: totalRowCount - offset - rows.length,
|
|
719
|
+
nextOffset,
|
|
720
|
+
inlineTextNodesOmitted: true,
|
|
721
|
+
narrowingRequired,
|
|
722
|
+
},
|
|
723
|
+
rows,
|
|
724
|
+
};
|
|
725
|
+
}
|
|
636
726
|
throw new Error(`unsupported-docx-observation-tool:${tool}`);
|
|
637
727
|
});
|
|
638
728
|
}
|
|
@@ -643,12 +733,21 @@ async function docxReadObject(args) {
|
|
|
643
733
|
const { output: _output, ...request } = args;
|
|
644
734
|
return withTempJsonFile(request, async requestPath => {
|
|
645
735
|
const result = await runJsonCandidateChain(docxCandidates, ['docx_read_object', requestPath]);
|
|
736
|
+
const observations = result.json.observations.map(compactDocxObservation);
|
|
737
|
+
const responseComplete = Buffer.byteLength(JSON.stringify(observations)) <= 6_500;
|
|
646
738
|
return {
|
|
647
739
|
tool: 'docx_read_object',
|
|
648
740
|
runtime: commandRuntime(result),
|
|
649
741
|
source: await fileArtifact(input),
|
|
650
742
|
artifact: await writeJsonArtifact(output, result.json),
|
|
651
|
-
|
|
743
|
+
receipt: {
|
|
744
|
+
schema: 'tiwater.docx-read-object-receipt/v1',
|
|
745
|
+
observationCount: observations.length,
|
|
746
|
+
returnedCount: responseComplete ? observations.length : 0,
|
|
747
|
+
responseComplete,
|
|
748
|
+
narrowingRequired: !responseComplete,
|
|
749
|
+
},
|
|
750
|
+
observations: responseComplete ? observations : [],
|
|
652
751
|
};
|
|
653
752
|
});
|
|
654
753
|
}
|