@xiaou66/vite-plugin-vue-mcp-next 1.0.4 → 1.1.0

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/dist/index.d.cts CHANGED
@@ -49,6 +49,8 @@ interface VueMcpNextOptions {
49
49
  readonly console?: ConsoleOptions;
50
50
  /** Screenshot 配置;CDP 真截图优先,runtime 降级使用 snapdom。 */
51
51
  readonly screenshot?: ScreenshotOptions;
52
+ /** 性能诊断配置;默认用轻量 Runtime 采样,配置 CDP 后可升级为 CPU Profile 与 Heap Snapshot。 */
53
+ readonly performance?: PerformanceOptions;
52
54
  }
53
55
  /**
54
56
  * Cursor MCP 配置写入策略。
@@ -103,6 +105,228 @@ interface RuntimeOptions {
103
105
  }
104
106
  /** 通用 DevTools 能力的数据源选择策略,用于在 CDP 和页面 Hook 之间明确边界。 */
105
107
  type RuntimeMode = 'auto' | 'cdp' | 'hook';
108
+ /**
109
+ * 性能诊断的运行模式。
110
+ *
111
+ * `off` 允许项目显式关闭性能采集,适合某些页面对调试采样非常敏感的场景。
112
+ */
113
+ type PerformanceMode = RuntimeMode | 'off';
114
+ /**
115
+ * 性能内存采样配置。
116
+ *
117
+ * 该开关允许项目仅采集卡顿信息而不持续读取内存趋势,适合对浏览器兼容性要求较高的场景。
118
+ */
119
+ interface PerformanceMemoryOptions {
120
+ /** 是否采集内存趋势,默认开启。 */
121
+ readonly enabled?: boolean;
122
+ }
123
+ /**
124
+ * 性能堆栈采样配置。
125
+ *
126
+ * 该开关允许项目在 runtime-only 场景下关闭额外的错误堆栈收集,减少调试噪音。
127
+ */
128
+ interface PerformanceStackOptions {
129
+ /** 是否采集可用堆栈信息,默认开启。 */
130
+ readonly enabled?: boolean;
131
+ }
132
+ /**
133
+ * 性能诊断配置。
134
+ *
135
+ * 配置层只负责约束采集窗口、保存目录和采样粒度,具体报告结构由运行时和 CDP 采集器统一输出。
136
+ */
137
+ interface PerformanceOptions {
138
+ /** 采集模式,`auto` 会优先使用 CDP,`hook` 只走 runtime,`cdp` 强制使用调试协议。 */
139
+ readonly mode?: PerformanceMode;
140
+ /** 单次采集最长时长,避免长期占用性能采样资源。 */
141
+ readonly maxDurationMs?: number;
142
+ /** 内存和事件循环延迟采样间隔,较短的间隔会增加少量采样开销。 */
143
+ readonly sampleIntervalMs?: number;
144
+ /** 视为卡顿的任务阈值,默认 50ms。 */
145
+ readonly longTaskThresholdMs?: number;
146
+ /** 原始 profile 和 heap 文件保存目录,默认保存在项目内 `.vite-mcp/performance`。 */
147
+ readonly saveDir?: string;
148
+ /** 内存趋势采样开关。 */
149
+ readonly memory?: PerformanceMemoryOptions;
150
+ /** 可用堆栈采样开关。 */
151
+ readonly stacks?: PerformanceStackOptions;
152
+ }
153
+ /**
154
+ * 长任务记录。
155
+ *
156
+ * runtime 和 CDP 都会把自己的卡顿信号归一成同一结构,便于 MCP 工具解释“哪一段卡住了”。
157
+ */
158
+ interface LongTaskRecord {
159
+ /** 长任务开始时间,和采集窗口同一时间基准。 */
160
+ readonly startTime: number;
161
+ /** 长任务持续时间,通常要与阈值比较后再计算 blocked time。 */
162
+ readonly durationMs: number;
163
+ /** 任务名称或来源信息,若可用则方便定位具体脚本。 */
164
+ readonly name?: string;
165
+ /** 浏览器暴露的 attribution 元信息,runtime 路径可能为空。 */
166
+ readonly attribution?: unknown[];
167
+ /** 对应堆栈 id,供 CDP profile 或错误堆栈关联。 */
168
+ readonly stackId?: string;
169
+ /** 数据来源,用于区分浏览器观察条目、事件循环延迟和 CPU Profile 采样。 */
170
+ readonly source: 'longtask' | 'long-animation-frame' | 'cpu-profile' | 'event-loop-lag';
171
+ }
172
+ /**
173
+ * 内存采样点。
174
+ *
175
+ * 只表达使用量趋势,不假装 runtime-only 路径能拿到完整 heap 结构。
176
+ */
177
+ interface MemorySample {
178
+ /** 采样时间戳。 */
179
+ readonly timestamp: number;
180
+ /** JS 堆已用大小。 */
181
+ readonly usedJSHeapSize?: number;
182
+ /** JS 堆总大小。 */
183
+ readonly totalJSHeapSize?: number;
184
+ /** JS 堆限制。 */
185
+ readonly jsHeapSizeLimit?: number;
186
+ /** 同步采样得到的事件循环延迟。 */
187
+ readonly eventLoopLagMs?: number;
188
+ }
189
+ /**
190
+ * 内存趋势摘要。
191
+ *
192
+ * 该结构不暴露对象引用链,只描述趋势是否持续增长。
193
+ */
194
+ interface MemorySummary {
195
+ /** 采样序列。 */
196
+ readonly samples: MemorySample[];
197
+ /** 初始堆使用量。 */
198
+ readonly initialUsedJSHeapSize?: number;
199
+ /** 结束堆使用量。 */
200
+ readonly finalUsedJSHeapSize?: number;
201
+ /** 峰值堆使用量。 */
202
+ readonly peakUsedJSHeapSize?: number;
203
+ /** 结束与开始之间的差值。 */
204
+ readonly deltaUsedJSHeapSize?: number;
205
+ /** 趋势结论。 */
206
+ readonly trend: 'stable' | 'growing' | 'unknown';
207
+ }
208
+ /**
209
+ * 可定位的堆栈帧摘要。
210
+ *
211
+ * CDP profile 会更完整,runtime-only 路径则通常只能补充错误栈里的少量函数名。
212
+ */
213
+ interface StackFrameSummary {
214
+ /** 函数名。 */
215
+ readonly functionName: string;
216
+ /** 关联脚本 URL。 */
217
+ readonly url?: string;
218
+ /** 行号。 */
219
+ readonly lineNumber?: number;
220
+ /** 列号。 */
221
+ readonly columnNumber?: number;
222
+ /** 自身耗时。 */
223
+ readonly selfTimeMs?: number;
224
+ /** 总耗时。 */
225
+ readonly totalTimeMs?: number;
226
+ /** 命中次数。 */
227
+ readonly hitCount?: number;
228
+ }
229
+ /**
230
+ * 堆栈摘要。
231
+ *
232
+ * 原始 profile 可能过大,不适合直接放进 MCP 响应,因此这里同时保留文件路径和摘要帧列表。
233
+ */
234
+ interface StackSummary {
235
+ /** 热点帧列表。 */
236
+ readonly topFrames: StackFrameSummary[];
237
+ /** 原始 profile 文件路径。 */
238
+ readonly rawProfilePath?: string;
239
+ /** 路径缺失或仅有 runtime 栈时的限制说明。 */
240
+ readonly limitation?: string;
241
+ }
242
+ /**
243
+ * 性能摘要。
244
+ *
245
+ * 该结构用于快速判断页面是否存在明显卡顿,不要求用户先看完整原始数据。
246
+ */
247
+ interface PerformanceSummary {
248
+ /** 阻塞时间。 */
249
+ readonly blockedTimeMs: number;
250
+ /** 长任务数量。 */
251
+ readonly longTaskCount: number;
252
+ /** 最大任务耗时。 */
253
+ readonly maxTaskDurationMs: number;
254
+ /** 平均任务耗时。 */
255
+ readonly averageTaskDurationMs?: number;
256
+ /** 是否疑似卡顿。 */
257
+ readonly suspectedJank: boolean;
258
+ /** 严重程度。 */
259
+ readonly severity: 'ok' | 'warning' | 'critical';
260
+ }
261
+ /**
262
+ * 性能报告。
263
+ *
264
+ * 该结构是 runtime 和 CDP 两条路径对外共同输出的最终结果,调用方只需要看 source 和 limitations 就能知道边界。
265
+ */
266
+ interface PerformanceReport {
267
+ /** 录制会话 id。 */
268
+ readonly recordingId: string;
269
+ /** 页面 id。 */
270
+ readonly pageId: string;
271
+ /** 数据来源。 */
272
+ readonly source: 'cdp' | 'hook';
273
+ /** 开始时间。 */
274
+ readonly startedAt: number;
275
+ /** 结束时间。 */
276
+ readonly endedAt: number;
277
+ /** 持续时间。 */
278
+ readonly durationMs: number;
279
+ /** 快速摘要。 */
280
+ readonly summary: PerformanceSummary;
281
+ /** 长任务列表。 */
282
+ readonly longTasks: LongTaskRecord[];
283
+ /** 内存摘要。 */
284
+ readonly memory?: MemorySummary;
285
+ /** 堆栈摘要。 */
286
+ readonly stacks?: StackSummary;
287
+ /** 原始产物。 */
288
+ readonly artifacts?: PerformanceArtifact[];
289
+ /** 能力限制说明。 */
290
+ readonly limitations: string[];
291
+ }
292
+ /**
293
+ * 性能产物。
294
+ *
295
+ * CDP 的原始 profile 与 heap snapshot 可能很大,因此用路径型产物表达而不是把内容直接塞进响应。
296
+ */
297
+ interface PerformanceArtifact {
298
+ /** 产物类型。 */
299
+ readonly kind: 'cpu-profile' | 'heap-snapshot';
300
+ /** 绝对路径。 */
301
+ readonly path: string;
302
+ /** 相对项目根目录的路径。 */
303
+ readonly relativePath: string;
304
+ /** 字节大小。 */
305
+ readonly byteLength: number;
306
+ /** 产物来源,当前仅 CDP 会生成这类文件。 */
307
+ readonly source: 'cdp';
308
+ }
309
+ /**
310
+ * 活动中的性能录制会话。
311
+ *
312
+ * MCP 工具可以通过 recordingId 暂停和恢复同一条采集链路,避免多个采集彼此污染。
313
+ */
314
+ interface PerformanceSession {
315
+ /** 会话 id。 */
316
+ readonly recordingId: string;
317
+ /** 页面 id。 */
318
+ readonly pageId: string;
319
+ /** 数据来源。 */
320
+ readonly source: 'cdp' | 'hook';
321
+ /** 开始时间。 */
322
+ readonly startedAt: number;
323
+ /** 是否采集内存。 */
324
+ readonly includeMemory: boolean;
325
+ /** 是否采集堆栈。 */
326
+ readonly includeStacks: boolean;
327
+ /** 采集模式。 */
328
+ readonly mode: PerformanceMode;
329
+ }
106
330
  /**
107
331
  * 控制台脚本执行配置。
108
332
  *
@@ -352,6 +576,11 @@ interface ResolvedVueMcpNextOptions {
352
576
  readonly screenshot: Required<Omit<ScreenshotOptions, 'snapdom'>> & {
353
577
  readonly snapdom: Required<Pick<SnapdomScreenshotOptions, 'options' | 'plugins'>> & Omit<SnapdomScreenshotOptions, 'options' | 'plugins'>;
354
578
  };
579
+ /** 已补齐默认值的性能配置。 */
580
+ readonly performance: Required<Omit<PerformanceOptions, 'memory' | 'stacks'>> & {
581
+ readonly memory: Required<PerformanceMemoryOptions>;
582
+ readonly stacks: Required<PerformanceStackOptions>;
583
+ };
355
584
  }
