@tiwater/office-mcp 0.17.4 → 0.17.6
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,13 @@ 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
|
+
openingText: z.array(z.string().min(1).max(240)).max(6),
|
|
177
|
+
}).strict(),
|
|
186
178
|
}).strict();
|
|
187
179
|
}
|
|
188
180
|
|
|
@@ -234,7 +226,7 @@ const docxReadObjectOutput = artifactOutput('docx_read_object').extend({
|
|
|
234
226
|
const tools = [
|
|
235
227
|
{
|
|
236
228
|
name: 'docx_inspect',
|
|
237
|
-
description: 'Inspect one current DOCX. The response returns its revision and a bounded
|
|
229
|
+
description: 'Inspect one current DOCX. The response returns its revision, table count, and a bounded sample of its opening non-empty paragraphs for document identification; use paged docx_find_literal or docx_list_objects to select native objects. The complete inspection remains in the evidence artifact.',
|
|
238
230
|
inputSchema: inputContract('docx_inspect'),
|
|
239
231
|
outputSchema: docxInspectionOutput('docx_inspect'),
|
|
240
232
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
@@ -497,11 +489,18 @@ function buildServer() {
|
|
|
497
489
|
return server;
|
|
498
490
|
}
|
|
499
491
|
|
|
500
|
-
function
|
|
501
|
-
if (!report?.revision || !Array.isArray(report.tables)) {
|
|
492
|
+
function compactDocxInspection(report) {
|
|
493
|
+
if (!report?.tables?.revision || !Array.isArray(report.tables.tables) || !Array.isArray(report.flow)) {
|
|
502
494
|
throw new Error('docx-table-inspection-result-invalid');
|
|
503
495
|
}
|
|
504
|
-
|
|
496
|
+
const openingText = report.flow
|
|
497
|
+
.filter(item => item?.type === 'paragraph' && typeof item.text === 'string' && item.text.trim())
|
|
498
|
+
.slice(0, 6)
|
|
499
|
+
.map(item => item.text.trim().replace(/\s+/gu, ' ').slice(0, 240));
|
|
500
|
+
return {
|
|
501
|
+
revision: report.tables.revision,
|
|
502
|
+
summary: { tableCount: report.tables.tables.length, openingText },
|
|
503
|
+
};
|
|
505
504
|
}
|
|
506
505
|
|
|
507
506
|
function compactDocxObjectIdentity(object) {
|
|
@@ -534,7 +533,7 @@ async function docxInspect(args) {
|
|
|
534
533
|
runtime: commandRuntime(result),
|
|
535
534
|
source: await fileArtifact(input),
|
|
536
535
|
artifact: await writeJsonArtifact(requireString(args.output, 'output'), result.json),
|
|
537
|
-
...
|
|
536
|
+
...compactDocxInspection(result.json),
|
|
538
537
|
};
|
|
539
538
|
}
|
|
540
539
|
|