wps-multitool-mcp 1.0.4 → 1.0.5

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.
Files changed (172) hide show
  1. package/dist/bridge/index.js +36 -1
  2. package/dist/bridge/index.js.map +1 -1
  3. package/dist/server/auto-snapshot.d.ts.map +1 -1
  4. package/dist/server/auto-snapshot.js +4 -0
  5. package/dist/server/auto-snapshot.js.map +1 -1
  6. package/dist/server/collab-guard.d.ts +13 -0
  7. package/dist/server/collab-guard.d.ts.map +1 -0
  8. package/dist/server/collab-guard.js +112 -0
  9. package/dist/server/collab-guard.js.map +1 -0
  10. package/dist/server/intent-miss-log.d.ts +28 -0
  11. package/dist/server/intent-miss-log.d.ts.map +1 -0
  12. package/dist/server/intent-miss-log.js +143 -0
  13. package/dist/server/intent-miss-log.js.map +1 -0
  14. package/dist/server/mcp-server.d.ts.map +1 -1
  15. package/dist/server/mcp-server.js +16 -3
  16. package/dist/server/mcp-server.js.map +1 -1
  17. package/dist/server/progress-context.js +1 -1
  18. package/dist/server/task-engine.d.ts +112 -0
  19. package/dist/server/task-engine.d.ts.map +1 -0
  20. package/dist/server/task-engine.js +305 -0
  21. package/dist/server/task-engine.js.map +1 -0
  22. package/dist/server/tool-aliases.generated.d.ts +1 -1
  23. package/dist/server/tool-aliases.generated.d.ts.map +1 -1
  24. package/dist/server/tool-aliases.generated.js +14 -2
  25. package/dist/server/tool-aliases.generated.js.map +1 -1
  26. package/dist/server/tool-annotations.d.ts.map +1 -1
  27. package/dist/server/tool-annotations.generated.d.ts.map +1 -1
  28. package/dist/server/tool-annotations.generated.js +2 -7
  29. package/dist/server/tool-annotations.generated.js.map +1 -1
  30. package/dist/server/tool-annotations.js +9 -0
  31. package/dist/server/tool-annotations.js.map +1 -1
  32. package/dist/server/tool-metadata.d.ts.map +1 -1
  33. package/dist/server/tool-metadata.js +13 -9
  34. package/dist/server/tool-metadata.js.map +1 -1
  35. package/dist/server/tool-registry.d.ts.map +1 -1
  36. package/dist/server/tool-registry.js +26 -1
  37. package/dist/server/tool-registry.js.map +1 -1
  38. package/dist/server/tool-tiers.d.ts +1 -1
  39. package/dist/server/tool-tiers.js +1 -1
  40. package/dist/server/tool-verification.d.ts +5 -5
  41. package/dist/server/tool-verification.generated.d.ts +4 -4
  42. package/dist/server/tool-verification.generated.d.ts.map +1 -1
  43. package/dist/server/tool-verification.generated.js +5 -10
  44. package/dist/server/tool-verification.generated.js.map +1 -1
  45. package/dist/server/tool-verification.js +2 -2
  46. package/dist/tools/common/index.d.ts +1 -0
  47. package/dist/tools/common/index.d.ts.map +1 -1
  48. package/dist/tools/common/index.js +3 -0
  49. package/dist/tools/common/index.js.map +1 -1
  50. package/dist/tools/common/intent.d.ts +10 -2
  51. package/dist/tools/common/intent.d.ts.map +1 -1
  52. package/dist/tools/common/intent.js +144 -36
  53. package/dist/tools/common/intent.js.map +1 -1
  54. package/dist/tools/common/snapshot.d.ts.map +1 -1
  55. package/dist/tools/common/snapshot.js +9 -1
  56. package/dist/tools/common/snapshot.js.map +1 -1
  57. package/dist/tools/common/taskrunner.d.ts +25 -0
  58. package/dist/tools/common/taskrunner.d.ts.map +1 -0
  59. package/dist/tools/common/taskrunner.js +100 -0
  60. package/dist/tools/common/taskrunner.js.map +1 -0
  61. package/dist/tools/excel/chart.d.ts.map +1 -1
  62. package/dist/tools/excel/chart.js +28 -12
  63. package/dist/tools/excel/chart.js.map +1 -1
  64. package/dist/tools/excel/comment-protect.js +2 -2
  65. package/dist/tools/excel/comment-protect.js.map +1 -1
  66. package/dist/tools/excel/data.d.ts.map +1 -1
  67. package/dist/tools/excel/data.js +18 -7
  68. package/dist/tools/excel/data.js.map +1 -1
  69. package/dist/tools/ppt/animation.d.ts +2 -2
  70. package/dist/tools/ppt/animation.d.ts.map +1 -1
  71. package/dist/tools/ppt/animation.js +24 -86
  72. package/dist/tools/ppt/animation.js.map +1 -1
  73. package/dist/tools/ppt/beautify-advanced.d.ts +3 -16
  74. package/dist/tools/ppt/beautify-advanced.d.ts.map +1 -1
  75. package/dist/tools/ppt/beautify-advanced.js +65 -355
  76. package/dist/tools/ppt/beautify-advanced.js.map +1 -1
  77. package/dist/tools/ppt/chart-flow.d.ts.map +1 -1
  78. package/dist/tools/ppt/chart-flow.js +41 -206
  79. package/dist/tools/ppt/chart-flow.js.map +1 -1
  80. package/dist/tools/ppt/data-viz.d.ts.map +1 -1
  81. package/dist/tools/ppt/data-viz.js +29 -227
  82. package/dist/tools/ppt/data-viz.js.map +1 -1
  83. package/dist/tools/ppt/deckkit.d.ts +75 -16
  84. package/dist/tools/ppt/deckkit.d.ts.map +1 -1
  85. package/dist/tools/ppt/deckkit.js +271 -32
  86. package/dist/tools/ppt/deckkit.js.map +1 -1
  87. package/dist/tools/ppt/helpers.d.ts +38 -0
  88. package/dist/tools/ppt/helpers.d.ts.map +1 -0
  89. package/dist/tools/ppt/helpers.js +60 -0
  90. package/dist/tools/ppt/helpers.js.map +1 -0
  91. package/dist/tools/ppt/image.d.ts +6 -4
  92. package/dist/tools/ppt/image.d.ts.map +1 -1
  93. package/dist/tools/ppt/image.js +102 -202
  94. package/dist/tools/ppt/image.js.map +1 -1
  95. package/dist/tools/ppt/index.d.ts +42 -30
  96. package/dist/tools/ppt/index.d.ts.map +1 -1
  97. package/dist/tools/ppt/index.js +102 -96
  98. package/dist/tools/ppt/index.js.map +1 -1
  99. package/dist/tools/ppt/misc.d.ts +1 -2
  100. package/dist/tools/ppt/misc.d.ts.map +1 -1
  101. package/dist/tools/ppt/misc.js +70 -385
  102. package/dist/tools/ppt/misc.js.map +1 -1
  103. package/dist/tools/ppt/page-effects.d.ts +28 -0
  104. package/dist/tools/ppt/page-effects.d.ts.map +1 -0
  105. package/dist/tools/ppt/page-effects.js +505 -0
  106. package/dist/tools/ppt/page-effects.js.map +1 -0
  107. package/dist/tools/ppt/{background.d.ts → page-info.d.ts} +11 -13
  108. package/dist/tools/ppt/page-info.d.ts.map +1 -0
  109. package/dist/tools/ppt/page-info.js +258 -0
  110. package/dist/tools/ppt/page-info.js.map +1 -0
  111. package/dist/tools/ppt/presentation.d.ts +3 -6
  112. package/dist/tools/ppt/presentation.d.ts.map +1 -1
  113. package/dist/tools/ppt/presentation.js +72 -373
  114. package/dist/tools/ppt/presentation.js.map +1 -1
  115. package/dist/tools/ppt/shape-basic.d.ts +22 -3
  116. package/dist/tools/ppt/shape-basic.d.ts.map +1 -1
  117. package/dist/tools/ppt/shape-basic.js +441 -344
  118. package/dist/tools/ppt/shape-basic.js.map +1 -1
  119. package/dist/tools/ppt/slide-ops.d.ts +6 -42
  120. package/dist/tools/ppt/slide-ops.d.ts.map +1 -1
  121. package/dist/tools/ppt/slide-ops.js +93 -1485
  122. package/dist/tools/ppt/slide-ops.js.map +1 -1
  123. package/dist/tools/ppt/slide.d.ts +1 -7
  124. package/dist/tools/ppt/slide.d.ts.map +1 -1
  125. package/dist/tools/ppt/slide.js +157 -289
  126. package/dist/tools/ppt/slide.js.map +1 -1
  127. package/dist/tools/ppt/table.d.ts.map +1 -1
  128. package/dist/tools/ppt/table.js +30 -200
  129. package/dist/tools/ppt/table.js.map +1 -1
  130. package/dist/tools/ppt/textbox.d.ts +1 -22
  131. package/dist/tools/ppt/textbox.d.ts.map +1 -1
  132. package/dist/tools/ppt/textbox.js +87 -107
  133. package/dist/tools/ppt/textbox.js.map +1 -1
  134. package/dist/tools/word/academic.d.ts +2 -0
  135. package/dist/tools/word/academic.d.ts.map +1 -1
  136. package/dist/tools/word/academic.js +77 -111
  137. package/dist/tools/word/academic.js.map +1 -1
  138. package/dist/tools/word/content.d.ts +7 -12
  139. package/dist/tools/word/content.d.ts.map +1 -1
  140. package/dist/tools/word/content.js +134 -452
  141. package/dist/tools/word/content.js.map +1 -1
  142. package/dist/tools/word/document.d.ts +1 -3
  143. package/dist/tools/word/document.d.ts.map +1 -1
  144. package/dist/tools/word/document.js +71 -328
  145. package/dist/tools/word/document.js.map +1 -1
  146. package/dist/tools/word/format.d.ts.map +1 -1
  147. package/dist/tools/word/format.js +59 -211
  148. package/dist/tools/word/format.js.map +1 -1
  149. package/dist/tools/word/helpers.d.ts +33 -0
  150. package/dist/tools/word/helpers.d.ts.map +1 -0
  151. package/dist/tools/word/helpers.js +50 -0
  152. package/dist/tools/word/helpers.js.map +1 -0
  153. package/dist/tools/word/index.d.ts +1 -1
  154. package/dist/tools/word/index.d.ts.map +1 -1
  155. package/dist/tools/word/index.js +2 -6
  156. package/dist/tools/word/index.js.map +1 -1
  157. package/dist/tools/word/professional.d.ts.map +1 -1
  158. package/dist/tools/word/professional.js +5 -3
  159. package/dist/tools/word/professional.js.map +1 -1
  160. package/dist/tools/word/proofread.d.ts.map +1 -1
  161. package/dist/tools/word/proofread.js +44 -184
  162. package/dist/tools/word/proofread.js.map +1 -1
  163. package/dist/types/tools.d.ts +6 -0
  164. package/dist/types/tools.d.ts.map +1 -1
  165. package/package.json +1 -1
  166. package/scripts/wps-com.ps1 +109 -21
  167. package/skills/wps-multitool/SKILL.md +16 -3
  168. package/skills/wps-multitool/references/recipes.md +20 -4
  169. package/skills/wps-multitool/references/routing.md +13 -0
  170. package/dist/tools/ppt/background.d.ts.map +0 -1
  171. package/dist/tools/ppt/background.js +0 -389
  172. package/dist/tools/ppt/background.js.map +0 -1
