@tiwater/office-mcp 0.17.6 → 0.17.7
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
|
@@ -187,6 +187,19 @@ const docxObjectIdentity = z.object({
|
|
|
187
187
|
verticalMerge: z.string().nullable(),
|
|
188
188
|
}).strict();
|
|
189
189
|
|
|
190
|
+
const docxNestedObjectIdentity = docxObjectIdentity.pick({
|
|
191
|
+
ref: true,
|
|
192
|
+
kind: true,
|
|
193
|
+
textPreview: true,
|
|
194
|
+
}).extend({
|
|
195
|
+
gridSpan: z.number().int().positive().optional(),
|
|
196
|
+
verticalMerge: z.string().optional(),
|
|
197
|
+
}).strict();
|
|
198
|
+
const docxObservationNode = z.lazy(() => z.object({
|
|
199
|
+
object: docxNestedObjectIdentity,
|
|
200
|
+
children: z.array(docxObservationNode).optional(),
|
|
201
|
+
}).strict());
|
|
202
|
+
|
|
190
203
|
const docxObservationReceipt = z.object({
|
|
191
204
|
schema: z.literal('tiwater.docx-observation-receipt/v1'),
|
|
192
205
|
operation: z.enum(['list', 'find', 'read']),
|
|
@@ -219,8 +232,7 @@ const docxFindLiteralOutput = z.object({
|
|
|
219
232
|
|
|
220
233
|
const docxReadObjectOutput = artifactOutput('docx_read_object').extend({
|
|
221
234
|
revision: docxRevision,
|
|
222
|
-
|
|
223
|
-
objects: z.array(docxObjectIdentity).min(1),
|
|
235
|
+
observation: docxObservationNode,
|
|
224
236
|
}).strict();
|
|
225
237
|
|
|
226
238
|
const tools = [
|
|
@@ -514,15 +526,24 @@ function compactDocxObjectIdentity(object) {
|
|
|
514
526
|
};
|
|
515
527
|
}
|
|
516
528
|
|
|
517
|
-
function
|
|
518
|
-
|
|
519
|
-
function
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
529
|
+
function compactDocxObservation(observation) {
|
|
530
|
+
if (!observation?.object) throw new Error('docx-read-object-missing-observation');
|
|
531
|
+
function compactNode(node) {
|
|
532
|
+
const identity = compactDocxObjectIdentity(node.object);
|
|
533
|
+
const object = {
|
|
534
|
+
ref: identity.ref,
|
|
535
|
+
kind: identity.kind,
|
|
536
|
+
textPreview: identity.textPreview,
|
|
537
|
+
...(identity.gridSpan === null ? {} : { gridSpan: identity.gridSpan }),
|
|
538
|
+
...(identity.verticalMerge === null ? {} : { verticalMerge: identity.verticalMerge }),
|
|
539
|
+
};
|
|
540
|
+
const children = (node.children ?? []).map(compactNode);
|
|
541
|
+
return {
|
|
542
|
+
object,
|
|
543
|
+
...(children.length === 0 ? {} : { children }),
|
|
544
|
+
};
|
|
523
545
|
}
|
|
524
|
-
|
|
525
|
-
return objects;
|
|
546
|
+
return compactNode(observation);
|
|
526
547
|
}
|
|
527
548
|
|
|
528
549
|
async function docxInspect(args) {
|
|
@@ -569,8 +590,7 @@ async function docxReadObject(args) {
|
|
|
569
590
|
source: await fileArtifact(input),
|
|
570
591
|
artifact: await writeJsonArtifact(output, result.json),
|
|
571
592
|
revision: result.json.receipt.revision,
|
|
572
|
-
|
|
573
|
-
objects: compactDocxObservationObjects(result.json.observation),
|
|
593
|
+
observation: compactDocxObservation(result.json.observation),
|
|
574
594
|
};
|
|
575
595
|
});
|
|
576
596
|
}
|