@@ -465,3 +465,80 @@ export const getHeapSnapshotObjectDetails = defineTool({
465465 response . setHeapSnapshotObjectDetails ( objectInfo ) ;
466466 } ,
467467} ) ;
468+
469+ export const queryHeapSnapshotObjects = defineTool ( {
470+ name : 'query_heapsnapshot_objects' ,
471+ description :
472+ 'Loads a memory heapsnapshot and queries objects matching specific filters (className, propertyName, nodeType, minRetainedSize, maxRetainedSize, minSelfSize, isDetached, sortBy).' ,
473+ annotations : {
474+ category : ToolCategory . MEMORY ,
475+ readOnlyHint : true ,
476+ conditions : [ 'memoryDebugging' ] ,
477+ } ,
478+ blockedByDialog : false ,
479+ verifyFilesSchema : { filePath : true } ,
480+ schema : {
481+ filePath : zod . string ( ) . describe ( 'A path to a .heapsnapshot file to read.' ) ,
482+ className : zod
483+ . string ( )
484+ . optional ( )
485+ . describe ( 'Optional regex or text matching object class name.' ) ,
486+ propertyName : zod
487+ . string ( )
488+ . optional ( )
489+ . describe ( 'Optional property name filter for outgoing reference edges.' ) ,
490+ nodeType : zod
491+ . string ( )
492+ . optional ( )
493+ . describe (
494+ 'Optional V8 node type filter (e.g. object, closure, string, array, code).' ,
495+ ) ,
496+ minRetainedSize : zod
497+ . number ( )
498+ . optional ( )
499+ . describe ( 'Minimum retained size in bytes.' ) ,
500+ maxRetainedSize : zod
501+ . number ( )
502+ . optional ( )
503+ . describe ( 'Maximum retained size in bytes.' ) ,
504+ minSelfSize : zod
505+ . number ( )
506+ . optional ( )
507+ . describe ( 'Minimum self size in bytes.' ) ,
508+ maxSelfSize : zod
509+ . number ( )
510+ . optional ( )
511+ . describe ( 'Maximum self size in bytes.' ) ,
512+ isDetached : zod
513+ . boolean ( )
514+ . optional ( )
515+ . describe ( 'Whether to filter for detached DOM nodes.' ) ,
516+ sortBy : zod
517+ . enum ( [ 'retainedSize' , 'selfSize' , 'id' ] )
518+ . optional ( )
519+ . describe ( 'Sort order for results. Default is retainedSize.' ) ,
520+ pageIdx : zod . number ( ) . optional ( ) . describe ( 'The page index for pagination.' ) ,
521+ pageSize : zod . number ( ) . optional ( ) . describe ( 'The page size for pagination.' ) ,
522+ } ,
523+ handler : async ( request , response , context ) => {
524+ const range = await context . queryHeapSnapshotObjects (
525+ request . params . filePath ,
526+ {
527+ className : request . params . className ,
528+ propertyName : request . params . propertyName ,
529+ nodeType : request . params . nodeType ,
530+ minRetainedSize : request . params . minRetainedSize ,
531+ maxRetainedSize : request . params . maxRetainedSize ,
532+ minSelfSize : request . params . minSelfSize ,
533+ maxSelfSize : request . params . maxSelfSize ,
534+ isDetached : request . params . isDetached ,
535+ sortBy : request . params . sortBy ,
536+ } ,
537+ ) ;
538+
539+ response . setHeapSnapshotNodes ( range , {
540+ pageIdx : request . params . pageIdx ,
541+ pageSize : request . params . pageSize ,
542+ } ) ;
543+ } ,
544+ } ) ;
0 commit comments