wps-multitool-mcp 0.0.0-stage → 1.0.1

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 (280) hide show
  1. package/README.md +3 -3
  2. package/dist/bridge/cancellable.d.ts +36 -0
  3. package/dist/bridge/cancellable.d.ts.map +1 -0
  4. package/dist/bridge/cancellable.js +155 -0
  5. package/dist/bridge/cancellable.js.map +1 -0
  6. package/dist/bridge/index.d.ts +37 -0
  7. package/dist/bridge/index.d.ts.map +1 -0
  8. package/dist/bridge/index.js +381 -0
  9. package/dist/bridge/index.js.map +1 -0
  10. package/dist/bridge/ps-child.d.ts +155 -0
  11. package/dist/bridge/ps-child.d.ts.map +1 -0
  12. package/dist/bridge/ps-child.js +578 -0
  13. package/dist/bridge/ps-child.js.map +1 -0
  14. package/dist/client/action-routes.d.ts +32 -0
  15. package/dist/client/action-routes.d.ts.map +1 -0
  16. package/dist/client/action-routes.generated.d.ts +10 -0
  17. package/dist/client/action-routes.generated.d.ts.map +1 -0
  18. package/dist/client/action-routes.generated.js +322 -0
  19. package/dist/client/action-routes.generated.js.map +1 -0
  20. package/dist/client/action-routes.js +57 -0
  21. package/dist/client/action-routes.js.map +1 -0
  22. package/dist/client/mac-poll-server.d.ts +77 -0
  23. package/dist/client/mac-poll-server.d.ts.map +1 -0
  24. package/dist/client/mac-poll-server.js +516 -0
  25. package/dist/client/mac-poll-server.js.map +1 -0
  26. package/dist/client/ps-daemon.d.ts +95 -0
  27. package/dist/client/ps-daemon.d.ts.map +1 -0
  28. package/dist/client/ps-daemon.js +424 -0
  29. package/dist/client/ps-daemon.js.map +1 -0
  30. package/dist/client/wps-client.d.ts +72 -0
  31. package/dist/client/wps-client.d.ts.map +1 -0
  32. package/dist/client/wps-client.js +408 -0
  33. package/dist/client/wps-client.js.map +1 -0
  34. package/dist/index.d.ts +29 -0
  35. package/dist/index.d.ts.map +1 -0
  36. package/dist/index.js +121 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/runtime-identity.d.ts +23 -0
  39. package/dist/runtime-identity.d.ts.map +1 -0
  40. package/dist/runtime-identity.js +26 -0
  41. package/dist/runtime-identity.js.map +1 -0
  42. package/dist/server/cancel-context.d.ts +30 -0
  43. package/dist/server/cancel-context.d.ts.map +1 -0
  44. package/dist/server/cancel-context.js +38 -0
  45. package/dist/server/cancel-context.js.map +1 -0
  46. package/dist/server/mcp-server.d.ts +74 -0
  47. package/dist/server/mcp-server.d.ts.map +1 -0
  48. package/dist/server/mcp-server.js +725 -0
  49. package/dist/server/mcp-server.js.map +1 -0
  50. package/dist/server/server-info.d.ts +21 -0
  51. package/dist/server/server-info.d.ts.map +1 -0
  52. package/dist/server/server-info.js +56 -0
  53. package/dist/server/server-info.js.map +1 -0
  54. package/dist/server/tool-annotations.d.ts +52 -0
  55. package/dist/server/tool-annotations.d.ts.map +1 -0
  56. package/dist/server/tool-annotations.generated.d.ts +14 -0
  57. package/dist/server/tool-annotations.generated.d.ts.map +1 -0
  58. package/dist/server/tool-annotations.generated.js +324 -0
  59. package/dist/server/tool-annotations.generated.js.map +1 -0
  60. package/dist/server/tool-annotations.js +116 -0
  61. package/dist/server/tool-annotations.js.map +1 -0
  62. package/dist/server/tool-group-events.d.ts +23 -0
  63. package/dist/server/tool-group-events.d.ts.map +1 -0
  64. package/dist/server/tool-group-events.js +44 -0
  65. package/dist/server/tool-group-events.js.map +1 -0
  66. package/dist/server/tool-metadata.d.ts +43 -0
  67. package/dist/server/tool-metadata.d.ts.map +1 -0
  68. package/dist/server/tool-metadata.js +657 -0
  69. package/dist/server/tool-metadata.js.map +1 -0
  70. package/dist/server/tool-registry.d.ts +164 -0
  71. package/dist/server/tool-registry.d.ts.map +1 -0
  72. package/dist/server/tool-registry.js +453 -0
  73. package/dist/server/tool-registry.js.map +1 -0
  74. package/dist/server/tool-tiers.d.ts +39 -0
  75. package/dist/server/tool-tiers.d.ts.map +1 -0
  76. package/dist/server/tool-tiers.js +102 -0
  77. package/dist/server/tool-tiers.js.map +1 -0
  78. package/dist/tools/common/batch.d.ts +33 -0
  79. package/dist/tools/common/batch.d.ts.map +1 -0
  80. package/dist/tools/common/batch.js +195 -0
  81. package/dist/tools/common/batch.js.map +1 -0
  82. package/dist/tools/common/convert.d.ts +41 -0
  83. package/dist/tools/common/convert.d.ts.map +1 -0
  84. package/dist/tools/common/convert.js +299 -0
  85. package/dist/tools/common/convert.js.map +1 -0
  86. package/dist/tools/common/general.d.ts +39 -0
  87. package/dist/tools/common/general.d.ts.map +1 -0
  88. package/dist/tools/common/general.js +624 -0
  89. package/dist/tools/common/general.js.map +1 -0
  90. package/dist/tools/common/index.d.ts +36 -0
  91. package/dist/tools/common/index.d.ts.map +1 -0
  92. package/dist/tools/common/index.js +102 -0
  93. package/dist/tools/common/index.js.map +1 -0
  94. package/dist/tools/common/intent.d.ts +48 -0
  95. package/dist/tools/common/intent.d.ts.map +1 -0
  96. package/dist/tools/common/intent.js +221 -0
  97. package/dist/tools/common/intent.js.map +1 -0
  98. package/dist/tools/common/repair.d.ts +29 -0
  99. package/dist/tools/common/repair.d.ts.map +1 -0
  100. package/dist/tools/common/repair.js +140 -0
  101. package/dist/tools/common/repair.js.map +1 -0
  102. package/dist/tools/common/status.d.ts +27 -0
  103. package/dist/tools/common/status.d.ts.map +1 -0
  104. package/dist/tools/common/status.js +139 -0
  105. package/dist/tools/common/status.js.map +1 -0
  106. package/dist/tools/common/toolgroups.d.ts +38 -0
  107. package/dist/tools/common/toolgroups.d.ts.map +1 -0
  108. package/dist/tools/common/toolgroups.js +238 -0
  109. package/dist/tools/common/toolgroups.js.map +1 -0
  110. package/dist/tools/excel/chart.d.ts +86 -0
  111. package/dist/tools/excel/chart.d.ts.map +1 -0
  112. package/dist/tools/excel/chart.js +659 -0
  113. package/dist/tools/excel/chart.js.map +1 -0
  114. package/dist/tools/excel/comment-protect.d.ts +58 -0
  115. package/dist/tools/excel/comment-protect.d.ts.map +1 -0
  116. package/dist/tools/excel/comment-protect.js +274 -0
  117. package/dist/tools/excel/comment-protect.js.map +1 -0
  118. package/dist/tools/excel/data-advanced.d.ts +47 -0
  119. package/dist/tools/excel/data-advanced.d.ts.map +1 -0
  120. package/dist/tools/excel/data-advanced.js +263 -0
  121. package/dist/tools/excel/data-advanced.js.map +1 -0
  122. package/dist/tools/excel/data.d.ts +91 -0
  123. package/dist/tools/excel/data.d.ts.map +1 -0
  124. package/dist/tools/excel/data.js +626 -0
  125. package/dist/tools/excel/data.js.map +1 -0
  126. package/dist/tools/excel/format.d.ts +42 -0
  127. package/dist/tools/excel/format.d.ts.map +1 -0
  128. package/dist/tools/excel/format.js +715 -0
  129. package/dist/tools/excel/format.js.map +1 -0
  130. package/dist/tools/excel/formula.d.ts +64 -0
  131. package/dist/tools/excel/formula.d.ts.map +1 -0
  132. package/dist/tools/excel/formula.js +333 -0
  133. package/dist/tools/excel/formula.js.map +1 -0
  134. package/dist/tools/excel/index.d.ts +44 -0
  135. package/dist/tools/excel/index.d.ts.map +1 -0
  136. package/dist/tools/excel/index.js +249 -0
  137. package/dist/tools/excel/index.js.map +1 -0
  138. package/dist/tools/excel/pivot.d.ts +39 -0
  139. package/dist/tools/excel/pivot.d.ts.map +1 -0
  140. package/dist/tools/excel/pivot.js +455 -0
  141. package/dist/tools/excel/pivot.js.map +1 -0
  142. package/dist/tools/excel/row-column.d.ts +64 -0
  143. package/dist/tools/excel/row-column.d.ts.map +1 -0
  144. package/dist/tools/excel/row-column.js +299 -0
  145. package/dist/tools/excel/row-column.js.map +1 -0
  146. package/dist/tools/excel/sheet-gaps.d.ts +50 -0
  147. package/dist/tools/excel/sheet-gaps.d.ts.map +1 -0
  148. package/dist/tools/excel/sheet-gaps.js +373 -0
  149. package/dist/tools/excel/sheet-gaps.js.map +1 -0
  150. package/dist/tools/excel/sheet.d.ts +112 -0
  151. package/dist/tools/excel/sheet.d.ts.map +1 -0
  152. package/dist/tools/excel/sheet.js +937 -0
  153. package/dist/tools/excel/sheet.js.map +1 -0
  154. package/dist/tools/excel/workbook.d.ts +62 -0
  155. package/dist/tools/excel/workbook.d.ts.map +1 -0
  156. package/dist/tools/excel/workbook.js +366 -0
  157. package/dist/tools/excel/workbook.js.map +1 -0
  158. package/dist/tools/index.d.ts +48 -0
  159. package/dist/tools/index.d.ts.map +1 -0
  160. package/dist/tools/index.js +113 -0
  161. package/dist/tools/index.js.map +1 -0
  162. package/dist/tools/ppt/animation.d.ts +79 -0
  163. package/dist/tools/ppt/animation.d.ts.map +1 -0
  164. package/dist/tools/ppt/animation.js +719 -0
  165. package/dist/tools/ppt/animation.js.map +1 -0
  166. package/dist/tools/ppt/background.d.ts +72 -0
  167. package/dist/tools/ppt/background.d.ts.map +1 -0
  168. package/dist/tools/ppt/background.js +595 -0
  169. package/dist/tools/ppt/background.js.map +1 -0
  170. package/dist/tools/ppt/beautify-advanced.d.ts +72 -0
  171. package/dist/tools/ppt/beautify-advanced.d.ts.map +1 -0
  172. package/dist/tools/ppt/beautify-advanced.js +663 -0
  173. package/dist/tools/ppt/beautify-advanced.js.map +1 -0
  174. package/dist/tools/ppt/chart-flow.d.ts +58 -0
  175. package/dist/tools/ppt/chart-flow.d.ts.map +1 -0
  176. package/dist/tools/ppt/chart-flow.js +523 -0
  177. package/dist/tools/ppt/chart-flow.js.map +1 -0
  178. package/dist/tools/ppt/data-viz.d.ts +64 -0
  179. package/dist/tools/ppt/data-viz.d.ts.map +1 -0
  180. package/dist/tools/ppt/data-viz.js +514 -0
  181. package/dist/tools/ppt/data-viz.js.map +1 -0
  182. package/dist/tools/ppt/image.d.ts +30 -0
  183. package/dist/tools/ppt/image.d.ts.map +1 -0
  184. package/dist/tools/ppt/image.js +452 -0
  185. package/dist/tools/ppt/image.js.map +1 -0
  186. package/dist/tools/ppt/index.d.ts +72 -0
  187. package/dist/tools/ppt/index.d.ts.map +1 -0
  188. package/dist/tools/ppt/index.js +350 -0
  189. package/dist/tools/ppt/index.js.map +1 -0
  190. package/dist/tools/ppt/misc.d.ts +99 -0
  191. package/dist/tools/ppt/misc.d.ts.map +1 -0
  192. package/dist/tools/ppt/misc.js +868 -0
  193. package/dist/tools/ppt/misc.js.map +1 -0
  194. package/dist/tools/ppt/presentation.d.ts +72 -0
  195. package/dist/tools/ppt/presentation.d.ts.map +1 -0
  196. package/dist/tools/ppt/presentation.js +680 -0
  197. package/dist/tools/ppt/presentation.js.map +1 -0
  198. package/dist/tools/ppt/shape-basic.d.ts +46 -0
  199. package/dist/tools/ppt/shape-basic.d.ts.map +1 -0
  200. package/dist/tools/ppt/shape-basic.js +756 -0
  201. package/dist/tools/ppt/shape-basic.js.map +1 -0
  202. package/dist/tools/ppt/slide-ops.d.ts +79 -0
  203. package/dist/tools/ppt/slide-ops.d.ts.map +1 -0
  204. package/dist/tools/ppt/slide-ops.js +1646 -0
  205. package/dist/tools/ppt/slide-ops.js.map +1 -0
  206. package/dist/tools/ppt/slide.d.ts +51 -0
  207. package/dist/tools/ppt/slide.d.ts.map +1 -0
  208. package/dist/tools/ppt/slide.js +470 -0
  209. package/dist/tools/ppt/slide.js.map +1 -0
  210. package/dist/tools/ppt/table.d.ts +58 -0
  211. package/dist/tools/ppt/table.d.ts.map +1 -0
  212. package/dist/tools/ppt/table.js +512 -0
  213. package/dist/tools/ppt/table.js.map +1 -0
  214. package/dist/tools/ppt/textbox.d.ts +47 -0
  215. package/dist/tools/ppt/textbox.d.ts.map +1 -0
  216. package/dist/tools/ppt/textbox.js +246 -0
  217. package/dist/tools/ppt/textbox.js.map +1 -0
  218. package/dist/tools/word/academic.d.ts +50 -0
  219. package/dist/tools/word/academic.d.ts.map +1 -0
  220. package/dist/tools/word/academic.js +500 -0
  221. package/dist/tools/word/academic.js.map +1 -0
  222. package/dist/tools/word/content.d.ts +97 -0
  223. package/dist/tools/word/content.d.ts.map +1 -0
  224. package/dist/tools/word/content.js +838 -0
  225. package/dist/tools/word/content.js.map +1 -0
  226. package/dist/tools/word/document.d.ts +70 -0
  227. package/dist/tools/word/document.d.ts.map +1 -0
  228. package/dist/tools/word/document.js +633 -0
  229. package/dist/tools/word/document.js.map +1 -0
  230. package/dist/tools/word/format.d.ts +50 -0
  231. package/dist/tools/word/format.d.ts.map +1 -0
  232. package/dist/tools/word/format.js +462 -0
  233. package/dist/tools/word/format.js.map +1 -0
  234. package/dist/tools/word/gaps.d.ts +58 -0
  235. package/dist/tools/word/gaps.d.ts.map +1 -0
  236. package/dist/tools/word/gaps.js +431 -0
  237. package/dist/tools/word/gaps.js.map +1 -0
  238. package/dist/tools/word/index.d.ts +34 -0
  239. package/dist/tools/word/index.d.ts.map +1 -0
  240. package/dist/tools/word/index.js +124 -0
  241. package/dist/tools/word/index.js.map +1 -0
  242. package/dist/tools/word/professional.d.ts +48 -0
  243. package/dist/tools/word/professional.d.ts.map +1 -0
  244. package/dist/tools/word/professional.js +657 -0
  245. package/dist/tools/word/professional.js.map +1 -0
  246. package/dist/tools/word/proofread.d.ts +25 -0
  247. package/dist/tools/word/proofread.d.ts.map +1 -0
  248. package/dist/tools/word/proofread.js +718 -0
  249. package/dist/tools/word/proofread.js.map +1 -0
  250. package/dist/types/index.d.ts +9 -0
  251. package/dist/types/index.d.ts.map +1 -0
  252. package/dist/types/index.js +25 -0
  253. package/dist/types/index.js.map +1 -0
  254. package/dist/types/tools.d.ts +163 -0
  255. package/dist/types/tools.d.ts.map +1 -0
  256. package/dist/types/tools.js +45 -0
  257. package/dist/types/tools.js.map +1 -0
  258. package/dist/types/wps.d.ts +190 -0
  259. package/dist/types/wps.d.ts.map +1 -0
  260. package/dist/types/wps.js +23 -0
  261. package/dist/types/wps.js.map +1 -0
  262. package/dist/utils/error.d.ts +147 -0
  263. package/dist/utils/error.d.ts.map +1 -0
  264. package/dist/utils/error.js +417 -0
  265. package/dist/utils/error.js.map +1 -0
  266. package/dist/utils/logger.d.ts +56 -0
  267. package/dist/utils/logger.d.ts.map +1 -0
  268. package/dist/utils/logger.js +138 -0
  269. package/dist/utils/logger.js.map +1 -0
  270. package/dist/version.d.ts +22 -0
  271. package/dist/version.d.ts.map +1 -0
  272. package/dist/version.js +101 -0
  273. package/dist/version.js.map +1 -0
  274. package/package.json +57 -4
  275. package/scripts/wps-com.ps1 +7260 -0
  276. package/scripts/wps-comd.ps1 +123 -0
  277. package/skills/wps-multitool/SKILL.md +111 -0
  278. package/skills/wps-multitool/references/errors.md +62 -0
  279. package/skills/wps-multitool/references/recipes.md +82 -0
  280. package/skills/wps-multitool/references/routing.md +88 -0