@@ -1,30 +1,220 @@
1
1
  "use strict";
2
2
  /**
3
- * Input: PPT 形状操作参数(删除、获取、位置、阴影、渐变、边框、透明度、对齐、分布、组合)
3
+ * Input: PPT 形状操作参数(删除、获取、位置、阴影、渐变、边框、透明度、对齐、分布、组合、添加、样式、文本框、标题、文字、填充)
4
4
  * Output: 形状操作结果
5
5
  * Pos: PPT 形状基础工具实现。一旦我被修改,请更新我的头部注释,以及所属文件夹的md。
6
6
  * PPT形状基础Tools - 形状管理模块
7
- * 处理形状的删除、获取、定位、样式设置、对齐分布和组合操作
7
+ * 处理形状的添加、删除、获取、定位、样式设置、对齐分布和组合操作
8
8
  *
9
- * 包含:
9
+ * 包含(16 个;add_shape/set_shape_style/add_textbox/set_slide_title/set_shape_text/set_shape_fill
10
+ * 自 slide-ops.ts 迁入——风格统一+拆分轮,见 ppt-audit §三之二):
11
+ * - wps_ppt_add_shape: 添加形状
12
+ * - wps_ppt_add_textbox: 添加文本框
10
13
  * - wps_ppt_delete_shape: 删除形状
11
14
  * - wps_ppt_get_shapes: 获取幻灯片中的形状列表
12
15
  * - wps_ppt_set_shape_position: 设置形状位置和大小
16
+ * - wps_ppt_set_shape_style: 设置形状样式
13
17
  * - wps_ppt_set_shape_shadow: 设置形状阴影
14
18
  * - wps_ppt_set_shape_gradient: 设置形状渐变填充
15
19
  * - wps_ppt_set_shape_border: 设置形状边框
16
20
  * - wps_ppt_set_shape_transparency: 设置形状透明度
21
+ * - wps_ppt_set_shape_text: 设置形状文字
22
+ * - wps_ppt_set_shape_fill: 设置形状填充颜色
23
+ * - wps_ppt_set_slide_title: 设置幻灯片标题
17
24
  * - wps_ppt_align_shapes: 对齐多个形状
18
25
  * - wps_ppt_distribute_shapes: 等距分布多个形状
19
26
  * - wps_ppt_group_shapes: 组合多个形状
20
27
  */