356
585
  /**
357
586
  * MCP 可选择的页面目标。
@@ -487,6 +716,10 @@ interface VueMcpNextContext {
487
716
  readonly consoleRecords: RingBuffer<ConsoleRecord>;
488
717
  /** Network 请求缓存,给 MCP Network 工具提供摘要和详情。 */
489
718
  readonly networkRecords: RingBuffer<NetworkRecord>;
719
+ /** 性能报告缓存,给 get_performance_report 和最近会话查询使用。 */
720
+ readonly performanceReports: RingBuffer<PerformanceReport>;
721
+ /** 活动中的性能录制会话,防止 start/stop 并发冲突。 */
722
+ readonly performanceSessions: Map<string, PerformanceSession>;
490
723
  /** 可选 CDP 生命周期控制器,用于纯 CDP target 被发现后启动 Console 和 Network 监听。 */
491
724
  cdpLifecycle?: CdpLifecycleController;
492
725
  }
@@ -588,6 +821,30 @@ interface VueRuntimeRpc {
588
821
  }): void | Promise<void>;
589
822
  /** 回传 Pinia store state。 */
590
823
  onPiniaInfoUpdated(event: string, data: unknown): void;
824
+ /** 进行一次性能诊断采样。 */
825
+ recordPerformance(options: {
826
+ event: string;
827
+ durationMs: number;
828
+ includeMemory: boolean;
829
+ includeStacks: boolean;
830
+ }): void | Promise<void>;
831
+ /** 回传一次性性能采样结果。 */
832
+ onPerformanceRecorded(event: string, data: unknown): void;
833
+ /** 启动一段交互式性能录制。 */
834
+ startPerformanceRecording(options: {
835
+ event: string;
836
+ includeMemory: boolean;
837
+ includeStacks: boolean;
838
+ }): void | Promise<void>;
839
+ /** 回传录制启动结果。 */
840
+ onPerformanceRecordingStarted(event: string, data: unknown): void;
841
+ /** 停止交互式性能录制。 */
842
+ stopPerformanceRecording(options: {
843
+ event: string;
844
+ recordingId: string;
845
+ }): void | Promise<void>;
846
+ /** 回传录制结束结果。 */
847
+ onPerformanceRecordingStopped(event: string, data: unknown): void;
591
848
  }
