@tiwater/office-mcp 0.17.3 → 0.17.5
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
|
@@ -168,21 +168,12 @@ const docxRevision = z.object({
|
|
|
168
168
|
toolVersion: z.string(),
|
|
169
169
|
}).strict();
|
|
170
170
|
|
|
171
|
-
const docxTableIndexEntry = z.object({
|
|
172
|
-
ref: z.string().regex(/^dox1_[0-9a-f]{64}$/),
|
|
173
|
-
parentRef: z.string().regex(/^dox1_[0-9a-f]{64}$/).nullable(),
|
|
174
|
-
storyPart: z.string(),
|
|
175
|
-
nativePath: z.string(),
|
|
176
|
-
rowCount: z.number().int().nonnegative(),
|
|
177
|
-
columnCount: z.number().int().nonnegative(),
|
|
178
|
-
textPreview: z.string(),
|
|
179
|
-
textLength: z.number().int().nonnegative(),
|
|
180
|
-
}).strict();
|
|
181
|
-
|
|
182
171
|
function docxInspectionOutput(tool) {
|
|
183
172
|
return artifactOutput(tool).extend({
|
|
184
173
|
revision: docxRevision,
|
|
185
|
-
|
|
174
|
+
summary: z.object({
|
|
175
|
+
tableCount: z.number().int().nonnegative(),
|
|
176
|
+
}).strict(),
|
|
186
177
|
}).strict();
|
|
187
178
|
}
|
|
188
179
|
|
|
@@ -195,6 +186,36 @@ const docxObjectIdentity = z.object({
|
|
|
195
186
|
verticalMerge: z.string().nullable(),
|
|
196
187
|
}).strict();
|
|
197
188
|
|
|
189
|
+
const docxObservationReceipt = z.object({
|
|
190
|
+
schema: z.literal('tiwater.docx-observation-receipt/v1'),
|
|
191
|
+
operation: z.enum(['list', 'find', 'read']),
|
|
192
|
+
revision: docxRevision,
|
|
193
|
+
totalCount: z.number().int().nonnegative(),
|
|
194
|
+
returnedCount: z.number().int().nonnegative(),
|
|
195
|
+
remaining: z.number().int().nonnegative(),
|
|
196
|
+
continuation: z.string().nullable(),
|
|
197
|
+
}).strict();
|
|
198
|
+
|
|
199
|
+
const docxListObjectsOutput = z.object({
|
|
200
|
+
schema: z.literal('tiwater.docx-observation-list/v1'),
|
|
201
|
+
receipt: docxObservationReceipt,
|
|
202
|
+
objects: z.array(docxObjectIdentity),
|
|
203
|
+
runtime: runtimeIdentity,
|
|
204
|
+
}).strict();
|
|
205
|
+
|
|
206
|
+
const docxFindLiteralOutput = z.object({
|
|
207
|
+
schema: z.literal('tiwater.docx-observation-find/v1'),
|
|
208
|
+
receipt: docxObservationReceipt,
|
|
209
|
+
matches: z.array(z.object({
|
|
210
|
+
object: docxObjectIdentity,
|
|
211
|
+
matches: z.array(z.object({
|
|
212
|
+
offset: z.number().int().nonnegative(),
|
|
213
|
+
length: z.number().int().positive(),
|
|
214
|
+
}).strict()),
|
|
215
|
+
}).strict()),
|
|
216
|
+
runtime: runtimeIdentity,
|
|
217
|
+
}).strict();
|
|
218
|
+
|
|
198
219
|
const docxReadObjectOutput = artifactOutput('docx_read_object').extend({
|
|
199
220
|
revision: docxRevision,
|
|
200
221
|
object: docxObjectIdentity,
|
|
@@ -204,7 +225,7 @@ const docxReadObjectOutput = artifactOutput('docx_read_object').extend({
|
|
|
204
225
|
const tools = [
|
|
205
226
|
{
|
|
206
227
|
name: 'docx_inspect',
|
|
207
|
-
description: 'Inspect one current DOCX. The response returns its revision and
|
|
228
|
+
description: 'Inspect one current DOCX. The response returns its revision and table count; use paged docx_find_literal or docx_list_objects to select native objects. The complete inspection remains in the evidence artifact.',
|
|
208
229
|
inputSchema: inputContract('docx_inspect'),
|
|
209
230
|
outputSchema: docxInspectionOutput('docx_inspect'),
|
|
210
231
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
@@ -214,6 +235,7 @@ const tools = [
|
|
|
214
235
|
name: 'docx_list_objects',
|
|
215
236
|
description: 'List one small page of revision-bound nearest-child identities. Use parentRef to restrict any container, such as body paragraphs, table rows, or row cells; use docx_find_literal when selecting by text.',
|
|
216
237
|
inputSchema: inputContract('docx_list_objects'),
|
|
238
|
+
outputSchema: docxListObjectsOutput,
|
|
217
239
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
218
240
|
handler: args => docxObservation('docx_list_objects', args),
|
|
219
241
|
},
|
|
@@ -221,6 +243,7 @@ const tools = [
|
|
|
221
243
|
name: 'docx_find_literal',
|
|
222
244
|
description: 'Find exact current text in one small page of revision-bound native DOCX objects. With kind table or row, matching includes descendant cell text.',
|
|
223
245
|
inputSchema: inputContract('docx_find_literal'),
|
|
246
|
+
outputSchema: docxFindLiteralOutput,
|
|
224
247
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
225
248
|
handler: args => docxObservation('docx_find_literal', args),
|
|
226
249
|
},
|
|
@@ -465,11 +488,11 @@ function buildServer() {
|
|
|
465
488
|
return server;
|
|
466
489
|
}
|
|
467
490
|
|
|
468
|
-
function
|
|
491
|
+
function compactDocxInspection(report) {
|
|
469
492
|
if (!report?.revision || !Array.isArray(report.tables)) {
|
|
470
493
|
throw new Error('docx-table-inspection-result-invalid');
|
|
471
494
|
}
|
|
472
|
-
return { revision: report.revision,
|
|
495
|
+
return { revision: report.revision, summary: { tableCount: report.tables.length } };
|
|
473
496
|
}
|
|
474
497
|
|
|
475
498
|
function compactDocxObjectIdentity(object) {
|
|
@@ -502,14 +525,27 @@ async function docxInspect(args) {
|
|
|
502
525
|
runtime: commandRuntime(result),
|
|
503
526
|
source: await fileArtifact(input),
|
|
504
527
|
artifact: await writeJsonArtifact(requireString(args.output, 'output'), result.json),
|
|
505
|
-
...
|
|
528
|
+
...compactDocxInspection(result.json.tables),
|
|
506
529
|
};
|
|
507
530
|
}
|
|
508
531
|
|
|
509
532
|
async function docxObservation(tool, args) {
|
|
510
533
|
return withTempJsonFile(args, async requestPath => {
|
|
511
534
|
const result = await runJsonCandidateChain(docxCandidates, [tool, requestPath]);
|
|
512
|
-
|
|
535
|
+
const payload = { ...result.json, runtime: commandRuntime(result) };
|
|
536
|
+
if (tool === 'docx_list_objects') {
|
|
537
|
+
return { ...payload, objects: payload.objects.map(compactDocxObjectIdentity) };
|
|
538
|
+
}
|
|
539
|
+
if (tool === 'docx_find_literal') {
|
|
540
|
+
return {
|
|
541
|
+
...payload,
|
|
542
|
+
matches: payload.matches.map(match => ({
|
|
543
|
+
object: compactDocxObjectIdentity(match.object),
|
|
544
|
+
matches: match.matches,
|
|
545
|
+
})),
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
throw new Error(`unsupported-docx-observation-tool:${tool}`);
|
|
513
549
|
});
|
|
514
550
|
}
|
|
515
551
|
|