21
28
  Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.shapeBasicTools = exports.groupShapesHandler = exports.groupShapesDefinition = exports.distributeShapesHandler = exports.distributeShapesDefinition = exports.alignShapesHandler = exports.alignShapesDefinition = exports.setShapeTransparencyHandler = exports.setShapeTransparencyDefinition = exports.setShapeBorderHandler = exports.setShapeBorderDefinition = exports.setShapeGradientHandler = exports.setShapeGradientDefinition = exports.setShapeShadowHandler = exports.setShapeShadowDefinition = exports.setShapePositionHandler = exports.setShapePositionDefinition = exports.getShapesHandler = exports.getShapesDefinition = exports.deleteShapeHandler = exports.deleteShapeDefinition = void 0;
23
- const uuid_1 = require("uuid");
29
+ exports.shapeBasicTools = exports.groupShapesHandler = exports.groupShapesDefinition = exports.distributeShapesHandler = exports.distributeShapesDefinition = exports.alignShapesHandler = exports.alignShapesDefinition = exports.setSlideTitleHandler = exports.setSlideTitleDefinition = exports.setShapeFillHandler = exports.setShapeFillDefinition = exports.setShapeTextHandler = exports.setShapeTextDefinition = exports.setShapeTransparencyHandler = exports.setShapeTransparencyDefinition = exports.setShapeBorderHandler = exports.setShapeBorderDefinition = exports.setShapeGradientHandler = exports.setShapeGradientDefinition = exports.setShapeShadowHandler = exports.setShapeShadowDefinition = exports.setShapeStyleHandler = exports.setShapeStyleDefinition = exports.setShapePositionHandler = exports.setShapePositionDefinition = exports.getShapesHandler = exports.getShapesDefinition = exports.deleteShapeHandler = exports.deleteShapeDefinition = exports.addTextboxHandler = exports.addTextboxDefinition = exports.addShapeHandler = exports.addShapeDefinition = void 0;
24
30
  const tools_1 = require("../../types/tools");