592
849
 
593
850
  /**
package/dist/index.d.ts CHANGED
@@ -49,6 +49,8 @@ interface VueMcpNextOptions {
49
49
  readonly console?: ConsoleOptions;
50
50
  /** Screenshot 配置;CDP 真截图优先,runtime 降级使用 snapdom。 */
51
51
  readonly screenshot?: ScreenshotOptions;
52
+ /** 性能诊断配置;默认用轻量 Runtime 采样,配置 CDP 后可升级为 CPU Profile 与 Heap Snapshot。 */
53
+ readonly performance?: PerformanceOptions;
52
54
  }
53
55
  /**
54
56
  * Cursor MCP 配置写入策略。
@@ -103,6 +105,228 @@ interface RuntimeOptions {
103
105
  }
104
106
  /** 通用 DevTools 能力的数据源选择策略,用于在 CDP 和页面 Hook 之间明确边界。 */
105
107
  type RuntimeMode = 'auto' | 'cdp' | 'hook';
108
+ /**
109
+ * 性能诊断的运行模式。
110
+ *
111
+ * `off` 允许项目显式关闭性能采集,适合某些页面对调试采样非常敏感的场景。
112
+ */
113
+ type PerformanceMode = RuntimeMode | 'off';
114
+ /**
115
+ * 性能内存采样配置。
116
+ *
117
+ * 该开关允许项目仅采集卡顿信息而不持续读取内存趋势,适合对浏览器兼容性要求较高的场景。
118
+ */
119
+ interface PerformanceMemoryOptions {
120
+ /** 是否采集内存趋势,默认开启。 */
121
+ readonly enabled?: boolean;
122
+ }
123
+ /**
124
+ * 性能堆栈采样配置。
125
+ *
126
+ * 该开关允许项目在 runtime-only 场景下关闭额外的错误堆栈收集,减少调试噪音。
127
+ */
128
+ interface PerformanceStackOptions {
129
+ /** 是否采集可用堆栈信息,默认开启。 */
130
+ readonly enabled?: boolean;
131
+ }
132
+ /**
133
+ * 性能诊断配置。
134
+ *
135
+ * 配置层只负责约束采集窗口、保存目录和采样粒度,具体报告结构由运行时和 CDP 采集器统一输出。
136
+ */
137
+ interface PerformanceOptions {
138
+ /** 采集模式,`auto` 会优先使用 CDP,`hook` 只走 runtime,`cdp` 强制使用调试协议。 */
139
+ readonly mode?: PerformanceMode;
140
+ /** 单次采集最长时长,避免长期占用性能采样资源。 */
141
+ readonly maxDurationMs?: number;
142
+ /** 内存和事件循环延迟采样间隔,较短的间隔会增加少量采样开销。 */
143
+ readonly sampleIntervalMs?: number;
144
+ /** 视为卡顿的任务阈值,默认 50ms。 */
145
+ readonly longTaskThresholdMs?: number;
146
+ /** 原始 profile 和 heap 文件保存目录,默认保存在项目内 `.vite-mcp/performance`。 */
147
+ readonly saveDir?: string;
148
+ /** 内存趋势采样开关。 */
149
+ readonly memory?: PerformanceMemoryOptions;
150
+ /** 可用堆栈采样开关。 */
151
+ readonly stacks?: PerformanceStackOptions;
152
+ }
153
+ /**
154
+ * 长任务记录。
155
+ *
156
+ * runtime 和 CDP 都会把自己的卡顿信号归一成同一结构,便于 MCP 工具解释“哪一段卡住了”。
157
+ */
158
+ interface LongTaskRecord {
159
+ /** 长任务开始时间,和采集窗口同一时间基准。 */
160
+ readonly startTime: number;
161
+ /** 长任务持续时间,通常要与阈值比较后再计算 blocked time。 */
162
+ readonly durationMs: number;
163
+ /** 任务名称或来源信息,若可用则方便定位具体脚本。 */
164
+ readonly name?: string;
165
+ /** 浏览器暴露的 attribution 元信息,runtime 路径可能为空。 */
166
+ readonly attribution?: unknown[];
167
+ /** 对应堆栈 id,供 CDP profile 或错误堆栈关联。 */
168
+ readonly stackId?: string;
169
+ /** 数据来源,用于区分浏览器观察条目、事件循环延迟和 CPU Profile 采样。 */
170
+ readonly source: 'longtask' | 'long-animation-frame' | 'cpu-profile' | 'event-loop-lag';
171
+ }
172
+ /**
173
+ * 内存采样点。
174
+ *
175
+ * 只表达使用量趋势,不假装 runtime-only 路径能拿到完整 heap 结构。
176
+ */
177
+ interface MemorySample {
178
+ /** 采样时间戳。 */
179
+ readonly timestamp: number;
180
+ /** JS 堆已用大小。 */
181
+ readonly usedJSHeapSize?: number;
182
+ /** JS 堆总大小。 */
183
+ readonly totalJSHeapSize?: number;
184
+ /** JS 堆限制。 */
185
+ readonly jsHeapSizeLimit?: number;
186
+ /** 同步采样得到的事件循环延迟。 */
187
+ readonly eventLoopLagMs?: number;
188
+ }
189
+ /**
190
+ * 内存趋势摘要。
191
+ *
192
+ * 该结构不暴露对象引用链,只描述趋势是否持续增长。
193
+ */
194
+ interface MemorySummary {
195
+ /** 采样序列。 */
196
+ readonly samples: MemorySample[];
197
+ /** 初始堆使用量。 */
198
+ readonly initialUsedJSHeapSize?: number;
199
+ /** 结束堆使用量。 */
200
+ readonly finalUsedJSHeapSize?: number;
201
+ /** 峰值堆使用量。 */
202
+ readonly peakUsedJSHeapSize?: number;
203
+ /** 结束与开始之间的差值。 */
204
+ readonly deltaUsedJSHeapSize?: number;
205
+ /** 趋势结论。 */
206
+ readonly trend: 'stable' | 'growing' | 'unknown';
207
+ }
208
+ /**
209
+ * 可定位的堆栈帧摘要。
210
+ *
211
+ * CDP profile 会更完整,runtime-only 路径则通常只能补充错误栈里的少量函数名。
212
+ */
213
+ interface StackFrameSummary {
214
+ /** 函数名。 */
215
+ readonly functionName: string;
216
+ /** 关联脚本 URL。 */
217
+ readonly url?: string;
218
+ /** 行号。 */
219
+ readonly lineNumber?: number;
220
+ /** 列号。 */
221
+ readonly columnNumber?: number;
222
+ /** 自身耗时。 */
223
+ readonly selfTimeMs?: number;
224
+ /** 总耗时。 */
225
+ readonly totalTimeMs?: number;
226
+ /** 命中次数。 */
227
+ readonly hitCount?: number;
228
+ }
229
+ /**
230
+ * 堆栈摘要。
231
+ *
232
+ * 原始 profile 可能过大,不适合直接放进 MCP 响应,因此这里同时保留文件路径和摘要帧列表。
233
+ */
234
+ interface StackSummary {
235
+ /** 热点帧列表。 */
236
+ readonly topFrames: StackFrameSummary[];
237
+ /** 原始 profile 文件路径。 */
238
+ readonly rawProfilePath?: string;
239
+ /** 路径缺失或仅有 runtime 栈时的限制说明。 */
240
+ readonly limitation?: string;
241
+ }
242
+ /**
243
+ * 性能摘要。
244
+ *
245
+ * 该结构用于快速判断页面是否存在明显卡顿,不要求用户先看完整原始数据。
246
+ */
247
+ interface PerformanceSummary {
248
+ /** 阻塞时间。 */
249
+ readonly blockedTimeMs: number;
250
+ /** 长任务数量。 */
251
+ readonly longTaskCount: number;
252
+ /** 最大任务耗时。 */
253
+ readonly maxTaskDurationMs: number;
254
+ /** 平均任务耗时。 */
255
+ readonly averageTaskDurationMs?: number;
256
+ /** 是否疑似卡顿。 */
257
+ readonly suspectedJank: boolean;
258
+ /** 严重程度。 */
259
+ readonly severity: 'ok' | 'warning' | 'critical';
260
+ }
261
+ /**
262
+ * 性能报告。
263
+ *
264
+ * 该结构是 runtime 和 CDP 两条路径对外共同输出的最终结果,调用方只需要看 source 和 limitations 就能知道边界。
265
+ */
266
+ interface PerformanceReport {
267
+ /** 录制会话 id。 */
268
+ readonly recordingId: string;
269
+ /** 页面 id。 */
270
+ readonly pageId: string;
271
+ /** 数据来源。 */
272
+ readonly source: 'cdp' | 'hook';
273
+ /** 开始时间。 */
274
+ readonly startedAt: number;
275
+ /** 结束时间。 */
276
+ readonly endedAt: number;
277
+ /** 持续时间。 */
278
+ readonly durationMs: number;
279
+ /** 快速摘要。 */
280
+ readonly summary: PerformanceSummary;
281
+ /** 长任务列表。 */
282
+ readonly longTasks: LongTaskRecord[];
283
+ /** 内存摘要。 */
284
+ readonly memory?: MemorySummary;
285
+ /** 堆栈摘要。 */
286
+ readonly stacks?: StackSummary;
287
+ /** 原始产物。 */
288
+ readonly artifacts?: PerformanceArtifact[];
289
+ /** 能力限制说明。 */
290
+ readonly limitations: string[];
291
+ }
292
+ /**
293
+ * 性能产物。
294
+ *
295
+ * CDP 的原始 profile 与 heap snapshot 可能很大,因此用路径型产物表达而不是把内容直接塞进响应。
296
+ */
297
+ interface PerformanceArtifact {
298
+ /** 产物类型。 */
299
+ readonly kind: 'cpu-profile' | 'heap-snapshot';
300
+ /** 绝对路径。 */
301
+ readonly path: string;
302
+ /** 相对项目根目录的路径。 */
303
+ readonly relativePath: string;
304
+ /** 字节大小。 */
305
+ readonly byteLength: number;
306
+ /** 产物来源,当前仅 CDP 会生成这类文件。 */
307
+ readonly source: 'cdp';
308
+ }
309
+ /**
310
+ * 活动中的性能录制会话。
311
+ *
312
+ * MCP 工具可以通过 recordingId 暂停和恢复同一条采集链路,避免多个采集彼此污染。
313
+ */
314
+ interface PerformanceSession {
315
+ /** 会话 id。 */
316
+ readonly recordingId: string;
317
+ /** 页面 id。 */
318
+ readonly pageId: string;
319
+ /** 数据来源。 */
320
+ readonly source: 'cdp' | 'hook';
321
+ /** 开始时间。 */
322
+ readonly startedAt: number;
323
+ /** 是否采集内存。 */
324
+ readonly includeMemory: boolean;
325
+ /** 是否采集堆栈。 */
326
+ readonly includeStacks: boolean;
327
+ /** 采集模式。 */
328
+ readonly mode: PerformanceMode;
329
+ }
106
330
  /**
107
331
  * 控制台脚本执行配置。
108
332
  *
@@ -352,6 +576,11 @@ interface ResolvedVueMcpNextOptions {
352
576
  readonly screenshot: Required<Omit<ScreenshotOptions, 'snapdom'>> & {
353
577
  readonly snapdom: Required<Pick<SnapdomScreenshotOptions, 'options' | 'plugins'>> & Omit<SnapdomScreenshotOptions, 'options' | 'plugins'>;
354
578
  };
579
+ /** 已补齐默认值的性能配置。 */
580
+ readonly performance: Required<Omit<PerformanceOptions, 'memory' | 'stacks'>> & {
581
+ readonly memory: Required<PerformanceMemoryOptions>;
582
+ readonly stacks: Required<PerformanceStackOptions>;
583
+ };
355
584
  }
