opera-devtools-mcp 0.6.0 → 0.7.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.
Files changed (51) hide show
  1. package/build/src/McpContext.js +78 -41
  2. package/build/src/McpPage.js +5 -1
  3. package/build/src/ToolHandler.js +45 -74
  4. package/build/src/bin/chrome-devtools-mcp-main.js +4 -4
  5. package/build/src/bin/chrome-devtools.js +29 -30
  6. package/build/src/bin/opera-devtools-cli-options.js +1 -1
  7. package/build/src/bin/opera-devtools-mcp-cli-options.js +1 -1
  8. package/build/src/browser.js +5 -16
  9. package/build/src/config/browser-options.js +126 -0
  10. package/build/src/config/category-options.js +81 -0
  11. package/build/src/{bin/chrome-devtools-cli-options.js → config/cli-options.js} +392 -26
  12. package/build/src/{bin/chrome-devtools-mcp-cli-options.js → config/mcp-options.js} +143 -164
  13. package/build/src/daemon/client.js +9 -0
  14. package/build/src/daemon/utils.js +6 -0
  15. package/build/src/devtools/DevtoolsUtils.js +27 -21
  16. package/build/src/formatters/NetworkFormatter.js +5 -2
  17. package/build/src/index.js +166 -100
  18. package/build/src/processors/HeapSnapshotManager.js +12 -0
  19. package/build/src/telemetry/ClearcutLogger.js +19 -6
  20. package/build/src/telemetry/transformation.js +4 -0
  21. package/build/src/telemetry/types.js +4 -0
  22. package/build/src/third_party/THIRD_PARTY_NOTICES +5 -5
  23. package/build/src/third_party/bundled-packages.json +3 -3
  24. package/build/src/third_party/devtools-formatter-worker.js +22 -0
  25. package/build/src/third_party/devtools-heap-snapshot-worker.js +100 -20
  26. package/build/src/third_party/index.js +15459 -14256
  27. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsBlockedByConnectionAllowlist.md +1 -0
  28. package/build/src/third_party/issue-descriptions/federatedAuthRequestConfigBlockedByConnectionAllowlist.md +1 -0
  29. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenBlockedByConnectionAllowlist.md +1 -0
  30. package/build/src/third_party/issue-descriptions/federatedAuthRequestWellKnownBlockedByConnectionAllowlist.md +1 -0
  31. package/build/src/tools/ToolDefinition.js +15 -0
  32. package/build/src/tools/categories.js +0 -6
  33. package/build/src/tools/comments.js +90 -0
  34. package/build/src/tools/console.js +1 -1
  35. package/build/src/tools/emulation.js +1 -1
  36. package/build/src/tools/extensions.js +1 -1
  37. package/build/src/tools/memory.js +60 -6
  38. package/build/src/tools/network.js +2 -2
  39. package/build/src/tools/pages.js +26 -15
  40. package/build/src/tools/performance.js +4 -3
  41. package/build/src/tools/screencast.js +3 -2
  42. package/build/src/tools/screenshot.js +39 -8
  43. package/build/src/tools/script.js +17 -4
  44. package/build/src/tools/slim/tools.js +41 -33
  45. package/build/src/tools/snapshot.js +1 -1
  46. package/build/src/tools/tools.js +2 -0
  47. package/build/src/utils/WaitForHelper.js +12 -1
  48. package/build/src/utils/bytes.js +105 -0
  49. package/build/src/utils/url.js +73 -0
  50. package/build/src/version.js +1 -1
  51. package/package.json +23 -4
@@ -5,110 +5,17 @@
5
5
  *
6
6
  * Modified by Opera Software AS.
7
7
  */
8
- import { CACHE_DIR_NAME, ENV_NO_USAGE_STATISTICS, MCP_BIN_NAME, PACKAGE_NAME, REPO_URL, } from '../opera/branding.js';
8
+ import { ENV_NO_USAGE_STATISTICS, PACKAGE_NAME, REPO_URL, } from '../opera/branding.js';
9
9
  import { PERFORMANCE_CRUX_DEFAULT, PERFORMANCE_CRUX_DESCRIPTION, USAGE_STATISTICS_DEFAULT, USAGE_STATISTICS_DESCRIPTION, } from '../opera/policy.js';
10
10
  import { yargs, hideBin } from '../third_party/index.js';
