@tiwater/office-mcp 0.21.46 → 0.21.47
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/contracts/docx_set_table.schema.json +7 -1
- package/office/contracts/tiwater-office-provider-contract-manifest-v1.json +3 -3
- package/office/file-backed-table.mjs +31 -0
- package/office/index.mjs +2 -1
- package/package.json +2 -1
- package/pdf/contracts/tiwater-pdf-provider-contract-manifest-v1.json +1 -1
- package/text/contracts/tiwater-text-provider-contract-manifest-v1.json +1 -1
|
@@ -93,9 +93,15 @@
|
|
|
93
93
|
}, "required": ["prototypeRow", "cells"], "additionalProperties": false
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
|
+
"tableInput": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"minLength": 1,
|
|
99
|
+
"description": "Absolute path to a JSON file containing exactly table, existingRows, columns, and rows. Use this for a large table replacement so its structure and content stay out of the tool call.",
|
|
100
|
+
"x-tiwater-file-role": "read"
|
|
101
|
+
},
|
|
96
102
|
"output": { "type": "string", "minLength": 1, "description": "Output DOCX path; may equal input for one atomic in-place update.", "x-tiwater-file-role": "write" },
|
|
97
103
|
"receiptOutput": { "type": "string", "minLength": 1, "x-tiwater-file-role": "write", "x-tiwater-file-effect": false }
|
|
98
104
|
},
|
|
99
|
-
"required": ["input", "
|
|
105
|
+
"required": ["input", "output", "receiptOutput"],
|
|
100
106
|
"additionalProperties": false
|
|
101
107
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schema": "tiwater.office-provider-contract-manifest/v1",
|
|
3
3
|
"provider": {
|
|
4
4
|
"id": "@tiwater/office-mcp",
|
|
5
|
-
"version": "0.21.
|
|
5
|
+
"version": "0.21.47"
|
|
6
6
|
},
|
|
7
7
|
"tools": [
|
|
8
8
|
{
|
|
@@ -207,11 +207,11 @@
|
|
|
207
207
|
"name": "docx_set_table",
|
|
208
208
|
"providerContract": {
|
|
209
209
|
"source": "packages/docx-cli/contracts/mcp-input/docx_set_table.schema.json",
|
|
210
|
-
"sha256": "
|
|
210
|
+
"sha256": "d04c40174ce3427689c970b26dd3a282f9d9f6889e4c5ac737eca5926ef709b9"
|
|
211
211
|
},
|
|
212
212
|
"inputContract": {
|
|
213
213
|
"path": "office/contracts/docx_set_table.schema.json",
|
|
214
|
-
"sha256": "
|
|
214
|
+
"sha256": "d04c40174ce3427689c970b26dd3a282f9d9f6889e4c5ac737eca5926ef709b9"
|
|
215
215
|
}
|
|
216
216
|
},
|
|
217
217
|
{
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
const tableFields = ['table', 'existingRows', 'columns', 'rows'];
|
|
5
|
+
|
|
6
|
+
function hasInlineTable(args) {
|
|
7
|
+
return tableFields.every((field) => args?.[field] !== undefined);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function resolveFileBackedTable(args) {
|
|
11
|
+
const hasInline = hasInlineTable(args);
|
|
12
|
+
const hasFile = typeof args?.tableInput === 'string' && args.tableInput.trim().length > 0;
|
|
13
|
+
if (!hasInline && !hasFile) throw new Error('provide-inline-table-or-tableInput');
|
|
14
|
+
if (hasInline && hasFile) throw new Error('provide-only-one-table-input');
|
|
15
|
+
if (hasInline) return args;
|
|
16
|
+
|
|
17
|
+
let tableRequest;
|
|
18
|
+
try {
|
|
19
|
+
tableRequest = JSON.parse(await readFile(path.resolve(args.tableInput), 'utf8'));
|
|
20
|
+
} catch (error) {
|
|
21
|
+
throw new Error(`tableInput-invalid: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
if (!tableRequest || typeof tableRequest !== 'object' || Array.isArray(tableRequest)
|
|
24
|
+
|| !tableFields.every((field) => tableRequest[field] !== undefined)
|
|
25
|
+
|| Object.keys(tableRequest).some((field) => !tableFields.includes(field))) {
|
|
26
|
+
throw new Error('tableInput-must-contain-table-existingRows-columns-and-rows');
|
|
27
|
+
}
|
|
28
|
+
const resolved = { ...args, ...tableRequest };
|
|
29
|
+
delete resolved.tableInput;
|
|
30
|
+
return resolved;
|
|
31
|
+
}
|
package/office/index.mjs
CHANGED
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
} from '../_shared/effect-kind.mjs';
|
|
32
32
|
import { compactDocxObjectIdentity } from './docx-object-identity.mjs';
|
|
33
33
|
import { resolveFileBackedChanges } from './file-backed-changes.mjs';
|
|
34
|
+
import { resolveFileBackedTable } from './file-backed-table.mjs';
|
|
34
35
|
|
|
35
36
|
const packageMetadata = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
|
|
36
37
|
const inputContractManifest = JSON.parse(await readFile(
|
|
@@ -619,7 +620,7 @@ const tools = [
|
|
|
619
620
|
description: 'Atomically replace one exact current target-table row range with a fully specified table body. Name every target grid column in native order. Every rows[] item must contain its own prototypeRow; there is no table-level prototypeRow. Every cell must contain text: use a string for derived plain text, or null together with sourceInput and exact native sourceSelections. Each explicit cell occupies contiguous columns and may span logical rows; covered columns are omitted from following rows. Native source selections retain run formatting such as superscript and subscript. The provider retains the target table, target cell styles, grid widths, and all content outside the replaced range, and exposes no intermediate document. It does not select source rows, map business columns, infer target shape, derive wording, or copy a source table wholesale.',
|
|
620
621
|
inputSchema: inputContract('docx_set_table'),
|
|
621
622
|
outputSchema: fixedEditOutput('docx_set_table'),
|
|
622
|
-
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
623
|
+
handler: async (args, tool) => fixedEdit(tool, await resolveFileBackedTable(args), docxCandidates),
|
|
623
624
|
},
|
|
624
625
|
{
|
|
625
626
|
name: 'docx_insert_objects',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiwater/office-mcp",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.47",
|
|
4
4
|
"description": "Published MCP distribution for independent Tiwater Office, PDF, and Text document capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"office/index.mjs",
|
|
28
28
|
"office/docx-object-identity.mjs",
|
|
29
29
|
"office/file-backed-changes.mjs",
|
|
30
|
+
"office/file-backed-table.mjs",
|
|
30
31
|
"office/README.md",
|
|
31
32
|
"office/contracts/tiwater-office-provider-contract-manifest-v1.json",
|
|
32
33
|
"office/contracts/*.schema.json",
|