356
585
  /**
357
586
  * MCP 可选择的页面目标。
@@ -487,6 +716,10 @@ interface VueMcpNextContext {
487
716
  readonly consoleRecords: RingBuffer<ConsoleRecord>;
488
717
  /** Network 请求缓存,给 MCP Network 工具提供摘要和详情。 */
489
718
  readonly networkRecords: RingBuffer<NetworkRecord>;
719
+ /** 性能报告缓存,给 get_performance_report 和最近会话查询使用。 */
720
+ readonly performanceReports: RingBuffer<PerformanceReport>;
721
+ /** 活动中的性能录制会话,防止 start/stop 并发冲突。 */
722
+ readonly performanceSessions: Map<string, PerformanceSession>;
490
723
  /** 可选 CDP 生命周期控制器,用于纯 CDP target 被发现后启动 Console 和 Network 监听。 */
491
724
  cdpLifecycle?: CdpLifecycleController;
492
725
  }
@@ -588,6 +821,30 @@ interface VueRuntimeRpc {
588
821
  }): void | Promise<void>;
589
822
  /** 回传 Pinia store state。 */
590
823
  onPiniaInfoUpdated(event: string, data: unknown): void;
824
+ /** 进行一次性能诊断采样。 */
825
+ recordPerformance(options: {
826
+ event: string;
827
+ durationMs: number;
828
+ includeMemory: boolean;
829
+ includeStacks: boolean;
830
+ }): void | Promise<void>;
831
+ /** 回传一次性性能采样结果。 */
832
+ onPerformanceRecorded(event: string, data: unknown): void;
833
+ /** 启动一段交互式性能录制。 */
834
+ startPerformanceRecording(options: {
835
+ event: string;
836
+ includeMemory: boolean;
837
+ includeStacks: boolean;
838
+ }): void | Promise<void>;
839
+ /** 回传录制启动结果。 */
840
+ onPerformanceRecordingStarted(event: string, data: unknown): void;
841
+ /** 停止交互式性能录制。 */
842
+ stopPerformanceRecording(options: {
843
+ event: string;
844
+ recordingId: string;
845
+ }): void | Promise<void>;
846
+ /** 回传录制结束结果。 */
847
+ onPerformanceRecordingStopped(event: string, data: unknown): void;
591
848
  }
592
849
 
593
850
  /**