11
- export const cliOptions = {
12
- autoConnect: {
13
- type: 'boolean',
14
- description: 'If specified, automatically connects to a browser (Chrome 144+) running locally from the user data directory identified by the channel param (default channel is stable). Requires the remote debugging server to be started in the Chrome instance via chrome://inspect/#remote-debugging.',
15
- conflicts: ['isolated', 'executablePath'],
16
- default: false,
17
- coerce: (value) => {
18
- if (!value) {
19
- return;
20
- }
21
- return value;
22
- },
23
- },
24
- browserUrl: {
25
- type: 'string',
26
- description: `Connect to a running, debuggable Chrome instance (e.g. \`http://127.0.0.1:9222\`). For more details see: ${REPO_URL}#connecting-to-a-running-chrome-instance.`,
27
- alias: 'u',
28
- conflicts: ['wsEndpoint'],
29
- coerce: (url) => {
30
- if (!url) {
31
- return;
32
- }
33
- try {
34
- new URL(url);
35
- }
36
- catch {
37
- throw new Error(`Provided browserUrl ${url} is not valid URL.`);
38
- }
39
- return url;
40
- },
41
- },
42
- wsEndpoint: {
43
- type: 'string',
44
- description: 'WebSocket endpoint to connect to a running Chrome instance (e.g., ws://127.0.0.1:9222/devtools/browser/<id>). Alternative to --browserUrl.',
45
- alias: 'w',
46
- conflicts: ['browserUrl'],
47
- coerce: (url) => {
48
- if (!url) {
49
- return;
50
- }
51
- try {
52
- const parsed = new URL(url);
53
- if (parsed.protocol !== 'ws:' && parsed.protocol !== 'wss:') {
54
- throw new Error(`Provided wsEndpoint ${url} must use ws:// or wss:// protocol.`);
55
- }
56
- return url;
57
- }
58
- catch (error) {
59
- if (error.message.includes('ws://')) {
60
- throw error;
61
- }
62
- throw new Error(`Provided wsEndpoint ${url} is not valid URL.`);
63
- }
64
- },
65
- },
66
- wsHeaders: {
67
- type: 'string',
68
- description: 'Custom headers for WebSocket connection in JSON format (e.g., \'{"Authorization":"Bearer token"}\'). Only works with --wsEndpoint.',
69
- implies: 'wsEndpoint',
70
- coerce: (val) => {
71
- if (!val) {
72
- return;
73
- }
74
- try {
75
- const parsed = JSON.parse(val);
76
- if (typeof parsed !== 'object' || Array.isArray(parsed)) {
77
- throw new Error('Headers must be a JSON object');
78
- }
79
- return parsed;
80
- }
81
- catch (error) {
82
- throw new Error(`Invalid JSON for wsHeaders: ${error.message}`);
83
- }
84
- },
85
- },
86
- headless: {
87
- type: 'boolean',
88
- description: 'Whether to run in headless (no UI) mode.',
89
- default: false,
90
- },
91
- executablePath: {
92
- type: 'string',
93
- description: 'Path to custom Chrome executable.',
94
- conflicts: ['browserUrl', 'wsEndpoint'],
95
- alias: 'e',
96
- },
97
- isolated: {
98
- type: 'boolean',
99
- description: 'If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed. Defaults to false.',
100
- },
101
- userDataDir: {
102
- type: 'string',
103
- description: `Path to the user data directory for Chrome. Default is $HOME/.cache/${CACHE_DIR_NAME}/chrome-profile$CHANNEL_SUFFIX_IF_NON_STABLE`,
104
- conflicts: ['browserUrl', 'wsEndpoint', 'isolated'],
105
- },
106
- channel: {
107
- type: 'string',
108
- description: 'Specify a different Chrome channel that should be used. The default is the stable channel version.',
109
- choices: ['canary', 'dev', 'beta', 'stable'],
110
- conflicts: ['browserUrl', 'wsEndpoint', 'executablePath'],
111
- },
11
+ import os from 'node:os';
12
+ import { readFileSync } from 'node:fs';
13
+ export const DEFAULT_FILESYSTEM_ROOT = [os.tmpdir()];
14
+ import { getCategoryOptions } from './category-options.js';
15
+ import { getBrowserOptions } from './browser-options.js';
16
+ export const mcpOptions = {
17
+ ...getCategoryOptions(),
18
+ ...getBrowserOptions(),
112
19
  logFile: {
113
20
  type: 'string',
114
21
  describe: 'Path to a file to write debug logs to. Set the env variable `DEBUG` to `*` to enable verbose logs. Useful for submitting bug reports.',
@@ -130,17 +37,20 @@ export const cliOptions = {
130
37
  };
131
38
  },
132
39
  },
133
- proxyServer: {
134
- type: 'string',
135
- description: `Proxy server configuration for Chrome passed as --proxy-server when launching the browser. See https://www.chromium.org/developers/design-documents/network-settings/ for details.`,
136
- },
137
40
  acceptInsecureCerts: {
138
41
  type: 'boolean',
139
42
  description: `If enabled, ignores errors relative to self-signed and expired certificates. Use with caution.`,
140
43
  },
141
- experimentalPageIdRouting: {
44
+ pageIdRouting: {
142
45
  type: 'boolean',
143
- describe: 'Whether to expose pageId on page-scoped tools and route requests by page ID (useful for concurrent agent sessions).',
46
+ describe: 'Require pageId on page-scoped tools and route requests by page ID (useful for concurrent agent sessions). Use --no-page-id-routing to disable.',
47
+ default: true,
48
+ },
49
+ devtoolsComments: {
50
+ type: 'boolean',
51
+ describe: 'Whether to enable DevTools comments tools. Internal WIP feature.',
52
+ hidden: true,
53
+ default: false,
144
54
  },
145
55
  experimentalDevtools: {
146
56
  type: 'boolean',
@@ -152,11 +62,13 @@ export const cliOptions = {
152
62
  },
153
63
  memoryDebugging: {
154
64
  type: 'boolean',
65
+ default: false,
155
66
  describe: 'Whether to enable memory debugging tools.',
156
67
  alias: 'experimentalMemory',
157
68
  },
158
69
  experimentalStructuredContent: {
159
70
  type: 'boolean',
71
+ default: false,
160
72
  describe: 'Whether to output structured formatted content.',
161
73
  },
162
74
  experimentalToonFormat: {
@@ -188,13 +100,19 @@ export const cliOptions = {
188
100
  describe: 'Path to ffmpeg executable for screencast recording.',
189
101
  implies: 'experimentalScreencast',
190
102
  },
191
- categoryExperimentalWebmcp: {
192
- type: 'boolean',
193
- describe: 'Set to true to enable debugging WebMCP tools. Requires Chrome 150+ with the following flag: `--enable-features=WebMCP`',
194
- },
195
- chromeArg: {
196
- type: 'array',
197
- describe: `Additional arguments for Chrome. Only applies when Chrome is launched by ${MCP_BIN_NAME}.`,
103
+ experimentalScreencastFps: {
104
+ type: 'number',
105
+ describe: 'Frames per second to use for screencast recording. Lower values can reduce memory pressure on pages that produce frames faster than ffmpeg can encode them.',
106
+ implies: 'experimentalScreencast',
107
+ coerce: (value) => {
108
+ if (value === undefined) {
109
+ return;
110
+ }
111
+ if (!Number.isInteger(value) || value <= 0) {
112
+ throw new Error(`Invalid experimentalScreencastFps ${value}. Expected a positive integer.`);
113
+ }
114
+ return value;
115
+ },
198
116
  },
199
117
  blockedUrlPattern: {
200
118
  type: 'array',
@@ -206,42 +124,6 @@ export const cliOptions = {
206
124
  describe: "Restricts browser's network access by allowing only specified URL patterns (uses https://urlpattern.spec.whatwg.org/). Requires Chrome 149+. Silently detaches from targets with unallowed URLs upon connection, and blocks runtime requests (including navigations and subresources). Accepts an array of patterns.",
207
125
  conflicts: ['blockedUrlPattern'],
208
126
  },
209
- ignoreDefaultChromeArg: {
210
- type: 'array',
211
- describe: `Explicitly disable default arguments for Chrome. Only applies when Chrome is launched by ${MCP_BIN_NAME}.`,
212
- },
213
- categoryEmulation: {
214
- type: 'boolean',
215
- default: true,
216
- describe: 'Set to false to exclude tools related to emulation.',
217
- },
218
- categoryPerformance: {
219
- type: 'boolean',
220
- default: true,
221
- describe: 'Set to false to exclude tools related to performance.',
222
- },
223
- categoryNetwork: {
224
- type: 'boolean',
225
- default: true,
226
- describe: 'Set to false to exclude tools related to network.',
227
- },
228
- categoryExtensions: {
229
- type: 'boolean',
230
- hidden: false,
231
- default: false,
232
- describe: 'Set to true to include tools related to extensions. Note: This feature is currently only supported with a pipe connection. autoConnect, browserUrl, and wsEndpoint are not supported with this feature until 149 will be released.',
233
- },
234
- categoryExperimentalThirdParty: {
235
- type: 'boolean',
236
- default: false,
237
- describe: 'Set to true to enable third-party developer tools exposed by the inspected page itself',
238
- },
239
- categoryPwa: {
240
- type: 'boolean',
241
- hidden: false,
242
- conflicts: ['autoConnect', 'browserUrl', 'wsEndpoint'],
243
- describe: 'Set to true to include tools for automating Progressive Web Apps (install, launch, uninstall, and OS state). This feature is only supported with a pipe connection; autoConnect, browserUrl, and wsEndpoint are not supported.',
244
- },
245
127
  performanceCrux: {
246
128
  type: 'boolean',
247
129
  default: PERFORMANCE_CRUX_DEFAULT,
@@ -252,6 +134,16 @@ export const cliOptions = {
252
134
  default: USAGE_STATISTICS_DEFAULT,
253
135
  describe: USAGE_STATISTICS_DESCRIPTION,
254
136
  },
137
+ javascriptEvaluation: {
138
+ type: 'boolean',
139
+ default: true,
140
+ describe: 'Set to false to disable JavaScript execution. When disabled, evaluation tools (evaluate_script and slim evaluate) are disabled, the initScript parameter in navigate_page is turned off, and navigating to javascript:, data:, or vbscript: URLs is disallowed.',
141
+ },
142
+ sourceMaps: {
143
+ type: 'boolean',
144
+ default: true,
145
+ describe: 'Whether to enable source maps in DevTools. Use --no-source-maps to disable.',
146
+ },
255
147
  clearcutEndpoint: {
256
148
  type: 'string',
257
149
  hidden: true,
@@ -269,7 +161,7 @@ export const cliOptions = {
269
161
  },
270
162
  screenshotFormat: {
271
163
  type: 'string',
272
- description: 'Override the default output format used by take_screenshot when the caller does not specify one. JPEG and WebP are ~3-5x smaller than PNG, which helps reduce context size in AI conversations. Unset preserves the existing default ("png").',
164
+ description: 'Override the default output format used by take_screenshot when the caller does not specify one. JPEG and WebP are ~3-5x smaller than PNG, which reduces transfer and storage size. To reduce context size use --screenshotMaxWidth / --screenshotMaxHeight, since image tokens scale with dimensions rather than encoded bytes. Unset preserves the existing default ("png").',
273
165
  choices: ['jpeg', 'png', 'webp'],
274
166
  },
275
167
  screenshotQuality: {
@@ -328,30 +220,78 @@ export const cliOptions = {
328
220
  allowUnrestrictedPaths: {
329
221
  type: 'boolean',
330
222
  default: false,
223
+ deprecated: 'Use --workspace=/ instead.',
331
224
  describe: 'If set, disables the default path restriction that applies when the MCP client does not negotiate ' +
332
225
  'the roots capability. By default, file-writing tools are restricted to the OS temp directory when ' +
333
226
  'no roots are configured. Use this only when connecting a trusted local client that does not implement ' +
334
227
  'MCP roots and requires access to paths outside the temp directory.',
335
228
  },
229
+ filesystemRoot: {
230
+ type: 'array',
231
+ alias: 'workspace',
232
+ default: DEFAULT_FILESYSTEM_ROOT,
233
+ defaultDescription: 'OS temp directory',
234
+ describe: 'A directory that filesystem tools are allowed to access. May be specified more than once.',
235
+ },
236
+ config: {
237
+ type: 'string',
238
+ describe: 'Path to JSON configuration file.',
239
+ },
336
240
  };
241
+ export function getMcpOptionsForViaCli() {
242
+ if (!('default' in mcpOptions.headless)) {
243
+ throw new Error('headless cli option unexpectedly does not have a default');
244
+ }
245
+ if (!('default' in mcpOptions.experimentalStructuredContent)) {
246
+ throw new Error('experimentalStructuredContent cli option unexpectedly does not have a default');
247
+ }
248
+ if ('default' in mcpOptions.isolated) {
249
+ throw new Error('isolated cli option unexpectedly has a default');
250
+ }
251
+ return {
252
+ ...mcpOptions,
253
+ headless: {
254
+ ...mcpOptions.headless,
255
+ default: true,
256
+ },
257
+ memoryDebugging: {
258
+ ...mcpOptions.memoryDebugging,
259
+ default: true,
260
+ },
261
+ categoryExtensions: {
262
+ ...mcpOptions.categoryExtensions,
263
+ default: true,
264
+ },
265
+ experimentalStructuredContent: {
266
+ ...mcpOptions.experimentalStructuredContent,
267
+ default: true,
268
+ },
269
+ isolated: {
270
+ ...mcpOptions.isolated,
271
+ description: 'If specified, creates a temporary user-data-dir that is automatically cleaned up after the browser is closed. Defaults to true unless userDataDir is provided.',
272
+ },
273
+ };
274
+ }
337
275
  /**
338
276
  * Exported only for testing to not trigger process exit.
339
277
  */
340
278
  export function parser(version, argv = process.argv, env = process.env) {
341
- // Preserve yargs' mixed camel/kebab-case expansion under strict validation.
342
- const kebabCaseAliases = {};
343
- for (const option of Object.keys(cliOptions)) {
344
- const alias = option.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);
345
- if (alias !== option) {
346
- kebabCaseAliases[option] = alias;
347
- }
348
- }
279
+ const isViaCli = argv.includes('--viaCli') || argv.includes('--via-cli');
280
+ const options = isViaCli ? getMcpOptionsForViaCli() : mcpOptions;
349
281
  const yargsInstance = yargs(hideBin(argv))
350
282
  .scriptName(`npx ${PACKAGE_NAME}@latest`)
351
- .options(cliOptions)
352
- .alias(kebabCaseAliases)
353
- .strictOptions()
283
+ .parserConfiguration({
284
+ 'strip-aliased': true,
285
+ 'strip-dashed': true,
286
+ })
287
+ .options(options)
288
+ .showHelpOnFail(false, 'Specify --help for available options')
354
289
  .middleware(args => {
290
+ if (isViaCli && args.filesystemRoot === DEFAULT_FILESYSTEM_ROOT) {
291
+ const cliFilesystemArgs = args;
292
+ cliFilesystemArgs.allowUnrestrictedPaths = true;
293
+ cliFilesystemArgs.filesystemRoot = undefined;
294
+ }
355
295
  // We can't set default in the options else
356
296
  // Yargs will complain
357
297
  if (!args.channel &&
@@ -364,6 +304,16 @@ export function parser(version, argv = process.argv, env = process.env) {
364
304
  console.error(`turning off usage statistics. process.env['CI'] || process.env['${ENV_NO_USAGE_STATISTICS}'] is set.`);
365
305
  args.usageStatistics = false;
366
306
  }
307
+ const cliOptionsAllowedArgs = [
308
+ ...Object.keys(options),
309
+ // Yargs populated with positional args
310
+ '_',
311
+ '$0',
312
+ ];
313
+ const unknownArgs = Object.keys(args).filter(arg => !cliOptionsAllowedArgs.includes(arg));
314
+ if (unknownArgs.length > 0) {
315
+ console.error(`Unknown arguments: ${unknownArgs.map(arg => `--${arg}`)}`);
316
+ }
367
317
  })
368
318
  .example([
369
319
  [
@@ -422,12 +372,41 @@ export function parser(version, argv = process.argv, env = process.env) {
422
372
  '$0 --no-performance-crux',
423
373
  'Disable CrUX (field data) integration in performance tools.',
424
374
  ],
375
+ ['$0 --no-source-maps', 'Disable source maps in DevTools.'],
376
+ [
377
+ '$0 --no-javascript-evaluation',
378
+ 'Disable JavaScript execution (disables evaluation tools, initScript in navigate_page, and navigating to javascript:, data:, or vbscript: URLs).',
379
+ ],
425
380
  [
426
381
  '$0 --slim',
427
382
  'Only 3 tools: navigation, JavaScript execution and screenshot',
428
383
  ],
429
384
  ]);
430
385
  return yargsInstance
386
+ .config('config', 'Path to JSON configuration file', configPath => {
387
+ try {
388
+ const parsed = JSON.parse(readFileSync(configPath, 'utf-8'));
389
+ if (typeof parsed !== 'object' ||
390
+ parsed === null ||
391
+ Array.isArray(parsed)) {
392
+ throw new Error('Config must be a JSON object');
393
+ }
394
+ return yargs()
395
+ .parserConfiguration({
396
+ 'strip-aliased': true,
397
+ 'camel-case-expansion': false,
398
+ })
399
+ .options(options)
400
+ .config(parsed)
401
+ .strict()
402
+ .fail(false)
403
+ .exitProcess(false)
404
+ .parseSync([]);
405
+ }
406
+ catch (err) {
407
+ throw new Error(`Invalid JSON config file: ${err.message}`);
408
+ }
409
+ })
431
410
  .wrap(Math.min(120, yargsInstance.terminalWidth()))
432
411
  .help()
433
412
  .version(version);
@@ -435,4 +414,4 @@ export function parser(version, argv = process.argv, env = process.env) {
435
414
  export function parseArguments(version, argv = process.argv, env = process.env) {
436
415
  return parser(version, argv, env).parseSync();
437
416
  }
438
- //# sourceMappingURL=chrome-devtools-mcp-cli-options.js.map
417
+ //# sourceMappingURL=mcp-options.js.map
@@ -165,6 +165,15 @@ export async function verifyDaemonVersion(sessionId, cliVersion) {
165
165
  }
166
166
  export async function handleResponse(response, format) {
167
167
  if (response.isError) {
168
+ if (format === 'md') {
169
+ const chunks = [];
170
+ for (const content of response.content) {
171
+ if (content.type === 'text') {
172
+ chunks.push(content.text);
173
+ }
174
+ }
175
+ return chunks.join(' ');
176
+ }
168
177
  return JSON.stringify(response.content);
169
178
  }
170
179
  const chunks = [];
@@ -110,6 +110,12 @@ export function serializeArgs(options, argv) {
110
110
  continue;
111
111
  }
112
112
  const value = argv[key];
113
+ const option = options[key];
114
+ // Yargs reuses the option `default` object; skip it so the daemon parser
115
+ // still sees the original default (needed for filesystemRoot identity).
116
+ if (option !== undefined && value === option.default) {
117
+ continue;
118
+ }
113
119
  const kebabKey = key.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);
114
120
  if (typeof value === 'boolean') {
115
121
  if (value) {
@@ -19,6 +19,11 @@ export function overrideDevToolsGlobals({ loadResource, }) {
19
19
  DevTools.Host.InspectorFrontendHost.installInspectorFrontendHost(new McpHostBindingAdapter(loadResource));
20
20
  // DevTools CDP errors can get noisy.
21
21
  DevTools.ProtocolClient.InspectorBackend.test.suppressRequestErrors = true;
22
+ const noopAgentCommand = () => {
23
+ return Promise.resolve({
24
+ getError: () => undefined,
25
+ });
26
+ };
22
27
  // Stub out Network emulation commands on the DevTools Agent prototype globally.
23
28
  // This prevents the DevTools Frontend from ever resetting/clearing Puppeteer's
24
29
  // active network blocking/throttling rules during target setup or session lifetime.
@@ -36,41 +41,37 @@ export function overrideDevToolsGlobals({ loadResource, }) {
36
41
  enumerable: true,
37
42
  });
38
43
  Object.defineProperty(networkAgentPrototype, 'invoke_overrideNetworkState', {
39
- value: () => {
40
- return Promise.resolve({
41
- getError: () => undefined,
42
- });
43
- },
44
+ value: noopAgentCommand,
44
45
  writable: true,
45
46
  configurable: true,
46
47
  enumerable: true,
47
48
  });
48
49
  Object.defineProperty(networkAgentPrototype, 'invoke_enable', {
49
- value: () => {
50
- return Promise.resolve({
51
- getError: () => undefined,
52
- });
53
- },
50
+ value: noopAgentCommand,
54
51
  writable: true,
55
52
  configurable: true,
56
53
  enumerable: true,
57
54
  });
58
55
  Object.defineProperty(networkAgentPrototype, 'invoke_disable', {
59
- value: () => {
60
- return Promise.resolve({
61
- getError: () => undefined,
62
- });
63
- },
56
+ value: noopAgentCommand,
64
57
  writable: true,
65
58
  configurable: true,
66
59
  enumerable: true,
67
60
  });
68
61
  Object.defineProperty(networkAgentPrototype, 'invoke_setBlockedURLs', {
69
- value: () => {
70
- return Promise.resolve({
71
- getError: () => undefined,
72
- });
73
- },
62
+ value: noopAgentCommand,
63
+ writable: true,
64
+ configurable: true,
65
+ enumerable: true,
66
+ });
67
+ }
68
+ // Puppeteer already collects issues from its own Audits subscription. Avoid
69
+ // enabling the DevTools Frontend's redundant subscription, which can replay
70
+ // a large retained issue backlog and delay unrelated page work.
71
+ const auditsAgentPrototype = DevTools.ProtocolClient.InspectorBackend.inspectorBackend.agentPrototypes.get('Audits');
72
+ if (auditsAgentPrototype) {
73
+ Object.defineProperty(auditsAgentPrototype, 'invoke_enable', {
74
+ value: noopAgentCommand,
74
75
  writable: true,
75
76
  configurable: true,
76
77
  enumerable: true,
@@ -91,7 +92,7 @@ export function overrideDevToolsGlobals({ loadResource, }) {
91
92
  .resolve('../third_party/devtools-formatter-worker.js'),
92
93
  });
93
94
  }
94
- export async function createTargetUniverse(session) {
95
+ export async function createTargetUniverse(session, options) {
95
96
  const settingStorage = new DevTools.Common.Settings.SettingsStorage({});
96
97
  const universe = new DevTools.Foundation.Universe.Universe({
97
98
  settingsCreationOptions: {
@@ -105,6 +106,11 @@ export async function createTargetUniverse(session) {
105
106
  inspectorFrontendHost: DevTools.Host.InspectorFrontendHost.InspectorFrontendHostInstance,
106
107
  supportsEmulation: false,
107
108
  });
109
+ const sourceMaps = options?.sourceMaps ?? true;
110
+ const jsSourceMapsSetting = universe.settings.resolve(DevTools.SDKSettings.jsSourceMapsEnabledSettingDescriptor);
111
+ jsSourceMapsSetting.set(sourceMaps);
112
+ const cssSourceMapsSetting = universe.settings.resolve(DevTools.SDKSettings.cssSourceMapsEnabledSettingDescriptor);
113
+ cssSourceMapsSetting.set(sourceMaps);
108
114
  const setting = universe.settings.resolve(DevTools.SourceMapManager.lazyLoadingSettingDescriptor);
109
115
  setting.set(true);
110
116
  const skipAllPausesSetting = universe.settings.resolve(DevTools.skipAllPausesSettingDescriptor);
@@ -6,6 +6,7 @@
6
6
  import { isUtf8 } from 'node:buffer';
7
7
  import { DevTools, } from '../third_party/index.js';
8
8
  const BODY_CONTEXT_SIZE_LIMIT = 10000;
9
+ const URL_CONTEXT_SIZE_LIMIT = 255;
9
10
  export class NetworkFormatter {
10
11
  #request;
11
12
  #options;
@@ -178,8 +179,10 @@ function getSizeLimitedString(text, sizeLimit) {
178
179
  return text;
179
180
  }
180
181
  function convertNetworkRequestConciseToString(data) {
181
- // TODO truncate the URL
182
- return `reqid=${data.requestId} ${data.method} ${data.url} [${data.status}]${data.selectedInDevToolsUI ? ` [selected in the DevTools Network panel]` : ''}`;
182
+ // Long URLs (e.g., data: URLs) bloat the concise list output. The full URL
183
+ // remains available via the detailed view and the structured content.
184
+ const url = getSizeLimitedString(data.url, URL_CONTEXT_SIZE_LIMIT);
185
+ return `reqid=${data.requestId} ${data.method} ${url} [${data.status}]${data.selectedInDevToolsUI ? ` [selected in the DevTools Network panel]` : ''}`;
183
186
  }
184
187
  function formatHeaders(headers) {
185
188
  const response = [];