ms-vite-plugin 1.3.2 → 1.3.4

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.
@@ -1,254 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.registerHidTools = registerHidTools;
37
- const fsExtra = __importStar(require("fs-extra"));
38
- const os = __importStar(require("os"));
39
- const path = __importStar(require("path"));
40
- const z = __importStar(require("zod/v4"));
41
- const tool_utils_1 = require("./tool-utils");
42
- /**
43
- * 请求 HID 路由
44
- * @param endpoint HID API 名称
45
- * @param query 可选查询参数
46
- * @returns 返回设备端 JSON 响应
47
- * @example
48
- * const payload = await requestHidApi("home")
49
- */
50
- async function requestHidApi(endpoint, query) {
51
- const target = await (0, tool_utils_1.resolveRuntimeHttpTarget)();
52
- return (0, tool_utils_1.requestRuntimePathJson)(target, `/api/hid/${endpoint}`, query);
53
- }
54
- /**
55
- * 格式化 HID 类 JSON 响应
56
- * @param actionName 操作名称
57
- * @param payload 设备端响应
58
- * @returns 返回标准文本工具响应
59
- * @example
60
- * formatHidResult("打开录屏", { success: true })
61
- */
62
- function formatHidResult(actionName, payload) {
63
- const success = payload.success === true;
64
- if ("data" in payload) {
65
- return (0, tool_utils_1.createTextToolResult)(`${actionName}${success ? "成功" : "失败"}:\n${(0, tool_utils_1.formatRuntimeJsonText)(payload.data)}`, !success);
66
- }
67
- return (0, tool_utils_1.createTextToolResult)(`${actionName}${success ? "成功" : "失败"}`, !success);
68
- }
69
- /**
70
- * 注册 HID API 对应 MCP 工具
71
- * @param server MCP 服务实例
72
- * @returns 无返回值
73
- * @example
74
- * registerHidTools(server)
75
- */
76
- function registerHidTools(server) {
77
- server.registerTool("hid_shortcut_screenshot", {
78
- title: "HID Shortcut Screenshot",
79
- description: "获取快捷指令截图。可返回 base64,或落地到文件后返回文件路径(默认写入系统临时目录)。",
80
- inputSchema: {
81
- format: z
82
- .enum(["file", "base64"])
83
- .optional()
84
- .default("file")
85
- .describe("截图返回格式:file=文件路径,base64=图片 base64"),
86
- outputPath: z
87
- .string()
88
- .min(1)
89
- .optional()
90
- .describe("当 format=file 时可指定输出路径,不传则写入系统临时目录"),
91
- },
92
- }, async ({ format, outputPath }) => {
93
- const target = await (0, tool_utils_1.resolveRuntimeHttpTarget)();
94
- const payload = await requestHidApi("shortcutScreenshotBase64");
95
- const success = payload.success === true;
96
- const base64 = typeof payload.data === "string" && payload.data ? payload.data : null;
97
- if (!success || !base64) {
98
- return (0, tool_utils_1.createTextToolResult)("快捷指令截图失败", true);
99
- }
100
- if (format === "base64") {
101
- return (0, tool_utils_1.createTextToolResult)(`快捷指令截图成功: ${target.label}\nformat: base64\n${base64}`);
102
- }
103
- const buffer = Buffer.from(base64, "base64");
104
- const targetPath = outputPath && outputPath.trim()
105
- ? path.resolve(outputPath.trim())
106
- : path.join(os.tmpdir(), `ms-mcp-hid-shortcut-screenshot-${Date.now()}-${Math.random()
107
- .toString(36)
108
- .slice(2, 8)}.jpg`);
109
- await fsExtra.ensureDir(path.dirname(targetPath));
110
- await fsExtra.writeFile(targetPath, buffer);
111
- return (0, tool_utils_1.createTextToolResult)(`快捷指令截图成功: ${target.label}\nformat: file\npath: ${targetPath}\nsize: ${buffer.length} bytes`);
112
- });
113
- server.registerTool("hid_open_record_screen", {
114
- title: "HID Open Record Screen",
115
- description: "打开录屏界面。",
116
- inputSchema: {},
117
- }, async () => formatHidResult("打开录屏界面", await requestHidApi("openRecordScreen")));
118
- server.registerTool("hid_is_recording", {
119
- title: "HID Is Recording",
120
- description: "检查是否正在录屏。",
121
- inputSchema: {},
122
- }, async () => formatHidResult("查询录屏状态", await requestHidApi("isRecording")));
123
- server.registerTool("hid_move", {
124
- title: "HID Move",
125
- description: "移动指针。",
126
- inputSchema: {
127
- x: z.number().int().describe("目标坐标 x"),
128
- y: z.number().int().describe("目标坐标 y"),
129
- },
130
- }, async ({ x, y }) => formatHidResult("移动指针", await requestHidApi("move", { x, y })));
131
- server.registerTool("hid_click", {
132
- title: "HID Click",
133
- description: "点击指针。",
134
- inputSchema: {
135
- x: z.number().int().describe("点击坐标 x"),
136
- y: z.number().int().describe("点击坐标 y"),
137
- duration: z
138
- .number()
139
- .int()
140
- .min(0)
141
- .optional()
142
- .describe("按压时长,默认 20"),
143
- jitter: z.boolean().optional().describe("是否启用抖动,默认 false"),
144
- },
145
- }, async ({ x, y, duration, jitter }) => formatHidResult("点击指针", await requestHidApi("click", { x, y, duration, jitter })));
146
- server.registerTool("hid_double_click", {
147
- title: "HID Double Click",
148
- description: "双击指针。",
149
- inputSchema: {
150
- x: z.number().int().describe("双击坐标 x"),
151
- y: z.number().int().describe("双击坐标 y"),
152
- duration: z
153
- .number()
154
- .int()
155
- .min(0)
156
- .optional()
157
- .describe("单次按压时长,默认 20"),
158
- interval: z
159
- .number()
160
- .int()
161
- .min(0)
162
- .optional()
163
- .describe("两次点击间隔,默认 100"),
164
- jitter: z.boolean().optional().describe("是否启用抖动,默认 false"),
165
- },
166
- }, async ({ x, y, duration, interval, jitter }) => formatHidResult("双击指针", await requestHidApi("doubleClick", {
167
- x,
168
- y,
169
- duration,
170
- interval,
171
- jitter,
172
- })));
173
- server.registerTool("hid_swipe", {
174
- title: "HID Swipe",
175
- description: "滑动指针。",
176
- inputSchema: {
177
- startX: z.number().int().describe("起点 x"),
178
- startY: z.number().int().describe("起点 y"),
179
- endX: z.number().int().describe("终点 x"),
180
- endY: z.number().int().describe("终点 y"),
181
- jitter: z.boolean().optional().describe("是否启用抖动,默认 true"),
182
- steps: z.number().int().min(1).optional().describe("分段步数,默认 10"),
183
- },
184
- }, async ({ startX, startY, endX, endY, jitter, steps }) => formatHidResult("滑动指针", await requestHidApi("swipe", {
185
- startX,
186
- startY,
187
- endX,
188
- endY,
189
- jitter,
190
- steps,
191
- })));
192
- server.registerTool("hid_home", {
193
- title: "HID Home",
194
- description: "返回桌面。",
195
- inputSchema: {},
196
- }, async () => formatHidResult("返回桌面", await requestHidApi("home")));
197
- server.registerTool("hid_recent", {
198
- title: "HID Recent",
199
- description: "打开 App 切换器。",
200
- inputSchema: {},
201
- }, async () => formatHidResult("打开最近任务", await requestHidApi("recent")));
202
- server.registerTool("hid_open_url", {
203
- title: "HID Open URL",
204
- description: "通过 HID 打开 URL。",
205
- inputSchema: {
206
- url: z.string().min(1).describe("目标 URL"),
207
- },
208
- }, async ({ url }) => formatHidResult("打开 URL", await requestHidApi("openURL", { url })));
209
- server.registerTool("hid_open_app", {
210
- title: "HID Open App",
211
- description: "打开应用。",
212
- inputSchema: {
213
- name: z.string().min(1).describe("应用名称或标识"),
214
- },
215
- }, async ({ name }) => formatHidResult("打开应用", await requestHidApi("openApp", { name })));
216
- server.registerTool("hid_close_app", {
217
- title: "HID Close App",
218
- description: "关闭应用。",
219
- inputSchema: {
220
- name: z.string().min(1).describe("应用名称或标识"),
221
- },
222
- }, async ({ name }) => formatHidResult("关闭应用", await requestHidApi("closeApp", { name })));
223
- server.registerTool("hid_current_app_info", {
224
- title: "HID Current App Info",
225
- description: "获取当前应用信息。",
226
- inputSchema: {},
227
- }, async () => formatHidResult("获取当前应用信息", await requestHidApi("currentAppInfo")));
228
- server.registerTool("hid_input", {
229
- title: "HID Input",
230
- description: "执行输入。",
231
- inputSchema: {
232
- text: z.string().min(1).describe("待输入文本"),
233
- },
234
- }, async ({ text }) => formatHidResult("输入文本", await requestHidApi("input", { text })));
235
- server.registerTool("hid_input_simple", {
236
- title: "HID Input Simple",
237
- description: "执行简单输入。",
238
- inputSchema: {
239
- text: z.string().min(1).describe("待输入文本"),
240
- },
241
- }, async ({ text }) => formatHidResult("简单输入", await requestHidApi("inputSimple", { text })));
242
- server.registerTool("hid_backspace", {
243
- title: "HID Backspace",
244
- description: "执行退格。",
245
- inputSchema: {
246
- count: z.number().int().min(1).optional().describe("退格次数,默认 1"),
247
- },
248
- }, async ({ count }) => formatHidResult("退格", await requestHidApi("backspace", { count })));
249
- server.registerTool("hid_enter", {
250
- title: "HID Enter",
251
- description: "执行回车。",
252
- inputSchema: {},
253
- }, async () => formatHidResult("回车", await requestHidApi("enter")));
254
- }
@@ -1,9 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- /**
3
- * 注册 IME API 对应 MCP 工具
4
- * @param server MCP 服务实例
5
- * @returns 无返回值
6
- * @example
7
- * registerImeTools(server)
8
- */
9
- export declare function registerImeTools(server: McpServer): void;
@@ -1,130 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.registerImeTools = registerImeTools;
37
- const z = __importStar(require("zod/v4"));
38
- const tool_utils_1 = require("./tool-utils");
39
- /**
40
- * 请求 IME 路由
41
- * @param endpoint IME API 名称
42
- * @param query 可选查询参数
43
- * @returns 返回设备端 JSON 响应
44
- * @example
45
- * const payload = await requestImeApi("getText")
46
- */
47
- async function requestImeApi(endpoint, query) {
48
- const target = await (0, tool_utils_1.resolveRuntimeHttpTarget)();
49
- return (0, tool_utils_1.requestRuntimePathJson)(target, `/api/ime/${endpoint}`, query);
50
- }
51
- /**
52
- * 格式化 IME 类 JSON 响应
53
- * @param actionName 操作名称
54
- * @param payload 设备端响应
55
- * @returns 返回标准文本工具响应
56
- * @example
57
- * formatImeResult("获取文本", { success: true, data: "hello" })
58
- */
59
- function formatImeResult(actionName, payload) {
60
- const success = payload.success === true;
61
- if ("data" in payload) {
62
- return (0, tool_utils_1.createTextToolResult)(`${actionName}${success ? "成功" : "失败"}:\n${(0, tool_utils_1.formatRuntimeJsonText)(payload.data)}`, !success);
63
- }
64
- return (0, tool_utils_1.createTextToolResult)(`${actionName}${success ? "成功" : "失败"}`, !success);
65
- }
66
- /**
67
- * 注册 IME API 对应 MCP 工具
68
- * @param server MCP 服务实例
69
- * @returns 无返回值
70
- * @example
71
- * registerImeTools(server)
72
- */
73
- function registerImeTools(server) {
74
- server.registerTool("ime_is_ok", {
75
- title: "IME Is OK",
76
- description: "检查 IME 是否可用。",
77
- inputSchema: {},
78
- }, async () => formatImeResult("检查 IME", await requestImeApi("isOk")));
79
- server.registerTool("ime_input", {
80
- title: "IME Input",
81
- description: "执行输入。",
82
- inputSchema: {
83
- text: z.string().min(1).describe("待输入文本"),
84
- },
85
- }, async ({ text }) => formatImeResult("输入文本", await requestImeApi("input", { text })));
86
- server.registerTool("ime_get_text", {
87
- title: "IME Get Text",
88
- description: "获取当前输入文本。",
89
- inputSchema: {},
90
- }, async () => formatImeResult("获取当前文本", await requestImeApi("getText")));
91
- server.registerTool("ime_clear_text", {
92
- title: "IME Clear Text",
93
- description: "清除当前输入文本。",
94
- inputSchema: {},
95
- }, async () => formatImeResult("清除文本", await requestImeApi("clearText")));
96
- server.registerTool("ime_paste", {
97
- title: "IME Paste",
98
- description: "粘贴文本。",
99
- inputSchema: {
100
- text: z.string().optional().default("").describe("待粘贴文本,可为空字符串"),
101
- },
102
- }, async ({ text }) => formatImeResult("粘贴文本", await requestImeApi("paste", { text })));
103
- server.registerTool("ime_press_del", {
104
- title: "IME Press Delete",
105
- description: "按下删除键。",
106
- inputSchema: {},
107
- }, async () => formatImeResult("删除字符", await requestImeApi("pressDel")));
108
- server.registerTool("ime_press_enter", {
109
- title: "IME Press Enter",
110
- description: "按下回车键。",
111
- inputSchema: {},
112
- }, async () => formatImeResult("按下回车", await requestImeApi("pressEnter")));
113
- server.registerTool("ime_dismiss", {
114
- title: "IME Dismiss",
115
- description: "隐藏 IME。",
116
- inputSchema: {},
117
- }, async () => formatImeResult("隐藏 IME", await requestImeApi("dismiss")));
118
- server.registerTool("ime_get_clipboard", {
119
- title: "IME Get Clipboard",
120
- description: "获取剪贴板内容。",
121
- inputSchema: {},
122
- }, async () => formatImeResult("获取剪贴板", await requestImeApi("getClipboard")));
123
- server.registerTool("ime_set_clipboard", {
124
- title: "IME Set Clipboard",
125
- description: "设置剪贴板内容。",
126
- inputSchema: {
127
- text: z.string().min(1).describe("剪贴板文本"),
128
- },
129
- }, async ({ text }) => formatImeResult("设置剪贴板", await requestImeApi("setClipboard", { text })));
130
- }
@@ -1,9 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- /**
3
- * 注册镜像流相关 MCP 工具
4
- * @param server MCP 服务实例
5
- * @returns 无返回值
6
- * @example
7
- * registerMirrorTools(server)
8
- */
9
- export declare function registerMirrorTools(server: McpServer): void;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.registerMirrorTools = registerMirrorTools;
37
- const z = __importStar(require("zod/v4"));
38
- const tool_utils_1 = require("./tool-utils");
39
- /**
40
- * 注册镜像流相关 MCP 工具
41
- * @param server MCP 服务实例
42
- * @returns 无返回值
43
- * @example
44
- * registerMirrorTools(server)
45
- */
46
- function registerMirrorTools(server) {
47
- server.registerTool("get_mirror_mjpeg_url", {
48
- title: "Get Mirror MJPEG URL",
49
- description: "生成设备镜像 MJPEG 流地址。MCP 普通文本/图片响应不适合持续显示 MJPEG,建议将返回 URL 交给浏览器或支持 MJPEG 的查看器打开。",
50
- inputSchema: {
51
- fps: z.number().int().min(1).max(60).optional().default(10).describe("帧率,默认 10"),
52
- quality: z
53
- .number()
54
- .min(0.1)
55
- .max(1)
56
- .optional()
57
- .default(0.25)
58
- .describe("压缩质量,默认 0.25"),
59
- scalingFactor: z
60
- .number()
61
- .min(0.1)
62
- .max(1)
63
- .optional()
64
- .default(1)
65
- .describe("缩放因子,默认 1.0"),
66
- },
67
- }, async ({ fps, quality, scalingFactor }) => {
68
- const target = await (0, tool_utils_1.resolveRuntimeHttpTarget)();
69
- const url = new URL(`http://${target.ip}:${target.port}/mirror/image`);
70
- url.searchParams.set("fps", String(fps));
71
- url.searchParams.set("quality", String(quality));
72
- url.searchParams.set("scalingFactor", String(scalingFactor));
73
- return (0, tool_utils_1.createTextToolResult)([
74
- `MJPEG 地址: ${url.toString()}`,
75
- `设备: ${target.label}`,
76
- `fps: ${fps}`,
77
- `quality: ${quality}`,
78
- `scalingFactor: ${scalingFactor}`,
79
- "说明: MCP 工具本身不适合持续渲染 MJPEG 流,建议把这个地址交给浏览器或支持 MJPEG 的播放器打开。",
80
- ].join("\n"));
81
- });
82
- }