25
- const wps_client_1 = require("../../client/wps-client");
26
- const wps_1 = require("../../types/wps");
27
- // ==================== 1. 删除形状 ====================
31
+ const helpers_1 = require("./helpers");
32
+ // ==================== 1. 添加形状 ====================
33
+ exports.addShapeDefinition = {
34
+ name: 'wps_ppt_add_shape',
35
+ description: `在幻灯片中添加形状。
36
+
37
+ 支持的形状类型:
38
+ - rectangle: 矩形
39
+ - oval: 椭圆
40
+ - triangle: 三角形
41
+ - diamond: 菱形
42
+ - pentagon: 五边形
43
+ - hexagon: 六边形
44
+ - arrow: 箭头
45
+ - star: 星形
46
+ - heart: 心形
47
+ - cloud: 云形
48
+
49
+ 使用场景:
50
+ - "在第1页添加一个矩形"
51
+ - "插入一个蓝色的圆形"
52
+ - "添加一个带文字的箭头"`,
53
+ category: tools_1.ToolCategory.PRESENTATION,
54
+ inputSchema: {
55
+ type: 'object',
56
+ properties: {
57
+ slideIndex: {
58
+ type: 'number',
59
+ description: '幻灯片索引(从1开始),默认1',
60
+ },
61
+ type: {
62
+ type: 'string',
63
+ description: '形状类型',
64
+ enum: ['rectangle', 'oval', 'triangle', 'diamond', 'pentagon', 'hexagon', 'arrow', 'star', 'heart', 'cloud'],
65
+ },
66
+ left: {
67
+ type: 'number',
68
+ description: '左边距(磅),默认100',
69
+ },
70
+ top: {
71
+ type: 'number',
72
+ description: '上边距(磅),默认100',
73
+ },
74
+ width: {
75
+ type: 'number',
76
+ description: '宽度(磅),默认100',
77
+ },
78
+ height: {
79
+ type: 'number',
80
+ description: '高度(磅),默认100',
81
+ },
82
+ text: {
83
+ type: 'string',
84
+ description: '形状内的文本',
85
+ },
86
+ fillColor: {
87
+ type: 'string',
88
+ description: '填充颜色,十六进制如 #FF0000',
89
+ },
90
+ },
91
+ required: [],
92
+ },
93
+ };
94
+ const addShapeHandler = async (args) => {
95
+ const { slideIndex, type, left, top, width, height, text, fillColor } = args;
96
+ const r = await (0, helpers_1.call)('addShape', {
97
+ slideIndex: slideIndex || 1,
98
+ type: type || 'rectangle',
99
+ // 坐标用 ?? 不用 ||:0 是合法坐标(全页底/竖条都从 0 起),|| 会把它吞成 100
100
+ // (deckkit 引擎的全页渐变底/标题色带/章节引文竖条全踩——审计三.1)
101
+ left: left ?? 100,
102
+ top: top ?? 100,
103
+ width: width ?? 100,
104
+ height: height ?? 100,
105
+ text,
106
+ fillColor,
107
+ });
108
+ if (!r.ok)
109
+ return (0, helpers_1.fail)((0, helpers_1.errText)('添加形状失败', r), r.error);
110
+ const shapeNameMap = {
111
+ rectangle: '矩形', oval: '椭圆', triangle: '三角形', diamond: '菱形',
112
+ pentagon: '五边形', hexagon: '六边形', arrow: '箭头', star: '星形',
113
+ heart: '心形', cloud: '云形',
114
+ };
115
+ const typeName = shapeNameMap[type || 'rectangle'] || type;
116
+ // 回包逐项拼:数据缺失就不打印该行(体验修复轮 A——此前"第 undefined 页、名称 undefined"就是这么来的)
117
+ const parts = [];
118
+ if (r.data?.slideIndex !== undefined)
119
+ parts.push(`幻灯片: 第 ${r.data.slideIndex} 页`);
120
+ parts.push(`形状类型: ${typeName}`);
121
+ if (r.data?.name) {
122
+ parts.push(`形状名称: ${r.data.name}`);
123
+ const idx = await (0, helpers_1.shapeIndexByName)(r.data.slideIndex ?? slideIndex ?? 1, r.data.name);
124
+ if (idx !== undefined)
125
+ parts.push(`形状索引: ${idx}(后续 set_shape_text / set_animation 用)`);
126
+ }
127
+ if (text)
128
+ parts.push(`文本: ${text}`);
129
+ if (fillColor)
130
+ parts.push(`填充色: ${fillColor}`);
131
+ return (0, helpers_1.ok)(`形状添加成功!\n${parts.join('\n')}`, r.warnings);
132
+ };
133
+ exports.addShapeHandler = addShapeHandler;
134
+ // ==================== 2. 添加文本框 ====================
135
+ exports.addTextboxDefinition = {
136
+ name: 'wps_ppt_add_textbox',
137
+ description: `在幻灯片中添加文本框。
138
+
139
+ 使用场景:
140
+ - "在第1页添加一个文本框"
141
+ - "插入一个写着标题的文本框"
142
+ - "添加文本框并设置字号"`,
143
+ category: tools_1.ToolCategory.PRESENTATION,
144
+ inputSchema: {
145
+ type: 'object',
146
+ properties: {
147
+ slideIndex: {
148
+ type: 'number',
149
+ description: '幻灯片索引(从1开始),默认1',
150
+ },
151
+ left: {
152
+ type: 'number',
153
+ description: '左边距(磅),默认100',
154
+ },
155
+ top: {
156
+ type: 'number',
157
+ description: '上边距(磅),默认100',
158
+ },
159
+ width: {
160
+ type: 'number',
161
+ description: '宽度(磅),默认200',
162
+ },
163
+ height: {
164
+ type: 'number',
165
+ description: '高度(磅),默认50',
166
+ },
167
+ text: {
168
+ type: 'string',
169
+ description: '文本框内容',
170
+ },
171
+ fontSize: {
172
+ type: 'number',
173
+ description: '字号大小',
174
+ },
175
+ fontName: {
176
+ type: 'string',
177
+ description: '字体名称,如 "微软雅黑"',
178
+ },
179
+ },
180
+ required: [],
181
+ },
182
+ };
183
+ const addTextboxHandler = async (args) => {
184
+ const { slideIndex, left, top, width, height, text, fontSize, fontName } = args;
185
+ const r = await (0, helpers_1.call)('addTextBox', {
186
+ slideIndex: slideIndex || 1,
187
+ // 坐标用 ?? 不用 ||:0 是合法坐标(同 add_shape,审计三.1)
188
+ left: left ?? 100,
189
+ top: top ?? 100,
190
+ width: width ?? 200,
191
+ height: height ?? 50,
192
+ text,
193
+ fontSize,
194
+ fontName,
195
+ });
196
+ if (!r.ok)
197
+ return (0, helpers_1.fail)((0, helpers_1.errText)('添加文本框失败', r), r.error);
198
+ // 回包逐项拼:数据缺失就不打印该行(同 add_shape,体验修复轮 A)
199
+ const parts = [];
200
+ if (r.data?.slideIndex !== undefined)
201
+ parts.push(`幻灯片: 第 ${r.data.slideIndex} 页`);
202
+ if (r.data?.name) {
203
+ parts.push(`名称: ${r.data.name}`);
204
+ const idx = await (0, helpers_1.shapeIndexByName)(r.data.slideIndex ?? slideIndex ?? 1, r.data.name);
205
+ if (idx !== undefined)
206
+ parts.push(`文本框索引: ${idx}(后续 set_textbox_text / set_textbox_style 用)`);
207
+ }
208
+ if (text)
209
+ parts.push(`内容: "${text}"`);
210
+ if (fontSize)
211
+ parts.push(`字号: ${fontSize}`);
212
+ if (fontName)
213
+ parts.push(`字体: ${fontName}`);
214
+ return (0, helpers_1.ok)(`文本框添加成功!\n${parts.join('\n')}`, r.warnings);
215
+ };
216
+ exports.addTextboxHandler = addTextboxHandler;
217
+ // ==================== 3. 删除形状 ====================
28
218
  exports.deleteShapeDefinition = {
29
219
  name: 'wps_ppt_delete_shape',
30
220
  description: `删除幻灯片中指定的形状。
@@ -50,46 +240,18 @@ exports.deleteShapeDefinition = {
50
240
  };
51
241
  const deleteShapeHandler = async (args) => {
52
242
  const { slideIndex, shapeIndex } = args;
53
- try {
54
- const response = await wps_client_1.wpsClient.executeMethod('deleteShape', { slideIndex, shapeIndex }, wps_1.WpsAppType.PRESENTATION);
55
- if (response.success) {
56
- return {
57
- id: (0, uuid_1.v4)(),
58
- success: true,
59
- content: [
60
- {
61
- type: 'text',
62
- text: `形状删除成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个`,
63
- },
64
- ],
65
- };
66
- }
67
- else {
68
- return {
69
- id: (0, uuid_1.v4)(),
70
- success: false,
71
- content: [{ type: 'text', text: `删除形状失败: ${response.error}` }],
72
- error: response.error,
73
- };
74
- }
75
- }
76
- catch (error) {
77
- const errMsg = error instanceof Error ? error.message : String(error);
78
- return {
79
- id: (0, uuid_1.v4)(),
80
- success: false,
81
- content: [{ type: 'text', text: `删除形状出错: ${errMsg}` }],
82
- error: errMsg,
83
- };
84
- }
243
+ const r = await (0, helpers_1.call)('deleteShape', { slideIndex, shapeIndex });
244
+ if (!r.ok)
245
+ return (0, helpers_1.fail)((0, helpers_1.errText)('删除形状失败', r), r.error);
246
+ return (0, helpers_1.ok)(`形状删除成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个`, r.warnings);
85
247
  };
86
248
  exports.deleteShapeHandler = deleteShapeHandler;
87
- // ==================== 2. 获取形状列表 ====================
249
+ // ==================== 4. 获取形状列表 ====================
88
250
  exports.getShapesDefinition = {
89
251
  name: 'wps_ppt_get_shapes',
90
252
  description: `获取幻灯片中所有形状的列表信息。
91
253
 
92
- 返回每个形状的类型、位置、大小等属性。
254
+ brief 模式(默认开,回包瘦身):只回序号/名称/几何摘要;全量字段传 brief:false。
93
255
 
94
256
  使用场景:
95
257
  - "这页PPT有哪些形状"
@@ -102,48 +264,34 @@ exports.getShapesDefinition = {
102
264
  type: 'number',
103
265
  description: '幻灯片页码(从1开始)',
104
266
  },
267
+ brief: {
268
+ type: 'boolean',
269
+ description: '回包瘦身开关(体验修复轮 B),默认 true 只回 index/name/几何摘要;false 回全量字段',
270
+ },
105
271
  },
106
272
  required: ['slideIndex'],
107
273
  },
108
274
  };
