@tiwater/office-mcp 0.21.44 → 0.21.46
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_replace_content_from_source.schema.json +6 -1
- package/office/contracts/tiwater-office-provider-contract-manifest-v1.json +3 -3
- package/office/file-backed-changes.mjs +22 -0
- package/office/index.mjs +3 -2
- 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
|
@@ -106,6 +106,12 @@
|
|
|
106
106
|
"additionalProperties": false
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
|
+
"changesInput": {
|
|
110
|
+
"type": "string",
|
|
111
|
+
"minLength": 1,
|
|
112
|
+
"description": "Absolute path to a JSON file containing the same non-empty changes array accepted by changes. Use this for large batches so the array stays out of the tool call.",
|
|
113
|
+
"x-tiwater-file-role": "read"
|
|
114
|
+
},
|
|
109
115
|
"output": {
|
|
110
116
|
"type": "string",
|
|
111
117
|
"minLength": 1,
|
|
@@ -122,7 +128,6 @@
|
|
|
122
128
|
},
|
|
123
129
|
"required": [
|
|
124
130
|
"input",
|
|
125
|
-
"changes",
|
|
126
131
|
"output",
|
|
127
132
|
"receiptOutput"
|
|
128
133
|
],
|
|
@@ -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.46"
|
|
6
6
|
},
|
|
7
7
|
"tools": [
|
|
8
8
|
{
|
|
@@ -174,11 +174,11 @@
|
|
|
174
174
|
"name": "docx_replace_content_from_source",
|
|
175
175
|
"providerContract": {
|
|
176
176
|
"source": "packages/docx-cli/contracts/mcp-input/docx_replace_content_from_source.schema.json",
|
|
177
|
-
"sha256": "
|
|
177
|
+
"sha256": "91f021a7a848778adaffdbf338524d8a94b5593665be064edc17bd09f94ccafa"
|
|
178
178
|
},
|
|
179
179
|
"inputContract": {
|
|
180
180
|
"path": "office/contracts/docx_replace_content_from_source.schema.json",
|
|
181
|
-
"sha256": "
|
|
181
|
+
"sha256": "91f021a7a848778adaffdbf338524d8a94b5593665be064edc17bd09f94ccafa"
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
184
|
{
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
export async function resolveFileBackedChanges(args) {
|
|
5
|
+
const hasInline = Array.isArray(args?.changes);
|
|
6
|
+
const hasFile = typeof args?.changesInput === 'string' && args.changesInput.trim().length > 0;
|
|
7
|
+
if (!hasInline && !hasFile) throw new Error('provide-changes-or-changesInput');
|
|
8
|
+
if (hasInline && !hasFile) return args;
|
|
9
|
+
|
|
10
|
+
let changes;
|
|
11
|
+
try {
|
|
12
|
+
changes = JSON.parse(await readFile(path.resolve(args.changesInput), 'utf8'));
|
|
13
|
+
} catch (error) {
|
|
14
|
+
throw new Error(`changesInput-invalid: ${error.message}`);
|
|
15
|
+
}
|
|
16
|
+
if (!Array.isArray(changes) || changes.length === 0) {
|
|
17
|
+
throw new Error('changesInput-must-contain-non-empty-json-array');
|
|
18
|
+
}
|
|
19
|
+
const resolved = { ...args, changes: hasInline ? [...args.changes, ...changes] : changes };
|
|
20
|
+
delete resolved.changesInput;
|
|
21
|
+
return resolved;
|
|
22
|
+
}
|
package/office/index.mjs
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
effectKindMetadata,
|
|
31
31
|
} from '../_shared/effect-kind.mjs';
|
|
32
32
|
import { compactDocxObjectIdentity } from './docx-object-identity.mjs';
|
|
33
|
+
import { resolveFileBackedChanges } from './file-backed-changes.mjs';
|
|
33
34
|
|
|
34
35
|
const packageMetadata = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
|
|
35
36
|
const inputContractManifest = JSON.parse(await readFile(
|
|
@@ -591,10 +592,10 @@ const tools = [
|
|
|
591
592
|
{
|
|
592
593
|
name: 'docx_replace_content_from_source',
|
|
593
594
|
effectKind: 'document-mutation',
|
|
594
|
-
description: 'Atomically replace one or more existing target paragraphs or cells with exactly the selected native source content. Select source cells, paragraphs, runs, text nodes, or Unicode-scalar text ranges; omitted content is omitted, while selected runs retain superscript, subscript, formulas, numbers, units, and symbols. This tool does not change table rows, spans, or merges.',
|
|
595
|
+
description: 'Atomically replace one or more existing target paragraphs or cells with exactly the selected native source content. Pass small batches in changes or keep a large batch out of the tool call by putting the same changes array in changesInput. Select source cells, paragraphs, runs, text nodes, or Unicode-scalar text ranges; omitted content is omitted, while selected runs retain superscript, subscript, formulas, numbers, units, and symbols. This tool does not change table rows, spans, or merges.',
|
|
595
596
|
inputSchema: inputContract('docx_replace_content_from_source'),
|
|
596
597
|
outputSchema: fixedEditOutput('docx_replace_content_from_source'),
|
|
597
|
-
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
598
|
+
handler: async (args, tool) => fixedEdit(tool, await resolveFileBackedChanges(args), docxCandidates),
|
|
598
599
|
},
|
|
599
600
|
{
|
|
600
601
|
name: 'docx_set_text',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiwater/office-mcp",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.46",
|
|
4
4
|
"description": "Published MCP distribution for independent Tiwater Office, PDF, and Text document capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"_shared/effect-kind.mjs",
|
|
27
27
|
"office/index.mjs",
|
|
28
28
|
"office/docx-object-identity.mjs",
|
|
29
|
+
"office/file-backed-changes.mjs",
|
|
29
30
|
"office/README.md",
|
|
30
31
|
"office/contracts/tiwater-office-provider-contract-manifest-v1.json",
|
|
31
32
|
"office/contracts/*.schema.json",
|