chrome-devtools-mcp 1.4.0 → 1.6.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 (56) hide show
  1. package/README.md +20 -3
  2. package/build/src/HeapSnapshotManager.js +83 -16
  3. package/build/src/McpContext.js +218 -367
  4. package/build/src/McpPage.js +242 -31
  5. package/build/src/McpResponse.js +165 -60
  6. package/build/src/PageCollector.js +48 -122
  7. package/build/src/TextSnapshot.js +20 -2
  8. package/build/src/ToolHandler.js +13 -3
  9. package/build/src/WaitForHelper.js +18 -8
  10. package/build/src/bin/chrome-devtools-cli-options.js +76 -4
  11. package/build/src/bin/chrome-devtools-mcp-cli-options.js +15 -6
  12. package/build/src/bin/chrome-devtools-mcp-main.js +2 -2
  13. package/build/src/bin/chrome-devtools.js +25 -1
  14. package/build/src/browser.js +1 -1
  15. package/build/src/daemon/client.js +33 -3
  16. package/build/src/daemon/daemon.js +3 -2
  17. package/build/src/daemon/utils.js +1 -1
  18. package/build/src/devtools/DevtoolsUtils.js +2 -63
  19. package/build/src/{issue-descriptions.js → devtools/issueDescriptions.js} +8 -6
  20. package/build/src/formatters/HeapSnapshotFormatter.js +43 -0
  21. package/build/src/formatters/IssueFormatter.js +2 -2
  22. package/build/src/index.js +14 -5
  23. package/build/src/telemetry/ClearcutLogger.js +1 -1
  24. package/build/src/telemetry/WatchdogClient.js +1 -1
  25. package/build/src/telemetry/metricsRegistry.js +2 -9
  26. package/build/src/telemetry/persistence.js +1 -1
  27. package/build/src/telemetry/transformation.js +20 -0
  28. package/build/src/telemetry/watchdog/ClearcutSender.js +1 -1
  29. package/build/src/telemetry/watchdog/main.js +1 -1
  30. package/build/src/third_party/THIRD_PARTY_NOTICES +13 -279
  31. package/build/src/third_party/bundled-packages.json +3 -5
  32. package/build/src/third_party/devtools-heap-snapshot-worker.js +81 -0
  33. package/build/src/third_party/index.js +2418 -2197
  34. package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +3082 -6343
  35. package/build/src/tools/emulation.js +2 -2
  36. package/build/src/tools/extensions.js +1 -1
  37. package/build/src/tools/input.js +17 -8
  38. package/build/src/tools/lighthouse.js +1 -1
  39. package/build/src/tools/memory.js +76 -6
  40. package/build/src/tools/network.js +4 -4
  41. package/build/src/tools/pages.js +21 -89
  42. package/build/src/tools/performance.js +2 -2
  43. package/build/src/tools/screencast.js +1 -2
  44. package/build/src/tools/script.js +6 -10
  45. package/build/src/tools/snapshot.js +2 -2
  46. package/build/src/tools/thirdPartyDeveloper.js +7 -7
  47. package/build/src/tools/webmcp.js +1 -1
  48. package/build/src/trace-processing/parse.js +1 -1
  49. package/build/src/utils/files.js +0 -4
  50. package/build/src/{logger.js → utils/logger.js} +1 -1
  51. package/build/src/{polyfill.js → utils/polyfill.js} +1 -1
  52. package/build/src/version.js +1 -1
  53. package/package.json +17 -5
  54. package/skills/memory-leak-debugging/SKILL.md +22 -14
  55. package/build/src/utils/types.js +0 -7
  56. /package/build/src/{Mutex.js → utils/Mutex.js} +0 -0
@@ -4,16 +4,16 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { ConsoleFormatter } from './formatters/ConsoleFormatter.js';
7
- import { HeapSnapshotFormatter } from './formatters/HeapSnapshotFormatter.js';
8
- import { isEdgeLike, isNodeLike } from './formatters/HeapSnapshotFormatter.js';
7
+ import { HeapSnapshotFormatter, isEdgeLike, isNodeLike, } from './formatters/HeapSnapshotFormatter.js';
9
8
  import { IssueFormatter } from './formatters/IssueFormatter.js';
