chrome-devtools-mcp 1.7.0 → 1.8.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/README.md +48 -14
- package/build/src/McpContext.js +60 -24
- package/build/src/McpPage.js +5 -3
- package/build/src/McpResponse.js +22 -4
- package/build/src/ToolHandler.js +66 -12
- package/build/src/bin/chrome-devtools-mcp-main.js +2 -2
- package/build/src/bin/chrome-devtools.js +29 -30
- package/build/src/browser.js +3 -1
- package/build/src/{PageCollector.js → collectors/PageCollector.js} +7 -7
- package/build/src/{ServiceWorkerCollector.js → collectors/ServiceWorkerCollector.js} +1 -1
- package/build/src/{bin/chrome-devtools-cli-options.js → config/cli-options.js} +378 -23
- package/build/src/{bin/chrome-devtools-mcp-cli-options.js → config/mcp-options.js} +73 -8
- package/build/src/daemon/client.js +11 -2
- package/build/src/daemon/daemon.js +2 -2
- package/build/src/devtools/DevtoolsUtils.js +2 -14
- package/build/src/formatters/ConsoleFormatter.js +43 -10
- package/build/src/formatters/HeapSnapshotFormatter.js +10 -2
- package/build/src/formatters/IssueFormatter.js +1 -1
- package/build/src/formatters/NetworkFormatter.js +7 -7
- package/build/src/index.js +33 -5
- package/build/src/{HeapSnapshotManager.js → processors/HeapSnapshotManager.js} +21 -5
- package/build/src/{trace-processing/parse.js → processors/PerformanceTrace.js} +1 -1
- package/build/src/telemetry/ClearcutLogger.js +13 -1
- package/build/src/telemetry/flagUtils.js +4 -3
- package/build/src/telemetry/types.js +4 -0
- package/build/src/third_party/THIRD_PARTY_NOTICES +6 -63
- package/build/src/third_party/bundled-packages.json +4 -4
- package/build/src/third_party/devtools-heap-snapshot-worker.js +274 -42
- package/build/src/third_party/index.js +35378 -35538
- package/build/src/third_party/issue-descriptions/connectionAllowlistEmbeddingRequirementNotSatisfied.md +26 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistIFrameAttributeLoosensEmbeddingRequirement.md +19 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowConnectionAllowlistFrom.md +21 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsBlockedByConnectionAllowlist.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestConfigBlockedByConnectionAllowlist.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenBlockedByConnectionAllowlist.md +1 -0
- package/build/src/third_party/issue-descriptions/federatedAuthRequestWellKnownBlockedByConnectionAllowlist.md +1 -0
- package/build/src/tools/categories.js +3 -0
- package/build/src/tools/console.js +9 -3
- package/build/src/tools/emulation.js +2 -2
- package/build/src/tools/extensions.js +7 -5
- package/build/src/tools/input.js +26 -16
- package/build/src/tools/lighthouse.js +3 -1
- package/build/src/tools/memory.js +112 -16
- package/build/src/tools/network.js +6 -3
- package/build/src/tools/pages.js +12 -16
- package/build/src/tools/performance.js +15 -25
- package/build/src/tools/pwa.js +128 -0
- package/build/src/tools/screencast.js +6 -4
- package/build/src/tools/screenshot.js +42 -9
- package/build/src/tools/script.js +28 -8
- package/build/src/tools/slim/tools.js +3 -3
- package/build/src/tools/snapshot.js +5 -3
- package/build/src/tools/thirdPartyDeveloper.js +2 -2
- package/build/src/tools/tools.js +2 -0
- package/build/src/tools/webmcp.js +2 -2
- package/build/src/{WaitForHelper.js → utils/WaitForHelper.js} +63 -38
- package/build/src/utils/bytes.js +105 -0
- package/build/src/utils/logger.js +25 -11
- package/build/src/version.js +1 -1
- package/package.json +20 -12
- package/skills/a11y-debugging/SKILL.md +2 -0
- package/skills/chrome-devtools/SKILL.md +5 -4
- package/skills/chrome-devtools-cli/SKILL.md +109 -64
- package/skills/debug-optimize-lcp/SKILL.md +9 -9
- package/skills/memory-leak-debugging/SKILL.md +2 -2
- package/skills/troubleshooting/SKILL.md +1 -0
- package/build/src/utils/string.js +0 -37
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# A framed document did not accept its embedder's `Connection-Allowlist`.
|
|
2
|
+
|
|
3
|
+
An embedder can require a framed document to enforce a `Connection-Allowlist` by
|
|
4
|
+
setting the `connectionallowlist` attribute on the frame. The framed document
|
|
5
|
+
must agree, in one of two ways:
|
|
6
|
+
|
|
7
|
+
* by responding with an `Allow-Connection-Allowlist-From` header naming the
|
|
8
|
+
embedder's origin (or `*` to accept any embedder), which installs the
|
|
9
|
+
embedder's allowlist on the framed document, or
|
|
10
|
+
* by responding with a `Connection-Allowlist` header of its own that is at
|
|
11
|
+
least as strict as the one required, which is then enforced instead.
|
|
12
|
+
|
|
13
|
+
This response did neither, so it was not displayed.
|
|
14
|
+
|
|
15
|
+
For example, a document framed by an embedder requiring
|
|
16
|
+
`("https://cdn.example/")` may accept that requirement outright:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
Allow-Connection-Allowlist-From: *
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
or satisfy it with an allowlist that is no more permissive:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Connection-Allowlist: ("https://cdn.example/")
|
|
26
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# A frame's `connectionallowlist` attribute was discarded.
|
|
2
|
+
|
|
3
|
+
An embedder can require a framed document to enforce a `Connection-Allowlist` by
|
|
4
|
+
setting the `connectionallowlist` attribute on the frame. When a requirement is
|
|
5
|
+
already in effect for the embedder itself, a nested frame's attribute may only
|
|
6
|
+
make that requirement stricter, never looser.
|
|
7
|
+
|
|
8
|
+
This frame's attribute allowed connections that the requirement it inherits from
|
|
9
|
+
an ancestor does not, so the attribute was discarded and the inherited
|
|
10
|
+
requirement applies unchanged.
|
|
11
|
+
|
|
12
|
+
For example, the nested frame below cannot re-admit `https://example.com/`, so
|
|
13
|
+
it inherits `("https://cdn.example/")` rather than the value it asked for:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
<!-- Framed by an ancestor that requires ("https://cdn.example/"): -->
|
|
17
|
+
<iframe connectionallowlist='("https://cdn.example/" "https://example.com/")'
|
|
18
|
+
src="..."></iframe>
|
|
19
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# The `Allow-Connection-Allowlist-From` header is invalid.
|
|
2
|
+
|
|
3
|
+
A document that is framed by an embedder requiring a `Connection-Allowlist` can
|
|
4
|
+
accept that requirement by responding with an `Allow-Connection-Allowlist-From`
|
|
5
|
+
header. The header's value must be either `*`, or a single serialized origin
|
|
6
|
+
naming the embedder whose requirement it is willing to accept.
|
|
7
|
+
|
|
8
|
+
This response's header was neither, so it could not be used to accept the
|
|
9
|
+
embedder's requirement.
|
|
10
|
+
|
|
11
|
+
For example, both of the following are valid:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Allow-Connection-Allowlist-From: *
|
|
15
|
+
Allow-Connection-Allowlist-From: https://example.com
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Note that an origin's serialization has no trailing slash, and carries no path,
|
|
19
|
+
query, or userinfo. Values like `https://example.com/` and
|
|
20
|
+
`https://user@example.com/path` are therefore rejected rather than being
|
|
21
|
+
silently reinterpreted as `https://example.com`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Fetching the provider's accounts list was blocked by the request's initiator's connection allowlists.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Fetching the provider's FedCM manifest configuration was blocked by the request's initiator's connection allowlists.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Fetching the provider's token was blocked by the request's initiator's connection allowlists.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Fetching the provider's well-known file was blocked by the request's initiator's connection allowlists.
|
|
@@ -15,6 +15,7 @@ export var ToolCategory;
|
|
|
15
15
|
ToolCategory["THIRD_PARTY"] = "experimentalThirdParty";
|
|
16
16
|
ToolCategory["MEMORY"] = "memory";
|
|
17
17
|
ToolCategory["WEBMCP"] = "experimentalWebmcp";
|
|
18
|
+
ToolCategory["PWA"] = "pwa";
|
|
18
19
|
})(ToolCategory || (ToolCategory = {}));
|
|
19
20
|
export const labels = {
|
|
20
21
|
[ToolCategory.INPUT]: 'Input automation',
|
|
@@ -27,10 +28,12 @@ export const labels = {
|
|
|
27
28
|
[ToolCategory.THIRD_PARTY]: 'Third-party',
|
|
28
29
|
[ToolCategory.MEMORY]: 'Memory',
|
|
29
30
|
[ToolCategory.WEBMCP]: 'WebMCP',
|
|
31
|
+
[ToolCategory.PWA]: 'Progressive Web Apps',
|
|
30
32
|
};
|
|
31
33
|
export const OFF_BY_DEFAULT_CATEGORIES = [
|
|
32
34
|
ToolCategory.EXTENSIONS,
|
|
33
35
|
ToolCategory.THIRD_PARTY,
|
|
34
36
|
ToolCategory.WEBMCP,
|
|
37
|
+
ToolCategory.PWA,
|
|
35
38
|
];
|
|
36
39
|
//# sourceMappingURL=categories.js.map
|
|
@@ -32,7 +32,7 @@ const LIST_CONSOLE_MESSAGES_TOOL_NAME = 'list_console_messages';
|
|
|
32
32
|
export const listConsoleMessages = definePageTool(cliArgs => {
|
|
33
33
|
return {
|
|
34
34
|
name: LIST_CONSOLE_MESSAGES_TOOL_NAME,
|
|
35
|
-
description: `List all console messages for the
|
|
35
|
+
description: `List all console messages for the target page since the last navigation.${cliArgs?.categoryExtensions ? ' This includes console messages originating from extensions content scripts.' : ''}`,
|
|
36
36
|
annotations: {
|
|
37
37
|
category: ToolCategory.DEBUGGING,
|
|
38
38
|
readOnlyHint: true,
|
|
@@ -59,19 +59,25 @@ export const listConsoleMessages = definePageTool(cliArgs => {
|
|
|
59
59
|
.default(false)
|
|
60
60
|
.optional()
|
|
61
61
|
.describe('Set to true to return the preserved messages over the last 3 navigations.'),
|
|
62
|
+
includeStackTraces: zod
|
|
63
|
+
.boolean()
|
|
64
|
+
.default(false)
|
|
65
|
+
.optional()
|
|
66
|
+
.describe('Set to true to include the stack trace for each message when available. Increases the response size.'),
|
|
62
67
|
serviceWorkerId: zod
|
|
63
68
|
.string()
|
|
64
69
|
.optional()
|
|
65
70
|
.describe('Filter messages to only return messages of the specified service worker.'),
|
|
66
71
|
},
|
|
67
72
|
blockedByDialog: false,
|
|
68
|
-
verifyFilesSchema:
|
|
73
|
+
verifyFilesSchema: {},
|
|
69
74
|
handler: async (request, response) => {
|
|
70
75
|
response.setIncludeConsoleData(true, {
|
|
71
76
|
pageSize: request.params.pageSize,
|
|
72
77
|
pageIdx: request.params.pageIdx,
|
|
73
78
|
types: request.params.types,
|
|
74
79
|
includePreservedMessages: request.params.includePreservedMessages,
|
|
80
|
+
includeStackTraces: request.params.includeStackTraces,
|
|
75
81
|
serviceWorkerId: request.params.serviceWorkerId,
|
|
76
82
|
});
|
|
77
83
|
},
|
|
@@ -90,7 +96,7 @@ export const getConsoleMessage = definePageTool({
|
|
|
90
96
|
.describe('The msgid of a console message on the page from the listed console messages'),
|
|
91
97
|
},
|
|
92
98
|
blockedByDialog: false,
|
|
93
|
-
verifyFilesSchema:
|
|
99
|
+
verifyFilesSchema: {},
|
|
94
100
|
handler: async (request, response) => {
|
|
95
101
|
response.attachConsoleMessage(request.params.msgid);
|
|
96
102
|
},
|
|
@@ -33,7 +33,7 @@ const throttlingOptions = [
|
|
|
33
33
|
];
|
|
34
34
|
export const emulate = definePageTool({
|
|
35
35
|
name: 'emulate',
|
|
36
|
-
description: `Emulates various features on the
|
|
36
|
+
description: `Emulates various features on the target page.`,
|
|
37
37
|
annotations: {
|
|
38
38
|
category: ToolCategory.EMULATION,
|
|
39
39
|
readOnlyHint: false,
|
|
@@ -74,7 +74,7 @@ export const emulate = definePageTool({
|
|
|
74
74
|
.describe('Extra HTTP headers as a JSON string object, e.g. {"X-Custom": "value", "Authorization": "Bearer token"}. Headers are included into every HTTP request originating from the page and persist across navigations until cleared. Pass an empty string to clear all extra headers.'),
|
|
75
75
|
},
|
|
76
76
|
blockedByDialog: true,
|
|
77
|
-
verifyFilesSchema:
|
|
77
|
+
verifyFilesSchema: {},
|
|
78
78
|
handler: async (request, response) => {
|
|
79
79
|
const page = request.page;
|
|
80
80
|
await page.emulate(request.params);
|
|
@@ -19,7 +19,9 @@ export const installExtension = defineTool({
|
|
|
19
19
|
.describe('Absolute path to the unpacked extension folder.'),
|
|
20
20
|
},
|
|
21
21
|
blockedByDialog: false,
|
|
22
|
-
verifyFilesSchema:
|
|
22
|
+
verifyFilesSchema: {
|
|
23
|
+
path: { local: true },
|
|
24
|
+
},
|
|
23
25
|
handler: async (request, response, context) => {
|
|
24
26
|
const { path } = request.params;
|
|
25
27
|
const id = await context.installExtension(path);
|
|
@@ -37,7 +39,7 @@ export const uninstallExtension = defineTool({
|
|
|
37
39
|
id: zod.string().describe('ID of the extension to uninstall.'),
|
|
38
40
|
},
|
|
39
41
|
blockedByDialog: false,
|
|
40
|
-
verifyFilesSchema:
|
|
42
|
+
verifyFilesSchema: {},
|
|
41
43
|
handler: async (request, response, context) => {
|
|
42
44
|
const { id } = request.params;
|
|
43
45
|
await context.uninstallExtension(id);
|
|
@@ -53,7 +55,7 @@ export const listExtensions = defineTool({
|
|
|
53
55
|
},
|
|
54
56
|
schema: {},
|
|
55
57
|
blockedByDialog: false,
|
|
56
|
-
verifyFilesSchema:
|
|
58
|
+
verifyFilesSchema: {},
|
|
57
59
|
handler: async (_request, response) => {
|
|
58
60
|
response.setListExtensions();
|
|
59
61
|
},
|
|
@@ -69,7 +71,7 @@ export const reloadExtension = defineTool({
|
|
|
69
71
|
id: zod.string().describe('ID of the extension to reload.'),
|
|
70
72
|
},
|
|
71
73
|
blockedByDialog: false,
|
|
72
|
-
verifyFilesSchema:
|
|
74
|
+
verifyFilesSchema: {},
|
|
73
75
|
handler: async (request, response, context) => {
|
|
74
76
|
const { id } = request.params;
|
|
75
77
|
const extension = await context.getExtension(id);
|
|
@@ -91,7 +93,7 @@ export const triggerExtensionAction = defineTool({
|
|
|
91
93
|
id: zod.string().describe('ID of the extension to trigger the action for.'),
|
|
92
94
|
},
|
|
93
95
|
blockedByDialog: false,
|
|
94
|
-
verifyFilesSchema:
|
|
96
|
+
verifyFilesSchema: {},
|
|
95
97
|
handler: async (request, response, context) => {
|
|
96
98
|
const { id } = request.params;
|
|
97
99
|
await context.triggerExtensionAction(id);
|
package/build/src/tools/input.js
CHANGED
|
@@ -131,7 +131,7 @@ export const click = definePageTool({
|
|
|
131
131
|
includeSnapshot: includeSnapshotSchema,
|
|
132
132
|
},
|
|
133
133
|
blockedByDialog: true,
|
|
134
|
-
verifyFilesSchema:
|
|
134
|
+
verifyFilesSchema: {},
|
|
135
135
|
handler: async (request, response) => {
|
|
136
136
|
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
137
137
|
try {
|
|
@@ -185,7 +185,7 @@ export const clickAt = definePageTool({
|
|
|
185
185
|
includeSnapshot: includeSnapshotSchema,
|
|
186
186
|
},
|
|
187
187
|
blockedByDialog: true,
|
|
188
|
-
verifyFilesSchema:
|
|
188
|
+
verifyFilesSchema: {},
|
|
189
189
|
handler: async (request, response) => {
|
|
190
190
|
const page = request.page;
|
|
191
191
|
const result = await page.waitForEventsAfterAction(async () => {
|
|
@@ -216,7 +216,7 @@ export const hover = definePageTool({
|
|
|
216
216
|
includeSnapshot: includeSnapshotSchema,
|
|
217
217
|
},
|
|
218
218
|
blockedByDialog: true,
|
|
219
|
-
verifyFilesSchema:
|
|
219
|
+
verifyFilesSchema: {},
|
|
220
220
|
handler: async (request, response) => {
|
|
221
221
|
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
222
222
|
try {
|
|
@@ -262,8 +262,8 @@ async function selectOption(handle, aXNode, value) {
|
|
|
262
262
|
try {
|
|
263
263
|
const childValueHandle = __addDisposableResource(env_5, await childHandle.getProperty('value'), false);
|
|
264
264
|
const childValue = await childValueHandle.jsonValue();
|
|
265
|
-
if (childValue) {
|
|
266
|
-
await handle.asLocator().fill(childValue
|
|
265
|
+
if (typeof childValue === 'string') {
|
|
266
|
+
await handle.asLocator().fill(childValue);
|
|
267
267
|
}
|
|
268
268
|
break;
|
|
269
269
|
}
|
|
@@ -356,7 +356,7 @@ export const fill = definePageTool({
|
|
|
356
356
|
includeSnapshot: includeSnapshotSchema,
|
|
357
357
|
},
|
|
358
358
|
blockedByDialog: true,
|
|
359
|
-
verifyFilesSchema:
|
|
359
|
+
verifyFilesSchema: {},
|
|
360
360
|
handler: async (request, response, context) => {
|
|
361
361
|
const page = request.page;
|
|
362
362
|
const result = await page.waitForEventsAfterAction(async () => {
|
|
@@ -381,7 +381,7 @@ export const typeText = definePageTool({
|
|
|
381
381
|
submitKey: submitKeySchema,
|
|
382
382
|
},
|
|
383
383
|
blockedByDialog: true,
|
|
384
|
-
verifyFilesSchema:
|
|
384
|
+
verifyFilesSchema: {},
|
|
385
385
|
handler: async (request, response) => {
|
|
386
386
|
const page = request.page;
|
|
387
387
|
const result = await page.waitForEventsAfterAction(async () => {
|
|
@@ -407,7 +407,7 @@ export const drag = definePageTool({
|
|
|
407
407
|
includeSnapshot: includeSnapshotSchema,
|
|
408
408
|
},
|
|
409
409
|
blockedByDialog: true,
|
|
410
|
-
verifyFilesSchema:
|
|
410
|
+
verifyFilesSchema: {},
|
|
411
411
|
handler: async (request, response) => {
|
|
412
412
|
const env_7 = { stack: [], error: void 0, hasError: false };
|
|
413
413
|
try {
|
|
@@ -454,7 +454,7 @@ export const fillForm = definePageTool({
|
|
|
454
454
|
includeSnapshot: includeSnapshotSchema,
|
|
455
455
|
},
|
|
456
456
|
blockedByDialog: true,
|
|
457
|
-
verifyFilesSchema:
|
|
457
|
+
verifyFilesSchema: {},
|
|
458
458
|
handler: async (request, response, context) => {
|
|
459
459
|
const page = request.page;
|
|
460
460
|
let lastResult = {};
|
|
@@ -481,18 +481,28 @@ export const uploadFile = definePageTool({
|
|
|
481
481
|
uid: zod
|
|
482
482
|
.string()
|
|
483
483
|
.describe('The uid of the file input element or an element that will open file chooser on the page from the page content snapshot'),
|
|
484
|
-
|
|
484
|
+
filePaths: zod
|
|
485
|
+
.array(zod.string())
|
|
486
|
+
.min(1)
|
|
487
|
+
.describe('One or more files paths to upload. File paths have to be local to the browser instance (not the MCP).'),
|
|
485
488
|
includeSnapshot: includeSnapshotSchema,
|
|
486
489
|
},
|
|
487
490
|
blockedByDialog: true,
|
|
488
|
-
|
|
491
|
+
// We do not validate file paths for remote browser instances
|
|
492
|
+
// because they are on the remote host and not accessed by the MCP server.
|
|
493
|
+
verifyFilesSchema: {
|
|
494
|
+
filePaths: {
|
|
495
|
+
local: true,
|
|
496
|
+
remote: false,
|
|
497
|
+
},
|
|
498
|
+
},
|
|
489
499
|
handler: async (request, response) => {
|
|
490
500
|
const env_8 = { stack: [], error: void 0, hasError: false };
|
|
491
501
|
try {
|
|
492
|
-
const { uid,
|
|
502
|
+
const { uid, filePaths } = request.params;
|
|
493
503
|
const handle = __addDisposableResource(env_8, (await request.page.getElementByUid(uid)), false);
|
|
494
504
|
try {
|
|
495
|
-
await handle.uploadFile(
|
|
505
|
+
await handle.uploadFile(...filePaths);
|
|
496
506
|
}
|
|
497
507
|
catch {
|
|
498
508
|
// Some sites use a proxy element to trigger file upload instead of
|
|
@@ -503,7 +513,7 @@ export const uploadFile = definePageTool({
|
|
|
503
513
|
request.page.pptrPage.waitForFileChooser({ timeout: 3000 }),
|
|
504
514
|
handle.asLocator().click(),
|
|
505
515
|
]);
|
|
506
|
-
await fileChooser.accept(
|
|
516
|
+
await fileChooser.accept(filePaths);
|
|
507
517
|
}
|
|
508
518
|
catch {
|
|
509
519
|
throw new Error(`Failed to upload file. The element could not accept the file directly, and clicking it did not trigger a file chooser.`);
|
|
@@ -512,7 +522,7 @@ export const uploadFile = definePageTool({
|
|
|
512
522
|
if (request.params.includeSnapshot) {
|
|
513
523
|
response.includeSnapshot();
|
|
514
524
|
}
|
|
515
|
-
response.appendResponseLine(`File uploaded from ${
|
|
525
|
+
response.appendResponseLine(`File uploaded from ${filePaths.join(', ')}.`);
|
|
516
526
|
}
|
|
517
527
|
catch (e_8) {
|
|
518
528
|
env_8.error = e_8;
|
|
@@ -537,7 +547,7 @@ export const pressKey = definePageTool({
|
|
|
537
547
|
includeSnapshot: includeSnapshotSchema,
|
|
538
548
|
},
|
|
539
549
|
blockedByDialog: true,
|
|
540
|
-
verifyFilesSchema:
|
|
550
|
+
verifyFilesSchema: {},
|
|
541
551
|
handler: async (request, response) => {
|
|
542
552
|
const page = request.page;
|
|
543
553
|
const tokens = parseKey(request.params.key);
|
|
@@ -30,7 +30,9 @@ export const lighthouseAudit = definePageTool({
|
|
|
30
30
|
.describe('Directory for reports. If omitted, uses temporary files.'),
|
|
31
31
|
},
|
|
32
32
|
blockedByDialog: true,
|
|
33
|
-
verifyFilesSchema:
|
|
33
|
+
verifyFilesSchema: {
|
|
34
|
+
outputDirPath: true,
|
|
35
|
+
},
|
|
34
36
|
handler: async (request, response, context) => {
|
|
35
37
|
const page = request.page;
|
|
36
38
|
const categories = [
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { zod } from '../third_party/index.js';
|
|
7
|
+
import { byteSizeRangeSchema } from '../utils/bytes.js';
|
|
7
8
|
import { ToolCategory } from './categories.js';
|
|
8
9
|
import { definePageTool, defineTool } from './ToolDefinition.js';
|
|
9
10
|
const HEAP_SNAPSHOT_FILTERS = [
|
|
@@ -17,7 +18,7 @@ const HEAP_SNAPSHOT_FILTERS = [
|
|
|
17
18
|
];
|
|
18
19
|
export const takeHeapSnapshot = definePageTool({
|
|
19
20
|
name: 'take_heapsnapshot',
|
|
20
|
-
description: `Capture a heap snapshot of the
|
|
21
|
+
description: `Capture a heap snapshot of the target page. Use to analyze the memory distribution of JavaScript objects and debug memory leaks.`,
|
|
21
22
|
annotations: {
|
|
22
23
|
category: ToolCategory.MEMORY,
|
|
23
24
|
readOnlyHint: false,
|
|
@@ -28,7 +29,9 @@ export const takeHeapSnapshot = definePageTool({
|
|
|
28
29
|
.describe('A path to a .heapsnapshot file to save the heapsnapshot to.'),
|
|
29
30
|
},
|
|
30
31
|
blockedByDialog: true,
|
|
31
|
-
verifyFilesSchema:
|
|
32
|
+
verifyFilesSchema: {
|
|
33
|
+
filePath: true,
|
|
34
|
+
},
|
|
32
35
|
handler: async (request, response, context) => {
|
|
33
36
|
const page = request.page;
|
|
34
37
|
const snapshotPath = await context.ensureExtension(request.params.filePath, '.heapsnapshot');
|
|
@@ -40,7 +43,7 @@ export const takeHeapSnapshot = definePageTool({
|
|
|
40
43
|
});
|
|
41
44
|
export const getHeapSnapshotSummary = defineTool({
|
|
42
45
|
name: 'get_heapsnapshot_summary',
|
|
43
|
-
description: 'Loads a memory heapsnapshot and returns snapshot summary stats, including native contexts and their sizes.',
|
|
46
|
+
description: 'Loads a memory heapsnapshot and returns snapshot summary stats, including native contexts and their sizes, and retained by context summary.',
|
|
44
47
|
annotations: {
|
|
45
48
|
category: ToolCategory.MEMORY,
|
|
46
49
|
readOnlyHint: true,
|
|
@@ -50,12 +53,15 @@ export const getHeapSnapshotSummary = defineTool({
|
|
|
50
53
|
filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),
|
|
51
54
|
},
|
|
52
55
|
blockedByDialog: false,
|
|
53
|
-
verifyFilesSchema:
|
|
56
|
+
verifyFilesSchema: {
|
|
57
|
+
filePath: true,
|
|
58
|
+
},
|
|
54
59
|
handler: async (request, response, context) => {
|
|
55
60
|
const stats = await context.getHeapSnapshotStats(request.params.filePath);
|
|
56
61
|
const staticData = await context.getHeapSnapshotStaticData(request.params.filePath);
|
|
57
62
|
const nativeContextSizes = await context.getHeapSnapshotNativeContextSizes(request.params.filePath);
|
|
58
|
-
|
|
63
|
+
const retainedByContextSummary = await context.getHeapSnapshotRetainedByContextSummary(request.params.filePath);
|
|
64
|
+
response.setHeapSnapshotStats(stats, staticData, nativeContextSizes, retainedByContextSummary);
|
|
59
65
|
},
|
|
60
66
|
});
|
|
61
67
|
export const getHeapSnapshotDetails = defineTool({
|
|
@@ -86,7 +92,9 @@ export const getHeapSnapshotDetails = defineTool({
|
|
|
86
92
|
.describe('The page size for pagination of aggregates.'),
|
|
87
93
|
},
|
|
88
94
|
blockedByDialog: false,
|
|
89
|
-
verifyFilesSchema:
|
|
95
|
+
verifyFilesSchema: {
|
|
96
|
+
filePath: true,
|
|
97
|
+
},
|
|
90
98
|
handler: async (request, response, context) => {
|
|
91
99
|
const aggregates = await context.getHeapSnapshotAggregates(request.params.filePath, request.params.filterName, request.params.objectId);
|
|
92
100
|
response.setHeapSnapshotAggregates(aggregates, {
|
|
@@ -118,7 +126,9 @@ export const getHeapSnapshotClassNodes = defineTool({
|
|
|
118
126
|
pageSize: zod.number().optional().describe('The page size for pagination.'),
|
|
119
127
|
},
|
|
120
128
|
blockedByDialog: false,
|
|
121
|
-
verifyFilesSchema:
|
|
129
|
+
verifyFilesSchema: {
|
|
130
|
+
filePath: true,
|
|
131
|
+
},
|
|
122
132
|
handler: async (request, response, context) => {
|
|
123
133
|
const nodes = await context.getHeapSnapshotNodesById(request.params.filePath, request.params.id, request.params.filterName, request.params.objectId);
|
|
124
134
|
response.setHeapSnapshotNodes(nodes, {
|
|
@@ -136,7 +146,9 @@ export const getHeapSnapshotRetainers = defineTool({
|
|
|
136
146
|
conditions: ['memoryDebugging'],
|
|
137
147
|
},
|
|
138
148
|
blockedByDialog: false,
|
|
139
|
-
verifyFilesSchema:
|
|
149
|
+
verifyFilesSchema: {
|
|
150
|
+
filePath: true,
|
|
151
|
+
},
|
|
140
152
|
schema: {
|
|
141
153
|
filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),
|
|
142
154
|
nodeId: zod.number().describe('The node ID to get retainers for.'),
|
|
@@ -159,7 +171,9 @@ export const closeHeapSnapshot = defineTool({
|
|
|
159
171
|
readOnlyHint: false,
|
|
160
172
|
conditions: ['memoryDebugging'],
|
|
161
173
|
},
|
|
162
|
-
verifyFilesSchema:
|
|
174
|
+
verifyFilesSchema: {
|
|
175
|
+
filePath: true,
|
|
176
|
+
},
|
|
163
177
|
schema: {
|
|
164
178
|
filePath: zod
|
|
165
179
|
.string()
|
|
@@ -182,7 +196,9 @@ export const getHeapSnapshotRetainingPaths = defineTool({
|
|
|
182
196
|
readOnlyHint: true,
|
|
183
197
|
conditions: ['memoryDebugging'],
|
|
184
198
|
},
|
|
185
|
-
verifyFilesSchema:
|
|
199
|
+
verifyFilesSchema: {
|
|
200
|
+
filePath: true,
|
|
201
|
+
},
|
|
186
202
|
blockedByDialog: false,
|
|
187
203
|
schema: {
|
|
188
204
|
filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),
|
|
@@ -214,15 +230,31 @@ export const getHeapSnapshotEdges = defineTool({
|
|
|
214
230
|
conditions: ['memoryDebugging'],
|
|
215
231
|
},
|
|
216
232
|
blockedByDialog: false,
|
|
217
|
-
verifyFilesSchema:
|
|
233
|
+
verifyFilesSchema: {
|
|
234
|
+
filePath: true,
|
|
235
|
+
},
|
|
218
236
|
schema: {
|
|
219
237
|
filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),
|
|
220
238
|
nodeId: zod.number().describe('The node ID to get outgoing edges for.'),
|
|
239
|
+
sortBy: zod
|
|
240
|
+
.enum(['retainedSize', 'selfSize', 'name'])
|
|
241
|
+
.optional()
|
|
242
|
+
.describe('Sort order for edges. Default is retainedSize.'),
|
|
243
|
+
retainedSize: byteSizeRangeSchema('Inclusive retained size range (e.g. "1MB-2MB", "-1MB", or "1MB-") for target nodes. A single value is treated as a minimum. Currently, only the lower bound is applied.').optional(),
|
|
244
|
+
excludePrimitives: zod
|
|
245
|
+
.boolean()
|
|
246
|
+
.optional()
|
|
247
|
+
.describe('Whether to exclude primitive target nodes. Default is true.'),
|
|
221
248
|
pageIdx: zod.number().optional().describe('The page index for pagination.'),
|
|
222
249
|
pageSize: zod.number().optional().describe('The page size for pagination.'),
|
|
223
250
|
},
|
|
224
251
|
handler: async (request, response, context) => {
|
|
225
|
-
const edges = await context.getHeapSnapshotEdges(request.params.filePath, request.params.nodeId
|
|
252
|
+
const edges = await context.getHeapSnapshotEdges(request.params.filePath, request.params.nodeId, {
|
|
253
|
+
sortBy: request.params.sortBy ?? 'retainedSize',
|
|
254
|
+
// DevTools currently only supports a lower retained-size bound here.
|
|
255
|
+
minRetainedSize: request.params.retainedSize?.min,
|
|
256
|
+
excludePrimitives: request.params.excludePrimitives ?? true,
|
|
257
|
+
});
|
|
226
258
|
response.setHeapSnapshotNodes(edges, {
|
|
227
259
|
pageIdx: request.params.pageIdx,
|
|
228
260
|
pageSize: request.params.pageSize,
|
|
@@ -238,7 +270,9 @@ export const getHeapSnapshotDominators = defineTool({
|
|
|
238
270
|
conditions: ['memoryDebugging'],
|
|
239
271
|
},
|
|
240
272
|
blockedByDialog: false,
|
|
241
|
-
verifyFilesSchema:
|
|
273
|
+
verifyFilesSchema: {
|
|
274
|
+
filePath: true,
|
|
275
|
+
},
|
|
242
276
|
schema: {
|
|
243
277
|
filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),
|
|
244
278
|
nodeId: zod
|
|
@@ -258,7 +292,10 @@ export const compareHeapSnapshots = defineTool({
|
|
|
258
292
|
readOnlyHint: true,
|
|
259
293
|
conditions: ['memoryDebugging'],
|
|
260
294
|
},
|
|
261
|
-
verifyFilesSchema:
|
|
295
|
+
verifyFilesSchema: {
|
|
296
|
+
baseFilePath: true,
|
|
297
|
+
currentFilePath: true,
|
|
298
|
+
},
|
|
262
299
|
schema: {
|
|
263
300
|
baseFilePath: zod
|
|
264
301
|
.string()
|
|
@@ -292,7 +329,9 @@ export const getHeapSnapshotDuplicateStrings = defineTool({
|
|
|
292
329
|
conditions: ['memoryDebugging'],
|
|
293
330
|
},
|
|
294
331
|
blockedByDialog: false,
|
|
295
|
-
verifyFilesSchema:
|
|
332
|
+
verifyFilesSchema: {
|
|
333
|
+
filePath: true,
|
|
334
|
+
},
|
|
296
335
|
schema: {
|
|
297
336
|
filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),
|
|
298
337
|
pageIdx: zod.number().optional().describe('The page index for pagination.'),
|
|
@@ -315,7 +354,9 @@ export const getHeapSnapshotObjectDetails = defineTool({
|
|
|
315
354
|
conditions: ['memoryDebugging'],
|
|
316
355
|
},
|
|
317
356
|
blockedByDialog: false,
|
|
318
|
-
verifyFilesSchema:
|
|
357
|
+
verifyFilesSchema: {
|
|
358
|
+
filePath: true,
|
|
359
|
+
},
|
|
319
360
|
schema: {
|
|
320
361
|
filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),
|
|
321
362
|
nodeId: zod.number().describe('The node ID to get object details for.'),
|
|
@@ -325,4 +366,59 @@ export const getHeapSnapshotObjectDetails = defineTool({
|
|
|
325
366
|
response.setHeapSnapshotObjectDetails(objectInfo);
|
|
326
367
|
},
|
|
327
368
|
});
|
|
369
|
+
export const queryHeapSnapshotObjects = defineTool({
|
|
370
|
+
name: 'query_heapsnapshot_objects',
|
|
371
|
+
description: 'Loads a memory heapsnapshot and queries objects matching specific filters (className, propertyName, nodeType, retainedSize, selfSize, isDetached, sortBy).',
|
|
372
|
+
annotations: {
|
|
373
|
+
category: ToolCategory.MEMORY,
|
|
374
|
+
readOnlyHint: true,
|
|
375
|
+
conditions: ['memoryDebugging'],
|
|
376
|
+
},
|
|
377
|
+
blockedByDialog: false,
|
|
378
|
+
verifyFilesSchema: { filePath: true },
|
|
379
|
+
schema: {
|
|
380
|
+
filePath: zod.string().describe('A path to a .heapsnapshot file to read.'),
|
|
381
|
+
className: zod
|
|
382
|
+
.string()
|
|
383
|
+
.optional()
|
|
384
|
+
.describe('Optional regex or text matching object class name.'),
|
|
385
|
+
propertyName: zod
|
|
386
|
+
.string()
|
|
387
|
+
.optional()
|
|
388
|
+
.describe('Optional property name filter for outgoing reference edges.'),
|
|
389
|
+
nodeType: zod
|
|
390
|
+
.string()
|
|
391
|
+
.optional()
|
|
392
|
+
.describe('Optional V8 node type filter (e.g. object, closure, string, array, code).'),
|
|
393
|
+
retainedSize: byteSizeRangeSchema('Inclusive retained size range (e.g. "1MB-2MB", "-1MB", or "1MB-"). A single value is treated as a minimum.').optional(),
|
|
394
|
+
selfSize: byteSizeRangeSchema('Inclusive self size range (e.g. "1MB-2MB", "-1MB", or "1MB-"). A single value is treated as a minimum.').optional(),
|
|
395
|
+
isDetached: zod
|
|
396
|
+
.boolean()
|
|
397
|
+
.optional()
|
|
398
|
+
.describe('Whether to filter for detached DOM nodes.'),
|
|
399
|
+
sortBy: zod
|
|
400
|
+
.enum(['retainedSize', 'selfSize', 'id'])
|
|
401
|
+
.optional()
|
|
402
|
+
.describe('Sort order for results. Default is retainedSize.'),
|
|
403
|
+
pageIdx: zod.number().optional().describe('The page index for pagination.'),
|
|
404
|
+
pageSize: zod.number().optional().describe('The page size for pagination.'),
|
|
405
|
+
},
|
|
406
|
+
handler: async (request, response, context) => {
|
|
407
|
+
const range = await context.queryHeapSnapshotObjects(request.params.filePath, {
|
|
408
|
+
className: request.params.className,
|
|
409
|
+
propertyName: request.params.propertyName,
|
|
410
|
+
nodeType: request.params.nodeType,
|
|
411
|
+
minRetainedSize: request.params.retainedSize?.min,
|
|
412
|
+
maxRetainedSize: request.params.retainedSize?.max,
|
|
413
|
+
minSelfSize: request.params.selfSize?.min,
|
|
414
|
+
maxSelfSize: request.params.selfSize?.max,
|
|
415
|
+
isDetached: request.params.isDetached,
|
|
416
|
+
sortBy: request.params.sortBy,
|
|
417
|
+
});
|
|
418
|
+
response.setHeapSnapshotNodes(range, {
|
|
419
|
+
pageIdx: request.params.pageIdx,
|
|
420
|
+
pageSize: request.params.pageSize,
|
|
421
|
+
});
|
|
422
|
+
},
|
|
423
|
+
});
|
|
328
424
|
//# sourceMappingURL=memory.js.map
|
|
@@ -29,7 +29,7 @@ const FILTERABLE_RESOURCE_TYPES = [
|
|
|
29
29
|
];
|
|
30
30
|
export const listNetworkRequests = definePageTool({
|
|
31
31
|
name: 'list_network_requests',
|
|
32
|
-
description: `Lists the most recent requests for the
|
|
32
|
+
description: `Lists the most recent requests for the target page since the last navigation.`,
|
|
33
33
|
annotations: {
|
|
34
34
|
category: ToolCategory.NETWORK,
|
|
35
35
|
readOnlyHint: true,
|
|
@@ -58,7 +58,7 @@ export const listNetworkRequests = definePageTool({
|
|
|
58
58
|
.describe('Set to true to return the preserved requests over the last 3 navigations.'),
|
|
59
59
|
},
|
|
60
60
|
blockedByDialog: false,
|
|
61
|
-
verifyFilesSchema:
|
|
61
|
+
verifyFilesSchema: {},
|
|
62
62
|
handler: async (request, response) => {
|
|
63
63
|
const data = await request.page.getDevToolsData();
|
|
64
64
|
response.attachDevToolsData(data);
|
|
@@ -96,7 +96,10 @@ export const getNetworkRequest = definePageTool({
|
|
|
96
96
|
.describe('The absolute or relative path to a .network-response file to save the response body to. If omitted, the body is returned inline.'),
|
|
97
97
|
},
|
|
98
98
|
blockedByDialog: true,
|
|
99
|
-
verifyFilesSchema:
|
|
99
|
+
verifyFilesSchema: {
|
|
100
|
+
requestFilePath: true,
|
|
101
|
+
responseFilePath: true,
|
|
102
|
+
},
|
|
100
103
|
handler: async (request, response) => {
|
|
101
104
|
if (request.params.reqid) {
|
|
102
105
|
response.attachNetworkRequest(request.params.reqid, {
|