@tiwater/office-mcp 0.21.33 → 0.21.35
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/_shared/effect-kind.mjs +64 -0
- package/office/contracts/docx_apply_font_policy.schema.json +1 -1
- package/office/contracts/docx_apply_toc_style_policy.schema.json +1 -1
- package/office/contracts/docx_delete_object.schema.json +1 -1
- package/office/contracts/docx_delete_table_columns.schema.json +1 -1
- package/office/contracts/docx_fill_table_from_tables.schema.json +1 -1
- package/office/contracts/docx_insert_objects.schema.json +1 -1
- package/office/contracts/docx_insert_table_columns.schema.json +1 -1
- package/office/contracts/docx_merge_cells.schema.json +1 -1
- package/office/contracts/docx_refresh_fields.schema.json +1 -1
- package/office/contracts/docx_replace_content_from_source.schema.json +1 -1
- package/office/contracts/docx_replace_style_ids.schema.json +1 -1
- package/office/contracts/docx_set_paragraph_pagination.schema.json +1 -1
- package/office/contracts/docx_set_table_body.schema.json +1 -1
- package/office/contracts/docx_set_text.schema.json +1 -1
- package/office/contracts/docx_split_cells.schema.json +1 -1
- package/office/contracts/docx_strip_direct_formatting.schema.json +1 -1
- package/office/contracts/pptx_apply_format.schema.json +1 -1
- package/office/contracts/pptx_apply_template.schema.json +1 -1
- package/office/contracts/pptx_replace_picture_image.schema.json +1 -1
- package/office/contracts/pptx_set_shape_geometry.schema.json +1 -1
- package/office/contracts/tiwater-office-provider-contract-manifest-v1.json +65 -65
- package/office/contracts/xlsx_copy_row.schema.json +1 -1
- package/office/contracts/xlsx_delete_rows.schema.json +1 -1
- package/office/contracts/xlsx_expand_section_rows.schema.json +1 -1
- package/office/contracts/xlsx_insert_rows.schema.json +1 -1
- package/office/contracts/xlsx_set_cell_number_format.schema.json +1 -1
- package/office/contracts/xlsx_set_cell_value.schema.json +1 -1
- package/office/contracts/xlsx_set_column_width.schema.json +1 -1
- package/office/contracts/xlsx_set_page_setup.schema.json +1 -1
- package/office/contracts/xlsx_set_print_area.schema.json +1 -1
- package/office/contracts/xlsx_set_range_values.schema.json +1 -1
- package/office/contracts/xlsx_set_rich_text_cell_value.schema.json +1 -1
- package/office/contracts/xlsx_set_row_page_breaks.schema.json +1 -1
- package/office/index.mjs +55 -37
- package/package.json +1 -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
package/_shared/effect-kind.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { evidenceRoleMetadataKey } from './evidence-role.mjs';
|
|
|
2
2
|
|
|
3
3
|
export const effectKindMetadataKey = 'x-tiwater-effect-kind';
|
|
4
4
|
export const effectKindSchema = 'tiwater.provider-effect-kind/v1';
|
|
5
|
+
export const documentRevisionRoleKey = 'x-tiwater-document-revision-role';
|
|
5
6
|
|
|
6
7
|
const effectKinds = new Set([
|
|
7
8
|
'document-mutation',
|
|
@@ -24,9 +25,18 @@ export function assertEffectKindToolContract(tool, expectedKind = undefined) {
|
|
|
24
25
|
const bindings = fileBindings(tool?.inputSchema);
|
|
25
26
|
const effectiveWrites = bindings.filter(binding => binding.role === 'write' && binding.effect);
|
|
26
27
|
const readOnly = tool?.annotations?.readOnlyHint === true;
|
|
28
|
+
const currentDocumentBindings = bindings.filter(binding => binding.revisionRole === 'current');
|
|
29
|
+
const invalidRevisionBindings = bindings.filter(binding => binding.revisionRole !== undefined
|
|
30
|
+
&& (binding.revisionRole !== 'current' || binding.role !== 'read'));
|
|
31
|
+
if (invalidRevisionBindings.length > 0) {
|
|
32
|
+
throw new Error(`document-revision-role-invalid:${tool?.name || 'unnamed'}`);
|
|
33
|
+
}
|
|
27
34
|
|
|
28
35
|
if (readOnly || effectiveWrites.length === 0) {
|
|
29
36
|
if (metadata !== undefined) throw new Error(`effect-kind-unexpected:${tool?.name || 'unnamed'}`);
|
|
37
|
+
if (currentDocumentBindings.length !== 0) {
|
|
38
|
+
throw new Error(`document-revision-role-unexpected:${tool?.name || 'unnamed'}`);
|
|
39
|
+
}
|
|
30
40
|
return null;
|
|
31
41
|
}
|
|
32
42
|
if (!metadata || Object.keys(metadata).sort().join(',') !== 'kind,schema'
|
|
@@ -39,6 +49,16 @@ export function assertEffectKindToolContract(tool, expectedKind = undefined) {
|
|
|
39
49
|
if (!bindings.some(binding => binding.role === 'read')) {
|
|
40
50
|
throw new Error(`effect-kind-source-binding-missing:${tool?.name || 'unnamed'}`);
|
|
41
51
|
}
|
|
52
|
+
if (metadata.kind === 'document-mutation') {
|
|
53
|
+
if (currentDocumentBindings.length !== 1) {
|
|
54
|
+
throw new Error(`document-mutation-current-binding-invalid:${tool?.name || 'unnamed'}`);
|
|
55
|
+
}
|
|
56
|
+
if (effectiveWrites.length !== 1) {
|
|
57
|
+
throw new Error(`document-mutation-output-binding-invalid:${tool?.name || 'unnamed'}`);
|
|
58
|
+
}
|
|
59
|
+
} else if (currentDocumentBindings.length !== 0) {
|
|
60
|
+
throw new Error(`document-revision-role-unexpected:${tool?.name || 'unnamed'}`);
|
|
61
|
+
}
|
|
42
62
|
|
|
43
63
|
const evidenceRole = tool?._meta?.[evidenceRoleMetadataKey]?.role;
|
|
44
64
|
if ((metadata.kind === 'native-render') !== (evidenceRole === 'native-render')) {
|
|
@@ -50,6 +70,17 @@ export function assertEffectKindToolContract(tool, expectedKind = undefined) {
|
|
|
50
70
|
return metadata.kind;
|
|
51
71
|
}
|
|
52
72
|
|
|
73
|
+
export function documentMutationFileArguments(tool, args) {
|
|
74
|
+
assertEffectKindToolContract(tool, 'document-mutation');
|
|
75
|
+
const bindings = boundFileArguments(tool?.inputSchema, args);
|
|
76
|
+
const current = bindings.filter(binding => binding.revisionRole === 'current');
|
|
77
|
+
const effectiveOutput = bindings.filter(binding => binding.role === 'write' && binding.effect);
|
|
78
|
+
if (current.length !== 1 || effectiveOutput.length !== 1) {
|
|
79
|
+
throw new Error(`document-mutation-file-arguments-invalid:${tool?.name || 'unnamed'}`);
|
|
80
|
+
}
|
|
81
|
+
return { current: current[0].value, effectiveOutput: effectiveOutput[0].value };
|
|
82
|
+
}
|
|
83
|
+
|
|
53
84
|
function fileBindings(schema) {
|
|
54
85
|
const bindings = [];
|
|
55
86
|
function visit(node) {
|
|
@@ -59,6 +90,7 @@ function fileBindings(schema) {
|
|
|
59
90
|
role: node['x-tiwater-file-role'],
|
|
60
91
|
effect: node['x-tiwater-file-role'] === 'write'
|
|
61
92
|
&& node['x-tiwater-file-effect'] !== false,
|
|
93
|
+
revisionRole: node[documentRevisionRoleKey],
|
|
62
94
|
});
|
|
63
95
|
}
|
|
64
96
|
for (const child of Object.values(node.properties || {})) visit(child);
|
|
@@ -70,3 +102,35 @@ function fileBindings(schema) {
|
|
|
70
102
|
visit(schema);
|
|
71
103
|
return bindings;
|
|
72
104
|
}
|
|
105
|
+
|
|
106
|
+
function boundFileArguments(schema, value) {
|
|
107
|
+
const bindings = [];
|
|
108
|
+
function visit(node, currentValue) {
|
|
109
|
+
if (!node || typeof node !== 'object' || Array.isArray(node)) return;
|
|
110
|
+
if (node['x-tiwater-file-role'] === 'read' || node['x-tiwater-file-role'] === 'write') {
|
|
111
|
+
if (typeof currentValue !== 'string' || currentValue.length === 0) {
|
|
112
|
+
throw new Error('provider-file-argument-invalid');
|
|
113
|
+
}
|
|
114
|
+
bindings.push({
|
|
115
|
+
role: node['x-tiwater-file-role'],
|
|
116
|
+
effect: node['x-tiwater-file-role'] === 'write'
|
|
117
|
+
&& node['x-tiwater-file-effect'] !== false,
|
|
118
|
+
revisionRole: node[documentRevisionRoleKey],
|
|
119
|
+
value: currentValue,
|
|
120
|
+
});
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (Array.isArray(currentValue)) {
|
|
124
|
+
for (const entry of currentValue) visit(node.items, entry);
|
|
125
|
+
} else if (currentValue && typeof currentValue === 'object') {
|
|
126
|
+
for (const [name, child] of Object.entries(node.properties || {})) {
|
|
127
|
+
if (Object.hasOwn(currentValue, name)) visit(child, currentValue[name]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
for (const keyword of ['allOf', 'anyOf', 'oneOf']) {
|
|
131
|
+
for (const child of node[keyword] || []) visit(child, currentValue);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
visit(schema, value);
|
|
135
|
+
return bindings;
|
|
136
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"$id": "tiwater.office-mcp-input/docx_apply_font_policy",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
6
|
-
"input": { "type": "string", "minLength": 1, "x-tiwater-file-role": "read" },
|
|
6
|
+
"input": { "type": "string", "minLength": 1, "x-tiwater-file-role": "read", "x-tiwater-document-revision-role": "current" },
|
|
7
7
|
"policy": {
|
|
8
8
|
"type": "string",
|
|
9
9
|
"minLength": 1,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"$id": "tiwater.office-mcp-input/docx_apply_toc_style_policy",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
6
|
-
"input": { "type": "string", "minLength": 1, "x-tiwater-file-role": "read" },
|
|
6
|
+
"input": { "type": "string", "minLength": 1, "x-tiwater-file-role": "read", "x-tiwater-document-revision-role": "current" },
|
|
7
7
|
"italic": { "type": "boolean" },
|
|
8
8
|
"indentCharactersPerLevel": { "type": "integer", "minimum": 0, "maximum": 21474836 },
|
|
9
9
|
"output": { "type": "string", "minLength": 1, "description": "Output DOCX path; may equal input for an atomic in-place update.", "x-tiwater-file-role": "write" },
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"$id": "tiwater.office-mcp-input/docx_delete_table_columns",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
6
|
-
"input": { "type": "string", "minLength": 1, "x-tiwater-file-role": "read" },
|
|
6
|
+
"input": { "type": "string", "minLength": 1, "x-tiwater-file-role": "read", "x-tiwater-document-revision-role": "current" },
|
|
7
7
|
"changes": {
|
|
8
8
|
"type": "array",
|
|
9
9
|
"minItems": 1,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Project source-table rows into one target template table atomically. Use this instead of manually rebuilding rows when target cells derive from source tables. Target formatting is reused, and native vertical-merge owners are preserved within each source range.",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|
|
7
|
-
"input": { "type": "string", "minLength": 1, "description": "Current target DOCX.", "x-tiwater-file-role": "read" },
|
|
7
|
+
"input": { "type": "string", "minLength": 1, "description": "Current target DOCX.", "x-tiwater-file-role": "read", "x-tiwater-document-revision-role": "current" },
|
|
8
8
|
"table": {
|
|
9
9
|
"type": "object",
|
|
10
10
|
"description": "Current target table address returned by docx_read_table or docx_table_index.",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"$id": "tiwater.office-mcp-input/docx_insert_table_columns",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
6
|
-
"input": { "type": "string", "minLength": 1, "x-tiwater-file-role": "read" },
|
|
6
|
+
"input": { "type": "string", "minLength": 1, "x-tiwater-file-role": "read", "x-tiwater-document-revision-role": "current" },
|
|
7
7
|
"changes": {
|
|
8
8
|
"type": "array",
|
|
9
9
|
"minItems": 1,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"type": "string",
|
|
7
7
|
"minLength": 1,
|
|
8
8
|
"description": "Current target DOCX containing every target paragraph or table cell.",
|
|
9
|
-
"x-tiwater-file-role": "read"
|
|
9
|
+
"x-tiwater-file-role": "read", "x-tiwater-document-revision-role": "current"
|
|
10
10
|
},
|
|
11
11
|
"changes": {
|
|
12
12
|
"minItems": 1,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"$id": "tiwater.office-mcp-input/docx_set_paragraph_pagination",
|
|
4
4
|
"type": "object",
|
|
5
5
|
"properties": {
|
|
6
|
-
"input": { "type": "string", "minLength": 1, "x-tiwater-file-role": "read" },
|
|
6
|
+
"input": { "type": "string", "minLength": 1, "x-tiwater-file-role": "read", "x-tiwater-document-revision-role": "current" },
|
|
7
7
|
"changes": {
|
|
8
8
|
"type": "array",
|
|
9
9
|
"minItems": 1,
|
|
@@ -2,29 +2,29 @@
|
|
|
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.35"
|
|
6
6
|
},
|
|
7
7
|
"tools": [
|
|
8
8
|
{
|
|
9
9
|
"name": "docx_apply_font_policy",
|
|
10
10
|
"providerContract": {
|
|
11
11
|
"source": "packages/docx-cli/contracts/mcp-input/docx_apply_font_policy.schema.json",
|
|
12
|
-
"sha256": "
|
|
12
|
+
"sha256": "7e1dfab7d9d0900d6616334c4b9a03e9e91f8c3a5af84324db581cd74608a419"
|
|
13
13
|
},
|
|
14
14
|
"inputContract": {
|
|
15
15
|
"path": "office/contracts/docx_apply_font_policy.schema.json",
|
|
16
|
-
"sha256": "
|
|
16
|
+
"sha256": "7e1dfab7d9d0900d6616334c4b9a03e9e91f8c3a5af84324db581cd74608a419"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"name": "docx_apply_toc_style_policy",
|
|
21
21
|
"providerContract": {
|
|
22
22
|
"source": "packages/docx-cli/contracts/mcp-input/docx_apply_toc_style_policy.schema.json",
|
|
23
|
-
"sha256": "
|
|
23
|
+
"sha256": "975fd24572ae28fb2181edaae9da856417cdcd657f8d83c5eb46c3ff069d2376"
|
|
24
24
|
},
|
|
25
25
|
"inputContract": {
|
|
26
26
|
"path": "office/contracts/docx_apply_toc_style_policy.schema.json",
|
|
27
|
-
"sha256": "
|
|
27
|
+
"sha256": "975fd24572ae28fb2181edaae9da856417cdcd657f8d83c5eb46c3ff069d2376"
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
{
|
|
@@ -42,22 +42,22 @@
|
|
|
42
42
|
"name": "docx_delete_object",
|
|
43
43
|
"providerContract": {
|
|
44
44
|
"source": "packages/docx-cli/contracts/mcp-input/docx_delete_object.schema.json",
|
|
45
|
-
"sha256": "
|
|
45
|
+
"sha256": "f841659d8e26e7c6a2b4b1e4c67ab3323111bff9b66c380c9aeea82c2143f848"
|
|
46
46
|
},
|
|
47
47
|
"inputContract": {
|
|
48
48
|
"path": "office/contracts/docx_delete_object.schema.json",
|
|
49
|
-
"sha256": "
|
|
49
|
+
"sha256": "f841659d8e26e7c6a2b4b1e4c67ab3323111bff9b66c380c9aeea82c2143f848"
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
"name": "docx_delete_table_columns",
|
|
54
54
|
"providerContract": {
|
|
55
55
|
"source": "packages/docx-cli/contracts/mcp-input/docx_delete_table_columns.schema.json",
|
|
56
|
-
"sha256": "
|
|
56
|
+
"sha256": "db9f9a75ce57c2fcff3ab58c114df0c36b733582b8c6bd1e1d1640b5fa83fb5c"
|
|
57
57
|
},
|
|
58
58
|
"inputContract": {
|
|
59
59
|
"path": "office/contracts/docx_delete_table_columns.schema.json",
|
|
60
|
-
"sha256": "
|
|
60
|
+
"sha256": "db9f9a75ce57c2fcff3ab58c114df0c36b733582b8c6bd1e1d1640b5fa83fb5c"
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
{
|
|
@@ -75,33 +75,33 @@
|
|
|
75
75
|
"name": "docx_fill_table_from_tables",
|
|
76
76
|
"providerContract": {
|
|
77
77
|
"source": "packages/docx-cli/contracts/mcp-input/docx_fill_table_from_tables.schema.json",
|
|
78
|
-
"sha256": "
|
|
78
|
+
"sha256": "81d335ffaf20b896ae043e96a5a83f1beb3debbaf7404a99c8b4f06a62989c7d"
|
|
79
79
|
},
|
|
80
80
|
"inputContract": {
|
|
81
81
|
"path": "office/contracts/docx_fill_table_from_tables.schema.json",
|
|
82
|
-
"sha256": "
|
|
82
|
+
"sha256": "81d335ffaf20b896ae043e96a5a83f1beb3debbaf7404a99c8b4f06a62989c7d"
|
|
83
83
|
}
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
86
|
"name": "docx_insert_objects",
|
|
87
87
|
"providerContract": {
|
|
88
88
|
"source": "packages/docx-cli/contracts/mcp-input/docx_insert_objects.schema.json",
|
|
89
|
-
"sha256": "
|
|
89
|
+
"sha256": "7215f42b1d6cd02db26d6df5141a8090e4d7817e822d104388c6ab8e1df820e5"
|
|
90
90
|
},
|
|
91
91
|
"inputContract": {
|
|
92
92
|
"path": "office/contracts/docx_insert_objects.schema.json",
|
|
93
|
-
"sha256": "
|
|
93
|
+
"sha256": "7215f42b1d6cd02db26d6df5141a8090e4d7817e822d104388c6ab8e1df820e5"
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
97
|
"name": "docx_insert_table_columns",
|
|
98
98
|
"providerContract": {
|
|
99
99
|
"source": "packages/docx-cli/contracts/mcp-input/docx_insert_table_columns.schema.json",
|
|
100
|
-
"sha256": "
|
|
100
|
+
"sha256": "e3a6e0ed81b82ad8efe315defc4ed1d989dbf5b208a2e4207627582a98bed3ce"
|
|
101
101
|
},
|
|
102
102
|
"inputContract": {
|
|
103
103
|
"path": "office/contracts/docx_insert_table_columns.schema.json",
|
|
104
|
-
"sha256": "
|
|
104
|
+
"sha256": "e3a6e0ed81b82ad8efe315defc4ed1d989dbf5b208a2e4207627582a98bed3ce"
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
{
|
|
@@ -130,11 +130,11 @@
|
|
|
130
130
|
"name": "docx_merge_cells",
|
|
131
131
|
"providerContract": {
|
|
132
132
|
"source": "packages/docx-cli/contracts/mcp-input/docx_merge_cells.schema.json",
|
|
133
|
-
"sha256": "
|
|
133
|
+
"sha256": "4ba37e5570ea7958c374111ae7c0f6460eec29937e5c822eba44eb1b8e908d17"
|
|
134
134
|
},
|
|
135
135
|
"inputContract": {
|
|
136
136
|
"path": "office/contracts/docx_merge_cells.schema.json",
|
|
137
|
-
"sha256": "
|
|
137
|
+
"sha256": "4ba37e5570ea7958c374111ae7c0f6460eec29937e5c822eba44eb1b8e908d17"
|
|
138
138
|
}
|
|
139
139
|
},
|
|
140
140
|
{
|
|
@@ -163,88 +163,88 @@
|
|
|
163
163
|
"name": "docx_refresh_fields",
|
|
164
164
|
"providerContract": {
|
|
165
165
|
"source": "packages/convert-cli/schemas/mcp-input/docx_refresh_fields.schema.json",
|
|
166
|
-
"sha256": "
|
|
166
|
+
"sha256": "54abe9d00cd535472b6aaec8309752d8f5d9b2432aaa9d0696180d71aba33b41"
|
|
167
167
|
},
|
|
168
168
|
"inputContract": {
|
|
169
169
|
"path": "office/contracts/docx_refresh_fields.schema.json",
|
|
170
|
-
"sha256": "
|
|
170
|
+
"sha256": "54abe9d00cd535472b6aaec8309752d8f5d9b2432aaa9d0696180d71aba33b41"
|
|
171
171
|
}
|
|
172
172
|
},
|
|
173
173
|
{
|
|
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": "beca665f61a19911e8c4cb17dc5bad27051c5561e8b31dd839f8825bee7e6385"
|
|
178
178
|
},
|
|
179
179
|
"inputContract": {
|
|
180
180
|
"path": "office/contracts/docx_replace_content_from_source.schema.json",
|
|
181
|
-
"sha256": "
|
|
181
|
+
"sha256": "beca665f61a19911e8c4cb17dc5bad27051c5561e8b31dd839f8825bee7e6385"
|
|
182
182
|
}
|
|
183
183
|
},
|
|
184
184
|
{
|
|
185
185
|
"name": "docx_replace_style_ids",
|
|
186
186
|
"providerContract": {
|
|
187
187
|
"source": "packages/docx-cli/contracts/mcp-input/docx_replace_style_ids.schema.json",
|
|
188
|
-
"sha256": "
|
|
188
|
+
"sha256": "5466f70cc69974d4cb2158760491820a43ab2c25ce1c950465a5169c9185ab81"
|
|
189
189
|
},
|
|
190
190
|
"inputContract": {
|
|
191
191
|
"path": "office/contracts/docx_replace_style_ids.schema.json",
|
|
192
|
-
"sha256": "
|
|
192
|
+
"sha256": "5466f70cc69974d4cb2158760491820a43ab2c25ce1c950465a5169c9185ab81"
|
|
193
193
|
}
|
|
194
194
|
},
|
|
195
195
|
{
|
|
196
196
|
"name": "docx_set_paragraph_pagination",
|
|
197
197
|
"providerContract": {
|
|
198
198
|
"source": "packages/docx-cli/contracts/mcp-input/docx_set_paragraph_pagination.schema.json",
|
|
199
|
-
"sha256": "
|
|
199
|
+
"sha256": "02343da9dd2072257781e7e94a07682639f3de80b4bec0c7d9c0fc5da6a3b2f5"
|
|
200
200
|
},
|
|
201
201
|
"inputContract": {
|
|
202
202
|
"path": "office/contracts/docx_set_paragraph_pagination.schema.json",
|
|
203
|
-
"sha256": "
|
|
203
|
+
"sha256": "02343da9dd2072257781e7e94a07682639f3de80b4bec0c7d9c0fc5da6a3b2f5"
|
|
204
204
|
}
|
|
205
205
|
},
|
|
206
206
|
{
|
|
207
207
|
"name": "docx_set_table_body",
|
|
208
208
|
"providerContract": {
|
|
209
209
|
"source": "packages/docx-cli/contracts/mcp-input/docx_set_table_body.schema.json",
|
|
210
|
-
"sha256": "
|
|
210
|
+
"sha256": "a22d7d38cd3bad30372d45e289e3dc4700a3e52715fec990ac4644888e92ac5e"
|
|
211
211
|
},
|
|
212
212
|
"inputContract": {
|
|
213
213
|
"path": "office/contracts/docx_set_table_body.schema.json",
|
|
214
|
-
"sha256": "
|
|
214
|
+
"sha256": "a22d7d38cd3bad30372d45e289e3dc4700a3e52715fec990ac4644888e92ac5e"
|
|
215
215
|
}
|
|
216
216
|
},
|
|
217
217
|
{
|
|
218
218
|
"name": "docx_set_text",
|
|
219
219
|
"providerContract": {
|
|
220
220
|
"source": "packages/docx-cli/contracts/mcp-input/docx_set_text.schema.json",
|
|
221
|
-
"sha256": "
|
|
221
|
+
"sha256": "4d6f69ef474c0a3ceade95cce362fba7e000946bb890e64119177c5519524db2"
|
|
222
222
|
},
|
|
223
223
|
"inputContract": {
|
|
224
224
|
"path": "office/contracts/docx_set_text.schema.json",
|
|
225
|
-
"sha256": "
|
|
225
|
+
"sha256": "4d6f69ef474c0a3ceade95cce362fba7e000946bb890e64119177c5519524db2"
|
|
226
226
|
}
|
|
227
227
|
},
|
|
228
228
|
{
|
|
229
229
|
"name": "docx_split_cells",
|
|
230
230
|
"providerContract": {
|
|
231
231
|
"source": "packages/docx-cli/contracts/mcp-input/docx_split_cells.schema.json",
|
|
232
|
-
"sha256": "
|
|
232
|
+
"sha256": "143e6953c3d03c3be723fdd807c06191f0833906322e565b27849aa256486f39"
|
|
233
233
|
},
|
|
234
234
|
"inputContract": {
|
|
235
235
|
"path": "office/contracts/docx_split_cells.schema.json",
|
|
236
|
-
"sha256": "
|
|
236
|
+
"sha256": "143e6953c3d03c3be723fdd807c06191f0833906322e565b27849aa256486f39"
|
|
237
237
|
}
|
|
238
238
|
},
|
|
239
239
|
{
|
|
240
240
|
"name": "docx_strip_direct_formatting",
|
|
241
241
|
"providerContract": {
|
|
242
242
|
"source": "packages/docx-cli/contracts/mcp-input/docx_strip_direct_formatting.schema.json",
|
|
243
|
-
"sha256": "
|
|
243
|
+
"sha256": "64509797afedcb98b6d8890681f2cd90a42ad1857e4ffc12b85d8ad51ec0569d"
|
|
244
244
|
},
|
|
245
245
|
"inputContract": {
|
|
246
246
|
"path": "office/contracts/docx_strip_direct_formatting.schema.json",
|
|
247
|
-
"sha256": "
|
|
247
|
+
"sha256": "64509797afedcb98b6d8890681f2cd90a42ad1857e4ffc12b85d8ad51ec0569d"
|
|
248
248
|
}
|
|
249
249
|
},
|
|
250
250
|
{
|
|
@@ -306,22 +306,22 @@
|
|
|
306
306
|
"name": "pptx_apply_format",
|
|
307
307
|
"providerContract": {
|
|
308
308
|
"source": "packages/pptx-cli/contracts/mcp-input/pptx_apply_format.schema.json",
|
|
309
|
-
"sha256": "
|
|
309
|
+
"sha256": "00c616c27bdcc2c0e66a0e59a4c2609ea32414993084d5987f5fc753334631c9"
|
|
310
310
|
},
|
|
311
311
|
"inputContract": {
|
|
312
312
|
"path": "office/contracts/pptx_apply_format.schema.json",
|
|
313
|
-
"sha256": "
|
|
313
|
+
"sha256": "00c616c27bdcc2c0e66a0e59a4c2609ea32414993084d5987f5fc753334631c9"
|
|
314
314
|
}
|
|
315
315
|
},
|
|
316
316
|
{
|
|
317
317
|
"name": "pptx_apply_template",
|
|
318
318
|
"providerContract": {
|
|
319
319
|
"source": "packages/pptx-cli/contracts/mcp-input/pptx_apply_template.schema.json",
|
|
320
|
-
"sha256": "
|
|
320
|
+
"sha256": "b059771ca8df233f63a73d94e8a21ca160656e76e6066d4b2c96babe0219a511"
|
|
321
321
|
},
|
|
322
322
|
"inputContract": {
|
|
323
323
|
"path": "office/contracts/pptx_apply_template.schema.json",
|
|
324
|
-
"sha256": "
|
|
324
|
+
"sha256": "b059771ca8df233f63a73d94e8a21ca160656e76e6066d4b2c96babe0219a511"
|
|
325
325
|
}
|
|
326
326
|
},
|
|
327
327
|
{
|
|
@@ -350,22 +350,22 @@
|
|
|
350
350
|
"name": "pptx_replace_picture_image",
|
|
351
351
|
"providerContract": {
|
|
352
352
|
"source": "packages/pptx-cli/contracts/mcp-input/pptx_replace_picture_image.schema.json",
|
|
353
|
-
"sha256": "
|
|
353
|
+
"sha256": "b74c4bba40a8dd7f2fd7e77c5292c9841316b570c7fb05676b3da47e8ae59880"
|
|
354
354
|
},
|
|
355
355
|
"inputContract": {
|
|
356
356
|
"path": "office/contracts/pptx_replace_picture_image.schema.json",
|
|
357
|
-
"sha256": "
|
|
357
|
+
"sha256": "b74c4bba40a8dd7f2fd7e77c5292c9841316b570c7fb05676b3da47e8ae59880"
|
|
358
358
|
}
|
|
359
359
|
},
|
|
360
360
|
{
|
|
361
361
|
"name": "pptx_set_shape_geometry",
|
|
362
362
|
"providerContract": {
|
|
363
363
|
"source": "packages/pptx-cli/contracts/mcp-input/pptx_set_shape_geometry.schema.json",
|
|
364
|
-
"sha256": "
|
|
364
|
+
"sha256": "7f828b26d0d49de519acb6348c141c459af9d42fd2279e6958edc7d50d75fb3d"
|
|
365
365
|
},
|
|
366
366
|
"inputContract": {
|
|
367
367
|
"path": "office/contracts/pptx_set_shape_geometry.schema.json",
|
|
368
|
-
"sha256": "
|
|
368
|
+
"sha256": "7f828b26d0d49de519acb6348c141c459af9d42fd2279e6958edc7d50d75fb3d"
|
|
369
369
|
}
|
|
370
370
|
},
|
|
371
371
|
{
|
|
@@ -394,33 +394,33 @@
|
|
|
394
394
|
"name": "xlsx_copy_row",
|
|
395
395
|
"providerContract": {
|
|
396
396
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_copy_row.schema.json",
|
|
397
|
-
"sha256": "
|
|
397
|
+
"sha256": "7159b2ed971a54a0c5f0c7e9686e6594908858694eab9e6e65b15771e0ab3500"
|
|
398
398
|
},
|
|
399
399
|
"inputContract": {
|
|
400
400
|
"path": "office/contracts/xlsx_copy_row.schema.json",
|
|
401
|
-
"sha256": "
|
|
401
|
+
"sha256": "7159b2ed971a54a0c5f0c7e9686e6594908858694eab9e6e65b15771e0ab3500"
|
|
402
402
|
}
|
|
403
403
|
},
|
|
404
404
|
{
|
|
405
405
|
"name": "xlsx_delete_rows",
|
|
406
406
|
"providerContract": {
|
|
407
407
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_delete_rows.schema.json",
|
|
408
|
-
"sha256": "
|
|
408
|
+
"sha256": "0d54bf1299dd8591baf2cd550adfb191ea6bfad91b3dfb28543a56d8dc135910"
|
|
409
409
|
},
|
|
410
410
|
"inputContract": {
|
|
411
411
|
"path": "office/contracts/xlsx_delete_rows.schema.json",
|
|
412
|
-
"sha256": "
|
|
412
|
+
"sha256": "0d54bf1299dd8591baf2cd550adfb191ea6bfad91b3dfb28543a56d8dc135910"
|
|
413
413
|
}
|
|
414
414
|
},
|
|
415
415
|
{
|
|
416
416
|
"name": "xlsx_expand_section_rows",
|
|
417
417
|
"providerContract": {
|
|
418
418
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_expand_section_rows.schema.json",
|
|
419
|
-
"sha256": "
|
|
419
|
+
"sha256": "93f9e8562e7bf99f3f0612bbf701efcd3c142f51be790e8b348a8472998f8f24"
|
|
420
420
|
},
|
|
421
421
|
"inputContract": {
|
|
422
422
|
"path": "office/contracts/xlsx_expand_section_rows.schema.json",
|
|
423
|
-
"sha256": "
|
|
423
|
+
"sha256": "93f9e8562e7bf99f3f0612bbf701efcd3c142f51be790e8b348a8472998f8f24"
|
|
424
424
|
}
|
|
425
425
|
},
|
|
426
426
|
{
|
|
@@ -438,11 +438,11 @@
|
|
|
438
438
|
"name": "xlsx_insert_rows",
|
|
439
439
|
"providerContract": {
|
|
440
440
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_insert_rows.schema.json",
|
|
441
|
-
"sha256": "
|
|
441
|
+
"sha256": "a295530a293a9930a5fe49d320f5d965fe4065322e2106575f0e74b18ec70680"
|
|
442
442
|
},
|
|
443
443
|
"inputContract": {
|
|
444
444
|
"path": "office/contracts/xlsx_insert_rows.schema.json",
|
|
445
|
-
"sha256": "
|
|
445
|
+
"sha256": "a295530a293a9930a5fe49d320f5d965fe4065322e2106575f0e74b18ec70680"
|
|
446
446
|
}
|
|
447
447
|
},
|
|
448
448
|
{
|
|
@@ -471,88 +471,88 @@
|
|
|
471
471
|
"name": "xlsx_set_cell_number_format",
|
|
472
472
|
"providerContract": {
|
|
473
473
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_set_cell_number_format.schema.json",
|
|
474
|
-
"sha256": "
|
|
474
|
+
"sha256": "b5f40eb92bea55b43166de3eea3944bcac000cb3b29f402ef1731ab190242db1"
|
|
475
475
|
},
|
|
476
476
|
"inputContract": {
|
|
477
477
|
"path": "office/contracts/xlsx_set_cell_number_format.schema.json",
|
|
478
|
-
"sha256": "
|
|
478
|
+
"sha256": "b5f40eb92bea55b43166de3eea3944bcac000cb3b29f402ef1731ab190242db1"
|
|
479
479
|
}
|
|
480
480
|
},
|
|
481
481
|
{
|
|
482
482
|
"name": "xlsx_set_cell_value",
|
|
483
483
|
"providerContract": {
|
|
484
484
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_set_cell_value.schema.json",
|
|
485
|
-
"sha256": "
|
|
485
|
+
"sha256": "ba49e6edd2741162161b9b98f3a4aa8d093f5552084cbdbc736b5e8e9431edc7"
|
|
486
486
|
},
|
|
487
487
|
"inputContract": {
|
|
488
488
|
"path": "office/contracts/xlsx_set_cell_value.schema.json",
|
|
489
|
-
"sha256": "
|
|
489
|
+
"sha256": "ba49e6edd2741162161b9b98f3a4aa8d093f5552084cbdbc736b5e8e9431edc7"
|
|
490
490
|
}
|
|
491
491
|
},
|
|
492
492
|
{
|
|
493
493
|
"name": "xlsx_set_column_width",
|
|
494
494
|
"providerContract": {
|
|
495
495
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_set_column_width.schema.json",
|
|
496
|
-
"sha256": "
|
|
496
|
+
"sha256": "b1435b0b12c1f2a8dcc504bfc78a8b8ca456e4a1fbd48ed0a8a61b9746d40839"
|
|
497
497
|
},
|
|
498
498
|
"inputContract": {
|
|
499
499
|
"path": "office/contracts/xlsx_set_column_width.schema.json",
|
|
500
|
-
"sha256": "
|
|
500
|
+
"sha256": "b1435b0b12c1f2a8dcc504bfc78a8b8ca456e4a1fbd48ed0a8a61b9746d40839"
|
|
501
501
|
}
|
|
502
502
|
},
|
|
503
503
|
{
|
|
504
504
|
"name": "xlsx_set_page_setup",
|
|
505
505
|
"providerContract": {
|
|
506
506
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_set_page_setup.schema.json",
|
|
507
|
-
"sha256": "
|
|
507
|
+
"sha256": "8340463fe45d05ab1c56c56a9c52d80cd2cf459722c02f5f795e8ef2214dd5e7"
|
|
508
508
|
},
|
|
509
509
|
"inputContract": {
|
|
510
510
|
"path": "office/contracts/xlsx_set_page_setup.schema.json",
|
|
511
|
-
"sha256": "
|
|
511
|
+
"sha256": "8340463fe45d05ab1c56c56a9c52d80cd2cf459722c02f5f795e8ef2214dd5e7"
|
|
512
512
|
}
|
|
513
513
|
},
|
|
514
514
|
{
|
|
515
515
|
"name": "xlsx_set_print_area",
|
|
516
516
|
"providerContract": {
|
|
517
517
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_set_print_area.schema.json",
|
|
518
|
-
"sha256": "
|
|
518
|
+
"sha256": "ca125ccbd01cf461872566ef3f13047b2bb735fc2157bea61c2ee2c0f41a4ecd"
|
|
519
519
|
},
|
|
520
520
|
"inputContract": {
|
|
521
521
|
"path": "office/contracts/xlsx_set_print_area.schema.json",
|
|
522
|
-
"sha256": "
|
|
522
|
+
"sha256": "ca125ccbd01cf461872566ef3f13047b2bb735fc2157bea61c2ee2c0f41a4ecd"
|
|
523
523
|
}
|
|
524
524
|
},
|
|
525
525
|
{
|
|
526
526
|
"name": "xlsx_set_range_values",
|
|
527
527
|
"providerContract": {
|
|
528
528
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_set_range_values.schema.json",
|
|
529
|
-
"sha256": "
|
|
529
|
+
"sha256": "5ce9843e5cb03c237a743e54bce185d4e597d22cd072cbd67adb2bd87f2692e0"
|
|
530
530
|
},
|
|
531
531
|
"inputContract": {
|
|
532
532
|
"path": "office/contracts/xlsx_set_range_values.schema.json",
|
|
533
|
-
"sha256": "
|
|
533
|
+
"sha256": "5ce9843e5cb03c237a743e54bce185d4e597d22cd072cbd67adb2bd87f2692e0"
|
|
534
534
|
}
|
|
535
535
|
},
|
|
536
536
|
{
|
|
537
537
|
"name": "xlsx_set_rich_text_cell_value",
|
|
538
538
|
"providerContract": {
|
|
539
539
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_set_rich_text_cell_value.schema.json",
|
|
540
|
-
"sha256": "
|
|
540
|
+
"sha256": "563308df6bbfd74b3679f9d12dda4572f2ebbd2328919f26c57ba3f67f31e201"
|
|
541
541
|
},
|
|
542
542
|
"inputContract": {
|
|
543
543
|
"path": "office/contracts/xlsx_set_rich_text_cell_value.schema.json",
|
|
544
|
-
"sha256": "
|
|
544
|
+
"sha256": "563308df6bbfd74b3679f9d12dda4572f2ebbd2328919f26c57ba3f67f31e201"
|
|
545
545
|
}
|
|
546
546
|
},
|
|
547
547
|
{
|
|
548
548
|
"name": "xlsx_set_row_page_breaks",
|
|
549
549
|
"providerContract": {
|
|
550
550
|
"source": "packages/xlsx-cli/contracts/mcp-input/xlsx_set_row_page_breaks.schema.json",
|
|
551
|
-
"sha256": "
|
|
551
|
+
"sha256": "d6ef42029c60481d58d840d3ae27f99cd7be15ad582c92d33f0dff66f04b26c3"
|
|
552
552
|
},
|
|
553
553
|
"inputContract": {
|
|
554
554
|
"path": "office/contracts/xlsx_set_row_page_breaks.schema.json",
|
|
555
|
-
"sha256": "
|
|
555
|
+
"sha256": "d6ef42029c60481d58d840d3ae27f99cd7be15ad582c92d33f0dff66f04b26c3"
|
|
556
556
|
}
|
|
557
557
|
},
|
|
558
558
|
{
|
package/office/index.mjs
CHANGED
|
@@ -24,7 +24,10 @@ import {
|
|
|
24
24
|
} from '../_shared/large-json-result.mjs';
|
|
25
25
|
import { withOutputWriteLock } from '../_shared/output-write-lock.mjs';
|
|
26
26
|
import { evidenceRoleMetadata } from '../_shared/evidence-role.mjs';
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
documentMutationFileArguments,
|
|
29
|
+
effectKindMetadata,
|
|
30
|
+
} from '../_shared/effect-kind.mjs';
|
|
28
31
|
import { compactDocxObjectIdentity } from './docx-object-identity.mjs';
|
|
29
32
|
|
|
30
33
|
const packageMetadata = JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8'));
|
|
@@ -38,14 +41,20 @@ if (inputContractManifest.provider?.id !== packageMetadata.name
|
|
|
38
41
|
}
|
|
39
42
|
const inputContracts = new Map(await Promise.all(inputContractManifest.tools.map(async entry => {
|
|
40
43
|
const schema = JSON.parse(await readFile(new URL(`./contracts/${entry.name}.schema.json`, import.meta.url), 'utf8'));
|
|
41
|
-
return [entry.name, z.fromJSONSchema(schema)];
|
|
44
|
+
return [entry.name, { schema, validator: z.fromJSONSchema(schema) }];
|
|
42
45
|
})));
|
|
43
46
|
const invocationCwd = process.cwd();
|
|
44
47
|
|
|
45
48
|
function inputContract(toolName) {
|
|
46
49
|
const contract = inputContracts.get(toolName);
|
|
47
50
|
if (!contract) throw new Error(`Missing provider-owned MCP input contract: ${toolName}`);
|
|
48
|
-
return contract;
|
|
51
|
+
return contract.validator;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function inputContractSchema(toolName) {
|
|
55
|
+
const contract = inputContracts.get(toolName);
|
|
56
|
+
if (!contract) throw new Error(`Missing provider-owned MCP input contract: ${toolName}`);
|
|
57
|
+
return contract.schema;
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
const docxCandidates = [
|
|
@@ -151,14 +160,14 @@ const xlsxFixedTools = [
|
|
|
151
160
|
{"name":"xlsx_set_column_width","description":"Set current worksheet column widths."},
|
|
152
161
|
];
|
|
153
162
|
|
|
154
|
-
function fixedToolDefinitions(definitions) {
|
|
163
|
+
function fixedToolDefinitions(definitions, candidates) {
|
|
155
164
|
return definitions.map(definition => ({
|
|
156
165
|
name: definition.name,
|
|
157
166
|
effectKind: 'document-mutation',
|
|
158
167
|
description: definition.description,
|
|
159
168
|
inputSchema: inputContract(definition.name),
|
|
160
169
|
outputSchema: fixedEditOutput(definition.name),
|
|
161
|
-
handler: args => fixedEdit(
|
|
170
|
+
handler: (args, tool) => fixedEdit(tool, args, candidates),
|
|
162
171
|
}));
|
|
163
172
|
}
|
|
164
173
|
|
|
@@ -472,7 +481,7 @@ const tools = [
|
|
|
472
481
|
description: 'Replace existing target paragraph or table-cell content from explicitly selected native source cells, paragraphs, runs, text nodes, or exact text ranges while retaining target container formatting and table structure. For a source cell already returned by docx_read_table, select a Unicode-scalar range directly against its returned text; the provider retains every crossed native run, including superscript and subscript, without another descendant read. Consecutive run or text selections from one source paragraph form one target paragraph, and source paragraph boundaries remain paragraph boundaries. Use it after docx_fill_table_from_tables when the target needs selected source content instead of the whole source cell; pass returned addresses unchanged and never retype source-owned text. It does not copy source rows, cells, spans, or merges.',
|
|
473
482
|
inputSchema: inputContract('docx_replace_content_from_source'),
|
|
474
483
|
outputSchema: fixedEditOutput('docx_replace_content_from_source'),
|
|
475
|
-
handler: args => fixedEdit(
|
|
484
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
476
485
|
},
|
|
477
486
|
{
|
|
478
487
|
name: 'docx_set_text',
|
|
@@ -480,7 +489,7 @@ const tools = [
|
|
|
480
489
|
description: 'Replace the whole text content of paragraph or cell objects observed from this exact input DOCX while retaining target formatting, bookmarks, spans, and vertical merges. For a vertically merged logical cell, write its visible text to the restart cell rather than a continue cell. Tabs and line breaks remain native document text controls; targets containing non-text objects are rejected. Use this only for newly derived text. Content copied or selected from a source DOCX uses docx_replace_content_from_source so native runs such as superscript and subscript are retained. This does not insert objects, change table structure, copy source formatting, or decide business wording.',
|
|
481
490
|
inputSchema: inputContract('docx_set_text'),
|
|
482
491
|
outputSchema: fixedEditOutput('docx_set_text'),
|
|
483
|
-
handler: args => fixedEdit(
|
|
492
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
484
493
|
},
|
|
485
494
|
{
|
|
486
495
|
name: 'docx_set_paragraph_pagination',
|
|
@@ -488,7 +497,7 @@ const tools = [
|
|
|
488
497
|
description: 'Set native pagination properties on explicitly selected current DOCX paragraphs. Each change sets at least one pagination property. keepWithNext keeps a paragraph with the immediately following paragraph or table but does not guarantee that a table header remains with its first body row. keepLinesTogether keeps one paragraph on one page; pageBreakBefore starts it on a new page; preventWidowOrphanLines controls isolated first or last lines. Omitted properties remain unchanged. The caller chooses paragraphs from current native addresses; the provider does not decide document layout or business meaning.',
|
|
489
498
|
inputSchema: inputContract('docx_set_paragraph_pagination'),
|
|
490
499
|
outputSchema: fixedEditOutput('docx_set_paragraph_pagination'),
|
|
491
|
-
handler: args => fixedEdit(
|
|
500
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
492
501
|
},
|
|
493
502
|
{
|
|
494
503
|
name: 'docx_set_table_body',
|
|
@@ -496,7 +505,7 @@ const tools = [
|
|
|
496
505
|
description: 'Atomically replace one exact current target-table row range while retaining the table, target styles, grid widths, and all rows and surrounding content outside the range. When retaining leading rows reported with repeatHeader=true, existingRows starts after all of them and never at a verticalMerge=continue row. Name every target grid column in native order and choose one current row inside existingRows as the style prototype for each final row. Horizontal spans use contiguous column IDs. Set rowSpan on one logical cell to occupy multiple rows and omit those columns from the covered rows; the provider writes native vertical merge cells. Set cantSplit on a final physical row when it must remain whole across page boundaries; omit it to preserve the prototype row property. Every other grid column remains explicit. Every explicit cell includes an already-derived value; source-owned content is not retyped here. An empty final row array removes the range when another table row remains. The provider commits once and returns structural readback. It does not read source tables, map source to target, derive text, choose business columns, identify headers, or accept non-text cell content; use docx_fill_table_from_tables and docx_replace_content_from_source for source-owned table content.',
|
|
497
506
|
inputSchema: inputContract('docx_set_table_body'),
|
|
498
507
|
outputSchema: fixedEditOutput('docx_set_table_body'),
|
|
499
|
-
handler: args => fixedEdit(
|
|
508
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
500
509
|
},
|
|
501
510
|
{
|
|
502
511
|
name: 'docx_fill_table_from_tables',
|
|
@@ -504,7 +513,7 @@ const tools = [
|
|
|
504
513
|
description: 'Fill one current target-table body from one or more explicitly ordered current source-table row ranges. For each source, select an unmerged record column when every physical source row must remain an output row; mapped columns still retain their native vertical merges. Select a merged record column only when every mapping into one target cell has one equal scalar value throughout that merge group. Map source grid columns onto every target prototype cell. The provider concatenates source records in declared order, copies each mapped source cell in full, preserves horizontal spans, rebuilds vertical merges only within each source range, validates the complete target grid, commits once, and returns structural readback. It does not discover source tables, choose source or target business meaning, filter records, translate or rewrite text, or apply business-specific rules. A single source uses the same sources array with one item. If a target needs only selected source descendants, such as one language from a bilingual cell, immediately use the returned target-cell addresses with docx_replace_content_from_source before releasing that source or reading back the completed target.',
|
|
505
514
|
inputSchema: inputContract('docx_fill_table_from_tables'),
|
|
506
515
|
outputSchema: fixedEditOutput('docx_fill_table_from_tables'),
|
|
507
|
-
handler: args => fixedEdit(
|
|
516
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
508
517
|
},
|
|
509
518
|
{
|
|
510
519
|
name: 'docx_insert_objects',
|
|
@@ -512,7 +521,7 @@ const tools = [
|
|
|
512
521
|
description: 'Insert selected current DOCX objects under an existing parent. Table rows are objects: expand a target table by copying one contiguous observed row range and use repeat for count; sourceInput may equal input. A row range beginning with vertical-merge continuations may be inserted only inside a target boundary with the same active grid spans, which extends those merges. Individual table cells are not raw insertion targets because that would bypass the table grid.',
|
|
513
522
|
inputSchema: inputContract('docx_insert_objects'),
|
|
514
523
|
outputSchema: fixedEditOutput('docx_insert_objects'),
|
|
515
|
-
handler: args => fixedEdit(
|
|
524
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
516
525
|
},
|
|
517
526
|
{
|
|
518
527
|
name: 'docx_delete_object',
|
|
@@ -520,7 +529,7 @@ const tools = [
|
|
|
520
529
|
description: 'Delete selected current DOCX objects directly from the current target document. Selected table rows must close every vertical merge and cannot remove the whole table. Individual table cells are not raw deletion targets; use column or merge operations for table structure.',
|
|
521
530
|
inputSchema: inputContract('docx_delete_object'),
|
|
522
531
|
outputSchema: fixedEditOutput('docx_delete_object'),
|
|
523
|
-
handler: args => fixedEdit(
|
|
532
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
524
533
|
},
|
|
525
534
|
{
|
|
526
535
|
name: 'docx_merge_cells',
|
|
@@ -528,7 +537,7 @@ const tools = [
|
|
|
528
537
|
description: 'Merge selected current DOCX cells when they form one closed rectangle. A one-column, multi-row rectangle creates a vertical merge whose first cell is the restart owner and whose later cells are continuations. All selected cell content moves into the top-left owner, so the selected content must already be correct for that one logical cell.',
|
|
529
538
|
inputSchema: inputContract('docx_merge_cells'),
|
|
530
539
|
outputSchema: fixedEditOutput('docx_merge_cells'),
|
|
531
|
-
handler: args => fixedEdit(
|
|
540
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
532
541
|
},
|
|
533
542
|
{
|
|
534
543
|
name: 'docx_split_cells',
|
|
@@ -536,7 +545,7 @@ const tools = [
|
|
|
536
545
|
description: 'Split selected current DOCX merged cells.',
|
|
537
546
|
inputSchema: inputContract('docx_split_cells'),
|
|
538
547
|
outputSchema: fixedEditOutput('docx_split_cells'),
|
|
539
|
-
handler: args => fixedEdit(
|
|
548
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
540
549
|
},
|
|
541
550
|
{
|
|
542
551
|
name: 'docx_insert_table_columns',
|
|
@@ -544,7 +553,7 @@ const tools = [
|
|
|
544
553
|
description: 'Insert empty template-shaped grid columns into one current main-document table. Select an observed source grid column for width and per-row cell formatting, and optionally a before grid-column address; cells spanning the insertion boundary expand instead of being split. It does not copy business values or decide column meaning.',
|
|
545
554
|
inputSchema: inputContract('docx_insert_table_columns'),
|
|
546
555
|
outputSchema: fixedEditOutput('docx_insert_table_columns'),
|
|
547
|
-
handler: args => fixedEdit(
|
|
556
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
548
557
|
},
|
|
549
558
|
{
|
|
550
559
|
name: 'docx_delete_table_columns',
|
|
@@ -552,7 +561,7 @@ const tools = [
|
|
|
552
561
|
description: 'Delete selected observed grid columns from one current main-document table while shrinking spanning cells and preserving the remaining table grid. It cannot remove every column and does not decide whether a business column is unused.',
|
|
553
562
|
inputSchema: inputContract('docx_delete_table_columns'),
|
|
554
563
|
outputSchema: fixedEditOutput('docx_delete_table_columns'),
|
|
555
|
-
handler: args => fixedEdit(
|
|
564
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
556
565
|
},
|
|
557
566
|
{
|
|
558
567
|
name: 'docx_compare',
|
|
@@ -593,7 +602,7 @@ const tools = [
|
|
|
593
602
|
description: 'Apply one explicit font family and size policy to current main-document body and table text. It does not derive a policy or alter other run semantics.',
|
|
594
603
|
inputSchema: inputContract('docx_apply_font_policy'),
|
|
595
604
|
outputSchema: fixedEditOutput('docx_apply_font_policy'),
|
|
596
|
-
handler: args => fixedEdit(
|
|
605
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
597
606
|
},
|
|
598
607
|
{
|
|
599
608
|
name: 'docx_validate_toc_style_policy',
|
|
@@ -609,7 +618,7 @@ const tools = [
|
|
|
609
618
|
description: 'Apply explicit italic and per-level indentation values to current built-in table-of-contents paragraph styles. It does not change heading text or refresh fields.',
|
|
610
619
|
inputSchema: inputContract('docx_apply_toc_style_policy'),
|
|
611
620
|
outputSchema: fixedEditOutput('docx_apply_toc_style_policy'),
|
|
612
|
-
handler: args => fixedEdit(
|
|
621
|
+
handler: (args, tool) => fixedEdit(tool, args, docxCandidates),
|
|
613
622
|
},
|
|
614
623
|
{
|
|
615
624
|
name: 'docx_refresh_fields',
|
|
@@ -676,7 +685,7 @@ const tools = [
|
|
|
676
685
|
annotations: { readOnlyHint: true, idempotentHint: true },
|
|
677
686
|
handler: xlsxReadRange,
|
|
678
687
|
},
|
|
679
|
-
...fixedToolDefinitions(xlsxFixedTools),
|
|
688
|
+
...fixedToolDefinitions(xlsxFixedTools, xlsxCandidates),
|
|
680
689
|
{
|
|
681
690
|
name: 'xlsx_validate',
|
|
682
691
|
description: 'Validate an XLSX workbook package and produce OpenXML validation evidence. Set returnContent true to return the complete result when it fits the response limit. Provide output to write the complete result to a new JSON file. The two choices are independent and may be used together; at least one is required.',
|
|
@@ -709,7 +718,7 @@ const tools = [
|
|
|
709
718
|
description: 'Apply one deterministic PPTX template-application plan to a current presentation. This tool executes the published plan; it does not select a template or derive business content, slide mappings, geometry, or formatting decisions.',
|
|
710
719
|
inputSchema: inputContract('pptx_apply_template'),
|
|
711
720
|
outputSchema: fixedEditOutput('pptx_apply_template'),
|
|
712
|
-
handler: args => fixedEdit(
|
|
721
|
+
handler: (args, tool) => fixedEdit(tool, args, pptxCandidates),
|
|
713
722
|
},
|
|
714
723
|
{
|
|
715
724
|
name: 'pptx_apply_format',
|
|
@@ -717,7 +726,7 @@ const tools = [
|
|
|
717
726
|
description: 'Apply one deterministic PPTX formatting plan to a current presentation. This tool executes published formatting operations; it does not derive values, coordinates, or business decisions.',
|
|
718
727
|
inputSchema: inputContract('pptx_apply_format'),
|
|
719
728
|
outputSchema: fixedEditOutput('pptx_apply_format'),
|
|
720
|
-
handler: args => fixedEdit(
|
|
729
|
+
handler: (args, tool) => fixedEdit(tool, args, pptxCandidates),
|
|
721
730
|
},
|
|
722
731
|
{
|
|
723
732
|
name: 'pptx_set_shape_geometry',
|
|
@@ -725,7 +734,7 @@ const tools = [
|
|
|
725
734
|
description: 'Set exact native EMU bounds for uniquely identified current-slide PPTX objects. One call batches only this fixed geometry action and does not infer repair coordinates.',
|
|
726
735
|
inputSchema: inputContract('pptx_set_shape_geometry'),
|
|
727
736
|
outputSchema: fixedEditOutput('pptx_set_shape_geometry'),
|
|
728
|
-
handler: args => fixedEdit(
|
|
737
|
+
handler: (args, tool) => fixedEdit(tool, args, pptxCandidates),
|
|
729
738
|
},
|
|
730
739
|
{
|
|
731
740
|
name: 'pptx_replace_picture_image',
|
|
@@ -733,7 +742,7 @@ const tools = [
|
|
|
733
742
|
description: 'Replace embedded PNG or JPEG media for uniquely identified current-slide PPTX pictures while preserving the picture object, geometry, crop, and unrelated media. One call batches only this fixed replacement action.',
|
|
734
743
|
inputSchema: inputContract('pptx_replace_picture_image'),
|
|
735
744
|
outputSchema: fixedEditOutput('pptx_replace_picture_image'),
|
|
736
|
-
handler: args => fixedEdit(
|
|
745
|
+
handler: (args, tool) => fixedEdit(tool, args, pptxCandidates),
|
|
737
746
|
},
|
|
738
747
|
{
|
|
739
748
|
name: 'pptx_validate',
|
|
@@ -769,8 +778,8 @@ function buildServer() {
|
|
|
769
778
|
},
|
|
770
779
|
async args => {
|
|
771
780
|
const payload = typeof args.output === 'string'
|
|
772
|
-
? await withOutputWriteLock(args.output, () => tool.handler(args))
|
|
773
|
-
: await tool.handler(args);
|
|
781
|
+
? await withOutputWriteLock(args.output, () => tool.handler(args, tool))
|
|
782
|
+
: await tool.handler(args, tool);
|
|
774
783
|
return createToolResult(payload, { isError: payload?.summary?.pass === false });
|
|
775
784
|
},
|
|
776
785
|
);
|
|
@@ -1165,28 +1174,37 @@ async function copyTransform(tool, candidates, command, args, suffix = []) {
|
|
|
1165
1174
|
}
|
|
1166
1175
|
}
|
|
1167
1176
|
|
|
1168
|
-
async function fixedEdit(tool, args) {
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1177
|
+
async function fixedEdit(tool, args, candidates) {
|
|
1178
|
+
const publishedContract = {
|
|
1179
|
+
name: tool.name,
|
|
1180
|
+
inputSchema: inputContractSchema(tool.name),
|
|
1181
|
+
annotations: tool.annotations,
|
|
1182
|
+
_meta: effectKindMetadata(tool.effectKind),
|
|
1183
|
+
};
|
|
1184
|
+
const bindings = documentMutationFileArguments(publishedContract, args);
|
|
1185
|
+
const input = path.resolve(bindings.current);
|
|
1186
|
+
const output = path.resolve(bindings.effectiveOutput);
|
|
1171
1187
|
const receiptOutput = path.resolve(requireString(args.receiptOutput, 'receiptOutput'));
|
|
1172
|
-
if (
|
|
1188
|
+
if (input !== output) await requireNewFile(output, 'output');
|
|
1173
1189
|
await requireNewFile(receiptOutput, 'receiptOutput');
|
|
1174
|
-
const candidates = tool.startsWith('docx_') ? docxCandidates
|
|
1175
|
-
: tool.startsWith('xlsx_') ? xlsxCandidates
|
|
1176
|
-
: pptxCandidates;
|
|
1177
1190
|
return withTempJsonFile(args, async requestPath => {
|
|
1178
|
-
const result = await runJsonCandidateChain(candidates, [tool, requestPath], { allowedExitCodes: [0, 1] });
|
|
1191
|
+
const result = await runJsonCandidateChain(candidates, [tool.name, requestPath], { allowedExitCodes: [0, 1] });
|
|
1179
1192
|
if (result.code !== 0) {
|
|
1180
|
-
const detail = result.stderr.trim() || result.stdout.trim()
|
|
1193
|
+
const detail = result.stderr.trim() || result.stdout.trim()
|
|
1194
|
+
|| `${tool.name} failed with exit code ${result.code}`;
|
|
1181
1195
|
throw new Error(detail);
|
|
1182
1196
|
}
|
|
1183
|
-
if (result.json?.tool !== tool) throw new Error(`${tool} returned a mismatched tool identity`);
|
|
1197
|
+
if (result.json?.tool !== tool.name) throw new Error(`${tool.name} returned a mismatched tool identity`);
|
|
1184
1198
|
await requireReturnedArtifact(result.json.receipt, receiptOutput, 'receipt');
|
|
1185
1199
|
if (result.json.output === null) {
|
|
1186
|
-
if (result.json.summary?.pass !== false)
|
|
1200
|
+
if (result.json.summary?.pass !== false) {
|
|
1201
|
+
throw new Error(`${tool.name} omitted output without reporting failure`);
|
|
1202
|
+
}
|
|
1187
1203
|
} else {
|
|
1188
1204
|
await requireReturnedArtifact(result.json.output, output, 'output');
|
|
1189
|
-
if (result.json.summary?.pass !== true)
|
|
1205
|
+
if (result.json.summary?.pass !== true) {
|
|
1206
|
+
throw new Error(`${tool.name} returned output without reporting success`);
|
|
1207
|
+
}
|
|
1190
1208
|
}
|
|
1191
1209
|
return { ...result.json, runtime: commandRuntime(result) };
|
|
1192
1210
|
});
|
package/package.json
CHANGED