@@ -0,0 +1,680 @@
1
+ "use strict";
2
+ /**
3
+ * Input: 演示文稿管理工具参数
4
+ * Output: 演示文稿操作结果
5
+ * Pos: PPT 演示文稿管理工具实现。一旦我被修改,请更新我的头部注释,以及所属文件夹的md。
6
+ *
7
+ * 包含:
8
+ * - wps_ppt_create_presentation: 新建空白演示文稿
9
+ * - wps_ppt_open_presentation: 打开指定路径的演示文稿
10
+ * - wps_ppt_close_presentation: 关闭演示文稿
11
+ * - wps_ppt_get_open_presentations: 获取所有已打开的演示文稿列表
12
+ * - wps_ppt_switch_presentation: 切换到指定演示文稿
13
+ * - wps_ppt_set_slide_theme: 设置演示文稿主题
14
+ * - wps_ppt_copy_slide: 复制幻灯片
15
+ * - wps_ppt_insert_slide_image: 在幻灯片中插入图片
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.presentationTools = exports.setActiveTargetHandler = exports.setActiveTargetDefinition = exports.insertSlidesFromFileHandler = exports.insertSlidesFromFileDefinition = exports.insertSlideImageHandler = exports.insertSlideImageDefinition = exports.copySlideHandler = exports.copySlideDefinition = exports.setSlideThemeHandler = exports.setSlideThemeDefinition = exports.switchPresentationHandler = exports.switchPresentationDefinition = exports.getOpenPresentationsHandler = exports.getOpenPresentationsDefinition = exports.closePresentationHandler = exports.closePresentationDefinition = exports.openPresentationHandler = exports.openPresentationDefinition = exports.createPresentationHandler = exports.createPresentationDefinition = void 0;
19
+ const uuid_1 = require("uuid");
20
+ const tools_1 = require("../../types/tools");
21
+ const wps_client_1 = require("../../client/wps-client");
22
+ const wps_1 = require("../../types/wps");
23
+ /**
24
+ * 新建空白演示文稿
25
+ */
26
+ exports.createPresentationDefinition = {
27
+ name: 'wps_ppt_create_presentation',
28
+ description: `新建空白演示文稿。
29
+
30
+ 使用场景:
31
+ - "新建一个PPT"
32
+ - "创建一个演示文稿"
33
+ - "打开一个新的PPT"`,
34
+ category: tools_1.ToolCategory.PRESENTATION,
35
+ inputSchema: {
36
+ type: 'object',
37
+ properties: {},
38
+ required: [],
39
+ },
40
+ };
41
+ const createPresentationHandler = async (_args) => {
42
+ try {
43
+ const response = await wps_client_1.wpsClient.executeMethod('createPresentation', {}, wps_1.WpsAppType.PRESENTATION);
44
+ if (response.success && response.data) {
45
+ return {
46
+ id: (0, uuid_1.v4)(),
47
+ success: true,
48
+ content: [
49
+ {
50
+ type: 'text',
51
+ text: `新建演示文稿成功!\n名称: ${response.data.name}`,
52
+ },
53
+ ],
54
+ };
55
+ }
56
+ else {
57
+ return {
58
+ id: (0, uuid_1.v4)(),
59
+ success: false,
60
+ content: [{ type: 'text', text: `新建演示文稿失败: ${response.error}` }],
61
+ error: response.error,
62
+ };
63
+ }
64
+ }
65
+ catch (error) {
66
+ const errMsg = error instanceof Error ? error.message : String(error);
67
+ return {
68
+ id: (0, uuid_1.v4)(),
69
+ success: false,
70
+ content: [{ type: 'text', text: `新建演示文稿出错: ${errMsg}` }],
71
+ error: errMsg,
72
+ };
73
+ }
74
+ };
75
+ exports.createPresentationHandler = createPresentationHandler;
76
+ /**
77
+ * 打开指定路径的演示文稿
78
+ */
79
+ exports.openPresentationDefinition = {
80
+ name: 'wps_ppt_open_presentation',
81
+ description: `打开指定路径的演示文稿文件。
82
+
83
+ 支持的文件格式:
84
+ - .pptx: PowerPoint 演示文稿
85
+ - .ppt: 旧版 PowerPoint 格式
86
+ - .dps: WPS 演示格式
87
+
88
+ 使用场景:
89
+ - "打开桌面上的演示文稿"
90
+ - "打开这个PPT文件"`,
91
+ category: tools_1.ToolCategory.PRESENTATION,
92
+ inputSchema: {
93
+ type: 'object',
94
+ properties: {
95
+ filePath: {
96
+ type: 'string',
97
+ description: '演示文稿文件的完整路径',
98
+ },
99
+ },
100
+ required: ['filePath'],
101
+ },
102
+ };
103
+ const openPresentationHandler = async (args) => {
104
+ const { filePath } = args;
105
+ try {
106
+ // 参数对齐:底层读取 params.path,需同时发送 path
107
+ const response = await wps_client_1.wpsClient.executeMethod('openPresentation', { filePath, path: filePath }, wps_1.WpsAppType.PRESENTATION);
108
+ if (response.success && response.data) {
109
+ return {
110
+ id: (0, uuid_1.v4)(),
111
+ success: true,
112
+ content: [
113
+ {
114
+ type: 'text',
115
+ text: `演示文稿打开成功!\n名称: ${response.data.name}\n路径: ${response.data.filePath}`,
116
+ },
117
+ ],
118
+ };
119
+ }
120
+ else {
121
+ return {
122
+ id: (0, uuid_1.v4)(),
123
+ success: false,
124
+ content: [{ type: 'text', text: `打开演示文稿失败: ${response.error}` }],
125
+ error: response.error,
126
+ };
127
+ }
128
+ }
129
+ catch (error) {
130
+ const errMsg = error instanceof Error ? error.message : String(error);
131
+ return {
132
+ id: (0, uuid_1.v4)(),
133
+ success: false,
134
+ content: [{ type: 'text', text: `打开演示文稿出错: ${errMsg}` }],
135
+ error: errMsg,
136
+ };
137
+ }
138
+ };
139
+ exports.openPresentationHandler = openPresentationHandler;
140
+ /**
141
+ * 关闭演示文稿
142
+ */
143
+ exports.closePresentationDefinition = {
144
+ name: 'wps_ppt_close_presentation',
145
+ description: `关闭演示文稿。可指定文稿名称,不指定则关闭当前活动文稿。
146
+
147
+ 使用场景:
148
+ - "关闭这个PPT"
149
+ - "关闭演示文稿不保存"
150
+ - "关闭指定的PPT"`,
151
+ category: tools_1.ToolCategory.PRESENTATION,
152
+ inputSchema: {
153
+ type: 'object',
154
+ properties: {
155
+ name: {
156
+ type: 'string',
157
+ description: '要关闭的演示文稿名称,不填则关闭当前活动文稿',
158
+ },
159
+ save: {
160
+ type: 'boolean',
161
+ description: '关闭前是否保存,默认true',
162
+ },
163
+ },
164
+ required: [],
165
+ },
166
+ };
167
+ const closePresentationHandler = async (args) => {
168
+ const { name, save } = args;
169
+ try {
170
+ const response = await wps_client_1.wpsClient.executeMethod('closePresentation', {
171
+ name,
172
+ save: save !== false,
173
+ }, wps_1.WpsAppType.PRESENTATION);
174
+ if (response.success && response.data) {
175
+ const saveStatus = save !== false ? '已保存' : '未保存';
176
+ return {
177
+ id: (0, uuid_1.v4)(),
178
+ success: true,
179
+ content: [
180
+ {
181
+ type: 'text',
182
+ text: `演示文稿已关闭!\n名称: ${response.data.name}\n保存状态: ${saveStatus}`,
183
+ },
184
+ ],
185
+ };
186
+ }
187
+ else {
188
+ return {
189
+ id: (0, uuid_1.v4)(),
190
+ success: false,
191
+ content: [{ type: 'text', text: `关闭演示文稿失败: ${response.error}` }],
192
+ error: response.error,
193
+ };
194
+ }
195
+ }
196
+ catch (error) {
197
+ const errMsg = error instanceof Error ? error.message : String(error);
198
+ return {
199
+ id: (0, uuid_1.v4)(),
200
+ success: false,
201
+ content: [{ type: 'text', text: `关闭演示文稿出错: ${errMsg}` }],
202
+ error: errMsg,
203
+ };
204
+ }
205
+ };
206
+ exports.closePresentationHandler = closePresentationHandler;
207
+ /**
208
+ * 获取所有已打开的演示文稿列表
209
+ */
210
+ exports.getOpenPresentationsDefinition = {
211
+ name: 'wps_ppt_get_open_presentations',
212
+ description: `获取当前所有已打开的演示文稿列表。
213
+
214
+ 使用场景:
215
+ - "有哪些PPT打开着"
216
+ - "列出所有演示文稿"
217
+ - "查看打开的PPT"`,
218
+ category: tools_1.ToolCategory.PRESENTATION,
219
+ inputSchema: {
220
+ type: 'object',
221
+ properties: {},
222
+ required: [],
223
+ },
224
+ };
225
+ const getOpenPresentationsHandler = async (_args) => {
226
+ try {
227
+ const response = await wps_client_1.wpsClient.executeMethod('getOpenPresentations', {}, wps_1.WpsAppType.PRESENTATION);
228
+ if (response.success && response.data) {
229
+ const { presentations, count } = response.data;
230
+ if (count === 0) {
231
+ return {
232
+ id: (0, uuid_1.v4)(),
233
+ success: true,
234
+ content: [{ type: 'text', text: '当前没有打开的演示文稿。' }],
235
+ };
236
+ }
237
+ let output = `当前打开 ${count} 个演示文稿:\n\n`;
238
+ presentations.forEach((p, i) => {
239
+ const activeTag = p.isActive ? ' [当前活动]' : '';
240
+ output += `${i + 1}. ${p.name}${activeTag}\n`;
241
+ output += ` 路径: ${p.path}\n`;
242
+ output += ` 页数: ${p.slideCount}\n`;
243
+ });
244
+ return {
245
+ id: (0, uuid_1.v4)(),
246
+ success: true,
247
+ content: [{ type: 'text', text: output }],
248
+ };
249
+ }
250
+ else {
251
+ return {
252
+ id: (0, uuid_1.v4)(),
253
+ success: false,
254
+ content: [{ type: 'text', text: `获取演示文稿列表失败: ${response.error}` }],
255
+ error: response.error,
256
+ };
257
+ }
258
+ }
259
+ catch (error) {
260
+ const errMsg = error instanceof Error ? error.message : String(error);
261
+ return {
262
+ id: (0, uuid_1.v4)(),
263
+ success: false,
264
+ content: [{ type: 'text', text: `获取演示文稿列表出错: ${errMsg}` }],
265
+ error: errMsg,
266
+ };
267
+ }
268
+ };
269
+ exports.getOpenPresentationsHandler = getOpenPresentationsHandler;
270
+ /**
271
+ * 切换到指定演示文稿
272
+ */
273
+ exports.switchPresentationDefinition = {
274
+ name: 'wps_ppt_switch_presentation',
275
+ description: `切换到指定名称的演示文稿。
276
+
277
+ 使用场景:
278
+ - "切换到另一个PPT"
279
+ - "打开那个叫xxx的演示文稿"
280
+ - "切换演示文稿"`,
281
+ category: tools_1.ToolCategory.PRESENTATION,
282
+ inputSchema: {
283
+ type: 'object',
284
+ properties: {
285
+ name: {
286
+ type: 'string',
287
+ description: '要切换到的演示文稿名称',
288
+ },
289
+ },
290
+ required: ['name'],
291
+ },
292
+ };
293
+ const switchPresentationHandler = async (args) => {
294
+ const { name } = args;
295
+ try {
296
+ const response = await wps_client_1.wpsClient.executeMethod('switchPresentation', { name }, wps_1.WpsAppType.PRESENTATION);
297
+ if (response.success && response.data) {
298
+ return {
299
+ id: (0, uuid_1.v4)(),
300
+ success: true,
301
+ content: [
302
+ {
303
+ type: 'text',
304
+ text: `已切换到演示文稿: ${response.data.name}`,
305
+ },
306
+ ],
307
+ };
308
+ }
309
+ else {
310
+ return {
311
+ id: (0, uuid_1.v4)(),
312
+ success: false,
313
+ content: [{ type: 'text', text: `切换演示文稿失败: ${response.error}` }],
314
+ error: response.error,
315
+ };
316
+ }
317
+ }
318
+ catch (error) {
319
+ const errMsg = error instanceof Error ? error.message : String(error);
320
+ return {
321
+ id: (0, uuid_1.v4)(),
322
+ success: false,
323
+ content: [{ type: 'text', text: `切换演示文稿出错: ${errMsg}` }],
324
+ error: errMsg,
325
+ };
326
+ }
327
+ };
328
+ exports.switchPresentationHandler = switchPresentationHandler;
329
+ /**
330
+ * 设置演示文稿主题
331
+ */
332
+ exports.setSlideThemeDefinition = {
333
+ name: 'wps_ppt_set_slide_theme',
334
+ description: `设置演示文稿主题。
335
+
336
+ 使用场景:
337
+ - "切换PPT主题"
338
+ - "应用商务主题"
339
+ - "更换演示文稿风格"`,
340
+ category: tools_1.ToolCategory.PRESENTATION,
341
+ inputSchema: {
342
+ type: 'object',
343
+ properties: {
344
+ theme: {
345
+ type: 'string',
346
+ description: '主题名称',
347
+ },
348
+ },
349
+ required: ['theme'],
350
+ },
351
+ };
352
+ const setSlideThemeHandler = async (args) => {
353
+ const { theme } = args;
354
+ try {
355
+ const response = await wps_client_1.wpsClient.executeMethod('setSlideTheme', // NOTE: 仅Windows支持
356
+ { theme }, wps_1.WpsAppType.PRESENTATION);
357
+ if (response.success && response.data) {
358
+ return {
359
+ id: (0, uuid_1.v4)(),
360
+ success: true,
361
+ content: [{ type: 'text', text: `主题已设置为: ${theme}` }],
362
+ };
363
+ }
364
+ else {
365
+ return {
366
+ id: (0, uuid_1.v4)(),
367
+ success: false,
368
+ content: [{ type: 'text', text: `设置主题失败: ${response.error}` }],
369
+ error: response.error,
370
+ };
371
+ }
372
+ }
373
+ catch (error) {
374
+ const errMsg = error instanceof Error ? error.message : String(error);
375
+ return {
376
+ id: (0, uuid_1.v4)(),
377
+ success: false,
378
+ content: [{ type: 'text', text: `设置主题出错: ${errMsg}` }],
379
+ error: errMsg,
380
+ };
381
+ }
382
+ };
383
+ exports.setSlideThemeHandler = setSlideThemeHandler;
384
+ /**
385
+ * 复制幻灯片
386
+ */
387
+ exports.copySlideDefinition = {
388
+ name: 'wps_ppt_copy_slide',
389
+ description: `复制幻灯片到指定位置。
390
+
391
+ 使用场景:
392
+ - "复制第2页幻灯片"
393
+ - "把这页复制到第5页后面"
394
+ - "克隆当前幻灯片"`,
395
+ category: tools_1.ToolCategory.PRESENTATION,
396
+ inputSchema: {
397
+ type: 'object',
398
+ properties: {
399
+ slideIndex: {
400
+ type: 'number',
401
+ description: '要复制的幻灯片索引(从1开始)',
402
+ },
403
+ targetIndex: {
404
+ type: 'number',
405
+ description: '目标位置索引(从1开始),不填则在原位置后插入',
406
+ },
407
+ },
408
+ required: ['slideIndex'],
409
+ },
410
+ };
411
+ const copySlideHandler = async (args) => {
412
+ const { slideIndex, targetIndex } = args;
413
+ try {
414
+ const response = await wps_client_1.wpsClient.executeMethod('duplicateSlide', { slideIndex, targetIndex }, wps_1.WpsAppType.PRESENTATION);
415
+ if (response.success && response.data) {
416
+ return {
417
+ id: (0, uuid_1.v4)(),
418
+ success: true,
419
+ content: [
420
+ {
421
+ type: 'text',
422
+ text: `幻灯片已复制!\n源页: 第${slideIndex}页\n新页位置: 第${response.data.newIndex}页`,
423
+ },
424
+ ],
425
+ };
426
+ }
427
+ else {
428
+ return {
429
+ id: (0, uuid_1.v4)(),
430
+ success: false,
431
+ content: [{ type: 'text', text: `复制幻灯片失败: ${response.error}` }],
432
+ error: response.error,
433
+ };
434
+ }
435
+ }
436
+ catch (error) {
437
+ const errMsg = error instanceof Error ? error.message : String(error);
438
+ return {
439
+ id: (0, uuid_1.v4)(),
440
+ success: false,
441
+ content: [{ type: 'text', text: `复制幻灯片出错: ${errMsg}` }],
442
+ error: errMsg,
443
+ };
444
+ }
445
+ };
446
+ exports.copySlideHandler = copySlideHandler;
447
+ /**
448
+ * 在幻灯片中插入图片
449
+ */
450
+ exports.insertSlideImageDefinition = {
451
+ name: 'wps_ppt_insert_slide_image',
452
+ description: `在幻灯片中插入图片。
453
+
454
+ 使用场景:
455
+ - "在第1页插入一张图片"
456
+ - "添加图片到幻灯片"
457
+ - "把这个图片放到PPT里"`,
458
+ category: tools_1.ToolCategory.PRESENTATION,
459
+ inputSchema: {
460
+ type: 'object',
461
+ properties: {
462
+ slideIndex: {
463
+ type: 'number',
464
+ description: '幻灯片索引(从1开始)',
465
+ },
466
+ imagePath: {
467
+ type: 'string',
468
+ description: '图片文件的完整路径',
469
+ },
470
+ left: {
471
+ type: 'number',
472
+ description: '左边距(像素),默认100',
473
+ },
474
+ top: {
475
+ type: 'number',
476
+ description: '上边距(像素),默认100',
477
+ },
478
+ },
479
+ required: ['slideIndex', 'imagePath'],
480
+ },
481
+ };
482
+ const insertSlideImageHandler = async (args) => {
483
+ const { slideIndex, imagePath, left, top } = args;
484
+ try {
485
+ // 参数对齐:insertImage handler 读取 path/filePath,需同时发送
486
+ const response = await wps_client_1.wpsClient.executeMethod('insertImage', { slideIndex, imagePath, path: imagePath, filePath: imagePath, left, top }, wps_1.WpsAppType.PRESENTATION);
487
+ if (response.success && response.data) {
488
+ return {
489
+ id: (0, uuid_1.v4)(),
490
+ success: true,
491
+ content: [
492
+ {
493
+ type: 'text',
494
+ text: `图片已插入到第${slideIndex}页幻灯片!\n图片路径: ${imagePath}`,
495
+ },
496
+ ],
497
+ };
498
+ }
499
+ else {
500
+ return {
501
+ id: (0, uuid_1.v4)(),
502
+ success: false,
503
+ content: [{ type: 'text', text: `插入图片失败: ${response.error}` }],
504
+ error: response.error,
505
+ };
506
+ }
507
+ }
508
+ catch (error) {
509
+ const errMsg = error instanceof Error ? error.message : String(error);
510
+ return {
511
+ id: (0, uuid_1.v4)(),
512
+ success: false,
513
+ content: [{ type: 'text', text: `插入图片出错: ${errMsg}` }],
514
+ error: errMsg,
515
+ };
516
+ }
517
+ };
518
+ exports.insertSlideImageHandler = insertSlideImageHandler;
519
+ /**
520
+ * 从其它演示文稿导入整页幻灯片(跨PPT整合,保留来源格式)
521
+ */
522
+ exports.insertSlidesFromFileDefinition = {
523
+ name: 'wps_ppt_insert_slides_from_file',
524
+ description: `从另一个 PPT 文件把整页幻灯片插入到【当前活动演示文稿】,并保留来源幻灯片的原始格式(字体/配色/版式/图片)。用于把多个 PPT 整合成一个。
525
+
526
+ 使用场景:
527
+ - "把可行性报告.pptx 的第3到5页插到当前PPT第10页后面"
528
+ - "整合多个PPT:把另一个演示文稿的所有幻灯片合并进来"
529
+ - "从某个PPT复制整页过来,保持原样式"
530
+
531
+ 说明:
532
+ - 先用 wps_ppt_switch_presentation 切换到【目标/接收页】演示文稿,再调用本工具
533
+ - afterIndex 表示插入到第几页之后(0=插到最前,不填=追加到末尾)
534
+ - slideStart/slideEnd 指定只导入来源文件的某段页码范围,不填则导入全部
535
+ - 底层调用 WPS COM Slides.InsertFromFile,原样保留来源格式,避免AI重排导致的版式失真`,
536
+ category: tools_1.ToolCategory.PRESENTATION,
537
+ inputSchema: {
538
+ type: 'object',
539
+ properties: {
540
+ filePath: {
541
+ type: 'string',
542
+ description: '来源 PPT 文件的完整路径',
543
+ },
544
+ afterIndex: {
545
+ type: 'number',
546
+ description: '插入到当前演示文稿第几页之后(0=最前,不填=末尾追加)',
547
+ },
548
+ slideStart: {
549
+ type: 'number',
550
+ description: '来源文件起始页码(从1开始,可选)',
551
+ },
552
+ slideEnd: {
553
+ type: 'number',
554
+ description: '来源文件结束页码(可选,与slideStart配合)',
555
+ },
556
+ },
557
+ required: ['filePath'],
558
+ },
559
+ };
560
+ const insertSlidesFromFileHandler = async (args) => {
561
+ const { filePath, afterIndex, slideStart, slideEnd } = args;
562
+ try {
563
+ const response = await wps_client_1.wpsClient.executeMethod('insertSlidesFromFile', { filePath, path: filePath, afterIndex, slideStart, slideEnd }, wps_1.WpsAppType.PRESENTATION);
564
+ if (response.success && response.data) {
565
+ return {
566
+ id: (0, uuid_1.v4)(),
567
+ success: true,
568
+ content: [
569
+ {
570
+ type: 'text',
571
+ text: `已从来源文件导入 ${response.data.inserted} 页幻灯片(保留来源格式)!\n来源: ${filePath}\n插入位置: 第 ${response.data.afterIndex} 页之后\n当前演示文稿总页数: ${response.data.totalSlides}`,
572
+ },
573
+ ],
574
+ };
575
+ }
576
+ else {
577
+ return {
578
+ id: (0, uuid_1.v4)(),
579
+ success: false,
580
+ content: [{ type: 'text', text: `导入幻灯片失败: ${response.error}` }],
581
+ error: response.error,
582
+ };
583
+ }
584
+ }
585
+ catch (error) {
586
+ const errMsg = error instanceof Error ? error.message : String(error);
587
+ return {
588
+ id: (0, uuid_1.v4)(),
589
+ success: false,
590
+ content: [{ type: 'text', text: `导入幻灯片出错: ${errMsg}` }],
591
+ error: errMsg,
592
+ };
593
+ }
594
+ };
595
+ exports.insertSlidesFromFileHandler = insertSlidesFromFileHandler;
596
+ /**
597
+ * 锁定后续所有 PPT 操作的目标演示文稿(避免多文稿打开时活动文稿漂移改错文件)
598
+ */
599
+ exports.setActiveTargetDefinition = {
600
+ name: 'wps_ppt_set_active_target',
601
+ description: `锁定后续所有 PPT 操作的【目标演示文稿】(按文件名)。锁定后,本服务器会给所有演示类调用自动注入该文稿名,底层精确定位,**彻底避免同时打开多个 PPT 时"活动文稿漂移"导致改错文件**。
602
+
603
+ 使用场景:
604
+ - 批量改某个 PPT 前先锁定:"把目标锁定为 关节模组申报PPT-生成版.pptx"
605
+ - 传 clear=true 或留空 name 取消锁定,恢复使用当前活动文稿
606
+
607
+ 强烈建议:在对一个特定 PPT 做成批增改前,先调用本工具锁定它。`,
608
+ category: tools_1.ToolCategory.PRESENTATION,
609
+ inputSchema: {
610
+ type: 'object',
611
+ properties: {
612
+ name: {
613
+ type: 'string',
614
+ description: '目标演示文稿文件名(如 关节模组申报PPT-生成版.pptx);留空或 clear=true 则取消锁定',
615
+ },
616
+ clear: {
617
+ type: 'boolean',
618
+ description: '为 true 时清除锁定,恢复使用当前活动文稿',
619
+ },
620
+ },
621
+ required: [],
622
+ },
623
+ };
624
+ const setActiveTargetHandler = async (args) => {
625
+ const { name, clear } = args;
626
+ if (clear || !name) {
627
+ (0, wps_client_1.setPptTarget)(undefined);
628
+ return {
629
+ id: (0, uuid_1.v4)(),
630
+ success: true,
631
+ content: [{ type: 'text', text: '已取消目标文稿锁定,后续 PPT 操作使用当前活动文稿。' }],
632
+ };
633
+ }
634
+ try {
635
+ const resp = await wps_client_1.wpsClient.executeMethod('getOpenPresentations', {});
636
+ const names = resp.success && resp.data ? resp.data.presentations.map((x) => x.name) : [];
637
+ const matched = names.includes(name);
638
+ (0, wps_client_1.setPptTarget)(name);
639
+ const warn = matched
640
+ ? ''
641
+ : `\n⚠️ 当前打开的文稿中没有完全同名的「${name}」。已打开:${names.join(' / ') || '(无)'}。若名称不符,后续操作会报"未找到目标文稿"。`;
642
+ return {
643
+ id: (0, uuid_1.v4)(),
644
+ success: true,
645
+ content: [
646
+ {
647
+ type: 'text',
648
+ text: `已锁定目标演示文稿:${name}\n后续所有 PPT 操作都会定位到该文稿(不受活动窗口切换影响)。${warn}`,
649
+ },
650
+ ],
651
+ };
652
+ }
653
+ catch (error) {
654
+ const errMsg = error instanceof Error ? error.message : String(error);
655
+ (0, wps_client_1.setPptTarget)(name);
656
+ return {
657
+ id: (0, uuid_1.v4)(),
658
+ success: true,
659
+ content: [{ type: 'text', text: `已锁定目标演示文稿:${name}(打开列表校验失败:${errMsg})` }],
660
+ };
661
+ }
662
+ };
663
+ exports.setActiveTargetHandler = setActiveTargetHandler;
664
+ /**
665
+ * 导出所有演示文稿管理相关的Tools
666
+ */
667
+ exports.presentationTools = [
668
+ { definition: exports.createPresentationDefinition, handler: exports.createPresentationHandler },
669
+ { definition: exports.openPresentationDefinition, handler: exports.openPresentationHandler },
670
+ { definition: exports.closePresentationDefinition, handler: exports.closePresentationHandler },
671
+ { definition: exports.getOpenPresentationsDefinition, handler: exports.getOpenPresentationsHandler },
672
+ { definition: exports.switchPresentationDefinition, handler: exports.switchPresentationHandler },
673
+ { definition: exports.setSlideThemeDefinition, handler: exports.setSlideThemeHandler },
674
+ { definition: exports.copySlideDefinition, handler: exports.copySlideHandler },
675
+ { definition: exports.insertSlideImageDefinition, handler: exports.insertSlideImageHandler },
676
+ { definition: exports.insertSlidesFromFileDefinition, handler: exports.insertSlidesFromFileHandler },
677
+ { definition: exports.setActiveTargetDefinition, handler: exports.setActiveTargetHandler },
678
+ ];
679
+ exports.default = exports.presentationTools;
680
+ //# sourceMappingURL=presentation.js.map