10
9
  import { NetworkFormatter } from './formatters/NetworkFormatter.js';
11
10
  import { SnapshotFormatter } from './formatters/SnapshotFormatter.js';
12
11
  import { UncaughtError } from './PageCollector.js';
13
12
  import { TextSnapshot } from './TextSnapshot.js';
14
- import { DevTools, toonEncode } from './third_party/index.js';
15
- import { handleDialog } from './tools/pages.js';
13
+ import { DevTools, getToonEncode, getGcfEncode, } from './third_party/index.js';
14
+ import { handleDialog, listPages } from './tools/pages.js';
16
15
  import { getInsightOutput, getTraceSummary } from './trace-processing/parse.js';
16
+ import { stableIdSymbol } from './utils/id.js';
17
17
  import { paginate } from './utils/pagination.js';
18
18
  export function replaceHtmlElementsWithUids(schema) {
19
19
  if (typeof schema === 'boolean') {
@@ -173,6 +173,7 @@ export class McpResponse {
173
173
  #redactNetworkHeaders = true;
174
174
  #error;
175
175
  #attachedWaitForResult;
176
+ #reconnectNotice = false;
176
177
  get #deviceScope() {
177
178
  return this.#page?.viewport?.isMobile ? 'PHONE' : 'DESKTOP';
178
179
  }
@@ -185,6 +186,13 @@ export class McpResponse {
185
186
  setRedactNetworkHeaders(value) {
186
187
  this.#redactNetworkHeaders = value;
187
188
  }
189
+ /**
190
+ * Surfaces a one-time note that the browser reconnected and page ids changed.
191
+ * Set by the tool handler when the context reports a pending reconnect notice.
192
+ */
193
+ setReconnectNotice() {
194
+ this.#reconnectNotice = true;
195
+ }
188
196
  attachDevToolsData(data) {
189
197
  this.#devToolsData = data;
190
198
  }
@@ -219,7 +227,7 @@ export class McpResponse {
219
227
  }
220
228
  this.#networkRequestsOptions = {
221
229
  include: value,
222
- pagination: options?.pageSize || options?.pageIdx
230
+ pagination: options?.pageSize !== undefined || options?.pageIdx !== undefined
223
231
  ? {
224
232
  pageSize: options.pageSize,
225
233
  pageIdx: options.pageIdx,
@@ -237,7 +245,7 @@ export class McpResponse {
237
245
  }
238
246
  this.#consoleDataOptions = {
239
247
  include: value,
240
- pagination: options?.pageSize || options?.pageIdx
248
+ pagination: options?.pageSize !== undefined || options?.pageIdx !== undefined
241
249
  ? {
242
250
  pageSize: options.pageSize,
243
251
  pageIdx: options.pageIdx,
@@ -310,11 +318,11 @@ export class McpResponse {
310
318
  attachWaitForResult(result) {
311
319
  this.#attachedWaitForResult = result;
312
320
  }
313
- setHeapSnapshotAggregates(aggregates, options) {
321
+ setHeapSnapshotAggregates(aggregateData, options) {
314
322
  this.#heapSnapshotOptions = {
315
323
  ...this.#heapSnapshotOptions,
316
324
  include: true,
317
- aggregates,
325
+ aggregateData,
318
326
  pagination: options,
319
327
  };
320
328
  }
@@ -334,6 +342,14 @@ export class McpResponse {
334
342
  pagination: options,
335
343
  };
336
344
  }
345
+ setHeapSnapshotDuplicateStrings(duplicateStrings, options) {
346
+ this.#heapSnapshotOptions = {
347
+ ...this.#heapSnapshotOptions,
348
+ include: true,
349
+ duplicateStrings,
350
+ pagination: options,
351
+ };
352
+ }
337
353
  setHeapSnapshotRetainingPaths(retainingPaths) {
338
354
  this.#heapSnapshotOptions = {
339
355
  ...this.#heapSnapshotOptions,
@@ -348,6 +364,20 @@ export class McpResponse {
348
364
  dominators,
349
365
  };
350
366
  }
367
+ setHeapSnapshotClassDiffs(classDiffs) {
368
+ this.#heapSnapshotOptions = {
369
+ ...this.#heapSnapshotOptions,
370
+ include: true,
371
+ classDiffs,
372
+ };
373
+ }
374
+ setHeapSnapshotDetailedClassDiff(detailedClassDiff) {
375
+ this.#heapSnapshotOptions = {
376
+ ...this.#heapSnapshotOptions,
377
+ include: true,
378
+ detailedClassDiff,
379
+ };
380
+ }
351
381
  attachImage(value) {
352
382
  this.#images.push(value);
353
383
  }
@@ -363,7 +393,7 @@ export class McpResponse {
363
393
  get listWebMcpTools() {
364
394
  return this.#listWebMcpTools;
365
395
  }
366
- async handle(toolName, context, useToon = false) {
396
+ async handle(toolName, context, dataFormat = 'default') {
367
397
  if (this.#includePages) {
368
398
  await context.createPagesSnapshot();
369
399
  }
@@ -396,10 +426,10 @@ export class McpResponse {
396
426
  if (!this.#page) {
397
427
  throw new Error(`Response must have an McpPage`);
398
428
  }
399
- const request = context.getNetworkRequestById(this.#page, this.#attachedNetworkRequestId);
429
+ const request = this.#page.getNetworkRequestById(this.#attachedNetworkRequestId);
400
430
  const formatter = await NetworkFormatter.from(request, {
401
431
  requestId: this.#attachedNetworkRequestId,
402
- requestIdResolver: req => context.getNetworkRequestStableId(req),
432
+ requestIdResolver: req => this.getNetworkRequestStableId(req),
403
433
  fetchData: true,
404
434
  requestFilePath: this.#attachedNetworkRequestOptions?.requestFilePath,
405
435
  responseFilePath: this.#attachedNetworkRequestOptions?.responseFilePath,
@@ -413,11 +443,11 @@ export class McpResponse {
413
443
  if (!this.#page) {
414
444
  throw new Error(`Response must have an McpPage`);
415
445
  }
416
- const message = context.getConsoleMessageById(this.#page, this.#attachedConsoleMessageId);
446
+ const message = this.#page.getConsoleMessageById(this.#attachedConsoleMessageId);
417
447
  const consoleMessageStableId = this.#attachedConsoleMessageId;
418
448
  if ('args' in message || message instanceof UncaughtError) {
419
449
  const consoleMessage = message;
420
- const devTools = context.getDevToolsUniverse(this.#page);
450
+ const devTools = this.#page.devtoolsUniverse;
421
451
  detailedConsoleMessage = await ConsoleFormatter.from(consoleMessage, {
422
452
  id: consoleMessageStableId,
423
453
  fetchDetailedData: true,
@@ -427,8 +457,8 @@ export class McpResponse {
427
457
  else if (message instanceof DevTools.AggregatedIssue) {
428
458
  const formatter = new IssueFormatter(message, {
429
459
  id: consoleMessageStableId,
430
- requestIdResolver: context.resolveCdpRequestId.bind(context, this.#page),
431
- elementIdResolver: this.#page.resolveCdpElementId.bind(this.#page),
460
+ requestIdResolver: this.#page.resolveCdpRequestId.bind(this.#page),
461
+ elementIdResolver: this.#page.textSnapshot?.resolveCdpElementId.bind(this.#page.textSnapshot),
432
462
  });
433
463
  if (!formatter.isValid()) {
434
464
  throw new Error("Can't provide details for the msgid " + consoleMessageStableId);
@@ -467,7 +497,7 @@ export class McpResponse {
467
497
  if (!page) {
468
498
  throw new Error(`Response must have an McpPage`);
469
499
  }
470
- messages = context.getConsoleData(page, this.#consoleDataOptions.includePreservedMessages);
500
+ messages = page.getConsoleData(this.#consoleDataOptions.includePreservedMessages);
471
501
  }
472
502
  if (this.#consoleDataOptions.types?.length) {
473
503
  const normalizedTypes = new Set(this.#consoleDataOptions.types);
@@ -482,16 +512,13 @@ export class McpResponse {
482
512
  });
483
513
  }
484
514
  consoleMessages = (await Promise.all(messages.map(async (item) => {
485
- const consoleMessageStableId = context.getConsoleMessageStableId(item);
515
+ const consoleMessageStableId = this.getConsoleMessageStableId(item);
486
516
  if ('args' in item || item instanceof UncaughtError) {
487
517
  const consoleMessage = item;
488
- const devTools = page
489
- ? context.getDevToolsUniverse(page)
490
- : null;
491
518
  return await ConsoleFormatter.from(consoleMessage, {
492
519
  id: consoleMessageStableId,
493
520
  fetchDetailedData: false,
494
- devTools: devTools ?? undefined,
521
+ devTools: page ? page.devtoolsUniverse : undefined,
495
522
  });
496
523
  }
497
524
  if (item instanceof DevTools.AggregatedIssue) {
@@ -511,7 +538,7 @@ export class McpResponse {
511
538
  if (!this.#page) {
512
539
  throw new Error(`Response must have an McpPage`);
513
540
  }
514
- let requests = context.getNetworkRequests(this.#page, this.#networkRequestsOptions?.includePreservedRequests);
541
+ let requests = this.#page.getNetworkRequests(this.#networkRequestsOptions?.includePreservedRequests);
515
542
  // Apply resource type filtering if specified
516
543
  if (this.#networkRequestsOptions.resourceTypes?.length) {
517
544
  const normalizedTypes = new Set(this.#networkRequestsOptions.resourceTypes);
@@ -522,8 +549,8 @@ export class McpResponse {
522
549
  }
523
550
  if (requests.length) {
524
551
  networkRequests = await Promise.all(requests.map(request => NetworkFormatter.from(request, {
525
- requestId: context.getNetworkRequestStableId(request),
526
- selectedInDevToolsUI: context.getNetworkRequestStableId(request) ===
552
+ requestId: this.getNetworkRequestStableId(request),
553
+ selectedInDevToolsUI: this.getNetworkRequestStableId(request) ===
527
554
  this.#networkRequestsOptions?.networkRequestIdInDevToolsUI,
528
555
  fetchData: false,
529
556
  saveFile: (data, filename, extension) => context.saveFile(data, filename, extension),
@@ -544,11 +571,45 @@ export class McpResponse {
544
571
  thirdPartyDeveloperTools,
545
572
  webmcpTools,
546
573
  errorMessage: this.#error?.message,
547
- }, useToon);
574
+ }, dataFormat);
575
+ }
576
+ getConsoleMessageStableId(message) {
577
+ return message[stableIdSymbol] ?? -1;
548
578
  }
549
- async format(toolName, context, data, useToon) {
579
+ getNetworkRequestStableId(request) {
580
+ return request[stableIdSymbol] ?? -1;
581
+ }
582
+ async format(toolName, context, data, dataFormat = 'default') {
550
583
  const structuredContent = {};
584
+ // Resolve the compact encoder based on the chosen format
585
+ let compactEncode;
586
+ if (dataFormat === 'toon') {
587
+ try {
588
+ compactEncode = await getToonEncode();
589
+ }
590
+ catch {
591
+ throw new Error('The `@toon-format/toon` package is required to use --experimentalDataFormat=toon. ' +
592
+ 'Make sure the peer dependency is installed:\n' +
593
+ '- For npx: npx --package chrome-devtools-mcp@latest --package @toon-format/toon@latest chrome-devtools-mcp --experimentalDataFormat=toon\n' +
594
+ '- For npm: npm install @toon-format/toon (add -g if installed globally)');
595
+ }
596
+ }
597
+ else if (dataFormat === 'gcf') {
598
+ try {
599
+ compactEncode = await getGcfEncode();
600
+ }
601
+ catch {
602
+ throw new Error('The `@blackwell-systems/gcf` package is required to use --experimentalDataFormat=gcf. ' +
603
+ 'Make sure the peer dependency is installed:\n' +
604
+ '- For npx: npx --package chrome-devtools-mcp@latest --package @blackwell-systems/gcf@latest chrome-devtools-mcp --experimentalDataFormat=gcf\n' +
605
+ '- For npm: npm install @blackwell-systems/gcf (add -g if installed globally)');
606
+ }
607
+ }
551
608
  const response = [];
609
+ if (this.#reconnectNotice) {
610
+ structuredContent.reconnected = true;
611
+ response.push(`Note: the browser was restarted or reconnected since the last call. Page ids have changed. Call ${listPages().name} to see open pages.`);
612
+ }
552
613
  if (this.#textResponseLines.length) {
553
614
  structuredContent.message = this.#textResponseLines.join('\n');
554
615
  response.push(...this.#textResponseLines);
@@ -609,29 +670,40 @@ Call ${handleDialog.name} to handle it before continuing.`);
609
670
  }
610
671
  if (this.#includePages) {
611
672
  const allPages = context.getPages();
612
- const { regularPages, extensionPages } = allPages.reduce((acc, page) => {
613
- if (page.url().startsWith('chrome-extension://')) {
614
- acc.extensionPages.push(page);
673
+ const { regularPages, extensionPages } = allPages.reduce((acc, mcpPage) => {
674
+ if (mcpPage.pptrPage.url().startsWith('chrome-extension://')) {
675
+ acc.extensionPages.push(mcpPage);
615
676
  }
616
677
  else {
617
- acc.regularPages.push(page);
678
+ acc.regularPages.push(mcpPage);
618
679
  }
619
680
  return acc;
620
681
  }, { regularPages: [], extensionPages: [] });
682
+ const selectionFallback = context.getSelectedPageFallback();
683
+ if (selectionFallback) {
684
+ let selectedPageId;
685
+ try {
686
+ selectedPageId = context.getSelectedMcpPage().id;
687
+ }
688
+ catch {
689
+ selectedPageId = undefined;
690
+ }
691
+ response.push(`Note: the previously selected page ${selectionFallback.wasClosed ? 'was closed' : 'is no longer listed'}.${selectedPageId !== undefined ? ` Page ${selectedPageId} is now selected.` : ''}`);
692
+ }
621
693
  if (regularPages.length) {
622
694
  const parts = [`## Pages`];
623
695
  const structuredPages = [];
624
- for (const page of regularPages) {
625
- const isolatedContextName = context.getIsolatedContextName(page);
696
+ for (const mcpPage of regularPages) {
697
+ const isolatedContextName = mcpPage.isolatedContextName;
626
698
  const contextLabel = isolatedContextName
627
699
  ? ` isolatedContext=${isolatedContextName}`
628
700
  : '';
629
- const title = await fetchPageTitle(page);
701
+ const title = await fetchPageTitle(mcpPage.pptrPage);
630
702
  const pageLabel = title
631
- ? `${truncateTitle(title)} (${page.url()})`
632
- : page.url();
633
- parts.push(`${context.getPageId(page)}: ${pageLabel}${context.isPageSelected(page) ? ' [selected]' : ''}${contextLabel}`);
634
- structuredPages.push(createStructuredPage(page, context, title));
703
+ ? `${truncateTitle(title)} (${mcpPage.pptrPage.url()})`
704
+ : mcpPage.pptrPage.url();
705
+ parts.push(`${mcpPage.id}: ${pageLabel}${context.isPageSelected(mcpPage) ? ' [selected]' : ''}${contextLabel}`);
706
+ structuredPages.push(createStructuredPage(mcpPage, context, title));
635
707
  }
636
708
  response.push(...parts);
637
709
  structuredContent.pages = structuredPages;
@@ -640,17 +712,17 @@ Call ${handleDialog.name} to handle it before continuing.`);
640
712
  if (extensionPages.length) {
641
713
  response.push(`## Extension Pages`);
642
714
  const structuredExtensionPages = [];
643
- for (const page of extensionPages) {
644
- const isolatedContextName = context.getIsolatedContextName(page);
715
+ for (const mcpPage of extensionPages) {
716
+ const isolatedContextName = mcpPage.isolatedContextName;
645
717
  const contextLabel = isolatedContextName
646
718
  ? ` isolatedContext=${isolatedContextName}`
647
719
  : '';
648
- const title = await fetchPageTitle(page);
720
+ const title = await fetchPageTitle(mcpPage.pptrPage);
649
721
  const pageLabel = title
650
- ? `${truncateTitle(title)} (${page.url()})`
651
- : page.url();
652
- response.push(`${context.getPageId(page)}: ${pageLabel}${context.isPageSelected(page) ? ' [selected]' : ''}${contextLabel}`);
653
- structuredExtensionPages.push(createStructuredPage(page, context, title));
722
+ ? `${truncateTitle(title)} (${mcpPage.pptrPage.url()})`
723
+ : mcpPage.pptrPage.url();
724
+ response.push(`${mcpPage.id}: ${pageLabel}${context.isPageSelected(mcpPage) ? ' [selected]' : ''}${contextLabel}`);
725
+ structuredExtensionPages.push(createStructuredPage(mcpPage, context, title));
654
726
  }
655
727
  structuredContent.extensionPages = structuredExtensionPages;
656
728
  }
@@ -726,8 +798,8 @@ Call ${handleDialog.name} to handle it before continuing.`);
726
798
  else {
727
799
  structuredContent.snapshot = data.snapshot.toJSON();
728
800
  response.push('## Latest page snapshot');
729
- response.push(useToon
730
- ? toonEncode(structuredContent.snapshot)
801
+ response.push(compactEncode
802
+ ? compactEncode(structuredContent.snapshot)
731
803
  : data.snapshot.toString());
732
804
  }
733
805
  }
@@ -745,17 +817,24 @@ Call ${handleDialog.name} to handle it before continuing.`);
745
817
  structuredContent.heapSnapshot = structuredContent.heapSnapshot || {};
746
818
  structuredContent.heapSnapshot.staticData = staticData;
747
819
  }
748
- const aggregates = this.#heapSnapshotOptions.aggregates;
749
- if (aggregates) {
750
- const sortedEntries = HeapSnapshotFormatter.sort(aggregates);
820
+ const aggregateData = this.#heapSnapshotOptions.aggregateData;
821
+ if (aggregateData) {
822
+ const sortedEntries = HeapSnapshotFormatter.sort(aggregateData.aggregates);
751
823
  const paginationData = this.#dataWithPagination(sortedEntries, this.#heapSnapshotOptions.pagination);
824
+ response.push(`Objects: ${aggregateData.objectCount}`);
825
+ response.push(`Total shallow size: ${DevTools.I18n.ByteUtilities.formatBytesToKb(aggregateData.totalSelfSize)}`);
826
+ structuredContent.heapSnapshot = structuredContent.heapSnapshot || {};
827
+ structuredContent.heapSnapshot.aggregateStats = {
828
+ objectCount: aggregateData.objectCount,
829
+ totalSelfSize: aggregateData.totalSelfSize,
830
+ };
752
831
  structuredContent.pagination = paginationData.pagination;
753
832
  response.push(...paginationData.info);
754
833
  const paginatedRecord = Object.fromEntries(paginationData.items);
755
834
  const formatter = new HeapSnapshotFormatter(paginatedRecord);
756
835
  structuredContent.heapSnapshotData = formatter.toJSON();
757
- response.push(useToon
758
- ? toonEncode(structuredContent.heapSnapshotData)
836
+ response.push(compactEncode
837
+ ? compactEncode(structuredContent.heapSnapshotData)
759
838
  : formatter.toString());
760
839
  }
761
840
  const nodes = this.#heapSnapshotOptions.nodes;
@@ -808,6 +887,32 @@ Call ${handleDialog.name} to handle it before continuing.`);
808
887
  }
809
888
  structuredContent.heapSnapshotDominators = dominators;
810
889
  }
890
+ const classDiffs = this.#heapSnapshotOptions.classDiffs;
891
+ if (classDiffs) {
892
+ response.push('### Heap Snapshot Diff');
893
+ response.push(compactEncode
894
+ ? compactEncode(classDiffs)
895
+ : HeapSnapshotFormatter.formatDiffSummary(classDiffs));
896
+ structuredContent.heapSnapshotClassDiffs = classDiffs;
897
+ }
898
+ const detailedClassDiff = this.#heapSnapshotOptions.detailedClassDiff;
899
+ if (detailedClassDiff) {
900
+ response.push('### Heap Snapshot Detailed Diff');
901
+ response.push(compactEncode
902
+ ? compactEncode(detailedClassDiff)
903
+ : HeapSnapshotFormatter.formatDiffDetails(detailedClassDiff));
904
+ structuredContent.heapSnapshotDetailedClassDiff = detailedClassDiff;
905
+ }
906
+ const duplicateStrings = this.#heapSnapshotOptions.duplicateStrings;
907
+ if (duplicateStrings) {
908
+ response.push('### Duplicate Strings');
909
+ const paginationData = this.#dataWithPagination(duplicateStrings, this.#heapSnapshotOptions.pagination);
910
+ structuredContent.pagination = paginationData.pagination;
911
+ response.push(...paginationData.info);
912
+ const formatted = HeapSnapshotFormatter.formatDuplicateStrings(paginationData.items);
913
+ response.push(formatted);
914
+ structuredContent.heapSnapshotDuplicateStrings = paginationData.items;
915
+ }
811
916
  }
812
917
  if (data.detailedNetworkRequest) {
813
918
  response.push(data.detailedNetworkRequest.toStringDetailed());
@@ -879,8 +984,8 @@ Call ${handleDialog.name} to handle it before continuing.`);
879
984
  response.push(...paginationData.info);
880
985
  if (data.networkRequests) {
881
986
  structuredContent.networkRequests = paginationData.items.map(i => i.toJSON());
882
- response.push(...(useToon
883
- ? [toonEncode(structuredContent.networkRequests)]
987
+ response.push(...(compactEncode
988
+ ? [compactEncode(structuredContent.networkRequests)]
884
989
  : paginationData.items.map(i => i.toString())));
885
990
  }
886
991
  }
@@ -897,8 +1002,8 @@ Call ${handleDialog.name} to handle it before continuing.`);
897
1002
  structuredContent.pagination = paginationData.pagination;
898
1003
  structuredContent.consoleMessages = paginationData.items.map(item => item.toJSON());
899
1004
  response.push(...paginationData.info);
900
- if (useToon) {
901
- response.push(toonEncode(structuredContent.consoleMessages));
1005
+ if (compactEncode) {
1006
+ response.push(compactEncode(structuredContent.consoleMessages));
902
1007
  }
903
1008
  else {
904
1009
  response.push(...paginationData.items.map(item => item.toString()));
@@ -973,14 +1078,14 @@ async function fetchPageTitle(page) {
973
1078
  new Promise(resolve => setTimeout(() => resolve(''), 1000)),
974
1079
  ]);
975
1080
  }
976
- function createStructuredPage(page, context, rawTitle) {
977
- const isolatedContextName = context.getIsolatedContextName(page);
1081
+ function createStructuredPage(mcpPage, context, rawTitle) {
1082
+ const isolatedContextName = mcpPage.isolatedContextName;
978
1083
  const title = truncateTitle(rawTitle);
979
1084
  const entry = {
980
- id: context.getPageId(page),
981
- url: page.url(),
1085
+ id: mcpPage.id,
1086
+ url: mcpPage.pptrPage.url(),
982
1087
  title,
983
- selected: context.isPageSelected(page),
1088
+ selected: context.isPageSelected(mcpPage),
984
1089
  };
985
1090
  if (isolatedContextName) {
986
1091
  entry.isolatedContext = isolatedContextName;