@@ -171,11 +171,13 @@ export class McpResponse implements Response {
171171 #images: ImageContentData [ ] = [ ] ;
172172 #heapSnapshotOptions?: {
173173 include : boolean ;
174- aggregates : Record <
174+ aggregates ? : Record <
175175 string ,
176176 DevTools . HeapSnapshotModel . HeapSnapshotModel . AggregatedInfo
177177 > ;
178178 pagination ?: PaginationOptions ;
179+ stats ?: DevTools . HeapSnapshotModel . HeapSnapshotModel . Statistics ;
180+ staticData ?: DevTools . HeapSnapshotModel . HeapSnapshotModel . StaticData | null ;
179181 } ;
180182 #networkRequestsOptions?: {
181183 include : boolean ;
@@ -374,20 +376,33 @@ export class McpResponse implements Response {
374376 this . #textResponseLines. push ( value ) ;
375377 }
376378
377- setHeapSnapshot (
379+ setHeapSnapshotAggregates (
378380 aggregates : Record <
379381 string ,
380382 DevTools . HeapSnapshotModel . HeapSnapshotModel . AggregatedInfo
381383 > ,
382384 options ?: PaginationOptions ,
383385 ) {
384386 this . #heapSnapshotOptions = {
387+ ...this . #heapSnapshotOptions,
385388 include : true ,
386389 aggregates,
387390 pagination : options ,
388391 } ;
389392 }
390393
394+ setHeapSnapshotStats (
395+ stats : DevTools . HeapSnapshotModel . HeapSnapshotModel . Statistics ,
396+ staticData : DevTools . HeapSnapshotModel . HeapSnapshotModel . StaticData | null ,
397+ ) {
398+ this . #heapSnapshotOptions = {
399+ ...this . #heapSnapshotOptions,
400+ include : true ,
401+ stats,
402+ staticData,
403+ } ;
404+ }
405+
391406 attachImage ( value : ImageContentData ) : void {
392407 this . #images. push ( value ) ;
393408 }
@@ -685,6 +700,8 @@ export class McpResponse implements Response {
685700 pages ?: object [ ] ;
686701 pagination ?: object ;
687702 heapSnapshot ?: object [ ] ;
703+ heapSnapshotStats ?: object ;
704+ heapSnapshotStaticData ?: object ;
688705 extensionServiceWorkers ?: object [ ] ;
689706 extensionPages ?: object [ ] ;
690707 } = { } ;
@@ -882,23 +899,35 @@ Call ${handleDialog.name} to handle it before continuing.`);
882899 }
883900
884901 if ( this . #heapSnapshotOptions?. include ) {
902+ const stats = this . #heapSnapshotOptions. stats ;
903+ const staticData = this . #heapSnapshotOptions. staticData ;
904+ if ( stats ) {
905+ response . push ( `Statistics: ${ JSON . stringify ( stats , null , 2 ) } ` ) ;
906+ structuredContent . heapSnapshotStats = stats ;
907+ }
908+ if ( staticData ) {
909+ response . push ( `Static Data: ${ JSON . stringify ( staticData , null , 2 ) } ` ) ;
910+ structuredContent . heapSnapshotStaticData = staticData ;
911+ }
885912 const aggregates = this . #heapSnapshotOptions. aggregates ;
886- const entries = Object . entries ( aggregates ) ;
887- const sortedEntries = entries . sort ( ( a , b ) => b [ 1 ] . self - a [ 1 ] . self ) ;
913+ if ( aggregates ) {
914+ const entries = Object . entries ( aggregates ) ;
915+ const sortedEntries = entries . sort ( ( a , b ) => b [ 1 ] . self - a [ 1 ] . self ) ;
888916
889- const paginationData = this . #dataWithPagination(
890- sortedEntries ,
891- this . #heapSnapshotOptions. pagination ,
892- ) ;
917+ const paginationData = this . #dataWithPagination(
918+ sortedEntries ,
919+ this . #heapSnapshotOptions. pagination ,
920+ ) ;
893921
894- structuredContent . pagination = paginationData . pagination ;
895- response . push ( ...paginationData . info ) ;
922+ structuredContent . pagination = paginationData . pagination ;
923+ response . push ( ...paginationData . info ) ;
896924
897- const paginatedRecord = Object . fromEntries ( paginationData . items ) ;
898- const formatter = new HeapSnapshotFormatter ( paginatedRecord ) ;
925+ const paginatedRecord = Object . fromEntries ( paginationData . items ) ;
926+ const formatter = new HeapSnapshotFormatter ( paginatedRecord ) ;
899927
900- response . push ( formatter . toString ( ) ) ;
901- structuredContent . heapSnapshot = formatter . toJSON ( ) ;
928+ response . push ( formatter . toString ( ) ) ;
929+ structuredContent . heapSnapshot = formatter . toJSON ( ) ;
930+ }
902931 }
903932
904933 if ( data . detailedNetworkRequest ) {
0 commit comments