109
275
  const getShapesHandler = async (args) => {
110
- const { slideIndex } = args;
111
- try {
112
- const response = await wps_client_1.wpsClient.executeMethod('getShapes', { slideIndex }, wps_1.WpsAppType.PRESENTATION);
113
- if (response.success && response.data) {
114
- const shapes = response.data.shapes;
115
- let output = `幻灯片第 ${slideIndex} 页的形状列表(共 ${shapes.length} 个):\n\n`;
116
- shapes.forEach((s) => {
117
- output += `[${s.index}] ${s.name} (${s.type})\n`;
118
- output += ` 位置: (${s.left}, ${s.top}) 大小: ${s.width} x ${s.height}\n`;
119
- });
120
- return {
121
- id: (0, uuid_1.v4)(),
122
- success: true,
123
- content: [{ type: 'text', text: output }],
124
- };
276
+ const { slideIndex, brief = true } = args;
277
+ const r = await (0, helpers_1.call)('getShapes', { slideIndex });
278
+ if (!r.ok || !r.data)
279
+ return (0, helpers_1.fail)((0, helpers_1.errText)('获取形状列表失败', r), r.error);
280
+ const shapes = r.data.shapes;
281
+ let output = `幻灯片第 ${slideIndex} 页的形状列表(共 ${shapes.length} 个${brief ? ',brief 摘要模式' : ''}):\n\n`;
282
+ shapes.forEach((s) => {
283
+ if (brief) {
284
+ output += `[${s.index}] ${s.name} — (${s.left}, ${s.top}) ${s.width} x ${s.height}\n`;
125
285
  }
126
286
  else {
127
- return {
128
- id: (0, uuid_1.v4)(),
129
- success: false,
130
- content: [{ type: 'text', text: `获取形状列表失败: ${response.error}` }],
131
- error: response.error,
132
- };
287
+ output += `[${s.index}] ${s.name} (${s.type})\n`;
288
+ output += ` 位置: (${s.left}, ${s.top}) 大小: ${s.width} x ${s.height}\n`;
133
289
  }
134
- }
135
- catch (error) {
136
- const errMsg = error instanceof Error ? error.message : String(error);
137
- return {
138
- id: (0, uuid_1.v4)(),
139
- success: false,
140
- content: [{ type: 'text', text: `获取形状列表出错: ${errMsg}` }],
141
- error: errMsg,
142
- };
143
- }
290
+ });
291
+ return (0, helpers_1.ok)(output, r.warnings);
144
292
  };
145
293
  exports.getShapesHandler = getShapesHandler;
146
- // ==================== 3. 设置形状位置 ====================
294
+ // ==================== 5. 设置形状位置 ====================
147
295
  exports.setShapePositionDefinition = {
148
296
  name: 'wps_ppt_set_shape_position',
149
297
  description: `设置幻灯片中指定形状的位置和大小。
@@ -186,41 +334,85 @@ exports.setShapePositionDefinition = {
186
334
  };
187
335
  const setShapePositionHandler = async (args) => {
188
336
  const { slideIndex, shapeIndex, left, top, width, height } = args;
189
- try {
190
- const response = await wps_client_1.wpsClient.executeMethod('setShapePosition', { slideIndex, shapeIndex, left, top, width, height }, wps_1.WpsAppType.PRESENTATION);
191
- if (response.success) {
192
- let text = `形状位置设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个\n位置: (${left}, ${top})`;
193
- if (width !== undefined)
194
- text += `\n宽度: ${width}`;
195
- if (height !== undefined)
196
- text += `\n高度: ${height}`;
197
- return {
198
- id: (0, uuid_1.v4)(),
199
- success: true,
200
- content: [{ type: 'text', text }],
201
- };
202
- }
203
- else {
204
- return {
205
- id: (0, uuid_1.v4)(),
206
- success: false,
207
- content: [{ type: 'text', text: `设置形状位置失败: ${response.error}` }],
208
- error: response.error,
209
- };
210
- }
211
- }
212
- catch (error) {
213
- const errMsg = error instanceof Error ? error.message : String(error);
214
- return {
215
- id: (0, uuid_1.v4)(),
216
- success: false,
217
- content: [{ type: 'text', text: `设置形状位置出错: ${errMsg}` }],
218
- error: errMsg,
219
- };
220
- }
337
+ const r = await (0, helpers_1.call)('setShapePosition', { slideIndex, shapeIndex, left, top, width, height });
338
+ if (!r.ok)
339
+ return (0, helpers_1.fail)((0, helpers_1.errText)('设置形状位置失败', r), r.error);
340
+ let text = `形状位置设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个\n位置: (${left}, ${top})`;
341
+ if (width !== undefined)
342
+ text += `\n宽度: ${width}`;
343
+ if (height !== undefined)
344
+ text += `\n高度: ${height}`;
345
+ return (0, helpers_1.ok)(text, r.warnings);
221
346
  };
222
347
  exports.setShapePositionHandler = setShapePositionHandler;
223
- // ==================== 4. 设置形状阴影 ====================
348
+ // ==================== 6. 设置形状样式 ====================
349
+ exports.setShapeStyleDefinition = {
350
+ name: 'wps_ppt_set_shape_style',
351
+ description: `设置幻灯片中形状的样式,包括填充颜色、边框颜色和边框粗细。
352
+
353
+ 使用场景:
354
+ - "把矩形改成红色"
355
+ - "设置形状的边框为蓝色"
356
+ - "修改形状样式"`,
357
+ category: tools_1.ToolCategory.PRESENTATION,
358
+ inputSchema: {
359
+ type: 'object',
360
+ properties: {
361
+ slideIndex: {
362
+ type: 'number',
363
+ description: '幻灯片索引(从1开始),默认1',
364
+ },
365
+ name: {
366
+ type: 'string',
367
+ description: '形状名称(通过getSlideInfo获取)',
368
+ },
369
+ shapeIndex: {
370
+ type: 'number',
371
+ description: '形状索引(与name二选一)',
372
+ },
373
+ fillColor: {
374
+ type: 'string',
375
+ description: '填充颜色,十六进制如 #FF0000',
376
+ },
377
+ lineColor: {
378
+ type: 'string',
379
+ description: '边框颜色,十六进制如 #000000',
380
+ },
381
+ lineWidth: {
382
+ type: 'number',
383
+ description: '边框粗细(磅)',
384
+ },
385
+ },
386
+ required: [],
387
+ },
388
+ };
389
+ const setShapeStyleHandler = async (args) => {
390
+ const { slideIndex, name, shapeIndex, fillColor, lineColor, lineWidth } = args;
391
+ // 定位参数至少给一个:都缺时 ps1 会 Shapes.Item($null) 直接炸(审计三.6),前置拦
392
+ if (!name && !shapeIndex) {
393
+ return (0, helpers_1.fail)(`要给 name(形状名,getSlideInfo 里看)或 shapeIndex(形状序号)至少一个,否则不知道改哪个形状`, 'Missing required parameter: name / shapeIndex(二选一)');
394
+ }
395
+ const r = await (0, helpers_1.call)('setShapeStyle', {
396
+ slideIndex: slideIndex || 1,
397
+ name,
398
+ shapeIndex,
399
+ fillColor,
400
+ lineColor,
401
+ lineWidth,
402
+ });
403
+ if (!r.ok || !r.data)
404
+ return (0, helpers_1.fail)((0, helpers_1.errText)('设置形状样式失败', r), r.error);
405
+ let output = `形状样式设置成功!\n形状: ${r.data.name}`;
406
+ if (fillColor)
407
+ output += `\n填充色: ${fillColor}`;
408
+ if (lineColor)
409
+ output += `\n边框色: ${lineColor}`;
410
+ if (lineWidth)
411
+ output += `\n边框粗细: ${lineWidth}pt`;
412
+ return (0, helpers_1.ok)(output, r.warnings);
413
+ };
414
+ exports.setShapeStyleHandler = setShapeStyleHandler;
415
+ // ==================== 7. 设置形状阴影 ====================
224
416
  exports.setShapeShadowDefinition = {
225
417
  name: 'wps_ppt_set_shape_shadow',
226
418
  description: `设置幻灯片中指定形状的阴影效果。
@@ -270,41 +462,13 @@ shadow对象属性:
270
462
  };
271
463
  const setShapeShadowHandler = async (args) => {
272
464
  const { slideIndex, shapeIndex, shadow } = args;
273
- try {
274
- const response = await wps_client_1.wpsClient.executeMethod('setShapeShadow', { slideIndex, shapeIndex, shadow }, wps_1.WpsAppType.PRESENTATION);
275
- if (response.success) {
276
- return {
277
- id: (0, uuid_1.v4)(),
278
- success: true,
279
- content: [
280
- {
281
- type: 'text',
282
- text: `形状阴影设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个`,
283
- },
284
- ],
285
- };
286
- }
287
- else {
288
- return {
289
- id: (0, uuid_1.v4)(),
290
- success: false,
291
- content: [{ type: 'text', text: `设置形状阴影失败: ${response.error}` }],
292
- error: response.error,
293
- };
294
- }
295
- }
296
- catch (error) {
297
- const errMsg = error instanceof Error ? error.message : String(error);
298
- return {
299
- id: (0, uuid_1.v4)(),
300
- success: false,
301
- content: [{ type: 'text', text: `设置形状阴影出错: ${errMsg}` }],
302
- error: errMsg,
303
- };
304
- }
465
+ const r = await (0, helpers_1.call)('setShapeShadow', { slideIndex, shapeIndex, shadow });
466
+ if (!r.ok)
467
+ return (0, helpers_1.fail)((0, helpers_1.errText)('设置形状阴影失败', r), r.error);
468
+ return (0, helpers_1.ok)(`形状阴影设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个`, r.warnings);
305
469
  };
306
470
  exports.setShapeShadowHandler = setShapeShadowHandler;
307
- // ==================== 5. 设置形状渐变填充 ====================
471
+ // ==================== 8. 设置形状渐变填充 ====================
308
472
  exports.setShapeGradientDefinition = {
309
473
  name: 'wps_ppt_set_shape_gradient',
310
474
  description: `设置幻灯片中指定形状的渐变填充效果。
@@ -354,41 +518,13 @@ gradient对象属性:
354
518
  };
355
519
  const setShapeGradientHandler = async (args) => {
356
520
  const { slideIndex, shapeIndex, gradient } = args;
357
- try {
358
- const response = await wps_client_1.wpsClient.executeMethod('setShapeGradient', { slideIndex, shapeIndex, gradient }, wps_1.WpsAppType.PRESENTATION);
359
- if (response.success) {
360
- return {
361
- id: (0, uuid_1.v4)(),
362
- success: true,
363
- content: [
364
- {
365
- type: 'text',
366
- text: `形状渐变填充设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个`,
367
- },
368
- ],
369
- };
370
- }
371
- else {
372
- return {
373
- id: (0, uuid_1.v4)(),
374
- success: false,
375
- content: [{ type: 'text', text: `设置形状渐变失败: ${response.error}` }],
376
- error: response.error,
377
- };
378
- }
379
- }
380
- catch (error) {
381
- const errMsg = error instanceof Error ? error.message : String(error);
382
- return {
383
- id: (0, uuid_1.v4)(),
384
- success: false,
385
- content: [{ type: 'text', text: `设置形状渐变出错: ${errMsg}` }],
386
- error: errMsg,
387
- };
388
- }
521
+ const r = await (0, helpers_1.call)('setShapeGradient', { slideIndex, shapeIndex, gradient });
522
+ if (!r.ok)
523
+ return (0, helpers_1.fail)((0, helpers_1.errText)('设置形状渐变失败', r), r.error);
524
+ return (0, helpers_1.ok)(`形状渐变填充设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个`, r.warnings);
389
525
  };
390
526
  exports.setShapeGradientHandler = setShapeGradientHandler;
391
- // ==================== 6. 设置形状边框 ====================
527
+ // ==================== 9. 设置形状边框 ====================
392
528
  exports.setShapeBorderDefinition = {
393
529
  name: 'wps_ppt_set_shape_border',
394
530
  description: `设置幻灯片中指定形状的边框样式。
@@ -430,41 +566,13 @@ border对象属性:
430
566
  };
431
567
  const setShapeBorderHandler = async (args) => {
432
568
  const { slideIndex, shapeIndex, border } = args;
433
- try {
434
- const response = await wps_client_1.wpsClient.executeMethod('setShapeBorder', { slideIndex, shapeIndex, border }, wps_1.WpsAppType.PRESENTATION);
435
- if (response.success) {
436
- return {
437
- id: (0, uuid_1.v4)(),
438
- success: true,
439
- content: [
440
- {
441
- type: 'text',
442
- text: `形状边框设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个`,
443
- },
444
- ],
445
- };
446
- }
447
- else {
448
- return {
449
- id: (0, uuid_1.v4)(),
450
- success: false,
451
- content: [{ type: 'text', text: `设置形状边框失败: ${response.error}` }],
452
- error: response.error,
453
- };
454
- }
455
- }
456
- catch (error) {
457
- const errMsg = error instanceof Error ? error.message : String(error);
458
- return {
459
- id: (0, uuid_1.v4)(),
460
- success: false,
461
- content: [{ type: 'text', text: `设置形状边框出错: ${errMsg}` }],
462
- error: errMsg,
463
- };
464
- }
569
+ const r = await (0, helpers_1.call)('setShapeBorder', { slideIndex, shapeIndex, border });
570
+ if (!r.ok)
571
+ return (0, helpers_1.fail)((0, helpers_1.errText)('设置形状边框失败', r), r.error);
572
+ return (0, helpers_1.ok)(`形状边框设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个`, r.warnings);
465
573
  };
466
574
  exports.setShapeBorderHandler = setShapeBorderHandler;
467
- // ==================== 7. 设置形状透明度 ====================
575
+ // ==================== 10. 设置形状透明度 ====================
468
576
  exports.setShapeTransparencyDefinition = {
469
577
  name: 'wps_ppt_set_shape_transparency',
470
578
  description: `设置幻灯片中指定形状的透明度。
@@ -494,41 +602,103 @@ exports.setShapeTransparencyDefinition = {
494
602
  };
495
603
  const setShapeTransparencyHandler = async (args) => {
496
604
  const { slideIndex, shapeIndex, transparency } = args;
497
- try {
498
- const response = await wps_client_1.wpsClient.executeMethod('setShapeTransparency', { slideIndex, shapeIndex, transparency }, wps_1.WpsAppType.PRESENTATION);
499
- if (response.success) {
500
- return {
501
- id: (0, uuid_1.v4)(),
502
- success: true,
503
- content: [
504
- {
505
- type: 'text',
506
- text: `形状透明度设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个\n透明度: ${transparency}%`,
507
- },
508
- ],
509
- };
510
- }
511
- else {
512
- return {
513
- id: (0, uuid_1.v4)(),
514
- success: false,
515
- content: [{ type: 'text', text: `设置形状透明度失败: ${response.error}` }],
516
- error: response.error,
517
- };
518
- }
519
- }
520
- catch (error) {
521
- const errMsg = error instanceof Error ? error.message : String(error);
522
- return {
523
- id: (0, uuid_1.v4)(),
524
- success: false,
525
- content: [{ type: 'text', text: `设置形状透明度出错: ${errMsg}` }],
526
- error: errMsg,
527
- };
528
- }
605
+ const r = await (0, helpers_1.call)('setShapeTransparency', { slideIndex, shapeIndex, transparency });
606
+ if (!r.ok)
607
+ return (0, helpers_1.fail)((0, helpers_1.errText)('设置形状透明度失败', r), r.error);
608
+ return (0, helpers_1.ok)(`形状透明度设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个\n透明度: ${transparency}%`, r.warnings);
529
609
  };
530
610
  exports.setShapeTransparencyHandler = setShapeTransparencyHandler;
531
- // ==================== 8. 对齐多个形状 ====================
611
+ // ==================== 11. 设置形状文字 ====================
612
+ exports.setShapeTextDefinition = {
613
+ name: 'wps_ppt_set_shape_text',
614
+ description: `设置幻灯片中指定形状的文字内容。
615
+
616
+ 使用场景:
617
+ - "把第1页的第2个形状文字改成'销售额'"
618
+ - "修改形状里的文字"`,
619
+ category: tools_1.ToolCategory.PRESENTATION,
620
+ inputSchema: {
621
+ type: 'object',
622
+ properties: {
623
+ slideIndex: { type: 'number', description: '幻灯片索引(从1开始)' },
624
+ shapeIndex: { type: 'number', description: '形状索引(从1开始)' },
625
+ text: { type: 'string', description: '要设置的文字内容' },
626
+ },
627
+ required: ['slideIndex', 'shapeIndex', 'text'],
628
+ },
629
+ };
630
+ const setShapeTextHandler = async (args) => {
631
+ const { slideIndex, shapeIndex, text } = args;
632
+ const r = await (0, helpers_1.call)('setShapeText', { slideIndex, shapeIndex, text });
633
+ if (!r.ok || !r.data)
634
+ return (0, helpers_1.fail)((0, helpers_1.errText)('设置形状文字失败', r), r.error);
635
+ return (0, helpers_1.ok)(`形状文字设置成功!\n形状: ${r.data.name}\n文字: "${text}"`, r.warnings);
636
+ };
637
+ exports.setShapeTextHandler = setShapeTextHandler;
638
+ // ==================== 12. 设置形状填充颜色 ====================
639
+ exports.setShapeFillDefinition = {
640
+ name: 'wps_ppt_set_shape_fill',
641
+ description: `设置幻灯片中指定形状的填充颜色。
642
+
643
+ 使用场景:
644
+ - "把第1页的第2个形状填充为红色"
645
+ - "修改形状背景色为#00FF00"
646
+ - "设置形状的填充颜色"`,
647
+ category: tools_1.ToolCategory.PRESENTATION,
648
+ inputSchema: {
649
+ type: 'object',
650
+ properties: {
651
+ slideIndex: { type: 'number', description: '幻灯片索引(从1开始)' },
652
+ shapeIndex: { type: 'number', description: '形状索引(从1开始)' },
653
+ color: { type: 'string', description: '填充颜色,十六进制如 #FF0000' },
654
+ },
655
+ required: ['slideIndex', 'shapeIndex', 'color'],
656
+ },
657
+ };
658
+ const setShapeFillHandler = async (args) => {
659
+ const { slideIndex, shapeIndex, color } = args;
660
+ const r = await (0, helpers_1.call)(
661
+ // 第 1 期第 2 章第 2 轮:这句原为「仅Windows支持」,是假注释 —— 该动作曾长期不存在于 ps1。第 6 轮已补 case,现在 Windows 上真能用。
662
+ 'setShapeFill', { slideIndex, shapeIndex, color });
663
+ if (!r.ok)
664
+ return (0, helpers_1.fail)((0, helpers_1.errText)('设置形状填充失败', r), r.error);
665
+ return (0, helpers_1.ok)(`形状填充颜色设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个\n填充颜色: ${color}`, r.warnings);
666
+ };
667
+ exports.setShapeFillHandler = setShapeFillHandler;
668
+ // ==================== 13. 设置幻灯片标题 ====================
669
+ exports.setSlideTitleDefinition = {
670
+ name: 'wps_ppt_set_slide_title',
671
+ description: `设置幻灯片的标题文本。
672
+
673
+ 使用场景:
674
+ - "把第1页标题改成'年度总结'"
675
+ - "设置标题为'项目进展'"
676
+ - "修改幻灯片标题"`,
677
+ category: tools_1.ToolCategory.PRESENTATION,
678
+ inputSchema: {
679
+ type: 'object',
680
+ properties: {
681
+ slideIndex: {
682
+ type: 'number',
683
+ description: '幻灯片索引(从1开始),默认1',
684
+ },
685
+ title: {
686
+ type: 'string',
687
+ description: '标题文本',
688
+ },
689
+ },
690
+ required: ['title'],
691
+ },
692
+ };
693
+ const setSlideTitleHandler = async (args) => {
694
+ const { slideIndex, title } = args;
695
+ const r = await (0, helpers_1.call)('setSlideTitle', { slideIndex: slideIndex || 1, title });
696
+ if (!r.ok || !r.data)
697
+ return (0, helpers_1.fail)((0, helpers_1.errText)('设置幻灯片标题失败', r), r.error);
698
+ return (0, helpers_1.ok)(`幻灯片标题设置成功!\n幻灯片: 第 ${r.data.slideIndex} 页\n标题: "${r.data.title}"`, r.warnings);
699
+ };
700
+ exports.setSlideTitleHandler = setSlideTitleHandler;
701
+ // ==================== 14. 对齐多个形状 ====================
532
702
  exports.alignShapesDefinition = {
533
703
  name: 'wps_ppt_align_shapes',
534
704
  description: `对齐幻灯片中的多个形状。
@@ -568,49 +738,21 @@ exports.alignShapesDefinition = {
568
738
  };
569
739
  const alignShapesHandler = async (args) => {
570
740
  const { slideIndex, shapeIndices, alignment } = args;
571
- try {
572
- const response = await wps_client_1.wpsClient.executeMethod('alignShapes', { slideIndex, shapeIndices, alignment }, wps_1.WpsAppType.PRESENTATION);
573
- if (response.success) {
574
- const alignName = {
575
- left: '左对齐',
576
- center: '水平居中',
577
- right: '右对齐',
578
- top: '顶部对齐',
579
- middle: '垂直居中',
580
- bottom: '底部对齐',
581
- };
582
- return {
583
- id: (0, uuid_1.v4)(),
584
- success: true,
585
- content: [
586
- {
587
- type: 'text',
588
- text: `形状对齐完成!\n幻灯片: 第 ${slideIndex} 页\n对齐方式: ${alignName[alignment] || alignment}\n形状数量: ${shapeIndices.length} 个`,
589
- },
590
- ],
591
- };
592
- }
593
- else {
594
- return {
595
- id: (0, uuid_1.v4)(),
596
- success: false,
597
- content: [{ type: 'text', text: `对齐形状失败: ${response.error}` }],
598
- error: response.error,
599
- };
600
- }
601
- }
602
- catch (error) {
603
- const errMsg = error instanceof Error ? error.message : String(error);
604
- return {
605
- id: (0, uuid_1.v4)(),
606
- success: false,
607
- content: [{ type: 'text', text: `对齐形状出错: ${errMsg}` }],
608
- error: errMsg,
609
- };
610
- }
741
+ const r = await (0, helpers_1.call)('alignShapes', { slideIndex, shapeIndices, alignment });
742
+ if (!r.ok)
743
+ return (0, helpers_1.fail)((0, helpers_1.errText)('对齐形状失败', r), r.error);
744
+ const alignName = {
745
+ left: '左对齐',
746
+ center: '水平居中',
747
+ right: '右对齐',
748
+ top: '顶部对齐',
749
+ middle: '垂直居中',
750
+ bottom: '底部对齐',
751
+ };
752
+ return (0, helpers_1.ok)(`形状对齐完成!\n幻灯片: 第 ${slideIndex} 页\n对齐方式: ${alignName[alignment] || alignment}\n形状数量: ${shapeIndices.length} 个`, r.warnings);
611
753
  };
612
754
  exports.alignShapesHandler = alignShapesHandler;
613
- // ==================== 9. 等距分布多个形状 ====================
755
+ // ==================== 15. 等距分布多个形状 ====================
614
756
  exports.distributeShapesDefinition = {
615
757
  name: 'wps_ppt_distribute_shapes',
616
758
  description: `等距分布幻灯片中的多个形状。
@@ -646,42 +788,14 @@ exports.distributeShapesDefinition = {
646
788
  };
647
789
  const distributeShapesHandler = async (args) => {
648
790
  const { slideIndex, shapeIndices, direction } = args;
649
- try {
650
- const response = await wps_client_1.wpsClient.executeMethod('distributeShapes', { slideIndex, shapeIndices, direction }, wps_1.WpsAppType.PRESENTATION);
651
- if (response.success) {
652
- const dirName = direction === 'horizontal' ? '水平等距' : '垂直等距';
653
- return {
654
- id: (0, uuid_1.v4)(),
655
- success: true,
656
- content: [
657
- {
658
- type: 'text',
659
- text: `形状分布完成!\n幻灯片: 第 ${slideIndex} 页\n分布方向: ${dirName}\n形状数量: ${shapeIndices.length} 个`,
660
- },
661
- ],
662
- };
663
- }
664
- else {
665
- return {
666
- id: (0, uuid_1.v4)(),
667
- success: false,
668
- content: [{ type: 'text', text: `分布形状失败: ${response.error}` }],
669
- error: response.error,
670
- };
671
- }
672
- }
673
- catch (error) {
674
- const errMsg = error instanceof Error ? error.message : String(error);
675
- return {
676
- id: (0, uuid_1.v4)(),
677
- success: false,
678
- content: [{ type: 'text', text: `分布形状出错: ${errMsg}` }],
679
- error: errMsg,
680
- };
681
- }
791
+ const r = await (0, helpers_1.call)('distributeShapes', { slideIndex, shapeIndices, direction });
792
+ if (!r.ok)
793
+ return (0, helpers_1.fail)((0, helpers_1.errText)('分布形状失败', r), r.error);
794
+ const dirName = direction === 'horizontal' ? '水平等距' : '垂直等距';
795
+ return (0, helpers_1.ok)(`形状分布完成!\n幻灯片: 第 ${slideIndex} 页\n分布方向: ${dirName}\n形状数量: ${shapeIndices.length} 个`, r.warnings);
682
796
  };
683
797
  exports.distributeShapesHandler = distributeShapesHandler;
684
- // ==================== 10. 组合多个形状 ====================
798
+ // ==================== 16. 组合多个形状 ====================
685
799
  exports.groupShapesDefinition = {
686
800
  name: 'wps_ppt_group_shapes',
687
801
  description: `将幻灯片中的多个形状组合为一个组。
@@ -708,50 +822,33 @@ exports.groupShapesDefinition = {
708
822
  };
709
823
  const groupShapesHandler = async (args) => {
710
824
  const { slideIndex, shapeIndices } = args;
711
- try {
712
- const response = await wps_client_1.wpsClient.executeMethod('groupShapes', { slideIndex, shapeIndices }, wps_1.WpsAppType.PRESENTATION);
713
- if (response.success) {
714
- let text = `形状组合成功!\n幻灯片: 第 ${slideIndex} 页\n组合形状: ${shapeIndices.length} 个`;
715
- if (response.data?.groupIndex) {
716
- text += `\n组合索引: ${response.data.groupIndex}`;
717
- }
718
- return {
719
- id: (0, uuid_1.v4)(),
720
- success: true,
721
- content: [{ type: 'text', text }],
722
- };
723
- }
724
- else {
725
- return {
726
- id: (0, uuid_1.v4)(),
727
- success: false,
728
- content: [{ type: 'text', text: `组合形状失败: ${response.error}` }],
729
- error: response.error,
730
- };
731
- }
732
- }
733
- catch (error) {
734
- const errMsg = error instanceof Error ? error.message : String(error);
735
- return {
736
- id: (0, uuid_1.v4)(),
737
- success: false,
738
- content: [{ type: 'text', text: `组合形状出错: ${errMsg}` }],
739
- error: errMsg,
740
- };
825
+ const r = await (0, helpers_1.call)('groupShapes', { slideIndex, shapeIndices });
826
+ if (!r.ok)
827
+ return (0, helpers_1.fail)((0, helpers_1.errText)('组合形状失败', r), r.error);
828
+ let text = `形状组合成功!\n幻灯片: 第 ${slideIndex} 页\n组合形状: ${shapeIndices.length} 个`;
829
+ if (r.data?.groupIndex) {
830
+ text += `\n组合索引: ${r.data.groupIndex}`;
741
831
  }
832
+ return (0, helpers_1.ok)(text, r.warnings);
742
833
  };
743
834
  exports.groupShapesHandler = groupShapesHandler;
744
835
  /**
745
836
  * 导出所有形状基础相关的Tools
746
837
  */
747
838
  exports.shapeBasicTools = [
839
+ { definition: exports.addShapeDefinition, handler: exports.addShapeHandler },
840
+ { definition: exports.addTextboxDefinition, handler: exports.addTextboxHandler },
748
841
  { definition: exports.deleteShapeDefinition, handler: exports.deleteShapeHandler },
749
842
  { definition: exports.getShapesDefinition, handler: exports.getShapesHandler },
750
843
  { definition: exports.setShapePositionDefinition, handler: exports.setShapePositionHandler },
844
+ { definition: exports.setShapeStyleDefinition, handler: exports.setShapeStyleHandler },
751
845
  { definition: exports.setShapeShadowDefinition, handler: exports.setShapeShadowHandler },
752
846
  { definition: exports.setShapeGradientDefinition, handler: exports.setShapeGradientHandler },
753
847
  { definition: exports.setShapeBorderDefinition, handler: exports.setShapeBorderHandler },
754
848
  { definition: exports.setShapeTransparencyDefinition, handler: exports.setShapeTransparencyHandler },
849
+ { definition: exports.setShapeTextDefinition, handler: exports.setShapeTextHandler },
850
+ { definition: exports.setShapeFillDefinition, handler: exports.setShapeFillHandler },
851
+ { definition: exports.setSlideTitleDefinition, handler: exports.setSlideTitleHandler },
755
852
  { definition: exports.alignShapesDefinition, handler: exports.alignShapesHandler },
756
853
  { definition: exports.distributeShapesDefinition, handler: exports.distributeShapesHandler },
757
854
  { definition: exports.groupShapesDefinition, handler: exports.groupShapesHandler },