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