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.
- package/README.md +3 -3
- package/dist/bridge/cancellable.d.ts +36 -0
- package/dist/bridge/cancellable.d.ts.map +1 -0
- package/dist/bridge/cancellable.js +155 -0
- package/dist/bridge/cancellable.js.map +1 -0
- package/dist/bridge/index.d.ts +37 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +381 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/bridge/ps-child.d.ts +155 -0
- package/dist/bridge/ps-child.d.ts.map +1 -0
- package/dist/bridge/ps-child.js +578 -0
- package/dist/bridge/ps-child.js.map +1 -0
- package/dist/client/action-routes.d.ts +32 -0
- package/dist/client/action-routes.d.ts.map +1 -0
- package/dist/client/action-routes.generated.d.ts +10 -0
- package/dist/client/action-routes.generated.d.ts.map +1 -0
- package/dist/client/action-routes.generated.js +322 -0
- package/dist/client/action-routes.generated.js.map +1 -0
- package/dist/client/action-routes.js +57 -0
- package/dist/client/action-routes.js.map +1 -0
- package/dist/client/mac-poll-server.d.ts +77 -0
- package/dist/client/mac-poll-server.d.ts.map +1 -0
- package/dist/client/mac-poll-server.js +516 -0
- package/dist/client/mac-poll-server.js.map +1 -0
- package/dist/client/ps-daemon.d.ts +95 -0
- package/dist/client/ps-daemon.d.ts.map +1 -0
- package/dist/client/ps-daemon.js +424 -0
- package/dist/client/ps-daemon.js.map +1 -0
- package/dist/client/wps-client.d.ts +72 -0
- package/dist/client/wps-client.d.ts.map +1 -0
- package/dist/client/wps-client.js +408 -0
- package/dist/client/wps-client.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +121 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime-identity.d.ts +23 -0
- package/dist/runtime-identity.d.ts.map +1 -0
- package/dist/runtime-identity.js +26 -0
- package/dist/runtime-identity.js.map +1 -0
- package/dist/server/cancel-context.d.ts +30 -0
- package/dist/server/cancel-context.d.ts.map +1 -0
- package/dist/server/cancel-context.js +38 -0
- package/dist/server/cancel-context.js.map +1 -0
- package/dist/server/mcp-server.d.ts +74 -0
- package/dist/server/mcp-server.d.ts.map +1 -0
- package/dist/server/mcp-server.js +725 -0
- package/dist/server/mcp-server.js.map +1 -0
- package/dist/server/server-info.d.ts +21 -0
- package/dist/server/server-info.d.ts.map +1 -0
- package/dist/server/server-info.js +56 -0
- package/dist/server/server-info.js.map +1 -0
- package/dist/server/tool-annotations.d.ts +52 -0
- package/dist/server/tool-annotations.d.ts.map +1 -0
- package/dist/server/tool-annotations.generated.d.ts +14 -0
- package/dist/server/tool-annotations.generated.d.ts.map +1 -0
- package/dist/server/tool-annotations.generated.js +324 -0
- package/dist/server/tool-annotations.generated.js.map +1 -0
- package/dist/server/tool-annotations.js +116 -0
- package/dist/server/tool-annotations.js.map +1 -0
- package/dist/server/tool-group-events.d.ts +23 -0
- package/dist/server/tool-group-events.d.ts.map +1 -0
- package/dist/server/tool-group-events.js +44 -0
- package/dist/server/tool-group-events.js.map +1 -0
- package/dist/server/tool-metadata.d.ts +43 -0
- package/dist/server/tool-metadata.d.ts.map +1 -0
- package/dist/server/tool-metadata.js +657 -0
- package/dist/server/tool-metadata.js.map +1 -0
- package/dist/server/tool-registry.d.ts +164 -0
- package/dist/server/tool-registry.d.ts.map +1 -0
- package/dist/server/tool-registry.js +453 -0
- package/dist/server/tool-registry.js.map +1 -0
- package/dist/server/tool-tiers.d.ts +39 -0
- package/dist/server/tool-tiers.d.ts.map +1 -0
- package/dist/server/tool-tiers.js +102 -0
- package/dist/server/tool-tiers.js.map +1 -0
- package/dist/tools/common/batch.d.ts +33 -0
- package/dist/tools/common/batch.d.ts.map +1 -0
- package/dist/tools/common/batch.js +195 -0
- package/dist/tools/common/batch.js.map +1 -0
- package/dist/tools/common/convert.d.ts +41 -0
- package/dist/tools/common/convert.d.ts.map +1 -0
- package/dist/tools/common/convert.js +299 -0
- package/dist/tools/common/convert.js.map +1 -0
- package/dist/tools/common/general.d.ts +39 -0
- package/dist/tools/common/general.d.ts.map +1 -0
- package/dist/tools/common/general.js +624 -0
- package/dist/tools/common/general.js.map +1 -0
- package/dist/tools/common/index.d.ts +36 -0
- package/dist/tools/common/index.d.ts.map +1 -0
- package/dist/tools/common/index.js +102 -0
- package/dist/tools/common/index.js.map +1 -0
- package/dist/tools/common/intent.d.ts +48 -0
- package/dist/tools/common/intent.d.ts.map +1 -0
- package/dist/tools/common/intent.js +221 -0
- package/dist/tools/common/intent.js.map +1 -0
- package/dist/tools/common/repair.d.ts +29 -0
- package/dist/tools/common/repair.d.ts.map +1 -0
- package/dist/tools/common/repair.js +140 -0
- package/dist/tools/common/repair.js.map +1 -0
- package/dist/tools/common/status.d.ts +27 -0
- package/dist/tools/common/status.d.ts.map +1 -0
- package/dist/tools/common/status.js +139 -0
- package/dist/tools/common/status.js.map +1 -0
- package/dist/tools/common/toolgroups.d.ts +38 -0
- package/dist/tools/common/toolgroups.d.ts.map +1 -0
- package/dist/tools/common/toolgroups.js +238 -0
- package/dist/tools/common/toolgroups.js.map +1 -0
- package/dist/tools/excel/chart.d.ts +86 -0
- package/dist/tools/excel/chart.d.ts.map +1 -0
- package/dist/tools/excel/chart.js +659 -0
- package/dist/tools/excel/chart.js.map +1 -0
- package/dist/tools/excel/comment-protect.d.ts +58 -0
- package/dist/tools/excel/comment-protect.d.ts.map +1 -0
- package/dist/tools/excel/comment-protect.js +274 -0
- package/dist/tools/excel/comment-protect.js.map +1 -0
- package/dist/tools/excel/data-advanced.d.ts +47 -0
- package/dist/tools/excel/data-advanced.d.ts.map +1 -0
- package/dist/tools/excel/data-advanced.js +263 -0
- package/dist/tools/excel/data-advanced.js.map +1 -0
- package/dist/tools/excel/data.d.ts +91 -0
- package/dist/tools/excel/data.d.ts.map +1 -0
- package/dist/tools/excel/data.js +626 -0
- package/dist/tools/excel/data.js.map +1 -0
- package/dist/tools/excel/format.d.ts +42 -0
- package/dist/tools/excel/format.d.ts.map +1 -0
- package/dist/tools/excel/format.js +715 -0
- package/dist/tools/excel/format.js.map +1 -0
- package/dist/tools/excel/formula.d.ts +64 -0
- package/dist/tools/excel/formula.d.ts.map +1 -0
- package/dist/tools/excel/formula.js +333 -0
- package/dist/tools/excel/formula.js.map +1 -0
- package/dist/tools/excel/index.d.ts +44 -0
- package/dist/tools/excel/index.d.ts.map +1 -0
- package/dist/tools/excel/index.js +249 -0
- package/dist/tools/excel/index.js.map +1 -0
- package/dist/tools/excel/pivot.d.ts +39 -0
- package/dist/tools/excel/pivot.d.ts.map +1 -0
- package/dist/tools/excel/pivot.js +455 -0
- package/dist/tools/excel/pivot.js.map +1 -0
- package/dist/tools/excel/row-column.d.ts +64 -0
- package/dist/tools/excel/row-column.d.ts.map +1 -0
- package/dist/tools/excel/row-column.js +299 -0
- package/dist/tools/excel/row-column.js.map +1 -0
- package/dist/tools/excel/sheet-gaps.d.ts +50 -0
- package/dist/tools/excel/sheet-gaps.d.ts.map +1 -0
- package/dist/tools/excel/sheet-gaps.js +373 -0
- package/dist/tools/excel/sheet-gaps.js.map +1 -0
- package/dist/tools/excel/sheet.d.ts +112 -0
- package/dist/tools/excel/sheet.d.ts.map +1 -0
- package/dist/tools/excel/sheet.js +937 -0
- package/dist/tools/excel/sheet.js.map +1 -0
- package/dist/tools/excel/workbook.d.ts +62 -0
- package/dist/tools/excel/workbook.d.ts.map +1 -0
- package/dist/tools/excel/workbook.js +366 -0
- package/dist/tools/excel/workbook.js.map +1 -0
- package/dist/tools/index.d.ts +48 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +113 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/ppt/animation.d.ts +79 -0
- package/dist/tools/ppt/animation.d.ts.map +1 -0
- package/dist/tools/ppt/animation.js +719 -0
- package/dist/tools/ppt/animation.js.map +1 -0
- package/dist/tools/ppt/background.d.ts +72 -0
- package/dist/tools/ppt/background.d.ts.map +1 -0
- package/dist/tools/ppt/background.js +595 -0
- package/dist/tools/ppt/background.js.map +1 -0
- package/dist/tools/ppt/beautify-advanced.d.ts +72 -0
- package/dist/tools/ppt/beautify-advanced.d.ts.map +1 -0
- package/dist/tools/ppt/beautify-advanced.js +663 -0
- package/dist/tools/ppt/beautify-advanced.js.map +1 -0
- package/dist/tools/ppt/chart-flow.d.ts +58 -0
- package/dist/tools/ppt/chart-flow.d.ts.map +1 -0
- package/dist/tools/ppt/chart-flow.js +523 -0
- package/dist/tools/ppt/chart-flow.js.map +1 -0
- package/dist/tools/ppt/data-viz.d.ts +64 -0
- package/dist/tools/ppt/data-viz.d.ts.map +1 -0
- package/dist/tools/ppt/data-viz.js +514 -0
- package/dist/tools/ppt/data-viz.js.map +1 -0
- package/dist/tools/ppt/image.d.ts +30 -0
- package/dist/tools/ppt/image.d.ts.map +1 -0
- package/dist/tools/ppt/image.js +452 -0
- package/dist/tools/ppt/image.js.map +1 -0
- package/dist/tools/ppt/index.d.ts +72 -0
- package/dist/tools/ppt/index.d.ts.map +1 -0
- package/dist/tools/ppt/index.js +350 -0
- package/dist/tools/ppt/index.js.map +1 -0
- package/dist/tools/ppt/misc.d.ts +99 -0
- package/dist/tools/ppt/misc.d.ts.map +1 -0
- package/dist/tools/ppt/misc.js +868 -0
- package/dist/tools/ppt/misc.js.map +1 -0
- package/dist/tools/ppt/presentation.d.ts +72 -0
- package/dist/tools/ppt/presentation.d.ts.map +1 -0
- package/dist/tools/ppt/presentation.js +680 -0
- package/dist/tools/ppt/presentation.js.map +1 -0
- package/dist/tools/ppt/shape-basic.d.ts +46 -0
- package/dist/tools/ppt/shape-basic.d.ts.map +1 -0
- package/dist/tools/ppt/shape-basic.js +756 -0
- package/dist/tools/ppt/shape-basic.js.map +1 -0
- package/dist/tools/ppt/slide-ops.d.ts +79 -0
- package/dist/tools/ppt/slide-ops.d.ts.map +1 -0
- package/dist/tools/ppt/slide-ops.js +1646 -0
- package/dist/tools/ppt/slide-ops.js.map +1 -0
- package/dist/tools/ppt/slide.d.ts +51 -0
- package/dist/tools/ppt/slide.d.ts.map +1 -0
- package/dist/tools/ppt/slide.js +470 -0
- package/dist/tools/ppt/slide.js.map +1 -0
- package/dist/tools/ppt/table.d.ts +58 -0
- package/dist/tools/ppt/table.d.ts.map +1 -0
- package/dist/tools/ppt/table.js +512 -0
- package/dist/tools/ppt/table.js.map +1 -0
- package/dist/tools/ppt/textbox.d.ts +47 -0
- package/dist/tools/ppt/textbox.d.ts.map +1 -0
- package/dist/tools/ppt/textbox.js +246 -0
- package/dist/tools/ppt/textbox.js.map +1 -0
- package/dist/tools/word/academic.d.ts +50 -0
- package/dist/tools/word/academic.d.ts.map +1 -0
- package/dist/tools/word/academic.js +500 -0
- package/dist/tools/word/academic.js.map +1 -0
- package/dist/tools/word/content.d.ts +97 -0
- package/dist/tools/word/content.d.ts.map +1 -0
- package/dist/tools/word/content.js +838 -0
- package/dist/tools/word/content.js.map +1 -0
- package/dist/tools/word/document.d.ts +70 -0
- package/dist/tools/word/document.d.ts.map +1 -0
- package/dist/tools/word/document.js +633 -0
- package/dist/tools/word/document.js.map +1 -0
- package/dist/tools/word/format.d.ts +50 -0
- package/dist/tools/word/format.d.ts.map +1 -0
- package/dist/tools/word/format.js +462 -0
- package/dist/tools/word/format.js.map +1 -0
- package/dist/tools/word/gaps.d.ts +58 -0
- package/dist/tools/word/gaps.d.ts.map +1 -0
- package/dist/tools/word/gaps.js +431 -0
- package/dist/tools/word/gaps.js.map +1 -0
- package/dist/tools/word/index.d.ts +34 -0
- package/dist/tools/word/index.d.ts.map +1 -0
- package/dist/tools/word/index.js +124 -0
- package/dist/tools/word/index.js.map +1 -0
- package/dist/tools/word/professional.d.ts +48 -0
- package/dist/tools/word/professional.d.ts.map +1 -0
- package/dist/tools/word/professional.js +657 -0
- package/dist/tools/word/professional.js.map +1 -0
- package/dist/tools/word/proofread.d.ts +25 -0
- package/dist/tools/word/proofread.d.ts.map +1 -0
- package/dist/tools/word/proofread.js +718 -0
- package/dist/tools/word/proofread.js.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +25 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/tools.d.ts +163 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +45 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/types/wps.d.ts +190 -0
- package/dist/types/wps.d.ts.map +1 -0
- package/dist/types/wps.js +23 -0
- package/dist/types/wps.js.map +1 -0
- package/dist/utils/error.d.ts +147 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +417 -0
- package/dist/utils/error.js.map +1 -0
- package/dist/utils/logger.d.ts +56 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +138 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/version.d.ts +22 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +101 -0
- package/dist/version.js.map +1 -0
- package/package.json +57 -4
- package/scripts/wps-com.ps1 +7260 -0
- package/scripts/wps-comd.ps1 +123 -0
- package/skills/wps-multitool/SKILL.md +111 -0
- package/skills/wps-multitool/references/errors.md +62 -0
- package/skills/wps-multitool/references/recipes.md +82 -0
- package/skills/wps-multitool/references/routing.md +88 -0
|
@@ -0,0 +1,1646 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Input: 幻灯片操作工具参数
|
|
4
|
+
* Output: 幻灯片操作结果
|
|
5
|
+
* Pos: PPT 幻灯片操作工具实现。一旦我被修改,请更新我的头部注释,以及所属文件夹的md。
|
|
6
|
+
*
|
|
7
|
+
* 幻灯片操作Tools - 删除/复制/移动/查询/切换/布局/备注
|
|
8
|
+
*
|
|
9
|
+
* 包含:
|
|
10
|
+
* - wps_ppt_delete_slide: 删除指定幻灯片
|
|
11
|
+
* - wps_ppt_duplicate_slide: 复制幻灯片
|
|
12
|
+
* - wps_ppt_move_slide: 移动幻灯片到指定位置
|
|
13
|
+
* - wps_ppt_get_slide_count: 获取幻灯片总数
|
|
14
|
+
* - wps_ppt_get_slide_info: 获取指定幻灯片的详细信息
|
|
15
|
+
* - wps_ppt_switch_slide: 切换到指定幻灯片
|
|
16
|
+
* - wps_ppt_set_slide_layout: 设置幻灯片版式布局
|
|
17
|
+
* - wps_ppt_get_slide_notes: 获取幻灯片备注内容
|
|
18
|
+
* - wps_ppt_set_slide_notes: 设置幻灯片备注
|
|
19
|
+
* - wps_ppt_add_shape: 添加形状
|
|
20
|
+
* - wps_ppt_set_shape_style: 设置形状样式
|
|
21
|
+
* - wps_ppt_add_textbox: 添加文本框
|
|
22
|
+
* - wps_ppt_set_slide_title: 设置幻灯片标题
|
|
23
|
+
* - wps_ppt_insert_image: 插入图片
|
|
24
|
+
* - wps_ppt_set_shape_text: 设置形状文字
|
|
25
|
+
* - wps_ppt_set_animation: 设置元素动画
|
|
26
|
+
* - wps_ppt_set_background: 设置幻灯片背景
|
|
27
|
+
* - wps_ppt_set_slide_size: 设置幻灯片尺寸
|
|
28
|
+
* - wps_ppt_set_transition: 设置幻灯片切换效果
|
|
29
|
+
* - wps_ppt_add_chart: 在幻灯片中插入图表
|
|
30
|
+
* - wps_ppt_set_shape_fill: 设置形状填充颜色
|
|
31
|
+
* - wps_ppt_add_speaker_notes: 添加演讲者备注
|
|
32
|
+
*/
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.slideOpsTools = exports.addSpeakerNotesHandler = exports.addSpeakerNotesDefinition = exports.setShapeFillHandler = exports.setShapeFillDefinition = exports.addChartHandler = exports.addChartDefinition = exports.setTransitionHandler = exports.setTransitionDefinition = exports.setSlideSizeHandler = exports.setSlideSizeDefinition = exports.setBackgroundHandler = exports.setBackgroundDefinition = exports.setAnimationHandler = exports.setAnimationDefinition = exports.setShapeTextHandler = exports.setShapeTextDefinition = exports.insertImageHandler = exports.insertImageDefinition = exports.setSlideTitleHandler = exports.setSlideTitleDefinition = exports.addTextboxHandler = exports.addTextboxDefinition = exports.setShapeStyleHandler = exports.setShapeStyleDefinition = exports.addShapeHandler = exports.addShapeDefinition = exports.setSlideNotesHandler = exports.setSlideNotesDefinition = exports.getSlideNotesHandler = exports.getSlideNotesDefinition = exports.setSlideLayoutHandler = exports.setSlideLayoutDefinition = exports.switchSlideHandler = exports.switchSlideDefinition = exports.getSlideInfoHandler = exports.getSlideInfoDefinition = exports.getSlideCountHandler = exports.getSlideCountDefinition = exports.moveSlideHandler = exports.moveSlideDefinition = exports.duplicateSlideHandler = exports.duplicateSlideDefinition = exports.deleteSlideHandler = exports.deleteSlideDefinition = void 0;
|
|
35
|
+
const uuid_1 = require("uuid");
|
|
36
|
+
const tools_1 = require("../../types/tools");
|
|
37
|
+
const wps_client_1 = require("../../client/wps-client");
|
|
38
|
+
const wps_1 = require("../../types/wps");
|
|
39
|
+
// ============================================================
|
|
40
|
+
// 1. wps_ppt_delete_slide - 删除指定幻灯片
|
|
41
|
+
// ============================================================
|
|
42
|
+
exports.deleteSlideDefinition = {
|
|
43
|
+
name: 'wps_ppt_delete_slide',
|
|
44
|
+
description: `删除指定的幻灯片。
|
|
45
|
+
|
|
46
|
+
使用场景:
|
|
47
|
+
- "删除第3页幻灯片"
|
|
48
|
+
- "把最后一页删掉"
|
|
49
|
+
- "移除多余的页面"`,
|
|
50
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
slideIndex: {
|
|
55
|
+
type: 'number',
|
|
56
|
+
description: '要删除的幻灯片索引(从1开始)',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
required: ['slideIndex'],
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
const deleteSlideHandler = async (args) => {
|
|
63
|
+
const { slideIndex } = args;
|
|
64
|
+
try {
|
|
65
|
+
const response = await wps_client_1.wpsClient.executeMethod('deleteSlide', { slideIndex }, wps_1.WpsAppType.PRESENTATION);
|
|
66
|
+
if (response.success) {
|
|
67
|
+
return {
|
|
68
|
+
id: (0, uuid_1.v4)(),
|
|
69
|
+
success: true,
|
|
70
|
+
content: [
|
|
71
|
+
{
|
|
72
|
+
type: 'text',
|
|
73
|
+
text: `幻灯片删除成功!\n已删除: 第 ${slideIndex} 页`,
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return {
|
|
80
|
+
id: (0, uuid_1.v4)(),
|
|
81
|
+
success: false,
|
|
82
|
+
content: [{ type: 'text', text: `删除幻灯片失败: ${response.error}` }],
|
|
83
|
+
error: response.error,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
89
|
+
return {
|
|
90
|
+
id: (0, uuid_1.v4)(),
|
|
91
|
+
success: false,
|
|
92
|
+
content: [{ type: 'text', text: `删除幻灯片出错: ${errMsg}` }],
|
|
93
|
+
error: errMsg,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
exports.deleteSlideHandler = deleteSlideHandler;
|
|
98
|
+
// ============================================================
|
|
99
|
+
// 2. wps_ppt_duplicate_slide - 复制幻灯片
|
|
100
|
+
// ============================================================
|
|
101
|
+
exports.duplicateSlideDefinition = {
|
|
102
|
+
name: 'wps_ppt_duplicate_slide',
|
|
103
|
+
description: `复制指定的幻灯片,在其后插入副本。
|
|
104
|
+
|
|
105
|
+
使用场景:
|
|
106
|
+
- "复制第2页幻灯片"
|
|
107
|
+
- "把这页再复制一份"
|
|
108
|
+
- "克隆当前幻灯片"`,
|
|
109
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
properties: {
|
|
113
|
+
slideIndex: {
|
|
114
|
+
type: 'number',
|
|
115
|
+
description: '要复制的幻灯片索引(从1开始)',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
required: ['slideIndex'],
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
const duplicateSlideHandler = async (args) => {
|
|
122
|
+
const { slideIndex } = args;
|
|
123
|
+
try {
|
|
124
|
+
const response = await wps_client_1.wpsClient.executeMethod('duplicateSlide', { slideIndex }, wps_1.WpsAppType.PRESENTATION);
|
|
125
|
+
if (response.success && response.data) {
|
|
126
|
+
return {
|
|
127
|
+
id: (0, uuid_1.v4)(),
|
|
128
|
+
success: true,
|
|
129
|
+
content: [
|
|
130
|
+
{
|
|
131
|
+
type: 'text',
|
|
132
|
+
text: `幻灯片复制成功!\n源幻灯片: 第 ${slideIndex} 页\n副本位置: 第 ${response.data.newSlideIndex} 页`,
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
return {
|
|
139
|
+
id: (0, uuid_1.v4)(),
|
|
140
|
+
success: false,
|
|
141
|
+
content: [{ type: 'text', text: `复制幻灯片失败: ${response.error}` }],
|
|
142
|
+
error: response.error,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
148
|
+
return {
|
|
149
|
+
id: (0, uuid_1.v4)(),
|
|
150
|
+
success: false,
|
|
151
|
+
content: [{ type: 'text', text: `复制幻灯片出错: ${errMsg}` }],
|
|
152
|
+
error: errMsg,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
exports.duplicateSlideHandler = duplicateSlideHandler;
|
|
157
|
+
// ============================================================
|
|
158
|
+
// 3. wps_ppt_move_slide - 移动幻灯片到指定位置
|
|
159
|
+
// ============================================================
|
|
160
|
+
exports.moveSlideDefinition = {
|
|
161
|
+
name: 'wps_ppt_move_slide',
|
|
162
|
+
description: `移动幻灯片到指定位置。
|
|
163
|
+
|
|
164
|
+
使用场景:
|
|
165
|
+
- "把第5页移到第2页"
|
|
166
|
+
- "把最后一页移到开头"
|
|
167
|
+
- "调整幻灯片顺序"`,
|
|
168
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
169
|
+
inputSchema: {
|
|
170
|
+
type: 'object',
|
|
171
|
+
properties: {
|
|
172
|
+
fromIndex: {
|
|
173
|
+
type: 'number',
|
|
174
|
+
description: '原位置索引(从1开始)',
|
|
175
|
+
},
|
|
176
|
+
toIndex: {
|
|
177
|
+
type: 'number',
|
|
178
|
+
description: '目标位置索引(从1开始)',
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
required: ['fromIndex', 'toIndex'],
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
const moveSlideHandler = async (args) => {
|
|
185
|
+
const { fromIndex, toIndex } = args;
|
|
186
|
+
try {
|
|
187
|
+
const response = await wps_client_1.wpsClient.executeMethod('moveSlide', { fromIndex, toIndex }, wps_1.WpsAppType.PRESENTATION);
|
|
188
|
+
if (response.success) {
|
|
189
|
+
return {
|
|
190
|
+
id: (0, uuid_1.v4)(),
|
|
191
|
+
success: true,
|
|
192
|
+
content: [
|
|
193
|
+
{
|
|
194
|
+
type: 'text',
|
|
195
|
+
text: `幻灯片移动成功!\n从第 ${fromIndex} 页 → 移到第 ${toIndex} 页`,
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
return {
|
|
202
|
+
id: (0, uuid_1.v4)(),
|
|
203
|
+
success: false,
|
|
204
|
+
content: [{ type: 'text', text: `移动幻灯片失败: ${response.error}` }],
|
|
205
|
+
error: response.error,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
211
|
+
return {
|
|
212
|
+
id: (0, uuid_1.v4)(),
|
|
213
|
+
success: false,
|
|
214
|
+
content: [{ type: 'text', text: `移动幻灯片出错: ${errMsg}` }],
|
|
215
|
+
error: errMsg,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
exports.moveSlideHandler = moveSlideHandler;
|
|
220
|
+
// ============================================================
|
|
221
|
+
// 4. wps_ppt_get_slide_count - 获取幻灯片总数
|
|
222
|
+
// ============================================================
|
|
223
|
+
exports.getSlideCountDefinition = {
|
|
224
|
+
name: 'wps_ppt_get_slide_count',
|
|
225
|
+
description: `获取演示文稿中的幻灯片总数。
|
|
226
|
+
|
|
227
|
+
使用场景:
|
|
228
|
+
- "一共有多少页幻灯片"
|
|
229
|
+
- "PPT有几页"
|
|
230
|
+
- "查看幻灯片数量"`,
|
|
231
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
232
|
+
inputSchema: {
|
|
233
|
+
type: 'object',
|
|
234
|
+
properties: {},
|
|
235
|
+
required: [],
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
const getSlideCountHandler = async (_args) => {
|
|
239
|
+
try {
|
|
240
|
+
const response = await wps_client_1.wpsClient.executeMethod('getSlideCount', {}, wps_1.WpsAppType.PRESENTATION);
|
|
241
|
+
if (response.success && response.data) {
|
|
242
|
+
return {
|
|
243
|
+
id: (0, uuid_1.v4)(),
|
|
244
|
+
success: true,
|
|
245
|
+
content: [
|
|
246
|
+
{
|
|
247
|
+
type: 'text',
|
|
248
|
+
text: `当前演示文稿共有 ${response.data.count} 页幻灯片`,
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
return {
|
|
255
|
+
id: (0, uuid_1.v4)(),
|
|
256
|
+
success: false,
|
|
257
|
+
content: [{ type: 'text', text: `获取幻灯片总数失败: ${response.error}` }],
|
|
258
|
+
error: response.error,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
264
|
+
return {
|
|
265
|
+
id: (0, uuid_1.v4)(),
|
|
266
|
+
success: false,
|
|
267
|
+
content: [{ type: 'text', text: `获取幻灯片总数出错: ${errMsg}` }],
|
|
268
|
+
error: errMsg,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
exports.getSlideCountHandler = getSlideCountHandler;
|
|
273
|
+
// ============================================================
|
|
274
|
+
// 5. wps_ppt_get_slide_info - 获取指定幻灯片的详细信息
|
|
275
|
+
// ============================================================
|
|
276
|
+
exports.getSlideInfoDefinition = {
|
|
277
|
+
name: 'wps_ppt_get_slide_info',
|
|
278
|
+
description: `获取指定幻灯片的详细信息,包括布局、元素列表等。
|
|
279
|
+
|
|
280
|
+
使用场景:
|
|
281
|
+
- "查看第3页的信息"
|
|
282
|
+
- "这页有什么内容"
|
|
283
|
+
- "获取幻灯片详情"`,
|
|
284
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
285
|
+
inputSchema: {
|
|
286
|
+
type: 'object',
|
|
287
|
+
properties: {
|
|
288
|
+
slideIndex: {
|
|
289
|
+
type: 'number',
|
|
290
|
+
description: '幻灯片索引(从1开始)',
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
required: ['slideIndex'],
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
const getSlideInfoHandler = async (args) => {
|
|
297
|
+
const { slideIndex } = args;
|
|
298
|
+
try {
|
|
299
|
+
const response = await wps_client_1.wpsClient.executeMethod('getSlideInfo', { slideIndex }, wps_1.WpsAppType.PRESENTATION);
|
|
300
|
+
if (response.success && response.data) {
|
|
301
|
+
const info = response.data;
|
|
302
|
+
let output = `第 ${info.slideIndex} 页幻灯片信息:\n`;
|
|
303
|
+
output += `布局: ${info.layout}\n`;
|
|
304
|
+
output += `元素数量: ${info.shapesCount}\n`;
|
|
305
|
+
if (info.shapes && info.shapes.length > 0) {
|
|
306
|
+
output += `\n元素列表:\n`;
|
|
307
|
+
info.shapes.forEach((shape, i) => {
|
|
308
|
+
output += ` ${i + 1}. [${shape.type}] ${shape.name}`;
|
|
309
|
+
if (shape.text) {
|
|
310
|
+
output += ` - "${shape.text.substring(0, 50)}${shape.text.length > 50 ? '...' : ''}"`;
|
|
311
|
+
}
|
|
312
|
+
output += '\n';
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
id: (0, uuid_1.v4)(),
|
|
317
|
+
success: true,
|
|
318
|
+
content: [{ type: 'text', text: output }],
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
return {
|
|
323
|
+
id: (0, uuid_1.v4)(),
|
|
324
|
+
success: false,
|
|
325
|
+
content: [{ type: 'text', text: `获取幻灯片信息失败: ${response.error}` }],
|
|
326
|
+
error: response.error,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
catch (error) {
|
|
331
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
332
|
+
return {
|
|
333
|
+
id: (0, uuid_1.v4)(),
|
|
334
|
+
success: false,
|
|
335
|
+
content: [{ type: 'text', text: `获取幻灯片信息出错: ${errMsg}` }],
|
|
336
|
+
error: errMsg,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
exports.getSlideInfoHandler = getSlideInfoHandler;
|
|
341
|
+
// ============================================================
|
|
342
|
+
// 6. wps_ppt_switch_slide - 切换到指定幻灯片
|
|
343
|
+
// ============================================================
|
|
344
|
+
exports.switchSlideDefinition = {
|
|
345
|
+
name: 'wps_ppt_switch_slide',
|
|
346
|
+
description: `切换到指定的幻灯片页面。
|
|
347
|
+
|
|
348
|
+
使用场景:
|
|
349
|
+
- "切换到第5页"
|
|
350
|
+
- "跳到最后一页"
|
|
351
|
+
- "显示第1页"`,
|
|
352
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
353
|
+
inputSchema: {
|
|
354
|
+
type: 'object',
|
|
355
|
+
properties: {
|
|
356
|
+
slideIndex: {
|
|
357
|
+
type: 'number',
|
|
358
|
+
description: '目标幻灯片索引(从1开始)',
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
required: ['slideIndex'],
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
const switchSlideHandler = async (args) => {
|
|
365
|
+
const { slideIndex } = args;
|
|
366
|
+
try {
|
|
367
|
+
const response = await wps_client_1.wpsClient.executeMethod('switchSlide', { slideIndex }, wps_1.WpsAppType.PRESENTATION);
|
|
368
|
+
if (response.success) {
|
|
369
|
+
return {
|
|
370
|
+
id: (0, uuid_1.v4)(),
|
|
371
|
+
success: true,
|
|
372
|
+
content: [
|
|
373
|
+
{
|
|
374
|
+
type: 'text',
|
|
375
|
+
text: `已切换到第 ${slideIndex} 页幻灯片`,
|
|
376
|
+
},
|
|
377
|
+
],
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
return {
|
|
382
|
+
id: (0, uuid_1.v4)(),
|
|
383
|
+
success: false,
|
|
384
|
+
content: [{ type: 'text', text: `切换幻灯片失败: ${response.error}` }],
|
|
385
|
+
error: response.error,
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
catch (error) {
|
|
390
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
391
|
+
return {
|
|
392
|
+
id: (0, uuid_1.v4)(),
|
|
393
|
+
success: false,
|
|
394
|
+
content: [{ type: 'text', text: `切换幻灯片出错: ${errMsg}` }],
|
|
395
|
+
error: errMsg,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
exports.switchSlideHandler = switchSlideHandler;
|
|
400
|
+
// ============================================================
|
|
401
|
+
// 7. wps_ppt_set_slide_layout - 设置幻灯片版式布局
|
|
402
|
+
// ============================================================
|
|
403
|
+
exports.setSlideLayoutDefinition = {
|
|
404
|
+
name: 'wps_ppt_set_slide_layout',
|
|
405
|
+
description: `设置幻灯片的版式布局。
|
|
406
|
+
|
|
407
|
+
支持的布局类型:
|
|
408
|
+
- title: 标题页
|
|
409
|
+
- title_content: 标题+内容
|
|
410
|
+
- blank: 空白页
|
|
411
|
+
- two_column: 两栏内容
|
|
412
|
+
- comparison: 对比布局
|
|
413
|
+
- section_header: 节标题
|
|
414
|
+
- title_only: 仅标题
|
|
415
|
+
|
|
416
|
+
使用场景:
|
|
417
|
+
- "把这页改成空白布局"
|
|
418
|
+
- "设置为两栏内容"
|
|
419
|
+
- "改成标题页版式"`,
|
|
420
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
421
|
+
inputSchema: {
|
|
422
|
+
type: 'object',
|
|
423
|
+
properties: {
|
|
424
|
+
slideIndex: {
|
|
425
|
+
type: 'number',
|
|
426
|
+
description: '幻灯片索引(从1开始)',
|
|
427
|
+
},
|
|
428
|
+
layout: {
|
|
429
|
+
type: 'string',
|
|
430
|
+
description: '布局名称',
|
|
431
|
+
},
|
|
432
|
+
},
|
|
433
|
+
required: ['slideIndex', 'layout'],
|
|
434
|
+
},
|
|
435
|
+
};
|
|
436
|
+
const setSlideLayoutHandler = async (args) => {
|
|
437
|
+
const { slideIndex, layout } = args;
|
|
438
|
+
try {
|
|
439
|
+
const response = await wps_client_1.wpsClient.executeMethod('setSlideLayout', { slideIndex, layout }, wps_1.WpsAppType.PRESENTATION);
|
|
440
|
+
if (response.success) {
|
|
441
|
+
const layoutName = {
|
|
442
|
+
title: '标题页',
|
|
443
|
+
title_content: '标题+内容',
|
|
444
|
+
blank: '空白页',
|
|
445
|
+
two_column: '两栏内容',
|
|
446
|
+
comparison: '对比布局',
|
|
447
|
+
section_header: '节标题',
|
|
448
|
+
title_only: '仅标题',
|
|
449
|
+
};
|
|
450
|
+
return {
|
|
451
|
+
id: (0, uuid_1.v4)(),
|
|
452
|
+
success: true,
|
|
453
|
+
content: [
|
|
454
|
+
{
|
|
455
|
+
type: 'text',
|
|
456
|
+
text: `幻灯片布局设置成功!\n幻灯片: 第 ${slideIndex} 页\n布局: ${layoutName[layout] || layout}`,
|
|
457
|
+
},
|
|
458
|
+
],
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
return {
|
|
463
|
+
id: (0, uuid_1.v4)(),
|
|
464
|
+
success: false,
|
|
465
|
+
content: [{ type: 'text', text: `设置幻灯片布局失败: ${response.error}` }],
|
|
466
|
+
error: response.error,
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
472
|
+
return {
|
|
473
|
+
id: (0, uuid_1.v4)(),
|
|
474
|
+
success: false,
|
|
475
|
+
content: [{ type: 'text', text: `设置幻灯片布局出错: ${errMsg}` }],
|
|
476
|
+
error: errMsg,
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
exports.setSlideLayoutHandler = setSlideLayoutHandler;
|
|
481
|
+
// ============================================================
|
|
482
|
+
// 8. wps_ppt_get_slide_notes - 获取幻灯片备注内容
|
|
483
|
+
// ============================================================
|
|
484
|
+
exports.getSlideNotesDefinition = {
|
|
485
|
+
name: 'wps_ppt_get_slide_notes',
|
|
486
|
+
description: `获取指定幻灯片的备注内容。
|
|
487
|
+
|
|
488
|
+
使用场景:
|
|
489
|
+
- "查看第3页的备注"
|
|
490
|
+
- "读取演讲备注"
|
|
491
|
+
- "这页有什么备注"`,
|
|
492
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
493
|
+
inputSchema: {
|
|
494
|
+
type: 'object',
|
|
495
|
+
properties: {
|
|
496
|
+
slideIndex: {
|
|
497
|
+
type: 'number',
|
|
498
|
+
description: '幻灯片索引(从1开始)',
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
required: ['slideIndex'],
|
|
502
|
+
},
|
|
503
|
+
};
|
|
504
|
+
const getSlideNotesHandler = async (args) => {
|
|
505
|
+
const { slideIndex } = args;
|
|
506
|
+
try {
|
|
507
|
+
const response = await wps_client_1.wpsClient.executeMethod('getSlideNotes', { slideIndex }, wps_1.WpsAppType.PRESENTATION);
|
|
508
|
+
if (response.success && response.data) {
|
|
509
|
+
const notes = response.data.notes;
|
|
510
|
+
return {
|
|
511
|
+
id: (0, uuid_1.v4)(),
|
|
512
|
+
success: true,
|
|
513
|
+
content: [
|
|
514
|
+
{
|
|
515
|
+
type: 'text',
|
|
516
|
+
text: notes
|
|
517
|
+
? `第 ${slideIndex} 页备注内容:\n${notes}`
|
|
518
|
+
: `第 ${slideIndex} 页没有备注内容`,
|
|
519
|
+
},
|
|
520
|
+
],
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
return {
|
|
525
|
+
id: (0, uuid_1.v4)(),
|
|
526
|
+
success: false,
|
|
527
|
+
content: [{ type: 'text', text: `获取幻灯片备注失败: ${response.error}` }],
|
|
528
|
+
error: response.error,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
catch (error) {
|
|
533
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
534
|
+
return {
|
|
535
|
+
id: (0, uuid_1.v4)(),
|
|
536
|
+
success: false,
|
|
537
|
+
content: [{ type: 'text', text: `获取幻灯片备注出错: ${errMsg}` }],
|
|
538
|
+
error: errMsg,
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
exports.getSlideNotesHandler = getSlideNotesHandler;
|
|
543
|
+
// ============================================================
|
|
544
|
+
// 9. wps_ppt_set_slide_notes - 设置幻灯片备注
|
|
545
|
+
// ============================================================
|
|
546
|
+
exports.setSlideNotesDefinition = {
|
|
547
|
+
name: 'wps_ppt_set_slide_notes',
|
|
548
|
+
description: `设置幻灯片的备注内容,用于演讲提示。
|
|
549
|
+
|
|
550
|
+
使用场景:
|
|
551
|
+
- "给第1页添加备注"
|
|
552
|
+
- "写一些演讲提示"
|
|
553
|
+
- "修改备注内容"`,
|
|
554
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
555
|
+
inputSchema: {
|
|
556
|
+
type: 'object',
|
|
557
|
+
properties: {
|
|
558
|
+
slideIndex: {
|
|
559
|
+
type: 'number',
|
|
560
|
+
description: '幻灯片索引(从1开始)',
|
|
561
|
+
},
|
|
562
|
+
notes: {
|
|
563
|
+
type: 'string',
|
|
564
|
+
description: '备注内容',
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
required: ['slideIndex', 'notes'],
|
|
568
|
+
},
|
|
569
|
+
};
|
|
570
|
+
const setSlideNotesHandler = async (args) => {
|
|
571
|
+
const { slideIndex, notes } = args;
|
|
572
|
+
try {
|
|
573
|
+
const response = await wps_client_1.wpsClient.executeMethod('setSlideNotes', { slideIndex, notes }, wps_1.WpsAppType.PRESENTATION);
|
|
574
|
+
if (response.success) {
|
|
575
|
+
return {
|
|
576
|
+
id: (0, uuid_1.v4)(),
|
|
577
|
+
success: true,
|
|
578
|
+
content: [
|
|
579
|
+
{
|
|
580
|
+
type: 'text',
|
|
581
|
+
text: `幻灯片备注设置成功!\n幻灯片: 第 ${slideIndex} 页\n备注内容: "${notes.substring(0, 80)}${notes.length > 80 ? '...' : ''}"`,
|
|
582
|
+
},
|
|
583
|
+
],
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
return {
|
|
588
|
+
id: (0, uuid_1.v4)(),
|
|
589
|
+
success: false,
|
|
590
|
+
content: [{ type: 'text', text: `设置幻灯片备注失败: ${response.error}` }],
|
|
591
|
+
error: response.error,
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
catch (error) {
|
|
596
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
597
|
+
return {
|
|
598
|
+
id: (0, uuid_1.v4)(),
|
|
599
|
+
success: false,
|
|
600
|
+
content: [{ type: 'text', text: `设置幻灯片备注出错: ${errMsg}` }],
|
|
601
|
+
error: errMsg,
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
exports.setSlideNotesHandler = setSlideNotesHandler;
|
|
606
|
+
// ============================================================
|
|
607
|
+
// 10. wps_ppt_add_shape - 添加形状
|
|
608
|
+
// ============================================================
|
|
609
|
+
exports.addShapeDefinition = {
|
|
610
|
+
name: 'wps_ppt_add_shape',
|
|
611
|
+
description: `在幻灯片中添加形状。
|
|
612
|
+
|
|
613
|
+
支持的形状类型:
|
|
614
|
+
- rectangle: 矩形
|
|
615
|
+
- oval: 椭圆
|
|
616
|
+
- triangle: 三角形
|
|
617
|
+
- diamond: 菱形
|
|
618
|
+
- pentagon: 五边形
|
|
619
|
+
- hexagon: 六边形
|
|
620
|
+
- arrow: 箭头
|
|
621
|
+
- star: 星形
|
|
622
|
+
- heart: 心形
|
|
623
|
+
- cloud: 云形
|
|
624
|
+
|
|
625
|
+
使用场景:
|
|
626
|
+
- "在第1页添加一个矩形"
|
|
627
|
+
- "插入一个蓝色的圆形"
|
|
628
|
+
- "添加一个带文字的箭头"`,
|
|
629
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
630
|
+
inputSchema: {
|
|
631
|
+
type: 'object',
|
|
632
|
+
properties: {
|
|
633
|
+
slideIndex: {
|
|
634
|
+
type: 'number',
|
|
635
|
+
description: '幻灯片索引(从1开始),默认1',
|
|
636
|
+
},
|
|
637
|
+
type: {
|
|
638
|
+
type: 'string',
|
|
639
|
+
description: '形状类型',
|
|
640
|
+
enum: ['rectangle', 'oval', 'triangle', 'diamond', 'pentagon', 'hexagon', 'arrow', 'star', 'heart', 'cloud'],
|
|
641
|
+
},
|
|
642
|
+
left: {
|
|
643
|
+
type: 'number',
|
|
644
|
+
description: '左边距(像素),默认100',
|
|
645
|
+
},
|
|
646
|
+
top: {
|
|
647
|
+
type: 'number',
|
|
648
|
+
description: '上边距(像素),默认100',
|
|
649
|
+
},
|
|
650
|
+
width: {
|
|
651
|
+
type: 'number',
|
|
652
|
+
description: '宽度(像素),默认100',
|
|
653
|
+
},
|
|
654
|
+
height: {
|
|
655
|
+
type: 'number',
|
|
656
|
+
description: '高度(像素),默认100',
|
|
657
|
+
},
|
|
658
|
+
text: {
|
|
659
|
+
type: 'string',
|
|
660
|
+
description: '形状内的文本',
|
|
661
|
+
},
|
|
662
|
+
fillColor: {
|
|
663
|
+
type: 'string',
|
|
664
|
+
description: '填充颜色,十六进制如 #FF0000',
|
|
665
|
+
},
|
|
666
|
+
},
|
|
667
|
+
required: [],
|
|
668
|
+
},
|
|
669
|
+
};
|
|
670
|
+
const addShapeHandler = async (args) => {
|
|
671
|
+
const { slideIndex, type, left, top, width, height, text, fillColor } = args;
|
|
672
|
+
try {
|
|
673
|
+
const response = await wps_client_1.wpsClient.executeMethod('addShape', {
|
|
674
|
+
slideIndex: slideIndex || 1,
|
|
675
|
+
type: type || 'rectangle',
|
|
676
|
+
left: left || 100,
|
|
677
|
+
top: top || 100,
|
|
678
|
+
width: width || 100,
|
|
679
|
+
height: height || 100,
|
|
680
|
+
text,
|
|
681
|
+
fillColor,
|
|
682
|
+
}, wps_1.WpsAppType.PRESENTATION);
|
|
683
|
+
if (response.success && response.data) {
|
|
684
|
+
const shapeNameMap = {
|
|
685
|
+
rectangle: '矩形', oval: '椭圆', triangle: '三角形', diamond: '菱形',
|
|
686
|
+
pentagon: '五边形', hexagon: '六边形', arrow: '箭头', star: '星形',
|
|
687
|
+
heart: '心形', cloud: '云形',
|
|
688
|
+
};
|
|
689
|
+
const typeName = shapeNameMap[type || 'rectangle'] || type;
|
|
690
|
+
return {
|
|
691
|
+
id: (0, uuid_1.v4)(),
|
|
692
|
+
success: true,
|
|
693
|
+
content: [
|
|
694
|
+
{
|
|
695
|
+
type: 'text',
|
|
696
|
+
text: `形状添加成功!\n幻灯片: 第 ${response.data.slideIndex} 页\n形状类型: ${typeName}\n形状名称: ${response.data.name}${text ? `\n文本: ${text}` : ''}${fillColor ? `\n填充色: ${fillColor}` : ''}`,
|
|
697
|
+
},
|
|
698
|
+
],
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
else {
|
|
702
|
+
return {
|
|
703
|
+
id: (0, uuid_1.v4)(),
|
|
704
|
+
success: false,
|
|
705
|
+
content: [{ type: 'text', text: `添加形状失败: ${response.error}` }],
|
|
706
|
+
error: response.error,
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
catch (error) {
|
|
711
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
712
|
+
return {
|
|
713
|
+
id: (0, uuid_1.v4)(),
|
|
714
|
+
success: false,
|
|
715
|
+
content: [{ type: 'text', text: `添加形状出错: ${errMsg}` }],
|
|
716
|
+
error: errMsg,
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
exports.addShapeHandler = addShapeHandler;
|
|
721
|
+
// ============================================================
|
|
722
|
+
// 11. wps_ppt_set_shape_style - 设置形状样式
|
|
723
|
+
// ============================================================
|
|
724
|
+
exports.setShapeStyleDefinition = {
|
|
725
|
+
name: 'wps_ppt_set_shape_style',
|
|
726
|
+
description: `设置幻灯片中形状的样式,包括填充颜色、边框颜色和边框粗细。
|
|
727
|
+
|
|
728
|
+
使用场景:
|
|
729
|
+
- "把矩形改成红色"
|
|
730
|
+
- "设置形状的边框为蓝色"
|
|
731
|
+
- "修改形状样式"`,
|
|
732
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
733
|
+
inputSchema: {
|
|
734
|
+
type: 'object',
|
|
735
|
+
properties: {
|
|
736
|
+
slideIndex: {
|
|
737
|
+
type: 'number',
|
|
738
|
+
description: '幻灯片索引(从1开始),默认1',
|
|
739
|
+
},
|
|
740
|
+
name: {
|
|
741
|
+
type: 'string',
|
|
742
|
+
description: '形状名称(通过getSlideInfo获取)',
|
|
743
|
+
},
|
|
744
|
+
shapeIndex: {
|
|
745
|
+
type: 'number',
|
|
746
|
+
description: '形状索引(与name二选一)',
|
|
747
|
+
},
|
|
748
|
+
fillColor: {
|
|
749
|
+
type: 'string',
|
|
750
|
+
description: '填充颜色,十六进制如 #FF0000',
|
|
751
|
+
},
|
|
752
|
+
lineColor: {
|
|
753
|
+
type: 'string',
|
|
754
|
+
description: '边框颜色,十六进制如 #000000',
|
|
755
|
+
},
|
|
756
|
+
lineWidth: {
|
|
757
|
+
type: 'number',
|
|
758
|
+
description: '边框粗细(磅)',
|
|
759
|
+
},
|
|
760
|
+
},
|
|
761
|
+
required: [],
|
|
762
|
+
},
|
|
763
|
+
};
|
|
764
|
+
const setShapeStyleHandler = async (args) => {
|
|
765
|
+
const { slideIndex, name, shapeIndex, fillColor, lineColor, lineWidth } = args;
|
|
766
|
+
try {
|
|
767
|
+
const response = await wps_client_1.wpsClient.executeMethod('setShapeStyle', {
|
|
768
|
+
slideIndex: slideIndex || 1,
|
|
769
|
+
name,
|
|
770
|
+
shapeIndex,
|
|
771
|
+
fillColor,
|
|
772
|
+
lineColor,
|
|
773
|
+
lineWidth,
|
|
774
|
+
}, wps_1.WpsAppType.PRESENTATION);
|
|
775
|
+
if (response.success && response.data) {
|
|
776
|
+
let output = `形状样式设置成功!\n形状: ${response.data.name}`;
|
|
777
|
+
if (fillColor)
|
|
778
|
+
output += `\n填充色: ${fillColor}`;
|
|
779
|
+
if (lineColor)
|
|
780
|
+
output += `\n边框色: ${lineColor}`;
|
|
781
|
+
if (lineWidth)
|
|
782
|
+
output += `\n边框粗细: ${lineWidth}pt`;
|
|
783
|
+
return {
|
|
784
|
+
id: (0, uuid_1.v4)(),
|
|
785
|
+
success: true,
|
|
786
|
+
content: [{ type: 'text', text: output }],
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
else {
|
|
790
|
+
return {
|
|
791
|
+
id: (0, uuid_1.v4)(),
|
|
792
|
+
success: false,
|
|
793
|
+
content: [{ type: 'text', text: `设置形状样式失败: ${response.error}` }],
|
|
794
|
+
error: response.error,
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
catch (error) {
|
|
799
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
800
|
+
return {
|
|
801
|
+
id: (0, uuid_1.v4)(),
|
|
802
|
+
success: false,
|
|
803
|
+
content: [{ type: 'text', text: `设置形状样式出错: ${errMsg}` }],
|
|
804
|
+
error: errMsg,
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
exports.setShapeStyleHandler = setShapeStyleHandler;
|
|
809
|
+
// ============================================================
|
|
810
|
+
// 12. wps_ppt_add_textbox - 添加文本框
|
|
811
|
+
// ============================================================
|
|
812
|
+
exports.addTextboxDefinition = {
|
|
813
|
+
name: 'wps_ppt_add_textbox',
|
|
814
|
+
description: `在幻灯片中添加文本框。
|
|
815
|
+
|
|
816
|
+
使用场景:
|
|
817
|
+
- "在第1页添加一个文本框"
|
|
818
|
+
- "插入一个写着标题的文本框"
|
|
819
|
+
- "添加文本框并设置字号"`,
|
|
820
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
821
|
+
inputSchema: {
|
|
822
|
+
type: 'object',
|
|
823
|
+
properties: {
|
|
824
|
+
slideIndex: {
|
|
825
|
+
type: 'number',
|
|
826
|
+
description: '幻灯片索引(从1开始),默认1',
|
|
827
|
+
},
|
|
828
|
+
left: {
|
|
829
|
+
type: 'number',
|
|
830
|
+
description: '左边距(像素),默认100',
|
|
831
|
+
},
|
|
832
|
+
top: {
|
|
833
|
+
type: 'number',
|
|
834
|
+
description: '上边距(像素),默认100',
|
|
835
|
+
},
|
|
836
|
+
width: {
|
|
837
|
+
type: 'number',
|
|
838
|
+
description: '宽度(像素),默认200',
|
|
839
|
+
},
|
|
840
|
+
height: {
|
|
841
|
+
type: 'number',
|
|
842
|
+
description: '高度(像素),默认50',
|
|
843
|
+
},
|
|
844
|
+
text: {
|
|
845
|
+
type: 'string',
|
|
846
|
+
description: '文本框内容',
|
|
847
|
+
},
|
|
848
|
+
fontSize: {
|
|
849
|
+
type: 'number',
|
|
850
|
+
description: '字号大小',
|
|
851
|
+
},
|
|
852
|
+
fontName: {
|
|
853
|
+
type: 'string',
|
|
854
|
+
description: '字体名称,如 "微软雅黑"',
|
|
855
|
+
},
|
|
856
|
+
},
|
|
857
|
+
required: [],
|
|
858
|
+
},
|
|
859
|
+
};
|
|
860
|
+
const addTextboxHandler = async (args) => {
|
|
861
|
+
const { slideIndex, left, top, width, height, text, fontSize, fontName } = args;
|
|
862
|
+
try {
|
|
863
|
+
const response = await wps_client_1.wpsClient.executeMethod('addTextBox', {
|
|
864
|
+
slideIndex: slideIndex || 1,
|
|
865
|
+
left: left || 100,
|
|
866
|
+
top: top || 100,
|
|
867
|
+
width: width || 200,
|
|
868
|
+
height: height || 50,
|
|
869
|
+
text,
|
|
870
|
+
fontSize,
|
|
871
|
+
fontName,
|
|
872
|
+
}, wps_1.WpsAppType.PRESENTATION);
|
|
873
|
+
if (response.success && response.data) {
|
|
874
|
+
return {
|
|
875
|
+
id: (0, uuid_1.v4)(),
|
|
876
|
+
success: true,
|
|
877
|
+
content: [
|
|
878
|
+
{
|
|
879
|
+
type: 'text',
|
|
880
|
+
text: `文本框添加成功!\n幻灯片: 第 ${response.data.slideIndex} 页\n名称: ${response.data.name}${text ? `\n内容: "${text}"` : ''}${fontSize ? `\n字号: ${fontSize}` : ''}${fontName ? `\n字体: ${fontName}` : ''}`,
|
|
881
|
+
},
|
|
882
|
+
],
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
else {
|
|
886
|
+
return {
|
|
887
|
+
id: (0, uuid_1.v4)(),
|
|
888
|
+
success: false,
|
|
889
|
+
content: [{ type: 'text', text: `添加文本框失败: ${response.error}` }],
|
|
890
|
+
error: response.error,
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
catch (error) {
|
|
895
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
896
|
+
return {
|
|
897
|
+
id: (0, uuid_1.v4)(),
|
|
898
|
+
success: false,
|
|
899
|
+
content: [{ type: 'text', text: `添加文本框出错: ${errMsg}` }],
|
|
900
|
+
error: errMsg,
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
exports.addTextboxHandler = addTextboxHandler;
|
|
905
|
+
// ============================================================
|
|
906
|
+
// 13. wps_ppt_set_slide_title - 设置幻灯片标题
|
|
907
|
+
// ============================================================
|
|
908
|
+
exports.setSlideTitleDefinition = {
|
|
909
|
+
name: 'wps_ppt_set_slide_title',
|
|
910
|
+
description: `设置幻灯片的标题文本。
|
|
911
|
+
|
|
912
|
+
使用场景:
|
|
913
|
+
- "把第1页标题改成'年度总结'"
|
|
914
|
+
- "设置标题为'项目进展'"
|
|
915
|
+
- "修改幻灯片标题"`,
|
|
916
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
917
|
+
inputSchema: {
|
|
918
|
+
type: 'object',
|
|
919
|
+
properties: {
|
|
920
|
+
slideIndex: {
|
|
921
|
+
type: 'number',
|
|
922
|
+
description: '幻灯片索引(从1开始),默认1',
|
|
923
|
+
},
|
|
924
|
+
title: {
|
|
925
|
+
type: 'string',
|
|
926
|
+
description: '标题文本',
|
|
927
|
+
},
|
|
928
|
+
},
|
|
929
|
+
required: ['title'],
|
|
930
|
+
},
|
|
931
|
+
};
|
|
932
|
+
const setSlideTitleHandler = async (args) => {
|
|
933
|
+
const { slideIndex, title } = args;
|
|
934
|
+
try {
|
|
935
|
+
const response = await wps_client_1.wpsClient.executeMethod('setSlideTitle', {
|
|
936
|
+
slideIndex: slideIndex || 1,
|
|
937
|
+
title,
|
|
938
|
+
}, wps_1.WpsAppType.PRESENTATION);
|
|
939
|
+
if (response.success && response.data) {
|
|
940
|
+
return {
|
|
941
|
+
id: (0, uuid_1.v4)(),
|
|
942
|
+
success: true,
|
|
943
|
+
content: [
|
|
944
|
+
{
|
|
945
|
+
type: 'text',
|
|
946
|
+
text: `幻灯片标题设置成功!\n幻灯片: 第 ${response.data.slideIndex} 页\n标题: "${response.data.title}"`,
|
|
947
|
+
},
|
|
948
|
+
],
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
else {
|
|
952
|
+
return {
|
|
953
|
+
id: (0, uuid_1.v4)(),
|
|
954
|
+
success: false,
|
|
955
|
+
content: [{ type: 'text', text: `设置幻灯片标题失败: ${response.error}` }],
|
|
956
|
+
error: response.error,
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
catch (error) {
|
|
961
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
962
|
+
return {
|
|
963
|
+
id: (0, uuid_1.v4)(),
|
|
964
|
+
success: false,
|
|
965
|
+
content: [{ type: 'text', text: `设置幻灯片标题出错: ${errMsg}` }],
|
|
966
|
+
error: errMsg,
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
exports.setSlideTitleHandler = setSlideTitleHandler;
|
|
971
|
+
// ============================================================
|
|
972
|
+
// 14. wps_ppt_insert_image - 插入图片
|
|
973
|
+
// ============================================================
|
|
974
|
+
exports.insertImageDefinition = {
|
|
975
|
+
name: 'wps_ppt_insert_image',
|
|
976
|
+
description: `在幻灯片中插入图片。
|
|
977
|
+
|
|
978
|
+
使用场景:
|
|
979
|
+
- "在第1页插入一张图片"
|
|
980
|
+
- "添加图片到幻灯片"
|
|
981
|
+
- "把这个图片放到PPT里"`,
|
|
982
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
983
|
+
inputSchema: {
|
|
984
|
+
type: 'object',
|
|
985
|
+
properties: {
|
|
986
|
+
slideIndex: {
|
|
987
|
+
type: 'number',
|
|
988
|
+
description: '幻灯片索引(从1开始),默认1',
|
|
989
|
+
},
|
|
990
|
+
path: {
|
|
991
|
+
type: 'string',
|
|
992
|
+
description: '图片文件的完整路径',
|
|
993
|
+
},
|
|
994
|
+
left: {
|
|
995
|
+
type: 'number',
|
|
996
|
+
description: '左边距(像素),默认100',
|
|
997
|
+
},
|
|
998
|
+
top: {
|
|
999
|
+
type: 'number',
|
|
1000
|
+
description: '上边距(像素),默认100',
|
|
1001
|
+
},
|
|
1002
|
+
width: {
|
|
1003
|
+
type: 'number',
|
|
1004
|
+
description: '宽度(像素),不填则保持原始尺寸',
|
|
1005
|
+
},
|
|
1006
|
+
height: {
|
|
1007
|
+
type: 'number',
|
|
1008
|
+
description: '高度(像素),不填则保持原始尺寸',
|
|
1009
|
+
},
|
|
1010
|
+
},
|
|
1011
|
+
required: ['path'],
|
|
1012
|
+
},
|
|
1013
|
+
};
|
|
1014
|
+
const insertImageHandler = async (args) => {
|
|
1015
|
+
const { slideIndex, path, left, top, width, height } = args;
|
|
1016
|
+
try {
|
|
1017
|
+
const response = await wps_client_1.wpsClient.executeMethod('insertPptImage', {
|
|
1018
|
+
slideIndex: slideIndex || 1,
|
|
1019
|
+
path,
|
|
1020
|
+
left: left || 100,
|
|
1021
|
+
top: top || 100,
|
|
1022
|
+
width: width || -1,
|
|
1023
|
+
height: height || -1,
|
|
1024
|
+
}, wps_1.WpsAppType.PRESENTATION);
|
|
1025
|
+
if (response.success && response.data) {
|
|
1026
|
+
return {
|
|
1027
|
+
id: (0, uuid_1.v4)(),
|
|
1028
|
+
success: true,
|
|
1029
|
+
content: [
|
|
1030
|
+
{
|
|
1031
|
+
type: 'text',
|
|
1032
|
+
text: `图片插入成功!\n幻灯片: 第 ${slideIndex || 1} 页\n图片名称: ${response.data.name}\n图片路径: ${response.data.path}`,
|
|
1033
|
+
},
|
|
1034
|
+
],
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1037
|
+
else {
|
|
1038
|
+
return {
|
|
1039
|
+
id: (0, uuid_1.v4)(),
|
|
1040
|
+
success: false,
|
|
1041
|
+
content: [{ type: 'text', text: `插入图片失败: ${response.error}` }],
|
|
1042
|
+
error: response.error,
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
catch (error) {
|
|
1047
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1048
|
+
return {
|
|
1049
|
+
id: (0, uuid_1.v4)(),
|
|
1050
|
+
success: false,
|
|
1051
|
+
content: [{ type: 'text', text: `插入图片出错: ${errMsg}` }],
|
|
1052
|
+
error: errMsg,
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
exports.insertImageHandler = insertImageHandler;
|
|
1057
|
+
// ============================================================
|
|
1058
|
+
// 15. wps_ppt_set_shape_text - 设置形状文字
|
|
1059
|
+
// ============================================================
|
|
1060
|
+
exports.setShapeTextDefinition = {
|
|
1061
|
+
name: 'wps_ppt_set_shape_text',
|
|
1062
|
+
description: `设置幻灯片中指定形状的文字内容。
|
|
1063
|
+
|
|
1064
|
+
使用场景:
|
|
1065
|
+
- "把第1页的第2个形状文字改成'销售额'"
|
|
1066
|
+
- "修改形状里的文字"`,
|
|
1067
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
1068
|
+
inputSchema: {
|
|
1069
|
+
type: 'object',
|
|
1070
|
+
properties: {
|
|
1071
|
+
slideIndex: { type: 'number', description: '幻灯片索引(从1开始)' },
|
|
1072
|
+
shapeIndex: { type: 'number', description: '形状索引(从1开始)' },
|
|
1073
|
+
text: { type: 'string', description: '要设置的文字内容' },
|
|
1074
|
+
},
|
|
1075
|
+
required: ['slideIndex', 'shapeIndex', 'text'],
|
|
1076
|
+
},
|
|
1077
|
+
};
|
|
1078
|
+
const setShapeTextHandler = async (args) => {
|
|
1079
|
+
const { slideIndex, shapeIndex, text } = args;
|
|
1080
|
+
try {
|
|
1081
|
+
const response = await wps_client_1.wpsClient.executeMethod('setShapeText', { slideIndex, shapeIndex, text }, wps_1.WpsAppType.PRESENTATION);
|
|
1082
|
+
if (response.success && response.data) {
|
|
1083
|
+
return {
|
|
1084
|
+
id: (0, uuid_1.v4)(),
|
|
1085
|
+
success: true,
|
|
1086
|
+
content: [{ type: 'text', text: `形状文字设置成功!\n形状: ${response.data.name}\n文字: "${text}"` }],
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
else {
|
|
1090
|
+
return {
|
|
1091
|
+
id: (0, uuid_1.v4)(),
|
|
1092
|
+
success: false,
|
|
1093
|
+
content: [{ type: 'text', text: `设置形状文字失败: ${response.error}` }],
|
|
1094
|
+
error: response.error,
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
catch (error) {
|
|
1099
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1100
|
+
return {
|
|
1101
|
+
id: (0, uuid_1.v4)(),
|
|
1102
|
+
success: false,
|
|
1103
|
+
content: [{ type: 'text', text: `设置形状文字出错: ${errMsg}` }],
|
|
1104
|
+
error: errMsg,
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
exports.setShapeTextHandler = setShapeTextHandler;
|
|
1109
|
+
// ============================================================
|
|
1110
|
+
// 16. wps_ppt_set_animation - 设置元素动画
|
|
1111
|
+
// ============================================================
|
|
1112
|
+
exports.setAnimationDefinition = {
|
|
1113
|
+
name: 'wps_ppt_set_animation',
|
|
1114
|
+
description: `设置幻灯片中指定元素的动画效果。
|
|
1115
|
+
|
|
1116
|
+
支持的动画类型:
|
|
1117
|
+
- fadeIn: 淡入
|
|
1118
|
+
- flyIn: 飞入
|
|
1119
|
+
- wipeIn: 擦除
|
|
1120
|
+
- zoomIn: 缩放进入
|
|
1121
|
+
- bounceIn: 弹跳进入
|
|
1122
|
+
- spinIn: 旋转进入
|
|
1123
|
+
- fadeOut: 淡出
|
|
1124
|
+
- flyOut: 飞出
|
|
1125
|
+
|
|
1126
|
+
使用场景:
|
|
1127
|
+
- "给第1页的第2个元素添加淡入动画"
|
|
1128
|
+
- "设置飞入效果"
|
|
1129
|
+
- "给形状加个弹跳动画"`,
|
|
1130
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
1131
|
+
inputSchema: {
|
|
1132
|
+
type: 'object',
|
|
1133
|
+
properties: {
|
|
1134
|
+
slideIndex: {
|
|
1135
|
+
type: 'number',
|
|
1136
|
+
description: '幻灯片索引(从1开始)',
|
|
1137
|
+
},
|
|
1138
|
+
shapeIndex: {
|
|
1139
|
+
type: 'number',
|
|
1140
|
+
description: '形状索引(从1开始)',
|
|
1141
|
+
},
|
|
1142
|
+
animationType: {
|
|
1143
|
+
type: 'string',
|
|
1144
|
+
description: '动画类型,如 fadeIn, flyIn, wipeIn, zoomIn, bounceIn, spinIn, fadeOut, flyOut',
|
|
1145
|
+
},
|
|
1146
|
+
},
|
|
1147
|
+
required: ['slideIndex', 'shapeIndex', 'animationType'],
|
|
1148
|
+
},
|
|
1149
|
+
};
|
|
1150
|
+
const setAnimationHandler = async (args) => {
|
|
1151
|
+
const { slideIndex, shapeIndex, animationType } = args;
|
|
1152
|
+
try {
|
|
1153
|
+
const response = await wps_client_1.wpsClient.executeMethod('addAnimation', { slideIndex, shapeIndex, animationType }, wps_1.WpsAppType.PRESENTATION);
|
|
1154
|
+
if (response.success) {
|
|
1155
|
+
const animNameMap = {
|
|
1156
|
+
fadeIn: '淡入', flyIn: '飞入', wipeIn: '擦除', zoomIn: '缩放进入',
|
|
1157
|
+
bounceIn: '弹跳进入', spinIn: '旋转进入', fadeOut: '淡出', flyOut: '飞出',
|
|
1158
|
+
};
|
|
1159
|
+
return {
|
|
1160
|
+
id: (0, uuid_1.v4)(),
|
|
1161
|
+
success: true,
|
|
1162
|
+
content: [
|
|
1163
|
+
{
|
|
1164
|
+
type: 'text',
|
|
1165
|
+
text: `动画设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个\n动画: ${animNameMap[animationType] || animationType}`,
|
|
1166
|
+
},
|
|
1167
|
+
],
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
else {
|
|
1171
|
+
return {
|
|
1172
|
+
id: (0, uuid_1.v4)(),
|
|
1173
|
+
success: false,
|
|
1174
|
+
content: [{ type: 'text', text: `设置动画失败: ${response.error}` }],
|
|
1175
|
+
error: response.error,
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
catch (error) {
|
|
1180
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1181
|
+
return {
|
|
1182
|
+
id: (0, uuid_1.v4)(),
|
|
1183
|
+
success: false,
|
|
1184
|
+
content: [{ type: 'text', text: `设置动画出错: ${errMsg}` }],
|
|
1185
|
+
error: errMsg,
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
exports.setAnimationHandler = setAnimationHandler;
|
|
1190
|
+
// ============================================================
|
|
1191
|
+
// 17. wps_ppt_set_background - 设置幻灯片背景
|
|
1192
|
+
// ============================================================
|
|
1193
|
+
exports.setBackgroundDefinition = {
|
|
1194
|
+
name: 'wps_ppt_set_background',
|
|
1195
|
+
description: `设置幻灯片的背景颜色或背景图片。
|
|
1196
|
+
|
|
1197
|
+
使用场景:
|
|
1198
|
+
- "把第1页背景改成蓝色"
|
|
1199
|
+
- "设置幻灯片背景图片"
|
|
1200
|
+
- "修改背景颜色为#FF0000"`,
|
|
1201
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
1202
|
+
inputSchema: {
|
|
1203
|
+
type: 'object',
|
|
1204
|
+
properties: {
|
|
1205
|
+
slideIndex: {
|
|
1206
|
+
type: 'number',
|
|
1207
|
+
description: '幻灯片索引(从1开始)',
|
|
1208
|
+
},
|
|
1209
|
+
color: {
|
|
1210
|
+
type: 'string',
|
|
1211
|
+
description: '背景颜色,十六进制如 #FF0000(与imagePath二选一)',
|
|
1212
|
+
},
|
|
1213
|
+
imagePath: {
|
|
1214
|
+
type: 'string',
|
|
1215
|
+
description: '背景图片路径(与color二选一)',
|
|
1216
|
+
},
|
|
1217
|
+
},
|
|
1218
|
+
required: ['slideIndex'],
|
|
1219
|
+
},
|
|
1220
|
+
};
|
|
1221
|
+
const setBackgroundHandler = async (args) => {
|
|
1222
|
+
const { slideIndex, color, imagePath } = args;
|
|
1223
|
+
try {
|
|
1224
|
+
// 参数对齐:setSlideBackground 读取 $p.imagePath;同时发送 path/filePath
|
|
1225
|
+
const response = await wps_client_1.wpsClient.executeMethod('setSlideBackground', {
|
|
1226
|
+
slideIndex,
|
|
1227
|
+
color,
|
|
1228
|
+
imagePath,
|
|
1229
|
+
...(imagePath ? { path: imagePath, filePath: imagePath } : {}),
|
|
1230
|
+
}, wps_1.WpsAppType.PRESENTATION);
|
|
1231
|
+
if (response.success) {
|
|
1232
|
+
let detail = '';
|
|
1233
|
+
if (color)
|
|
1234
|
+
detail = `背景颜色: ${color}`;
|
|
1235
|
+
else if (imagePath)
|
|
1236
|
+
detail = `背景图片: ${imagePath}`;
|
|
1237
|
+
return {
|
|
1238
|
+
id: (0, uuid_1.v4)(),
|
|
1239
|
+
success: true,
|
|
1240
|
+
content: [
|
|
1241
|
+
{
|
|
1242
|
+
type: 'text',
|
|
1243
|
+
text: `幻灯片背景设置成功!\n幻灯片: 第 ${slideIndex} 页\n${detail}`,
|
|
1244
|
+
},
|
|
1245
|
+
],
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
else {
|
|
1249
|
+
return {
|
|
1250
|
+
id: (0, uuid_1.v4)(),
|
|
1251
|
+
success: false,
|
|
1252
|
+
content: [{ type: 'text', text: `设置背景失败: ${response.error}` }],
|
|
1253
|
+
error: response.error,
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
catch (error) {
|
|
1258
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1259
|
+
return {
|
|
1260
|
+
id: (0, uuid_1.v4)(),
|
|
1261
|
+
success: false,
|
|
1262
|
+
content: [{ type: 'text', text: `设置背景出错: ${errMsg}` }],
|
|
1263
|
+
error: errMsg,
|
|
1264
|
+
};
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1267
|
+
exports.setBackgroundHandler = setBackgroundHandler;
|
|
1268
|
+
// ============================================================
|
|
1269
|
+
// 18. wps_ppt_set_slide_size - 设置幻灯片尺寸
|
|
1270
|
+
// ============================================================
|
|
1271
|
+
exports.setSlideSizeDefinition = {
|
|
1272
|
+
name: 'wps_ppt_set_slide_size',
|
|
1273
|
+
description: `设置演示文稿的幻灯片尺寸。
|
|
1274
|
+
|
|
1275
|
+
常用尺寸:
|
|
1276
|
+
- 标准(4:3): 宽960, 高720
|
|
1277
|
+
- 宽屏(16:9): 宽960, 高540
|
|
1278
|
+
- 宽屏(16:10): 宽960, 高600
|
|
1279
|
+
- A4横版: 宽1123, 高794
|
|
1280
|
+
- A4竖版: 宽794, 高1123
|
|
1281
|
+
|
|
1282
|
+
使用场景:
|
|
1283
|
+
- "把PPT改成16:9宽屏"
|
|
1284
|
+
- "设置幻灯片为A4尺寸"
|
|
1285
|
+
- "修改幻灯片大小"`,
|
|
1286
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
1287
|
+
inputSchema: {
|
|
1288
|
+
type: 'object',
|
|
1289
|
+
properties: {
|
|
1290
|
+
width: {
|
|
1291
|
+
type: 'number',
|
|
1292
|
+
description: '幻灯片宽度(像素)',
|
|
1293
|
+
},
|
|
1294
|
+
height: {
|
|
1295
|
+
type: 'number',
|
|
1296
|
+
description: '幻灯片高度(像素)',
|
|
1297
|
+
},
|
|
1298
|
+
},
|
|
1299
|
+
required: ['width', 'height'],
|
|
1300
|
+
},
|
|
1301
|
+
};
|
|
1302
|
+
const setSlideSizeHandler = async (args) => {
|
|
1303
|
+
const { width, height } = args;
|
|
1304
|
+
try {
|
|
1305
|
+
const response = await wps_client_1.wpsClient.executeMethod('setSlideSize', // NOTE: 仅Windows支持
|
|
1306
|
+
{ width, height }, wps_1.WpsAppType.PRESENTATION);
|
|
1307
|
+
if (response.success) {
|
|
1308
|
+
return {
|
|
1309
|
+
id: (0, uuid_1.v4)(),
|
|
1310
|
+
success: true,
|
|
1311
|
+
content: [
|
|
1312
|
+
{
|
|
1313
|
+
type: 'text',
|
|
1314
|
+
text: `幻灯片尺寸设置成功!\n宽度: ${width}px\n高度: ${height}px`,
|
|
1315
|
+
},
|
|
1316
|
+
],
|
|
1317
|
+
};
|
|
1318
|
+
}
|
|
1319
|
+
else {
|
|
1320
|
+
return {
|
|
1321
|
+
id: (0, uuid_1.v4)(),
|
|
1322
|
+
success: false,
|
|
1323
|
+
content: [{ type: 'text', text: `设置幻灯片尺寸失败: ${response.error}` }],
|
|
1324
|
+
error: response.error,
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
catch (error) {
|
|
1329
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1330
|
+
return {
|
|
1331
|
+
id: (0, uuid_1.v4)(),
|
|
1332
|
+
success: false,
|
|
1333
|
+
content: [{ type: 'text', text: `设置幻灯片尺寸出错: ${errMsg}` }],
|
|
1334
|
+
error: errMsg,
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1338
|
+
exports.setSlideSizeHandler = setSlideSizeHandler;
|
|
1339
|
+
// ============================================================
|
|
1340
|
+
// 19. wps_ppt_set_transition - 设置幻灯片切换效果
|
|
1341
|
+
// ============================================================
|
|
1342
|
+
exports.setTransitionDefinition = {
|
|
1343
|
+
name: 'wps_ppt_set_transition',
|
|
1344
|
+
description: `设置幻灯片切换效果。
|
|
1345
|
+
|
|
1346
|
+
支持的切换类型:
|
|
1347
|
+
- fade: 淡出
|
|
1348
|
+
- push: 推入
|
|
1349
|
+
- wipe: 擦除
|
|
1350
|
+
- split: 拆分
|
|
1351
|
+
- reveal: 揭开
|
|
1352
|
+
- cover: 覆盖
|
|
1353
|
+
- dissolve: 溶解
|
|
1354
|
+
- curtains: 帷幕
|
|
1355
|
+
|
|
1356
|
+
使用场景:
|
|
1357
|
+
- "给第2页设置淡出切换效果"
|
|
1358
|
+
- "设置幻灯片切换为推入"
|
|
1359
|
+
- "修改页面切换动画"`,
|
|
1360
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
1361
|
+
inputSchema: {
|
|
1362
|
+
type: 'object',
|
|
1363
|
+
properties: {
|
|
1364
|
+
slideIndex: {
|
|
1365
|
+
type: 'number',
|
|
1366
|
+
description: '幻灯片索引(从1开始)',
|
|
1367
|
+
},
|
|
1368
|
+
transition: {
|
|
1369
|
+
type: 'string',
|
|
1370
|
+
description: '切换效果类型,如 fade, push, wipe, split, reveal, cover, dissolve, curtains',
|
|
1371
|
+
},
|
|
1372
|
+
},
|
|
1373
|
+
required: ['slideIndex', 'transition'],
|
|
1374
|
+
},
|
|
1375
|
+
};
|
|
1376
|
+
const setTransitionHandler = async (args) => {
|
|
1377
|
+
const { slideIndex, transition } = args;
|
|
1378
|
+
try {
|
|
1379
|
+
const response = await wps_client_1.wpsClient.executeMethod('setSlideTransition', { slideIndex, transition }, wps_1.WpsAppType.PRESENTATION);
|
|
1380
|
+
if (response.success) {
|
|
1381
|
+
const transNameMap = {
|
|
1382
|
+
fade: '淡出', push: '推入', wipe: '擦除', split: '拆分',
|
|
1383
|
+
reveal: '揭开', cover: '覆盖', dissolve: '溶解', curtains: '帷幕',
|
|
1384
|
+
};
|
|
1385
|
+
return {
|
|
1386
|
+
id: (0, uuid_1.v4)(),
|
|
1387
|
+
success: true,
|
|
1388
|
+
content: [
|
|
1389
|
+
{
|
|
1390
|
+
type: 'text',
|
|
1391
|
+
text: `切换效果设置成功!\n幻灯片: 第 ${slideIndex} 页\n切换效果: ${transNameMap[transition] || transition}`,
|
|
1392
|
+
},
|
|
1393
|
+
],
|
|
1394
|
+
};
|
|
1395
|
+
}
|
|
1396
|
+
else {
|
|
1397
|
+
return {
|
|
1398
|
+
id: (0, uuid_1.v4)(),
|
|
1399
|
+
success: false,
|
|
1400
|
+
content: [{ type: 'text', text: `设置切换效果失败: ${response.error}` }],
|
|
1401
|
+
error: response.error,
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
catch (error) {
|
|
1406
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1407
|
+
return {
|
|
1408
|
+
id: (0, uuid_1.v4)(),
|
|
1409
|
+
success: false,
|
|
1410
|
+
content: [{ type: 'text', text: `设置切换效果出错: ${errMsg}` }],
|
|
1411
|
+
error: errMsg,
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
};
|
|
1415
|
+
exports.setTransitionHandler = setTransitionHandler;
|
|
1416
|
+
// ============================================================
|
|
1417
|
+
// 20. wps_ppt_add_chart - 在幻灯片中插入图表
|
|
1418
|
+
// ============================================================
|
|
1419
|
+
exports.addChartDefinition = {
|
|
1420
|
+
name: 'wps_ppt_add_chart',
|
|
1421
|
+
description: `在幻灯片中插入图表。
|
|
1422
|
+
|
|
1423
|
+
支持的图表类型:
|
|
1424
|
+
- bar: 柱形图
|
|
1425
|
+
- line: 折线图
|
|
1426
|
+
- pie: 饼图
|
|
1427
|
+
- scatter: 散点图
|
|
1428
|
+
- area: 面积图
|
|
1429
|
+
- doughnut: 圆环图
|
|
1430
|
+
|
|
1431
|
+
使用场景:
|
|
1432
|
+
- "在第1页插入一个柱形图"
|
|
1433
|
+
- "添加饼图展示数据"
|
|
1434
|
+
- "插入折线图显示趋势"`,
|
|
1435
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
1436
|
+
inputSchema: {
|
|
1437
|
+
type: 'object',
|
|
1438
|
+
properties: {
|
|
1439
|
+
slideIndex: {
|
|
1440
|
+
type: 'number',
|
|
1441
|
+
description: '幻灯片索引(从1开始)',
|
|
1442
|
+
},
|
|
1443
|
+
chartType: {
|
|
1444
|
+
type: 'string',
|
|
1445
|
+
description: '图表类型,如 bar, line, pie, scatter, area, doughnut',
|
|
1446
|
+
},
|
|
1447
|
+
data: {
|
|
1448
|
+
type: 'array',
|
|
1449
|
+
description: '图表数据数组,每项包含标签和数值',
|
|
1450
|
+
items: {
|
|
1451
|
+
type: 'object',
|
|
1452
|
+
properties: {
|
|
1453
|
+
label: { type: 'string', description: '数据标签' },
|
|
1454
|
+
value: { type: 'number', description: '数据值' },
|
|
1455
|
+
},
|
|
1456
|
+
},
|
|
1457
|
+
},
|
|
1458
|
+
},
|
|
1459
|
+
required: ['slideIndex', 'chartType', 'data'],
|
|
1460
|
+
},
|
|
1461
|
+
};
|
|
1462
|
+
const addChartHandler = async (args) => {
|
|
1463
|
+
const { slideIndex, chartType, data } = args;
|
|
1464
|
+
try {
|
|
1465
|
+
const response = await wps_client_1.wpsClient.executeMethod('insertPptChart', { slideIndex, chartType, data }, wps_1.WpsAppType.PRESENTATION);
|
|
1466
|
+
if (response.success) {
|
|
1467
|
+
const chartNameMap = {
|
|
1468
|
+
bar: '柱形图', line: '折线图', pie: '饼图', scatter: '散点图',
|
|
1469
|
+
area: '面积图', doughnut: '圆环图',
|
|
1470
|
+
};
|
|
1471
|
+
return {
|
|
1472
|
+
id: (0, uuid_1.v4)(),
|
|
1473
|
+
success: true,
|
|
1474
|
+
content: [
|
|
1475
|
+
{
|
|
1476
|
+
type: 'text',
|
|
1477
|
+
text: `图表插入成功!\n幻灯片: 第 ${slideIndex} 页\n图表类型: ${chartNameMap[chartType] || chartType}\n数据点数: ${data.length}`,
|
|
1478
|
+
},
|
|
1479
|
+
],
|
|
1480
|
+
};
|
|
1481
|
+
}
|
|
1482
|
+
else {
|
|
1483
|
+
return {
|
|
1484
|
+
id: (0, uuid_1.v4)(),
|
|
1485
|
+
success: false,
|
|
1486
|
+
content: [{ type: 'text', text: `插入图表失败: ${response.error}` }],
|
|
1487
|
+
error: response.error,
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
catch (error) {
|
|
1492
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1493
|
+
return {
|
|
1494
|
+
id: (0, uuid_1.v4)(),
|
|
1495
|
+
success: false,
|
|
1496
|
+
content: [{ type: 'text', text: `插入图表出错: ${errMsg}` }],
|
|
1497
|
+
error: errMsg,
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1501
|
+
exports.addChartHandler = addChartHandler;
|
|
1502
|
+
// ============================================================
|
|
1503
|
+
// 21. wps_ppt_set_shape_fill - 设置形状填充颜色
|
|
1504
|
+
// ============================================================
|
|
1505
|
+
exports.setShapeFillDefinition = {
|
|
1506
|
+
name: 'wps_ppt_set_shape_fill',
|
|
1507
|
+
description: `设置幻灯片中指定形状的填充颜色。
|
|
1508
|
+
|
|
1509
|
+
使用场景:
|
|
1510
|
+
- "把第1页的第2个形状填充为红色"
|
|
1511
|
+
- "修改形状背景色为#00FF00"
|
|
1512
|
+
- "设置形状的填充颜色"`,
|
|
1513
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
1514
|
+
inputSchema: {
|
|
1515
|
+
type: 'object',
|
|
1516
|
+
properties: {
|
|
1517
|
+
slideIndex: { type: 'number', description: '幻灯片索引(从1开始)' },
|
|
1518
|
+
shapeIndex: { type: 'number', description: '形状索引(从1开始)' },
|
|
1519
|
+
color: { type: 'string', description: '填充颜色,十六进制如 #FF0000' },
|
|
1520
|
+
},
|
|
1521
|
+
required: ['slideIndex', 'shapeIndex', 'color'],
|
|
1522
|
+
},
|
|
1523
|
+
};
|
|
1524
|
+
const setShapeFillHandler = async (args) => {
|
|
1525
|
+
const { slideIndex, shapeIndex, color } = args;
|
|
1526
|
+
try {
|
|
1527
|
+
const response = await wps_client_1.wpsClient.executeMethod('setShapeFill', // NOTE: 仅Windows支持
|
|
1528
|
+
{ slideIndex, shapeIndex, color }, wps_1.WpsAppType.PRESENTATION);
|
|
1529
|
+
if (response.success) {
|
|
1530
|
+
return {
|
|
1531
|
+
id: (0, uuid_1.v4)(),
|
|
1532
|
+
success: true,
|
|
1533
|
+
content: [
|
|
1534
|
+
{
|
|
1535
|
+
type: 'text',
|
|
1536
|
+
text: `形状填充颜色设置成功!\n幻灯片: 第 ${slideIndex} 页\n形状: 第 ${shapeIndex} 个\n填充颜色: ${color}`,
|
|
1537
|
+
},
|
|
1538
|
+
],
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
else {
|
|
1542
|
+
return {
|
|
1543
|
+
id: (0, uuid_1.v4)(),
|
|
1544
|
+
success: false,
|
|
1545
|
+
content: [{ type: 'text', text: `设置形状填充失败: ${response.error}` }],
|
|
1546
|
+
error: response.error,
|
|
1547
|
+
};
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
catch (error) {
|
|
1551
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1552
|
+
return {
|
|
1553
|
+
id: (0, uuid_1.v4)(),
|
|
1554
|
+
success: false,
|
|
1555
|
+
content: [{ type: 'text', text: `设置形状填充出错: ${errMsg}` }],
|
|
1556
|
+
error: errMsg,
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
};
|
|
1560
|
+
exports.setShapeFillHandler = setShapeFillHandler;
|
|
1561
|
+
// ============================================================
|
|
1562
|
+
// 22. wps_ppt_add_speaker_notes - 添加演讲者备注
|
|
1563
|
+
// ============================================================
|
|
1564
|
+
exports.addSpeakerNotesDefinition = {
|
|
1565
|
+
name: 'wps_ppt_add_speaker_notes',
|
|
1566
|
+
description: `添加或追加演讲者备注到指定幻灯片。
|
|
1567
|
+
|
|
1568
|
+
使用场景:
|
|
1569
|
+
- "给第1页添加演讲者备注"
|
|
1570
|
+
- "在备注中写上提示词"
|
|
1571
|
+
- "追加演讲提示到第3页"`,
|
|
1572
|
+
category: tools_1.ToolCategory.PRESENTATION,
|
|
1573
|
+
inputSchema: {
|
|
1574
|
+
type: 'object',
|
|
1575
|
+
properties: {
|
|
1576
|
+
slideIndex: { type: 'number', description: '幻灯片索引(从1开始)' },
|
|
1577
|
+
notes: { type: 'string', description: '演讲者备注内容' },
|
|
1578
|
+
},
|
|
1579
|
+
required: ['slideIndex', 'notes'],
|
|
1580
|
+
},
|
|
1581
|
+
};
|
|
1582
|
+
const addSpeakerNotesHandler = async (args) => {
|
|
1583
|
+
const { slideIndex, notes } = args;
|
|
1584
|
+
try {
|
|
1585
|
+
const response = await wps_client_1.wpsClient.executeMethod('setSlideNotes', { slideIndex, notes }, wps_1.WpsAppType.PRESENTATION);
|
|
1586
|
+
if (response.success) {
|
|
1587
|
+
return {
|
|
1588
|
+
id: (0, uuid_1.v4)(),
|
|
1589
|
+
success: true,
|
|
1590
|
+
content: [
|
|
1591
|
+
{
|
|
1592
|
+
type: 'text',
|
|
1593
|
+
text: `演讲者备注添加成功!\n幻灯片: 第 ${slideIndex} 页\n备注内容: "${notes.length > 50 ? notes.substring(0, 50) + '...' : notes}"`,
|
|
1594
|
+
},
|
|
1595
|
+
],
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1598
|
+
else {
|
|
1599
|
+
return {
|
|
1600
|
+
id: (0, uuid_1.v4)(),
|
|
1601
|
+
success: false,
|
|
1602
|
+
content: [{ type: 'text', text: `添加演讲者备注失败: ${response.error}` }],
|
|
1603
|
+
error: response.error,
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
catch (error) {
|
|
1608
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
1609
|
+
return {
|
|
1610
|
+
id: (0, uuid_1.v4)(),
|
|
1611
|
+
success: false,
|
|
1612
|
+
content: [{ type: 'text', text: `添加演讲者备注出错: ${errMsg}` }],
|
|
1613
|
+
error: errMsg,
|
|
1614
|
+
};
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1617
|
+
exports.addSpeakerNotesHandler = addSpeakerNotesHandler;
|
|
1618
|
+
// ============================================================
|
|
1619
|
+
// 导出所有幻灯片操作相关的Tools
|
|
1620
|
+
// ============================================================
|
|
1621
|
+
exports.slideOpsTools = [
|
|
1622
|
+
{ definition: exports.deleteSlideDefinition, handler: exports.deleteSlideHandler },
|
|
1623
|
+
{ definition: exports.duplicateSlideDefinition, handler: exports.duplicateSlideHandler },
|
|
1624
|
+
{ definition: exports.moveSlideDefinition, handler: exports.moveSlideHandler },
|
|
1625
|
+
{ definition: exports.getSlideCountDefinition, handler: exports.getSlideCountHandler },
|
|
1626
|
+
{ definition: exports.getSlideInfoDefinition, handler: exports.getSlideInfoHandler },
|
|
1627
|
+
{ definition: exports.switchSlideDefinition, handler: exports.switchSlideHandler },
|
|
1628
|
+
{ definition: exports.setSlideLayoutDefinition, handler: exports.setSlideLayoutHandler },
|
|
1629
|
+
{ definition: exports.getSlideNotesDefinition, handler: exports.getSlideNotesHandler },
|
|
1630
|
+
{ definition: exports.setSlideNotesDefinition, handler: exports.setSlideNotesHandler },
|
|
1631
|
+
{ definition: exports.addShapeDefinition, handler: exports.addShapeHandler },
|
|
1632
|
+
{ definition: exports.setShapeStyleDefinition, handler: exports.setShapeStyleHandler },
|
|
1633
|
+
{ definition: exports.addTextboxDefinition, handler: exports.addTextboxHandler },
|
|
1634
|
+
{ definition: exports.setSlideTitleDefinition, handler: exports.setSlideTitleHandler },
|
|
1635
|
+
{ definition: exports.insertImageDefinition, handler: exports.insertImageHandler },
|
|
1636
|
+
{ definition: exports.setShapeTextDefinition, handler: exports.setShapeTextHandler },
|
|
1637
|
+
{ definition: exports.setAnimationDefinition, handler: exports.setAnimationHandler },
|
|
1638
|
+
{ definition: exports.setBackgroundDefinition, handler: exports.setBackgroundHandler },
|
|
1639
|
+
{ definition: exports.setSlideSizeDefinition, handler: exports.setSlideSizeHandler },
|
|
1640
|
+
{ definition: exports.setTransitionDefinition, handler: exports.setTransitionHandler },
|
|
1641
|
+
{ definition: exports.addChartDefinition, handler: exports.addChartHandler },
|
|
1642
|
+
{ definition: exports.setShapeFillDefinition, handler: exports.setShapeFillHandler },
|
|
1643
|
+
{ definition: exports.addSpeakerNotesDefinition, handler: exports.addSpeakerNotesHandler },
|
|
1644
|
+
];
|
|
1645
|
+
exports.default = exports.slideOpsTools;
|
|
1646
|
+
//# sourceMappingURL=slide-ops.js.map
|