@tiwater/office-mcp 0.17.34 → 0.18.0
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/README.md +3 -3
- package/office/contracts/docx_apply_font_policy.schema.json +2 -10
- package/office/contracts/docx_apply_toc_style_policy.schema.json +2 -10
- package/office/contracts/docx_copy_content.schema.json +76 -34
- package/office/contracts/docx_copy_object.schema.json +73 -50
- package/office/contracts/docx_delete_object.schema.json +36 -29
- package/office/contracts/docx_list_objects.schema.json +27 -13
- package/office/contracts/docx_merge_cells.schema.json +47 -18
- package/office/contracts/docx_read_object.schema.json +24 -13
- package/office/contracts/docx_replace_table_rows.schema.json +234 -51
- package/office/contracts/docx_set_text.schema.json +42 -19
- package/office/contracts/docx_split_cells.schema.json +47 -18
- package/office/contracts/tiwater-office-provider-contract-manifest-v1.json +23 -23
- package/office/index.mjs +20 -26
- package/package.json +1 -1
|
@@ -2,29 +2,29 @@
|
|
|
2
2
|
"schema": "tiwater.office-provider-contract-manifest/v1",
|
|
3
3
|
"provider": {
|
|
4
4
|
"id": "@tiwater/office-mcp",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.18.0"
|
|
6
6
|
},
|
|
7
7
|
"tools": [
|
|
8
8
|
{
|
|
9
9
|
"name": "docx_apply_font_policy",
|
|
10
10
|
"providerContract": {
|
|
11
11
|
"source": "packages/docx-cli/contracts/mcp-input/docx_apply_font_policy.schema.json",
|
|
12
|
-
"sha256": "
|
|
12
|
+
"sha256": "d7c0006cc1ee6a001f8a82f26a9ed260c4ff48babcc7a93b785c019cfa91a3a0"
|
|
13
13
|
},
|
|
14
14
|
"inputContract": {
|
|
15
15
|
"path": "office/contracts/docx_apply_font_policy.schema.json",
|
|
16
|
-
"sha256": "
|
|
16
|
+
"sha256": "d7c0006cc1ee6a001f8a82f26a9ed260c4ff48babcc7a93b785c019cfa91a3a0"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"name": "docx_apply_toc_style_policy",
|
|
21
21
|
"providerContract": {
|
|
22
22
|
"source": "packages/docx-cli/contracts/mcp-input/docx_apply_toc_style_policy.schema.json",
|
|
23
|
-
"sha256": "
|
|
23
|
+
"sha256": "20e97023efe9a06354f22c93fff1576e0102a5d8b16058e9684af9478cb36286"
|
|
24
24
|
},
|
|
25
25
|
"inputContract": {
|
|
26
26
|
"path": "office/contracts/docx_apply_toc_style_policy.schema.json",
|
|
27
|
-
"sha256": "
|
|
27
|
+
"sha256": "20e97023efe9a06354f22c93fff1576e0102a5d8b16058e9684af9478cb36286"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
{
|
|
@@ -42,33 +42,33 @@
|
|
|
42
42
|
"name": "docx_copy_content",
|
|
43
43
|
"providerContract": {
|
|
44
44
|
"source": "packages/docx-cli/contracts/mcp-input/docx_copy_content.schema.json",
|
|
45
|
-
"sha256": "
|
|
45
|
+
"sha256": "50e1633e97d0aaab32c58935b92aa73128b566ae3ed742bc3ae1a62d0b1ba617"
|
|
46
46
|
},
|
|
47
47
|
"inputContract": {
|
|
48
48
|
"path": "office/contracts/docx_copy_content.schema.json",
|
|
49
|
-
"sha256": "
|
|
49
|
+
"sha256": "50e1633e97d0aaab32c58935b92aa73128b566ae3ed742bc3ae1a62d0b1ba617"
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
"name": "docx_copy_object",
|
|
54
54
|
"providerContract": {
|
|
55
55
|
"source": "packages/docx-cli/contracts/mcp-input/docx_copy_object.schema.json",
|
|
56
|
-
"sha256": "
|
|
56
|
+
"sha256": "03bbda134699a76193054a18ca72199d4e74ebd6437a94bb6512a68597dcb0df"
|
|
57
57
|
},
|
|
58
58
|
"inputContract": {
|
|
59
59
|
"path": "office/contracts/docx_copy_object.schema.json",
|
|
60
|
-
"sha256": "
|
|
60
|
+
"sha256": "03bbda134699a76193054a18ca72199d4e74ebd6437a94bb6512a68597dcb0df"
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
"name": "docx_delete_object",
|
|
65
65
|
"providerContract": {
|
|
66
66
|
"source": "packages/docx-cli/contracts/mcp-input/docx_delete_object.schema.json",
|
|
67
|
-
"sha256": "
|
|
67
|
+
"sha256": "efbb9017fe4b5dd0a66ee7d1229560d006fbca09beffbc6a600bda225b4f2d05"
|
|
68
68
|
},
|
|
69
69
|
"inputContract": {
|
|
70
70
|
"path": "office/contracts/docx_delete_object.schema.json",
|
|
71
|
-
"sha256": "
|
|
71
|
+
"sha256": "efbb9017fe4b5dd0a66ee7d1229560d006fbca09beffbc6a600bda225b4f2d05"
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
{
|
|
@@ -97,33 +97,33 @@
|
|
|
97
97
|
"name": "docx_list_objects",
|
|
98
98
|
"providerContract": {
|
|
99
99
|
"source": "packages/docx-cli/contracts/mcp-input/docx_list_objects.schema.json",
|
|
100
|
-
"sha256": "
|
|
100
|
+
"sha256": "2709c5e81ce6a421d12b8ae5752b9251c7e379c0dc5fb5872b658466172a1c2f"
|
|
101
101
|
},
|
|
102
102
|
"inputContract": {
|
|
103
103
|
"path": "office/contracts/docx_list_objects.schema.json",
|
|
104
|
-
"sha256": "
|
|
104
|
+
"sha256": "2709c5e81ce6a421d12b8ae5752b9251c7e379c0dc5fb5872b658466172a1c2f"
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
"name": "docx_merge_cells",
|
|
109
109
|
"providerContract": {
|
|
110
110
|
"source": "packages/docx-cli/contracts/mcp-input/docx_merge_cells.schema.json",
|
|
111
|
-
"sha256": "
|
|
111
|
+
"sha256": "417def05619b271471c76883eea52a2f5772ac399111215df5a7259b8a41c3d1"
|
|
112
112
|
},
|
|
113
113
|
"inputContract": {
|
|
114
114
|
"path": "office/contracts/docx_merge_cells.schema.json",
|
|
115
|
-
"sha256": "
|
|
115
|
+
"sha256": "417def05619b271471c76883eea52a2f5772ac399111215df5a7259b8a41c3d1"
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
"name": "docx_read_object",
|
|
120
120
|
"providerContract": {
|
|
121
121
|
"source": "packages/docx-cli/contracts/mcp-input/docx_read_object.schema.json",
|
|
122
|
-
"sha256": "
|
|
122
|
+
"sha256": "f8d29a89c0a321332d5d964c970b2cb18c7ecd59f87e9892e6779747a00f9825"
|
|
123
123
|
},
|
|
124
124
|
"inputContract": {
|
|
125
125
|
"path": "office/contracts/docx_read_object.schema.json",
|
|
126
|
-
"sha256": "
|
|
126
|
+
"sha256": "f8d29a89c0a321332d5d964c970b2cb18c7ecd59f87e9892e6779747a00f9825"
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
129
|
{
|
|
@@ -152,33 +152,33 @@
|
|
|
152
152
|
"name": "docx_replace_table_rows",
|
|
153
153
|
"providerContract": {
|
|
154
154
|
"source": "packages/docx-cli/contracts/mcp-input/docx_replace_table_rows.schema.json",
|
|
155
|
-
"sha256": "
|
|
155
|
+
"sha256": "8dfc2cb6f366610281eb6f14118d3855e1e27a34f27b5e2a425690b581ada5a6"
|
|
156
156
|
},
|
|
157
157
|
"inputContract": {
|
|
158
158
|
"path": "office/contracts/docx_replace_table_rows.schema.json",
|
|
159
|
-
"sha256": "
|
|
159
|
+
"sha256": "8dfc2cb6f366610281eb6f14118d3855e1e27a34f27b5e2a425690b581ada5a6"
|
|
160
160
|
}
|
|
161
161
|
},
|
|
162
162
|
{
|
|
163
163
|
"name": "docx_set_text",
|
|
164
164
|
"providerContract": {
|
|
165
165
|
"source": "packages/docx-cli/contracts/mcp-input/docx_set_text.schema.json",
|
|
166
|
-
"sha256": "
|
|
166
|
+
"sha256": "0e0ccfb2ac910660c6aea6b4dca0e023bd30931c691913647576999b096f43e9"
|
|
167
167
|
},
|
|
168
168
|
"inputContract": {
|
|
169
169
|
"path": "office/contracts/docx_set_text.schema.json",
|
|
170
|
-
"sha256": "
|
|
170
|
+
"sha256": "0e0ccfb2ac910660c6aea6b4dca0e023bd30931c691913647576999b096f43e9"
|
|
171
171
|
}
|
|
172
172
|
},
|
|
173
173
|
{
|
|
174
174
|
"name": "docx_split_cells",
|
|
175
175
|
"providerContract": {
|
|
176
176
|
"source": "packages/docx-cli/contracts/mcp-input/docx_split_cells.schema.json",
|
|
177
|
-
"sha256": "
|
|
177
|
+
"sha256": "9d53d0234d98c6cc5cb5b523e1457b777d015c5aaf49cbd745e6598c1793d6bb"
|
|
178
178
|
},
|
|
179
179
|
"inputContract": {
|
|
180
180
|
"path": "office/contracts/docx_split_cells.schema.json",
|
|
181
|
-
"sha256": "
|
|
181
|
+
"sha256": "9d53d0234d98c6cc5cb5b523e1457b777d015c5aaf49cbd745e6598c1793d6bb"
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
184
|
{
|
package/office/index.mjs
CHANGED
|
@@ -161,20 +161,17 @@ function artifactOutput(tool) {
|
|
|
161
161
|
return z.object({ tool: z.literal(tool), runtime: runtimeIdentity, source: artifact, artifact }).strict();
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
provider: z.literal('tiwater.docx.cli'),
|
|
168
|
-
toolVersion: z.string(),
|
|
164
|
+
const docxAddress = z.object({
|
|
165
|
+
part: z.string().min(1),
|
|
166
|
+
path: z.string().startsWith('/'),
|
|
169
167
|
}).strict();
|
|
170
168
|
|
|
171
169
|
function docxInspectionOutput(tool) {
|
|
172
170
|
return artifactOutput(tool).extend({
|
|
173
|
-
revision: docxRevision,
|
|
174
171
|
summary: z.object({
|
|
175
172
|
tableCount: z.number().int().nonnegative(),
|
|
176
173
|
openingParagraphs: z.array(z.object({
|
|
177
|
-
|
|
174
|
+
address: docxAddress,
|
|
178
175
|
textPreview: z.string().min(1).max(240),
|
|
179
176
|
}).strict()).max(6),
|
|
180
177
|
}).strict(),
|
|
@@ -182,8 +179,8 @@ function docxInspectionOutput(tool) {
|
|
|
182
179
|
}
|
|
183
180
|
|
|
184
181
|
const docxObjectIdentity = z.object({
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
address: docxAddress,
|
|
183
|
+
parentAddress: docxAddress.nullable(),
|
|
187
184
|
kind: z.string(),
|
|
188
185
|
textPreview: z.string().nullable(),
|
|
189
186
|
gridSpan: z.number().int().positive().nullable(),
|
|
@@ -191,7 +188,7 @@ const docxObjectIdentity = z.object({
|
|
|
191
188
|
}).strict();
|
|
192
189
|
|
|
193
190
|
const docxNestedObjectIdentity = docxObjectIdentity.pick({
|
|
194
|
-
|
|
191
|
+
address: true,
|
|
195
192
|
kind: true,
|
|
196
193
|
textPreview: true,
|
|
197
194
|
}).extend({
|
|
@@ -206,11 +203,10 @@ const docxObservationNode = z.lazy(() => z.object({
|
|
|
206
203
|
const docxObservationReceipt = z.object({
|
|
207
204
|
schema: z.literal('tiwater.docx-observation-receipt/v1'),
|
|
208
205
|
operation: z.literal('list'),
|
|
209
|
-
revision: docxRevision,
|
|
210
206
|
totalCount: z.number().int().nonnegative(),
|
|
211
207
|
returnedCount: z.number().int().nonnegative(),
|
|
212
208
|
remaining: z.number().int().nonnegative(),
|
|
213
|
-
|
|
209
|
+
nextOffset: z.number().int().nonnegative().nullable(),
|
|
214
210
|
}).strict();
|
|
215
211
|
|
|
216
212
|
const docxListObjectsOutput = artifactOutput('docx_list_objects').extend({
|
|
@@ -221,14 +217,13 @@ const docxListObjectsOutput = artifactOutput('docx_list_objects').extend({
|
|
|
221
217
|
}).strict();
|
|
222
218
|
|
|
223
219
|
const docxReadObjectOutput = artifactOutput('docx_read_object').extend({
|
|
224
|
-
revision: docxRevision,
|
|
225
220
|
observations: z.array(docxObservationNode).min(1),
|
|
226
221
|
}).strict();
|
|
227
222
|
|
|
228
223
|
const tools = [
|
|
229
224
|
{
|
|
230
225
|
name: 'docx_inspect',
|
|
231
|
-
description: 'Inspect one current DOCX and retain its complete machine observation at output. The response returns the
|
|
226
|
+
description: 'Inspect one current DOCX and retain its complete machine observation at output. The response returns the observation artifact, table count, and up to six opening non-empty body paragraphs with their OpenXML addresses. Use list and read operations to traverse selected document objects in native structure order.',
|
|
232
227
|
inputSchema: inputContract('docx_inspect'),
|
|
233
228
|
outputSchema: docxInspectionOutput('docx_inspect'),
|
|
234
229
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
@@ -236,7 +231,7 @@ const tools = [
|
|
|
236
231
|
},
|
|
237
232
|
{
|
|
238
233
|
name: 'docx_list_objects',
|
|
239
|
-
description: 'List one small page of nearest-child
|
|
234
|
+
description: 'List one small page of nearest-child OpenXML addresses from the current DOCX in native document order and retain the exact page at output. Continue with nextOffset and descend through a returned address as parent. Text previews describe already located objects; they do not prove descendant content.',
|
|
240
235
|
inputSchema: inputContract('docx_list_objects'),
|
|
241
236
|
outputSchema: docxListObjectsOutput,
|
|
242
237
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
@@ -244,7 +239,7 @@ const tools = [
|
|
|
244
239
|
},
|
|
245
240
|
{
|
|
246
241
|
name: 'docx_read_object',
|
|
247
|
-
description: 'Read selected rows, cells, or paragraphs from one native DOCX in one call and return them in
|
|
242
|
+
description: 'Read selected rows, cells, or paragraphs from one native DOCX in one call and return them in address order. Pass the document path once and only the OpenXML addresses needed for the current target. For exact inline content, use an observed cell or paragraph address and request run or text.',
|
|
248
243
|
inputSchema: inputContract('docx_read_object'),
|
|
249
244
|
outputSchema: docxReadObjectOutput,
|
|
250
245
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
@@ -252,7 +247,7 @@ const tools = [
|
|
|
252
247
|
},
|
|
253
248
|
{
|
|
254
249
|
name: 'docx_copy_content',
|
|
255
|
-
description: 'Replace content in existing plain-text target paragraphs or cells while retaining target container formatting and source inline meaning.
|
|
250
|
+
description: 'Replace content in existing plain-text target paragraphs or cells while retaining target container formatting and source inline meaning. A selection copies a whole object by OpenXML address, or an exact substring when range is attached to a run or text address.',
|
|
256
251
|
inputSchema: inputContract('docx_copy_content'),
|
|
257
252
|
outputSchema: fixedEditOutput('docx_copy_content'),
|
|
258
253
|
handler: args => fixedEdit('docx_copy_content', args),
|
|
@@ -266,7 +261,7 @@ const tools = [
|
|
|
266
261
|
},
|
|
267
262
|
{
|
|
268
263
|
name: 'docx_replace_table_rows',
|
|
269
|
-
description: 'Replace one or more data-row ranges in one current target document.
|
|
264
|
+
description: 'Replace one or more data-row ranges in one current target document. input appears once; each tables item binds sourceInput and exact source and target OpenXML addresses. All source-cell paragraphs copy by default; sourceCellContents selects exact observed content that the target keeps.',
|
|
270
265
|
inputSchema: inputContract('docx_replace_table_rows'),
|
|
271
266
|
outputSchema: fixedEditOutput('docx_replace_table_rows'),
|
|
272
267
|
handler: args => fixedEdit('docx_replace_table_rows', args),
|
|
@@ -484,20 +479,20 @@ function buildServer() {
|
|
|
484
479
|
}
|
|
485
480
|
|
|
486
481
|
function compactDocxInspection(report) {
|
|
487
|
-
if (!
|
|
482
|
+
if (!Array.isArray(report?.tables?.tables) || !Array.isArray(report.flow)) {
|
|
488
483
|
throw new Error('docx-table-inspection-result-invalid');
|
|
489
484
|
}
|
|
490
485
|
const openingParagraphs = report.flow
|
|
491
486
|
.filter(item => item?.type === 'paragraph'
|
|
492
|
-
&&
|
|
487
|
+
&& typeof item.address?.part === 'string'
|
|
488
|
+
&& typeof item.address?.path === 'string'
|
|
493
489
|
&& typeof item.text === 'string' && item.text.trim())
|
|
494
490
|
.slice(0, 6)
|
|
495
491
|
.map(item => ({
|
|
496
|
-
|
|
492
|
+
address: item.address,
|
|
497
493
|
textPreview: item.text.trim().replace(/\s+/gu, ' ').slice(0, 240),
|
|
498
494
|
}));
|
|
499
495
|
return {
|
|
500
|
-
revision: report.tables.revision,
|
|
501
496
|
summary: {
|
|
502
497
|
tableCount: report.tables.tables.length,
|
|
503
498
|
openingParagraphs,
|
|
@@ -507,8 +502,8 @@ function compactDocxInspection(report) {
|
|
|
507
502
|
|
|
508
503
|
function compactDocxObjectIdentity(object) {
|
|
509
504
|
return {
|
|
510
|
-
|
|
511
|
-
|
|
505
|
+
address: object.address,
|
|
506
|
+
parentAddress: object.parentAddress,
|
|
512
507
|
kind: object.kind,
|
|
513
508
|
textPreview: object.textPreview,
|
|
514
509
|
gridSpan: object.gridSpan,
|
|
@@ -522,7 +517,7 @@ function compactDocxObservation(observation) {
|
|
|
522
517
|
const identity = compactDocxObjectIdentity(node.object);
|
|
523
518
|
const children = (node.children ?? []).map(compactNode);
|
|
524
519
|
const object = {
|
|
525
|
-
|
|
520
|
+
address: identity.address,
|
|
526
521
|
kind: identity.kind,
|
|
527
522
|
textPreview: children.length === 0 ? identity.textPreview : null,
|
|
528
523
|
...(identity.gridSpan === null ? {} : { gridSpan: identity.gridSpan }),
|
|
@@ -582,7 +577,6 @@ async function docxReadObject(args) {
|
|
|
582
577
|
runtime: commandRuntime(result),
|
|
583
578
|
source: await fileArtifact(input),
|
|
584
579
|
artifact: await writeJsonArtifact(output, result.json),
|
|
585
|
-
revision: result.json.receipt.revision,
|
|
586
580
|
observations: result.json.observations.map(compactDocxObservation),
|
|
587
581
|
};
|
|
588
582
|
});
|