@tiwater/office-mcp 0.17.2 → 0.17.4
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
|
@@ -195,6 +195,36 @@ const docxObjectIdentity = z.object({
|
|
|
195
195
|
verticalMerge: z.string().nullable(),
|
|
196
196
|
}).strict();
|
|
197
197
|
|
|
198
|
+
const docxObservationReceipt = z.object({
|
|
199
|
+
schema: z.literal('tiwater.docx-observation-receipt/v1'),
|
|
200
|
+
operation: z.enum(['list', 'find', 'read']),
|
|
201
|
+
revision: docxRevision,
|
|
202
|
+
totalCount: z.number().int().nonnegative(),
|
|
203
|
+
returnedCount: z.number().int().nonnegative(),
|
|
204
|
+
remaining: z.number().int().nonnegative(),
|
|
205
|
+
continuation: z.string().nullable(),
|
|
206
|
+
}).strict();
|
|
207
|
+
|
|
208
|
+
const docxListObjectsOutput = z.object({
|
|
209
|
+
schema: z.literal('tiwater.docx-observation-list/v1'),
|
|
210
|
+
receipt: docxObservationReceipt,
|
|
211
|
+
objects: z.array(docxObjectIdentity),
|
|
212
|
+
runtime: runtimeIdentity,
|
|
213
|
+
}).strict();
|
|
214
|
+
|
|
215
|
+
const docxFindLiteralOutput = z.object({
|
|
216
|
+
schema: z.literal('tiwater.docx-observation-find/v1'),
|
|
217
|
+
receipt: docxObservationReceipt,
|
|
218
|
+
matches: z.array(z.object({
|
|
219
|
+
object: docxObjectIdentity,
|
|
220
|
+
matches: z.array(z.object({
|
|
221
|
+
offset: z.number().int().nonnegative(),
|
|
222
|
+
length: z.number().int().positive(),
|
|
223
|
+
}).strict()),
|
|
224
|
+
}).strict()),
|
|
225
|
+
runtime: runtimeIdentity,
|
|
226
|
+
}).strict();
|
|
227
|
+
|
|
198
228
|
const docxReadObjectOutput = artifactOutput('docx_read_object').extend({
|
|
199
229
|
revision: docxRevision,
|
|
200
230
|
object: docxObjectIdentity,
|
|
@@ -212,8 +242,9 @@ const tools = [
|
|
|
212
242
|
},
|
|
213
243
|
{
|
|
214
244
|
name: 'docx_list_objects',
|
|
215
|
-
description: 'List one small page of revision-bound
|
|
245
|
+
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
246
|
inputSchema: inputContract('docx_list_objects'),
|
|
247
|
+
outputSchema: docxListObjectsOutput,
|
|
217
248
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
218
249
|
handler: args => docxObservation('docx_list_objects', args),
|
|
219
250
|
},
|
|
@@ -221,6 +252,7 @@ const tools = [
|
|
|
221
252
|
name: 'docx_find_literal',
|
|
222
253
|
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
254
|
inputSchema: inputContract('docx_find_literal'),
|
|
255
|
+
outputSchema: docxFindLiteralOutput,
|
|
224
256
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
225
257
|
handler: args => docxObservation('docx_find_literal', args),
|
|
226
258
|
},
|
|
@@ -509,7 +541,20 @@ async function docxInspect(args) {
|
|
|
509
541
|
async function docxObservation(tool, args) {
|
|
510
542
|
return withTempJsonFile(args, async requestPath => {
|
|
511
543
|
const result = await runJsonCandidateChain(docxCandidates, [tool, requestPath]);
|
|
512
|
-
|
|
544
|
+
const payload = { ...result.json, runtime: commandRuntime(result) };
|
|
545
|
+
if (tool === 'docx_list_objects') {
|
|
546
|
+
return { ...payload, objects: payload.objects.map(compactDocxObjectIdentity) };
|
|
547
|
+
}
|
|
548
|
+
if (tool === 'docx_find_literal') {
|
|
549
|
+
return {
|
|
550
|
+
...payload,
|
|
551
|
+
matches: payload.matches.map(match => ({
|
|
552
|
+
object: compactDocxObjectIdentity(match.object),
|
|
553
|
+
matches: match.matches,
|
|
554
|
+
})),
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
throw new Error(`unsupported-docx-observation-tool:${tool}`);
|
|
513
558
|
});
|
|
514
559
|
}
|
|
515
560
|
|