vite-plugin-opencode-assistant 1.1.24 → 1.1.26

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,6 +1,8 @@
1
1
  import type { ViteDevServer } from "vite";
2
2
  import type { EndpointContext } from "./types";
3
+ import { MCP_API_PATH } from "./mcp";
4
+ import type { McpProxy } from "../core/mcp-proxy";
3
5
  import { LOGS_API_PATH } from "@vite-plugin-opencode-assistant/shared";
4
6
  export * from "./types";
5
- export { LOGS_API_PATH };
6
- export declare function setupMiddlewares(server: ViteDevServer, ctx: EndpointContext): void;
7
+ export { LOGS_API_PATH, MCP_API_PATH };
8
+ export declare function setupMiddlewares(server: ViteDevServer, ctx: EndpointContext, mcp?: McpProxy): void;
@@ -0,0 +1,541 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, { get: all[name], enumerable: true });
22
+ };
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") {
25
+ for (let key of __getOwnPropNames(from))
26
+ if (!__hasOwnProp.call(to, key) && key !== except)
27
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28
+ }
29
+ return to;
30
+ };
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+ var mcp_tools_exports = {};
33
+ __export(mcp_tools_exports, {
34
+ CUSTOM_TOOLS: () => CUSTOM_TOOLS,
35
+ TOOL_MAP: () => TOOL_MAP
36
+ });
37
+ module.exports = __toCommonJS(mcp_tools_exports);
38
+ const PAGE_ID_PROP = {
39
+ pageId: { type: "number", description: "\u76EE\u6807\u9875\u9762 ID\uFF08\u4ECE devtools_list_pages \u83B7\u53D6\uFF09" }
40
+ };
41
+ function withPageId(properties, required = []) {
42
+ return {
43
+ properties: __spreadValues(__spreadValues({}, PAGE_ID_PROP), properties),
44
+ required: ["pageId", ...required]
45
+ };
46
+ }
47
+ const CUSTOM_TOOLS = [
48
+ // ===== 页面管理 =====
49
+ {
50
+ name: "devtools_list_pages",
51
+ description: "\u83B7\u53D6\u5F53\u524D\u9879\u76EE\u6240\u6709\u6253\u5F00\u7684\u9875\u9762\u5217\u8868\uFF0C\u542B active\uFF08\u7528\u6237\u6B63\u5728\u6D4F\u89C8\uFF09\u548C selected\uFF08Chrome DevTools \u5F53\u524D\u64CD\u4F5C\u76EE\u6807\uFF09\u6807\u8BB0",
52
+ inputSchema: {
53
+ type: "object",
54
+ properties: {}
55
+ }
56
+ },
57
+ // ===== 截图与快照 =====
58
+ {
59
+ name: "devtools_snapshot",
60
+ description: "\u83B7\u53D6\u6307\u5B9A\u9875\u9762\u53EF\u8BBF\u95EE\u6027\u6811\u5FEB\u7167\uFF0C\u8FD4\u56DE\u5143\u7D20 uid\u3001\u89D2\u8272\u3001\u6587\u672C\u7B49",
61
+ inputSchema: __spreadValues({
62
+ type: "object"
63
+ }, withPageId({
64
+ verbose: { type: "boolean", description: "\u662F\u5426\u83B7\u53D6\u5B8C\u6574 a11y \u6811\u4FE1\u606F\uFF0C\u9ED8\u8BA4 false" },
65
+ filePath: { type: "string", description: "\u4FDD\u5B58\u5FEB\u7167\u7684\u6587\u4EF6\u8DEF\u5F84\uFF0C\u7701\u7565\u5219\u5185\u8054\u8FD4\u56DE" }
66
+ }))
67
+ },
68
+ {
69
+ name: "devtools_screenshot",
70
+ description: "\u622A\u53D6\u6307\u5B9A\u9875\u9762\u6216\u5143\u7D20\u5C4F\u5E55\u622A\u56FE\uFF0C\u8FD4\u56DE base64 \u6216\u4FDD\u5B58\u5230\u6587\u4EF6",
71
+ inputSchema: __spreadValues({
72
+ type: "object"
73
+ }, withPageId({
74
+ format: {
75
+ type: "string",
76
+ enum: ["png", "jpeg", "webp"],
77
+ description: "\u56FE\u7247\u683C\u5F0F\uFF0C\u9ED8\u8BA4 png"
78
+ },
79
+ quality: {
80
+ type: "number",
81
+ minimum: 0,
82
+ maximum: 100,
83
+ description: "JPEG/WebP \u538B\u7F29\u8D28\u91CF 0-100"
84
+ },
85
+ uid: { type: "string", description: "\u5143\u7D20 uid\uFF08\u4ECE devtools_snapshot \u83B7\u53D6\uFF09\uFF0C\u7701\u7565\u622A\u53D6\u6574\u9875" },
86
+ fullPage: { type: "boolean", description: "\u662F\u5426\u622A\u53D6\u5B8C\u6574\u9875\u9762\uFF08\u4E0E uid \u4E92\u65A5\uFF09" },
87
+ filePath: { type: "string", description: "\u4FDD\u5B58\u622A\u56FE\u7684\u6587\u4EF6\u8DEF\u5F84\uFF0C\u7701\u7565\u8FD4\u56DE base64" }
88
+ }))
89
+ },
90
+ // ===== 交互操作 =====
91
+ {
92
+ name: "devtools_click",
93
+ description: "\u70B9\u51FB\u9875\u9762\u5143\u7D20",
94
+ inputSchema: __spreadValues({
95
+ type: "object"
96
+ }, withPageId(
97
+ {
98
+ uid: { type: "string", description: "\u5143\u7D20 uid\uFF08\u4ECE devtools_snapshot \u83B7\u53D6\uFF09" },
99
+ dblClick: { type: "boolean", description: "\u662F\u5426\u53CC\u51FB\uFF0C\u9ED8\u8BA4 false" },
100
+ includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
101
+ },
102
+ ["uid"]
103
+ ))
104
+ },
105
+ {
106
+ name: "devtools_hover",
107
+ description: "\u9F20\u6807\u60AC\u505C\u5728\u9875\u9762\u5143\u7D20\u4E0A",
108
+ inputSchema: __spreadValues({
109
+ type: "object"
110
+ }, withPageId(
111
+ {
112
+ uid: { type: "string", description: "\u5143\u7D20 uid" },
113
+ includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
114
+ },
115
+ ["uid"]
116
+ ))
117
+ },
118
+ {
119
+ name: "devtools_drag",
120
+ description: "\u62D6\u62FD\u9875\u9762\u5143\u7D20\u5230\u53E6\u4E00\u4E2A\u5143\u7D20\u4E0A",
121
+ inputSchema: __spreadValues({
122
+ type: "object"
123
+ }, withPageId(
124
+ {
125
+ from_uid: { type: "string", description: "\u88AB\u62D6\u62FD\u5143\u7D20\u7684 uid" },
126
+ to_uid: { type: "string", description: "\u76EE\u6807\u653E\u7F6E\u5143\u7D20\u7684 uid" },
127
+ includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
128
+ },
129
+ ["from_uid", "to_uid"]
130
+ ))
131
+ },
132
+ {
133
+ name: "devtools_type",
134
+ description: "\u5728\u5DF2\u805A\u7126\u7684\u8F93\u5165\u6846\u4E2D\u4F7F\u7528\u952E\u76D8\u8F93\u5165\u6587\u672C",
135
+ inputSchema: __spreadValues({
136
+ type: "object"
137
+ }, withPageId(
138
+ {
139
+ text: { type: "string", description: "\u8981\u8F93\u5165\u7684\u6587\u672C" },
140
+ submitKey: {
141
+ type: "string",
142
+ description: '\u8F93\u5165\u540E\u6309\u4E0B\u7684\u6309\u952E\uFF0C\u5982 "Enter"\u3001"Tab"\u3001"Escape"'
143
+ }
144
+ },
145
+ ["text"]
146
+ ))
147
+ },
148
+ {
149
+ name: "devtools_press_key",
150
+ description: "\u6309\u4E0B\u952E\u76D8\u6309\u952E\u6216\u7EC4\u5408\u952E\uFF08\u5FEB\u6377\u952E\u3001\u5BFC\u822A\u952E\u7B49\uFF09",
151
+ inputSchema: __spreadValues({
152
+ type: "object"
153
+ }, withPageId(
154
+ {
155
+ key: {
156
+ type: "string",
157
+ description: '\u6309\u952E\u6216\u7EC4\u5408\u952E\uFF0C\u5982 "Enter"\u3001"Control+A"\u3002\u4FEE\u9970\u952E: Control, Shift, Alt, Meta'
158
+ },
159
+ includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
160
+ },
161
+ ["key"]
162
+ ))
163
+ },
164
+ {
165
+ name: "devtools_fill",
166
+ description: "\u586B\u5199\u8F93\u5165\u6846\u503C\u6216\u9009\u62E9 select \u9009\u9879\uFF0C\u89E6\u53D1 input/change \u4E8B\u4EF6",
167
+ inputSchema: __spreadValues({
168
+ type: "object"
169
+ }, withPageId(
170
+ {
171
+ uid: { type: "string", description: "\u8F93\u5165\u6846/select \u5143\u7D20 uid" },
172
+ value: {
173
+ type: "string",
174
+ description: '\u8981\u586B\u5165\u7684\u503C\u3002checkbox/toggle \u7528 "true"/"false"\uFF0Cradio \u7528 "true"'
175
+ },
176
+ includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
177
+ },
178
+ ["uid", "value"]
179
+ ))
180
+ },
181
+ {
182
+ name: "devtools_fill_form",
183
+ description: "\u6279\u91CF\u586B\u5199\u8868\u5355\u5B57\u6BB5\uFF0C\u6BD4\u591A\u6B21\u8C03\u7528 fill/click \u66F4\u5FEB\u66F4\u53EF\u9760",
184
+ inputSchema: __spreadValues({
185
+ type: "object"
186
+ }, withPageId(
187
+ {
188
+ elements: {
189
+ type: "array",
190
+ items: {
191
+ type: "object",
192
+ properties: { uid: { type: "string" }, value: { type: "string" } }
193
+ },
194
+ description: "\u8868\u5355\u5143\u7D20\u6570\u7EC4 [{ uid, value }]"
195
+ },
196
+ includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
197
+ },
198
+ ["elements"]
199
+ ))
200
+ },
201
+ // ===== 页面导航 =====
202
+ {
203
+ name: "devtools_navigate",
204
+ description: "\u5BFC\u822A\u9875\u9762\uFF08url/reload/back/forward\uFF09",
205
+ inputSchema: __spreadValues({
206
+ type: "object"
207
+ }, withPageId(
208
+ {
209
+ type: {
210
+ type: "string",
211
+ enum: ["url", "back", "forward", "reload"],
212
+ description: "\u5BFC\u822A\u7C7B\u578B"
213
+ },
214
+ url: { type: "string", description: "\u76EE\u6807 URL\uFF08type=url \u65F6\u5FC5\u586B\uFF09" },
215
+ ignoreCache: { type: "boolean", description: "reload \u65F6\u662F\u5426\u5FFD\u7565\u7F13\u5B58" },
216
+ handleBeforeUnload: {
217
+ type: "string",
218
+ enum: ["accept", "dismiss"],
219
+ description: "beforeunload \u5BF9\u8BDD\u6846\u5904\u7406\u65B9\u5F0F"
220
+ },
221
+ initScript: {
222
+ type: "string",
223
+ description: "\u4E0B\u4E00\u6B21\u5BFC\u822A\u65F6\uFF0C\u5728\u6BCF\u4E2A\u65B0 document \u52A0\u8F7D\u524D\u6267\u884C\u7684 JS \u811A\u672C"
224
+ },
225
+ timeout: { type: "integer", description: "\u6700\u5927\u7B49\u5F85\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C0 \u4F7F\u7528\u9ED8\u8BA4\u8D85\u65F6" }
226
+ },
227
+ ["type"]
228
+ ))
229
+ },
230
+ {
231
+ name: "devtools_resize_page",
232
+ description: "\u8C03\u6574\u9875\u9762\u89C6\u53E3\u5927\u5C0F",
233
+ inputSchema: __spreadValues({
234
+ type: "object"
235
+ }, withPageId(
236
+ {
237
+ width: { type: "number", description: "\u89C6\u53E3\u5BBD\u5EA6" },
238
+ height: { type: "number", description: "\u89C6\u53E3\u9AD8\u5EA6" }
239
+ },
240
+ ["width", "height"]
241
+ ))
242
+ },
243
+ {
244
+ name: "devtools_emulate",
245
+ description: "\u6A21\u62DF\u8BBE\u5907\u7279\u6027\uFF08\u7F51\u7EDC\u8282\u6D41\u3001CPU \u964D\u901F\u3001\u5730\u7406\u4F4D\u7F6E\u3001UA\u3001\u989C\u8272\u65B9\u6848\u3001\u89C6\u53E3\u7B49\uFF09",
246
+ inputSchema: __spreadValues({
247
+ type: "object"
248
+ }, withPageId({
249
+ networkConditions: {
250
+ type: "string",
251
+ enum: ["Offline", "Slow 3G", "Fast 3G", "Slow 4G", "Fast 4G"],
252
+ description: "\u7F51\u7EDC\u8282\u6D41\u6A21\u5F0F"
253
+ },
254
+ cpuThrottlingRate: {
255
+ type: "number",
256
+ minimum: 1,
257
+ maximum: 20,
258
+ description: "CPU \u964D\u901F\u500D\u6570\uFF0C1 \u4E0D\u964D\u901F"
259
+ },
260
+ geolocation: { type: "string", description: "\u5730\u7406\u4F4D\u7F6E\uFF0C\u683C\u5F0F `<\u7EAC\u5EA6>,<\u7ECF\u5EA6>`" },
261
+ userAgent: { type: "string", description: "UA \u5B57\u7B26\u4E32\uFF0C\u7A7A\u5B57\u7B26\u4E32\u6E05\u9664" },
262
+ colorScheme: {
263
+ type: "string",
264
+ enum: ["dark", "light", "auto"],
265
+ description: '\u989C\u8272\u65B9\u6848\uFF0C"auto" \u6062\u590D\u9ED8\u8BA4'
266
+ },
267
+ viewport: {
268
+ type: "string",
269
+ description: "\u89C6\u53E3\u6A21\u62DF\uFF0C\u683C\u5F0F `<\u5BBD>x<\u9AD8>x<\u7F29\u653E\u6BD4>[,mobile][,touch][,landscape]`"
270
+ },
271
+ extraHttpHeaders: {
272
+ type: "string",
273
+ description: `\u989D\u5916 HTTP \u8BF7\u6C42\u5934 JSON\uFF0C\u5982 '{"X-Custom":"value"}'`
274
+ }
275
+ }))
276
+ },
277
+ // ===== JS 执行 =====
278
+ {
279
+ name: "devtools_evaluate",
280
+ description: "\u5728\u6307\u5B9A\u9875\u9762\u6267\u884C JavaScript \u51FD\u6570\u5E76\u8FD4\u56DE\u7ED3\u679C\uFF08\u8FD4\u56DE\u503C\u9700\u53EF JSON \u5E8F\u5217\u5316\uFF09",
281
+ inputSchema: __spreadValues({
282
+ type: "object"
283
+ }, withPageId(
284
+ {
285
+ function: {
286
+ type: "string",
287
+ description: "JS \u51FD\u6570\u58F0\u660E\u3002\u65E0\u53C2\u6570: `() => document.title`\uFF0C\u6709\u53C2\u6570: `(el) => el.innerText`"
288
+ },
289
+ args: {
290
+ type: "array",
291
+ items: { type: "string" },
292
+ description: "\u4F20\u7ED9\u51FD\u6570\u7684\u53C2\u6570\u5217\u8868\uFF08\u5143\u7D20 uid\uFF09"
293
+ },
294
+ filePath: { type: "string", description: "\u4FDD\u5B58\u8F93\u51FA\u5230\u6587\u4EF6\uFF0C\u7701\u7565\u5219\u5185\u8054\u8FD4\u56DE" },
295
+ dialogAction: {
296
+ type: "string",
297
+ description: '\u5BF9\u8BDD\u6846\u5904\u7406: "accept"\u3001"dismiss" \u6216 prompt \u6587\u672C'
298
+ }
299
+ },
300
+ ["function"]
301
+ ))
302
+ },
303
+ // ===== 网络监控 =====
304
+ {
305
+ name: "devtools_network",
306
+ description: "\u83B7\u53D6\u6307\u5B9A\u9875\u9762\u7F51\u7EDC\u8BF7\u6C42\u5217\u8868\uFF08\u652F\u6301\u5206\u9875\u548C\u8FC7\u6EE4\uFF09",
307
+ inputSchema: __spreadValues({
308
+ type: "object"
309
+ }, withPageId({
310
+ pageSize: { type: "integer", description: "\u6BCF\u9875\u6700\u5927\u8BF7\u6C42\u6570" },
311
+ pageIdx: { type: "integer", minimum: 0, description: "\u9875\u7801\uFF08\u4ECE 0 \u5F00\u59CB\uFF09" },
312
+ resourceTypes: {
313
+ type: "array",
314
+ items: {
315
+ type: "string",
316
+ enum: [
317
+ "document",
318
+ "stylesheet",
319
+ "image",
320
+ "media",
321
+ "font",
322
+ "script",
323
+ "xhr",
324
+ "fetch",
325
+ "websocket",
326
+ "manifest",
327
+ "other"
328
+ ]
329
+ },
330
+ description: "\u6309\u8D44\u6E90\u7C7B\u578B\u8FC7\u6EE4"
331
+ },
332
+ includePreservedRequests: {
333
+ type: "boolean",
334
+ description: "\u662F\u5426\u8FD4\u56DE\u6700\u8FD1 3 \u6B21\u5BFC\u822A\u7684\u4FDD\u7559\u8BF7\u6C42"
335
+ }
336
+ }))
337
+ },
338
+ {
339
+ name: "devtools_network_request",
340
+ description: "\u83B7\u53D6\u7F51\u7EDC\u8BF7\u6C42\u7684\u8BE6\u7EC6\u4FE1\u606F\uFF0C\u53EF\u4FDD\u5B58\u8BF7\u6C42/\u54CD\u5E94\u4F53\u5230\u6587\u4EF6",
341
+ inputSchema: __spreadValues({
342
+ type: "object"
343
+ }, withPageId({
344
+ reqid: {
345
+ type: "number",
346
+ description: "\u8BF7\u6C42 ID\uFF08\u4ECE devtools_network \u83B7\u53D6\uFF09\uFF0C\u7701\u7565\u8FD4\u56DE\u5F53\u524D\u9009\u4E2D\u8BF7\u6C42"
347
+ },
348
+ requestFilePath: {
349
+ type: "string",
350
+ description: "\u4FDD\u5B58\u8BF7\u6C42\u4F53\u5230 .network-request \u6587\u4EF6\u7684\u8DEF\u5F84"
351
+ },
352
+ responseFilePath: {
353
+ type: "string",
354
+ description: "\u4FDD\u5B58\u54CD\u5E94\u4F53\u5230 .network-response \u6587\u4EF6\u7684\u8DEF\u5F84"
355
+ }
356
+ }))
357
+ },
358
+ // ===== 控制台 =====
359
+ {
360
+ name: "devtools_console",
361
+ description: "\u83B7\u53D6\u6307\u5B9A\u9875\u9762\u63A7\u5236\u53F0\u6D88\u606F\uFF08\u652F\u6301\u5206\u9875\u548C\u8FC7\u6EE4\uFF09",
362
+ inputSchema: __spreadValues({
363
+ type: "object"
364
+ }, withPageId({
365
+ pageSize: { type: "integer", description: "\u6BCF\u9875\u6700\u5927\u6D88\u606F\u6570" },
366
+ pageIdx: { type: "integer", minimum: 0, description: "\u9875\u7801\uFF08\u4ECE 0 \u5F00\u59CB\uFF09" },
367
+ types: {
368
+ type: "array",
369
+ items: {
370
+ type: "string",
371
+ enum: ["log", "debug", "info", "error", "warn", "trace", "verbose", "issue"]
372
+ },
373
+ description: "\u6309\u6D88\u606F\u7C7B\u578B\u8FC7\u6EE4"
374
+ },
375
+ includePreservedMessages: {
376
+ type: "boolean",
377
+ description: "\u662F\u5426\u8FD4\u56DE\u6700\u8FD1 3 \u6B21\u5BFC\u822A\u7684\u4FDD\u7559\u6D88\u606F"
378
+ },
379
+ serviceWorkerId: { type: "string", description: "\u6309 service worker ID \u8FC7\u6EE4" }
380
+ }))
381
+ },
382
+ {
383
+ name: "devtools_console_message",
384
+ description: "\u83B7\u53D6\u67D0\u6761\u63A7\u5236\u53F0\u6D88\u606F\u7684\u8BE6\u7EC6\u4FE1\u606F",
385
+ inputSchema: __spreadValues({
386
+ type: "object"
387
+ }, withPageId(
388
+ {
389
+ msgid: { type: "number", description: "\u6D88\u606F ID\uFF08\u4ECE devtools_console \u83B7\u53D6\uFF09" }
390
+ },
391
+ ["msgid"]
392
+ ))
393
+ },
394
+ // ===== 其他 =====
395
+ {
396
+ name: "devtools_wait_for",
397
+ description: "\u7B49\u5F85\u6307\u5B9A\u9875\u9762\u51FA\u73B0\u6307\u5B9A\u6587\u672C\uFF08\u4EFB\u4E00\u5339\u914D\u5373\u8FD4\u56DE\uFF09",
398
+ inputSchema: __spreadValues({
399
+ type: "object"
400
+ }, withPageId(
401
+ {
402
+ text: {
403
+ type: "array",
404
+ items: { type: "string" },
405
+ minItems: 1,
406
+ description: "\u7B49\u5F85\u51FA\u73B0\u7684\u6587\u672C\u5217\u8868"
407
+ },
408
+ timeout: { type: "integer", description: "\u6700\u5927\u7B49\u5F85\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09\uFF0C0 \u4F7F\u7528\u9ED8\u8BA4\u8D85\u65F6" }
409
+ },
410
+ ["text"]
411
+ ))
412
+ },
413
+ {
414
+ name: "devtools_handle_dialog",
415
+ description: "\u5904\u7406 JavaScript \u5BF9\u8BDD\u6846\uFF08alert/confirm/prompt\uFF09",
416
+ inputSchema: __spreadValues({
417
+ type: "object"
418
+ }, withPageId(
419
+ {
420
+ action: { type: "string", enum: ["accept", "dismiss"], description: "\u63A5\u53D7\u6216\u5173\u95ED\u5BF9\u8BDD\u6846" },
421
+ promptText: { type: "string", description: "prompt \u5BF9\u8BDD\u6846\u7684\u8F93\u5165\u6587\u672C" }
422
+ },
423
+ ["action"]
424
+ ))
425
+ },
426
+ {
427
+ name: "devtools_upload_file",
428
+ description: "\u4E0A\u4F20\u6587\u4EF6\u5230\u6587\u4EF6\u8F93\u5165\u6846",
429
+ inputSchema: __spreadValues({
430
+ type: "object"
431
+ }, withPageId(
432
+ {
433
+ uid: { type: "string", description: "\u6587\u4EF6\u8F93\u5165\u6846\u5143\u7D20 uid" },
434
+ filePath: { type: "string", description: "\u672C\u5730\u6587\u4EF6\u8DEF\u5F84" },
435
+ includeSnapshot: { type: "boolean", description: "\u662F\u5426\u5728\u54CD\u5E94\u4E2D\u5305\u542B\u5FEB\u7167\uFF0C\u9ED8\u8BA4 false" }
436
+ },
437
+ ["uid", "filePath"]
438
+ ))
439
+ },
440
+ // ===== 性能分析 =====
441
+ {
442
+ name: "devtools_performance_start",
443
+ description: "\u5728\u6307\u5B9A\u9875\u9762\u5F00\u59CB\u8BB0\u5F55\u6027\u80FD trace\uFF08\u7528\u4E8E\u53D1\u73B0 Core Web Vitals \u6027\u80FD\u95EE\u9898\uFF09",
444
+ inputSchema: __spreadValues({
445
+ type: "object"
446
+ }, withPageId({
447
+ reload: { type: "boolean", description: "\u5F00\u59CB\u540E\u662F\u5426\u81EA\u52A8\u5237\u65B0\u9875\u9762\uFF0C\u9ED8\u8BA4 true" },
448
+ autoStop: { type: "boolean", description: "\u662F\u5426\u81EA\u52A8\u505C\u6B62\u5F55\u5236\uFF0C\u9ED8\u8BA4 true" },
449
+ filePath: { type: "string", description: "\u4FDD\u5B58\u539F\u59CB trace \u6570\u636E\u7684\u8DEF\u5F84\uFF0C\u5982 trace.json.gz" }
450
+ }))
451
+ },
452
+ {
453
+ name: "devtools_performance_stop",
454
+ description: "\u505C\u6B62\u6027\u80FD trace \u8BB0\u5F55\u5E76\u8FD4\u56DE\u7ED3\u679C",
455
+ inputSchema: __spreadValues({
456
+ type: "object"
457
+ }, withPageId({
458
+ filePath: { type: "string", description: "\u4FDD\u5B58\u539F\u59CB trace \u6570\u636E\u7684\u8DEF\u5F84\uFF0C\u5982 trace.json.gz" }
459
+ }))
460
+ },
461
+ {
462
+ name: "devtools_performance_insight",
463
+ description: "\u83B7\u53D6\u7279\u5B9A\u6027\u80FD\u6307\u6807\u7684\u8BE6\u7EC6\u5206\u6790",
464
+ inputSchema: __spreadValues({
465
+ type: "object"
466
+ }, withPageId(
467
+ {
468
+ insightSetId: { type: "string", description: "\u6307\u6807\u96C6 ID\uFF08\u4ECE trace \u7ED3\u679C\u83B7\u53D6\uFF09" },
469
+ insightName: {
470
+ type: "string",
471
+ description: '\u6307\u6807\u540D\u79F0\uFF0C\u5982 "DocumentLatency"\u3001"LCPBreakdown"'
472
+ }
473
+ },
474
+ ["insightSetId", "insightName"]
475
+ ))
476
+ },
477
+ {
478
+ name: "devtools_lighthouse",
479
+ description: "\u5BF9\u6307\u5B9A\u9875\u9762\u8FD0\u884C Lighthouse \u5BA1\u8BA1\uFF08\u53EF\u8BBF\u95EE\u6027/SEO/\u6700\u4F73\u5B9E\u8DF5\uFF0C\u4E0D\u542B\u6027\u80FD\uFF09",
480
+ inputSchema: __spreadValues({
481
+ type: "object"
482
+ }, withPageId({
483
+ mode: {
484
+ type: "string",
485
+ enum: ["navigation", "snapshot"],
486
+ description: "navigation \u5237\u65B0\u5BA1\u8BA1\uFF0Csnapshot \u5206\u6790\u5F53\u524D\u72B6\u6001"
487
+ },
488
+ device: {
489
+ type: "string",
490
+ enum: ["desktop", "mobile"],
491
+ description: "\u6A21\u62DF\u8BBE\u5907\u7C7B\u578B\uFF0C\u9ED8\u8BA4 desktop"
492
+ },
493
+ outputDirPath: { type: "string", description: "\u62A5\u544A\u8F93\u51FA\u76EE\u5F55\uFF0C\u7701\u7565\u4F7F\u7528\u4E34\u65F6\u6587\u4EF6" }
494
+ }))
495
+ },
496
+ {
497
+ name: "devtools_heapsnapshot",
498
+ description: "\u6355\u83B7\u6307\u5B9A\u9875\u9762\u5806\u5185\u5B58\u5FEB\u7167\uFF0C\u7528\u4E8E\u5206\u6790 JS \u5BF9\u8C61\u5185\u5B58\u5206\u5E03\u548C\u8C03\u8BD5\u5185\u5B58\u6CC4\u6F0F",
499
+ inputSchema: __spreadValues({
500
+ type: "object"
501
+ }, withPageId(
502
+ {
503
+ filePath: { type: "string", description: "\u4FDD\u5B58 .heapsnapshot \u6587\u4EF6\u7684\u8DEF\u5F84" }
504
+ },
505
+ ["filePath"]
506
+ ))
507
+ }
508
+ ];
509
+ const TOOL_MAP = {
510
+ devtools_list_pages: "list_pages",
511
+ devtools_snapshot: "take_snapshot",
512
+ devtools_screenshot: "take_screenshot",
513
+ devtools_evaluate: "evaluate_script",
514
+ devtools_click: "click",
515
+ devtools_hover: "hover",
516
+ devtools_drag: "drag",
517
+ devtools_type: "type_text",
518
+ devtools_press_key: "press_key",
519
+ devtools_fill: "fill",
520
+ devtools_fill_form: "fill_form",
521
+ devtools_navigate: "navigate_page",
522
+ devtools_resize_page: "resize_page",
523
+ devtools_emulate: "emulate",
524
+ devtools_network: "list_network_requests",
525
+ devtools_network_request: "get_network_request",
526
+ devtools_console: "list_console_messages",
527
+ devtools_console_message: "get_console_message",
528
+ devtools_wait_for: "wait_for",
529
+ devtools_handle_dialog: "handle_dialog",
530
+ devtools_upload_file: "upload_file",
531
+ devtools_performance_start: "performance_start_trace",
532
+ devtools_performance_stop: "performance_stop_trace",
533
+ devtools_performance_insight: "performance_analyze_insight",
534
+ devtools_lighthouse: "lighthouse_audit",
535
+ devtools_heapsnapshot: "take_heapsnapshot"
536
+ };
537
+ // Annotate the CommonJS export names for ESM import in node:
538
+ 0 && (module.exports = {
539
+ CUSTOM_TOOLS,
540
+ TOOL_MAP
541
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 自定义 DevTools 工具定义
3
+ * 所有工具(除 devtools_list_pages)必须传入 pageId 参数,
4
+ * 代理层校验 pageId 是否为项目页面后方可调用 chrome-devtools-mcp。
5
+ */
6
+ export interface CustomTool {
7
+ name: string;
8
+ description: string;
9
+ inputSchema: {
10
+ type: "object";
11
+ properties: Record<string, unknown>;
12
+ required?: string[];
13
+ };
14
+ }
15
+ export declare const CUSTOM_TOOLS: CustomTool[];
16
+ /** 工具名映射(自定义 → chrome-devtools-mcp) */
17
+ export declare const TOOL_MAP: Record<string, string>;