@tontoko/fast-playwright-mcp 0.0.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.
- package/LICENSE +202 -0
- package/README.md +1047 -0
- package/cli.js +18 -0
- package/config.d.ts +124 -0
- package/index.d.ts +25 -0
- package/index.js +18 -0
- package/lib/actions.d.js +0 -0
- package/lib/batch/batch-executor.js +137 -0
- package/lib/browser-context-factory.js +252 -0
- package/lib/browser-server-backend.js +139 -0
- package/lib/config/constants.js +80 -0
- package/lib/config.js +405 -0
- package/lib/context.js +274 -0
- package/lib/diagnostics/common/diagnostic-base.js +63 -0
- package/lib/diagnostics/common/error-enrichment-utils.js +212 -0
- package/lib/diagnostics/common/index.js +56 -0
- package/lib/diagnostics/common/initialization-manager.js +210 -0
- package/lib/diagnostics/common/performance-tracker.js +132 -0
- package/lib/diagnostics/diagnostic-error.js +140 -0
- package/lib/diagnostics/diagnostic-level.js +123 -0
- package/lib/diagnostics/diagnostic-thresholds.js +347 -0
- package/lib/diagnostics/element-discovery.js +441 -0
- package/lib/diagnostics/enhanced-error-handler.js +376 -0
- package/lib/diagnostics/error-enrichment.js +157 -0
- package/lib/diagnostics/frame-reference-manager.js +179 -0
- package/lib/diagnostics/page-analyzer.js +639 -0
- package/lib/diagnostics/parallel-page-analyzer.js +129 -0
- package/lib/diagnostics/resource-manager.js +134 -0
- package/lib/diagnostics/smart-config.js +482 -0
- package/lib/diagnostics/smart-handle.js +118 -0
- package/lib/diagnostics/unified-system.js +717 -0
- package/lib/extension/cdp-relay.js +486 -0
- package/lib/extension/extension-context-factory.js +74 -0
- package/lib/extension/main.js +41 -0
- package/lib/file-utils.js +42 -0
- package/lib/generate-keys.js +75 -0
- package/lib/http-server.js +50 -0
- package/lib/in-process-client.js +64 -0
- package/lib/index.js +48 -0
- package/lib/javascript.js +90 -0
- package/lib/log.js +33 -0
- package/lib/loop/loop-claude.js +247 -0
- package/lib/loop/loop-open-ai.js +222 -0
- package/lib/loop/loop.js +174 -0
- package/lib/loop/main.js +46 -0
- package/lib/loopTools/context.js +76 -0
- package/lib/loopTools/main.js +65 -0
- package/lib/loopTools/perform.js +40 -0
- package/lib/loopTools/snapshot.js +37 -0
- package/lib/loopTools/tool.js +26 -0
- package/lib/manual-promise.js +125 -0
- package/lib/mcp/in-process-transport.js +91 -0
- package/lib/mcp/proxy-backend.js +127 -0
- package/lib/mcp/server.js +123 -0
- package/lib/mcp/transport.js +159 -0
- package/lib/package.js +28 -0
- package/lib/program.js +82 -0
- package/lib/response.js +493 -0
- package/lib/schemas/expectation.js +152 -0
- package/lib/session-log.js +210 -0
- package/lib/tab.js +417 -0
- package/lib/tools/base-tool-handler.js +141 -0
- package/lib/tools/batch-execute.js +150 -0
- package/lib/tools/common.js +65 -0
- package/lib/tools/console.js +60 -0
- package/lib/tools/diagnose/diagnose-analysis-runner.js +101 -0
- package/lib/tools/diagnose/diagnose-config-handler.js +130 -0
- package/lib/tools/diagnose/diagnose-report-builder.js +394 -0
- package/lib/tools/diagnose.js +147 -0
- package/lib/tools/dialogs.js +57 -0
- package/lib/tools/evaluate.js +67 -0
- package/lib/tools/files.js +53 -0
- package/lib/tools/find-elements.js +307 -0
- package/lib/tools/install.js +60 -0
- package/lib/tools/keyboard.js +93 -0
- package/lib/tools/mouse.js +110 -0
- package/lib/tools/navigate.js +82 -0
- package/lib/tools/network.js +50 -0
- package/lib/tools/pdf.js +46 -0
- package/lib/tools/screenshot.js +113 -0
- package/lib/tools/snapshot.js +158 -0
- package/lib/tools/tabs.js +97 -0
- package/lib/tools/tool.js +47 -0
- package/lib/tools/utils.js +131 -0
- package/lib/tools/wait.js +64 -0
- package/lib/tools.js +65 -0
- package/lib/types/batch.js +47 -0
- package/lib/types/diff.js +0 -0
- package/lib/types/performance.js +0 -0
- package/lib/types/threshold-base.js +0 -0
- package/lib/utils/array-utils.js +44 -0
- package/lib/utils/code-deduplication-utils.js +141 -0
- package/lib/utils/common-formatters.js +252 -0
- package/lib/utils/console-filter.js +64 -0
- package/lib/utils/diagnostic-report-utils.js +178 -0
- package/lib/utils/diff-formatter.js +126 -0
- package/lib/utils/disposable-manager.js +135 -0
- package/lib/utils/error-handler-middleware.js +77 -0
- package/lib/utils/image-processor.js +137 -0
- package/lib/utils/index.js +92 -0
- package/lib/utils/report-builder.js +189 -0
- package/lib/utils/request-logger.js +82 -0
- package/lib/utils/response-diff-detector.js +150 -0
- package/lib/utils/section-builder.js +62 -0
- package/lib/utils/tool-patterns.js +153 -0
- package/lib/utils.js +46 -0
- package/package.json +77 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
20
|
+
// src/tools/common.ts
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
import { expectationSchema } from "../schemas/expectation.js";
|
|
23
|
+
import { defineTabTool, defineTool } from "./tool.js";
|
|
24
|
+
var close = defineTool({
|
|
25
|
+
capability: "core",
|
|
26
|
+
schema: {
|
|
27
|
+
name: "browser_close",
|
|
28
|
+
title: "Close browser",
|
|
29
|
+
description: "Close the page",
|
|
30
|
+
inputSchema: z.object({}),
|
|
31
|
+
type: "readOnly"
|
|
32
|
+
},
|
|
33
|
+
handle: async (context, _params, response) => {
|
|
34
|
+
await context.closeBrowserContext();
|
|
35
|
+
response.setIncludeTabs();
|
|
36
|
+
response.addCode("await page.close()");
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
var resize = defineTabTool({
|
|
40
|
+
capability: "core",
|
|
41
|
+
schema: {
|
|
42
|
+
name: "browser_resize",
|
|
43
|
+
title: "Resize browser window",
|
|
44
|
+
description: "Resize the browser window",
|
|
45
|
+
inputSchema: z.object({
|
|
46
|
+
width: z.number().describe("Width of the browser window"),
|
|
47
|
+
height: z.number().describe("Height of the browser window"),
|
|
48
|
+
expectation: expectationSchema
|
|
49
|
+
}),
|
|
50
|
+
type: "readOnly"
|
|
51
|
+
},
|
|
52
|
+
handle: async (tab, params, response) => {
|
|
53
|
+
response.addCode(`await page.setViewportSize({ width: ${params.width}, height: ${params.height} });`);
|
|
54
|
+
await tab.waitForCompletion(async () => {
|
|
55
|
+
await tab.page.setViewportSize({
|
|
56
|
+
width: params.width,
|
|
57
|
+
height: params.height
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
var common_default = [close, resize];
|
|
63
|
+
export {
|
|
64
|
+
common_default as default
|
|
65
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
20
|
+
// src/tools/console.ts
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
import { filterConsoleMessages } from "../utils/console-filter.js";
|
|
23
|
+
import { defineTabTool } from "./tool.js";
|
|
24
|
+
var consoleOptionsSchema = z.object({
|
|
25
|
+
levels: z.array(z.enum(["log", "warn", "error", "info"])).optional(),
|
|
26
|
+
maxMessages: z.number().optional().default(10),
|
|
27
|
+
patterns: z.array(z.string()).optional().describe("Regex patterns to filter messages"),
|
|
28
|
+
removeDuplicates: z.boolean().optional().default(false).describe("Remove duplicate messages")
|
|
29
|
+
}).optional();
|
|
30
|
+
var console = defineTabTool({
|
|
31
|
+
capability: "core",
|
|
32
|
+
schema: {
|
|
33
|
+
name: "browser_console_messages",
|
|
34
|
+
title: "Get console messages",
|
|
35
|
+
description: "Returns all console messages",
|
|
36
|
+
inputSchema: z.object({
|
|
37
|
+
consoleOptions: consoleOptionsSchema
|
|
38
|
+
}),
|
|
39
|
+
type: "readOnly"
|
|
40
|
+
},
|
|
41
|
+
handle: async (tab, params, response) => {
|
|
42
|
+
const messages = await Promise.resolve(tab.consoleMessages());
|
|
43
|
+
if (messages.length === 0) {
|
|
44
|
+
response.addResult("No console messages");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const filteredMessages = filterConsoleMessages(messages, params.consoleOptions);
|
|
48
|
+
if (filteredMessages.length === 0) {
|
|
49
|
+
response.addResult("No console messages match the filter criteria");
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
for (const message of filteredMessages) {
|
|
53
|
+
response.addResult(message.toString());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
var console_default = [console];
|
|
58
|
+
export {
|
|
59
|
+
console_default as default
|
|
60
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
20
|
+
// src/tools/diagnose/diagnose-analysis-runner.ts
|
|
21
|
+
class DiagnoseAnalysisRunner {
|
|
22
|
+
async runAnalysis(unifiedSystem, pageAnalyzer, useParallelAnalysis, includeSystemStats) {
|
|
23
|
+
if (unifiedSystem) {
|
|
24
|
+
return await this.runUnifiedSystemAnalysis(unifiedSystem, useParallelAnalysis, includeSystemStats);
|
|
25
|
+
}
|
|
26
|
+
if (useParallelAnalysis && pageAnalyzer) {
|
|
27
|
+
return await this.runLegacyParallelAnalysis(pageAnalyzer);
|
|
28
|
+
}
|
|
29
|
+
if (pageAnalyzer) {
|
|
30
|
+
return await this.runStandardAnalysis(pageAnalyzer);
|
|
31
|
+
}
|
|
32
|
+
throw new Error("No analysis system available");
|
|
33
|
+
}
|
|
34
|
+
async runUnifiedSystemAnalysis(unifiedSystem, useParallelAnalysis, includeSystemStats) {
|
|
35
|
+
const structureResult = await unifiedSystem.analyzePageStructure(useParallelAnalysis);
|
|
36
|
+
if (!structureResult.success) {
|
|
37
|
+
throw new Error(`Unified system analysis failed: ${structureResult.error?.message ?? "Unknown error"}`);
|
|
38
|
+
}
|
|
39
|
+
let diagnosticInfo = structureResult.data;
|
|
40
|
+
let performanceMetrics;
|
|
41
|
+
let analysisType;
|
|
42
|
+
let analysisStatus;
|
|
43
|
+
if ("structureAnalysis" in diagnosticInfo) {
|
|
44
|
+
const parallelResult = diagnosticInfo;
|
|
45
|
+
performanceMetrics = parallelResult.performanceMetrics;
|
|
46
|
+
diagnosticInfo = parallelResult.structureAnalysis;
|
|
47
|
+
analysisType = `Enhanced Parallel Analysis (${structureResult.executionTime}ms)`;
|
|
48
|
+
analysisStatus = "Successfully executed with resource monitoring";
|
|
49
|
+
} else {
|
|
50
|
+
analysisType = `Standard Analysis (${structureResult.executionTime}ms)`;
|
|
51
|
+
analysisStatus = useParallelAnalysis ? "Parallel analysis requested but fell back to standard" : "Standard analysis by configuration";
|
|
52
|
+
}
|
|
53
|
+
let systemHealthInfo;
|
|
54
|
+
if (includeSystemStats) {
|
|
55
|
+
const healthResult = unifiedSystem.performHealthCheck();
|
|
56
|
+
systemHealthInfo = {
|
|
57
|
+
...healthResult,
|
|
58
|
+
timestamp: Date.now()
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
diagnosticInfo,
|
|
63
|
+
performanceMetrics,
|
|
64
|
+
systemHealthInfo,
|
|
65
|
+
analysisType,
|
|
66
|
+
executionTime: structureResult.executionTime,
|
|
67
|
+
analysisStatus
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async runLegacyParallelAnalysis(pageAnalyzer) {
|
|
71
|
+
const parallelRecommendation = await pageAnalyzer.shouldUseParallelAnalysis();
|
|
72
|
+
if (parallelRecommendation.recommended) {
|
|
73
|
+
const parallelResult = await pageAnalyzer.runParallelAnalysis();
|
|
74
|
+
return {
|
|
75
|
+
diagnosticInfo: parallelResult.structureAnalysis,
|
|
76
|
+
performanceMetrics: parallelResult.performanceMetrics,
|
|
77
|
+
analysisType: "Enhanced Diagnostic Report (Parallel Analysis)",
|
|
78
|
+
executionTime: parallelResult.executionTime,
|
|
79
|
+
analysisStatus: "Parallel analysis completed successfully",
|
|
80
|
+
errors: parallelResult.errors.map((err) => `${err.step}: ${err.error}`)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const diagnosticInfo = await pageAnalyzer.analyzePageStructure();
|
|
84
|
+
return {
|
|
85
|
+
diagnosticInfo,
|
|
86
|
+
analysisType: "Standard Diagnostic Report",
|
|
87
|
+
analysisStatus: `Parallel Analysis: Not recommended - ${parallelRecommendation.reason}`
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
async runStandardAnalysis(pageAnalyzer) {
|
|
91
|
+
const diagnosticInfo = await pageAnalyzer.analyzePageStructure();
|
|
92
|
+
return {
|
|
93
|
+
diagnosticInfo,
|
|
94
|
+
analysisType: "Standard Analysis",
|
|
95
|
+
analysisStatus: "Standard analysis completed"
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
DiagnoseAnalysisRunner
|
|
101
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
19
|
+
|
|
20
|
+
// src/tools/diagnose/diagnose-config-handler.ts
|
|
21
|
+
import debug from "debug";
|
|
22
|
+
import { getCurrentThresholds } from "../../diagnostics/diagnostic-thresholds.js";
|
|
23
|
+
import { PageAnalyzer } from "../../diagnostics/page-analyzer.js";
|
|
24
|
+
import { UnifiedDiagnosticSystem } from "../../diagnostics/unified-system.js";
|
|
25
|
+
var configDebug = debug("pw:mcp:diagnose-config");
|
|
26
|
+
|
|
27
|
+
class DiagnoseConfigHandler {
|
|
28
|
+
validateConfiguration() {
|
|
29
|
+
try {
|
|
30
|
+
const thresholdsManager = getCurrentThresholds();
|
|
31
|
+
return thresholdsManager.getConfigDiagnostics();
|
|
32
|
+
} catch (error) {
|
|
33
|
+
configDebug("Configuration validation failed:", error);
|
|
34
|
+
return {
|
|
35
|
+
status: "failed",
|
|
36
|
+
warnings: [
|
|
37
|
+
"Configuration system validation failed - using fallback settings"
|
|
38
|
+
],
|
|
39
|
+
customizations: []
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
initializeSystems(tab, useUnifiedSystem, _useParallelAnalysis, configOverrides) {
|
|
44
|
+
const appliedOverrides = [];
|
|
45
|
+
if (useUnifiedSystem) {
|
|
46
|
+
const configUpdates = this.buildConfigUpdates(configOverrides, appliedOverrides);
|
|
47
|
+
const unifiedSystem = UnifiedDiagnosticSystem.getInstance(tab.page, configUpdates);
|
|
48
|
+
return {
|
|
49
|
+
unifiedSystem,
|
|
50
|
+
appliedOverrides
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const pageAnalyzer = new PageAnalyzer(tab.page);
|
|
54
|
+
return {
|
|
55
|
+
pageAnalyzer,
|
|
56
|
+
appliedOverrides
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
buildConfigUpdates(configOverrides, appliedOverrides = []) {
|
|
60
|
+
const configUpdates = {};
|
|
61
|
+
if (!configOverrides) {
|
|
62
|
+
return configUpdates;
|
|
63
|
+
}
|
|
64
|
+
if (configOverrides.enableResourceMonitoring !== undefined) {
|
|
65
|
+
configUpdates.features = {
|
|
66
|
+
enableParallelAnalysis: true,
|
|
67
|
+
enableSmartHandleManagement: true,
|
|
68
|
+
enableAdvancedElementDiscovery: true,
|
|
69
|
+
enableResourceLeakDetection: configOverrides.enableResourceMonitoring,
|
|
70
|
+
enableRealTimeMonitoring: false
|
|
71
|
+
};
|
|
72
|
+
appliedOverrides.push(`Resource Monitoring: ${configOverrides.enableResourceMonitoring ? "Enabled" : "Disabled"}`);
|
|
73
|
+
}
|
|
74
|
+
if (configOverrides.enableErrorEnrichment !== undefined) {
|
|
75
|
+
configUpdates.errorHandling = {
|
|
76
|
+
enableErrorEnrichment: configOverrides.enableErrorEnrichment,
|
|
77
|
+
enableContextualSuggestions: true,
|
|
78
|
+
logLevel: "warn",
|
|
79
|
+
maxErrorHistory: 100,
|
|
80
|
+
enablePerformanceErrorDetection: true
|
|
81
|
+
};
|
|
82
|
+
appliedOverrides.push(`Error Enrichment: ${configOverrides.enableErrorEnrichment ? "Enabled" : "Disabled"}`);
|
|
83
|
+
}
|
|
84
|
+
if (configOverrides.enableAdaptiveThresholds !== undefined) {
|
|
85
|
+
configUpdates.runtime = {
|
|
86
|
+
enableAdaptiveThresholds: configOverrides.enableAdaptiveThresholds,
|
|
87
|
+
enableAutoTuning: false,
|
|
88
|
+
statsCollectionEnabled: true
|
|
89
|
+
};
|
|
90
|
+
appliedOverrides.push(`Adaptive Thresholds: ${configOverrides.enableAdaptiveThresholds ? "Enabled" : "Disabled"}`);
|
|
91
|
+
}
|
|
92
|
+
if (configOverrides.performanceThresholds) {
|
|
93
|
+
this.applyPerformanceThresholds(configUpdates, configOverrides.performanceThresholds, appliedOverrides);
|
|
94
|
+
}
|
|
95
|
+
return configUpdates;
|
|
96
|
+
}
|
|
97
|
+
applyPerformanceThresholds(configUpdates, performanceThresholds, appliedOverrides) {
|
|
98
|
+
const baseThresholds = getCurrentThresholds().getMetricsThresholds();
|
|
99
|
+
const customThresholds = { ...baseThresholds };
|
|
100
|
+
const thresholdChanges = [];
|
|
101
|
+
if (performanceThresholds.pageAnalysis) {
|
|
102
|
+
const oldValue = customThresholds.executionTime.pageAnalysis;
|
|
103
|
+
customThresholds.executionTime.pageAnalysis = performanceThresholds.pageAnalysis;
|
|
104
|
+
thresholdChanges.push(`Page Analysis: ${oldValue}ms → ${performanceThresholds.pageAnalysis}ms`);
|
|
105
|
+
}
|
|
106
|
+
if (performanceThresholds.elementDiscovery) {
|
|
107
|
+
const oldValue = customThresholds.executionTime.elementDiscovery;
|
|
108
|
+
customThresholds.executionTime.elementDiscovery = performanceThresholds.elementDiscovery;
|
|
109
|
+
thresholdChanges.push(`Element Discovery: ${oldValue}ms → ${performanceThresholds.elementDiscovery}ms`);
|
|
110
|
+
}
|
|
111
|
+
if (performanceThresholds.resourceMonitoring) {
|
|
112
|
+
const oldValue = customThresholds.executionTime.resourceMonitoring;
|
|
113
|
+
customThresholds.executionTime.resourceMonitoring = performanceThresholds.resourceMonitoring;
|
|
114
|
+
thresholdChanges.push(`Resource Monitoring: ${oldValue}ms → ${performanceThresholds.resourceMonitoring}ms`);
|
|
115
|
+
}
|
|
116
|
+
if (thresholdChanges.length > 0) {
|
|
117
|
+
appliedOverrides.push(`Performance Thresholds: ${thresholdChanges.join(", ")}`);
|
|
118
|
+
configUpdates.performance = {
|
|
119
|
+
enableMetricsCollection: true,
|
|
120
|
+
enableResourceMonitoring: true,
|
|
121
|
+
enablePerformanceWarnings: true,
|
|
122
|
+
autoOptimization: true,
|
|
123
|
+
thresholds: customThresholds
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
DiagnoseConfigHandler
|
|
130
|
+
};
|