@memlab/mcp-server 2.18.1 → 2.86.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 (374) hide show
  1. package/README.md +30 -16
  2. package/bin/.eslintrc.js +26 -0
  3. package/bin/memlab-cli.js +313 -0
  4. package/dist/anonymized-snapshot.d.ts +75 -0
  5. package/dist/anonymized-snapshot.d.ts.map +1 -0
  6. package/dist/anonymized-snapshot.js +101 -0
  7. package/dist/anonymized-snapshot.js.map +1 -0
  8. package/dist/artifact-classes.d.ts +86 -0
  9. package/dist/artifact-classes.d.ts.map +1 -0
  10. package/dist/artifact-classes.js +261 -0
  11. package/dist/artifact-classes.js.map +1 -0
  12. package/dist/capture-mode.d.ts +60 -0
  13. package/dist/capture-mode.d.ts.map +1 -0
  14. package/dist/capture-mode.js +39 -0
  15. package/dist/capture-mode.js.map +1 -0
  16. package/dist/eval-hints.d.ts +41 -0
  17. package/dist/eval-hints.d.ts.map +1 -0
  18. package/dist/eval-hints.js +115 -0
  19. package/dist/eval-hints.js.map +1 -0
  20. package/dist/guardrail.d.ts.map +1 -1
  21. package/dist/guardrail.js +13 -0
  22. package/dist/guardrail.js.map +1 -1
  23. package/dist/heap-budget.d.ts +32 -0
  24. package/dist/heap-budget.d.ts.map +1 -0
  25. package/dist/heap-budget.js +90 -0
  26. package/dist/heap-budget.js.map +1 -0
  27. package/dist/heap-shapes.d.ts +148 -0
  28. package/dist/heap-shapes.d.ts.map +1 -0
  29. package/dist/heap-shapes.js +193 -0
  30. package/dist/heap-shapes.js.map +1 -0
  31. package/dist/heap-state.d.ts +109 -2
  32. package/dist/heap-state.d.ts.map +1 -1
  33. package/dist/heap-state.js +194 -3
  34. package/dist/heap-state.js.map +1 -1
  35. package/dist/index.js +102 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/progress.d.ts +25 -0
  38. package/dist/progress.d.ts.map +1 -0
  39. package/dist/progress.js +46 -0
  40. package/dist/progress.js.map +1 -0
  41. package/dist/react-shapes.d.ts +42 -0
  42. package/dist/react-shapes.d.ts.map +1 -0
  43. package/dist/react-shapes.js +149 -0
  44. package/dist/react-shapes.js.map +1 -0
  45. package/dist/result-handles.d.ts +11 -0
  46. package/dist/result-handles.d.ts.map +1 -0
  47. package/dist/result-handles.js +77 -0
  48. package/dist/result-handles.js.map +1 -0
  49. package/dist/server-version.d.ts +19 -0
  50. package/dist/server-version.d.ts.map +1 -0
  51. package/dist/server-version.js +19 -0
  52. package/dist/server-version.js.map +1 -0
  53. package/dist/snapshot-borrow.d.ts +67 -0
  54. package/dist/snapshot-borrow.d.ts.map +1 -0
  55. package/dist/snapshot-borrow.js +113 -0
  56. package/dist/snapshot-borrow.js.map +1 -0
  57. package/dist/string-index.d.ts +55 -0
  58. package/dist/string-index.d.ts.map +1 -0
  59. package/dist/string-index.js +99 -0
  60. package/dist/string-index.js.map +1 -0
  61. package/dist/tool-registry.d.ts +42 -0
  62. package/dist/tool-registry.d.ts.map +1 -0
  63. package/dist/tool-registry.js +20 -0
  64. package/dist/tool-registry.js.map +1 -0
  65. package/dist/tools/analyze-run.d.ts +12 -0
  66. package/dist/tools/analyze-run.d.ts.map +1 -0
  67. package/dist/tools/analyze-run.js +404 -0
  68. package/dist/tools/analyze-run.js.map +1 -0
  69. package/dist/tools/anonymize-snapshot.d.ts +12 -0
  70. package/dist/tools/anonymize-snapshot.d.ts.map +1 -0
  71. package/dist/tools/anonymize-snapshot.js +159 -0
  72. package/dist/tools/anonymize-snapshot.js.map +1 -0
  73. package/dist/tools/app-config.d.ts +12 -0
  74. package/dist/tools/app-config.d.ts.map +1 -0
  75. package/dist/tools/app-config.js +217 -0
  76. package/dist/tools/app-config.js.map +1 -0
  77. package/dist/tools/app-heap.d.ts +30 -0
  78. package/dist/tools/app-heap.d.ts.map +1 -0
  79. package/dist/tools/app-heap.js +106 -0
  80. package/dist/tools/app-heap.js.map +1 -0
  81. package/dist/tools/artifact-budget.d.ts +12 -0
  82. package/dist/tools/artifact-budget.d.ts.map +1 -0
  83. package/dist/tools/artifact-budget.js +219 -0
  84. package/dist/tools/artifact-budget.js.map +1 -0
  85. package/dist/tools/async-census.d.ts +12 -0
  86. package/dist/tools/async-census.d.ts.map +1 -0
  87. package/dist/tools/async-census.js +243 -0
  88. package/dist/tools/async-census.js.map +1 -0
  89. package/dist/tools/auto-investigate.d.ts.map +1 -1
  90. package/dist/tools/auto-investigate.js +54 -5
  91. package/dist/tools/auto-investigate.js.map +1 -1
  92. package/dist/tools/batch.d.ts +12 -0
  93. package/dist/tools/batch.d.ts.map +1 -0
  94. package/dist/tools/batch.js +196 -0
  95. package/dist/tools/batch.js.map +1 -0
  96. package/dist/tools/cache-analysis.d.ts +15 -0
  97. package/dist/tools/cache-analysis.d.ts.map +1 -1
  98. package/dist/tools/cache-analysis.js +240 -14
  99. package/dist/tools/cache-analysis.js.map +1 -1
  100. package/dist/tools/census-diff.d.ts +55 -0
  101. package/dist/tools/census-diff.d.ts.map +1 -0
  102. package/dist/tools/census-diff.js +228 -0
  103. package/dist/tools/census-diff.js.map +1 -0
  104. package/dist/tools/chain-walk.d.ts +12 -0
  105. package/dist/tools/chain-walk.d.ts.map +1 -0
  106. package/dist/tools/chain-walk.js +184 -0
  107. package/dist/tools/chain-walk.js.map +1 -0
  108. package/dist/tools/class-histogram.d.ts.map +1 -1
  109. package/dist/tools/class-histogram.js +14 -3
  110. package/dist/tools/class-histogram.js.map +1 -1
  111. package/dist/tools/collection-diff.d.ts +44 -0
  112. package/dist/tools/collection-diff.d.ts.map +1 -0
  113. package/dist/tools/collection-diff.js +343 -0
  114. package/dist/tools/collection-diff.js.map +1 -0
  115. package/dist/tools/collection-trend.d.ts +55 -0
  116. package/dist/tools/collection-trend.d.ts.map +1 -0
  117. package/dist/tools/collection-trend.js +315 -0
  118. package/dist/tools/collection-trend.js.map +1 -0
  119. package/dist/tools/detached-dom.d.ts +5 -0
  120. package/dist/tools/detached-dom.d.ts.map +1 -1
  121. package/dist/tools/detached-dom.js +368 -22
  122. package/dist/tools/detached-dom.js.map +1 -1
  123. package/dist/tools/dev-artifacts.d.ts +62 -6
  124. package/dist/tools/dev-artifacts.d.ts.map +1 -1
  125. package/dist/tools/dev-artifacts.js +685 -24
  126. package/dist/tools/dev-artifacts.js.map +1 -1
  127. package/dist/tools/diff-snapshots.d.ts.map +1 -1
  128. package/dist/tools/diff-snapshots.js +18 -2
  129. package/dist/tools/diff-snapshots.js.map +1 -1
  130. package/dist/tools/dom-audit.d.ts +37 -0
  131. package/dist/tools/dom-audit.d.ts.map +1 -0
  132. package/dist/tools/dom-audit.js +247 -0
  133. package/dist/tools/dom-audit.js.map +1 -0
  134. package/dist/tools/dominator-attribution.d.ts +12 -0
  135. package/dist/tools/dominator-attribution.d.ts.map +1 -0
  136. package/dist/tools/dominator-attribution.js +189 -0
  137. package/dist/tools/dominator-attribution.js.map +1 -0
  138. package/dist/tools/dominator-chain.d.ts +12 -0
  139. package/dist/tools/dominator-chain.d.ts.map +1 -0
  140. package/dist/tools/dominator-chain.js +92 -0
  141. package/dist/tools/dominator-chain.js.map +1 -0
  142. package/dist/tools/duplicate-objects.d.ts +12 -0
  143. package/dist/tools/duplicate-objects.d.ts.map +1 -0
  144. package/dist/tools/duplicate-objects.js +172 -0
  145. package/dist/tools/duplicate-objects.js.map +1 -0
  146. package/dist/tools/duplicated-strings.d.ts.map +1 -1
  147. package/dist/tools/duplicated-strings.js +49 -40
  148. package/dist/tools/duplicated-strings.js.map +1 -1
  149. package/dist/tools/eval-across.d.ts +12 -0
  150. package/dist/tools/eval-across.d.ts.map +1 -0
  151. package/dist/tools/eval-across.js +135 -0
  152. package/dist/tools/eval-across.js.map +1 -0
  153. package/dist/tools/eval.d.ts +79 -0
  154. package/dist/tools/eval.d.ts.map +1 -1
  155. package/dist/tools/eval.js +2523 -197
  156. package/dist/tools/eval.js.map +1 -1
  157. package/dist/tools/event-listener-leaks.d.ts.map +1 -1
  158. package/dist/tools/event-listener-leaks.js +42 -17
  159. package/dist/tools/event-listener-leaks.js.map +1 -1
  160. package/dist/tools/event-registry.d.ts.map +1 -1
  161. package/dist/tools/event-registry.js +42 -8
  162. package/dist/tools/event-registry.js.map +1 -1
  163. package/dist/tools/explain-delta.d.ts +12 -0
  164. package/dist/tools/explain-delta.d.ts.map +1 -0
  165. package/dist/tools/explain-delta.js +221 -0
  166. package/dist/tools/explain-delta.js.map +1 -0
  167. package/dist/tools/find-nodes-by-class.d.ts.map +1 -1
  168. package/dist/tools/find-nodes-by-class.js +112 -13
  169. package/dist/tools/find-nodes-by-class.js.map +1 -1
  170. package/dist/tools/finding-index.d.ts +203 -0
  171. package/dist/tools/finding-index.d.ts.map +1 -0
  172. package/dist/tools/finding-index.js +566 -0
  173. package/dist/tools/finding-index.js.map +1 -0
  174. package/dist/tools/for-each.d.ts.map +1 -1
  175. package/dist/tools/for-each.js +15 -3
  176. package/dist/tools/for-each.js.map +1 -1
  177. package/dist/tools/get-referrers.d.ts.map +1 -1
  178. package/dist/tools/get-referrers.js +17 -0
  179. package/dist/tools/get-referrers.js.map +1 -1
  180. package/dist/tools/get-value.d.ts +16 -0
  181. package/dist/tools/get-value.d.ts.map +1 -1
  182. package/dist/tools/get-value.js +96 -2
  183. package/dist/tools/get-value.js.map +1 -1
  184. package/dist/tools/hunt-report.d.ts +12 -0
  185. package/dist/tools/hunt-report.d.ts.map +1 -0
  186. package/dist/tools/hunt-report.js +186 -0
  187. package/dist/tools/hunt-report.js.map +1 -0
  188. package/dist/tools/hypothesis.d.ts +12 -0
  189. package/dist/tools/hypothesis.d.ts.map +1 -0
  190. package/dist/tools/hypothesis.js +280 -0
  191. package/dist/tools/hypothesis.js.map +1 -0
  192. package/dist/tools/id-space-audit.d.ts +12 -0
  193. package/dist/tools/id-space-audit.d.ts.map +1 -0
  194. package/dist/tools/id-space-audit.js +262 -0
  195. package/dist/tools/id-space-audit.js.map +1 -0
  196. package/dist/tools/identify.d.ts +12 -0
  197. package/dist/tools/identify.d.ts.map +1 -0
  198. package/dist/tools/identify.js +205 -0
  199. package/dist/tools/identify.js.map +1 -0
  200. package/dist/tools/identity-diff.d.ts +12 -0
  201. package/dist/tools/identity-diff.d.ts.map +1 -0
  202. package/dist/tools/identity-diff.js +188 -0
  203. package/dist/tools/identity-diff.js.map +1 -0
  204. package/dist/tools/intern-opportunities.d.ts.map +1 -1
  205. package/dist/tools/intern-opportunities.js +116 -50
  206. package/dist/tools/intern-opportunities.js.map +1 -1
  207. package/dist/tools/ladder-probe.d.ts +65 -0
  208. package/dist/tools/ladder-probe.d.ts.map +1 -0
  209. package/dist/tools/ladder-probe.js +445 -0
  210. package/dist/tools/ladder-probe.js.map +1 -0
  211. package/dist/tools/ladder.d.ts +33 -0
  212. package/dist/tools/ladder.d.ts.map +1 -0
  213. package/dist/tools/ladder.js +266 -0
  214. package/dist/tools/ladder.js.map +1 -0
  215. package/dist/tools/largest-objects.d.ts.map +1 -1
  216. package/dist/tools/largest-objects.js +6 -2
  217. package/dist/tools/largest-objects.js.map +1 -1
  218. package/dist/tools/leak-report.d.ts +35 -0
  219. package/dist/tools/leak-report.d.ts.map +1 -0
  220. package/dist/tools/leak-report.js +398 -0
  221. package/dist/tools/leak-report.js.map +1 -0
  222. package/dist/tools/load-snapshot.d.ts +29 -0
  223. package/dist/tools/load-snapshot.d.ts.map +1 -1
  224. package/dist/tools/load-snapshot.js +294 -23
  225. package/dist/tools/load-snapshot.js.map +1 -1
  226. package/dist/tools/map-entries.d.ts +12 -0
  227. package/dist/tools/map-entries.d.ts.map +1 -0
  228. package/dist/tools/map-entries.js +139 -0
  229. package/dist/tools/map-entries.js.map +1 -0
  230. package/dist/tools/match-object.d.ts +12 -0
  231. package/dist/tools/match-object.d.ts.map +1 -0
  232. package/dist/tools/match-object.js +165 -0
  233. package/dist/tools/match-object.js.map +1 -0
  234. package/dist/tools/metric.d.ts +13 -0
  235. package/dist/tools/metric.d.ts.map +1 -0
  236. package/dist/tools/metric.js +185 -0
  237. package/dist/tools/metric.js.map +1 -0
  238. package/dist/tools/module-attribution.d.ts +36 -0
  239. package/dist/tools/module-attribution.d.ts.map +1 -0
  240. package/dist/tools/module-attribution.js +235 -0
  241. package/dist/tools/module-attribution.js.map +1 -0
  242. package/dist/tools/next-measurement.d.ts +26 -0
  243. package/dist/tools/next-measurement.d.ts.map +1 -0
  244. package/dist/tools/next-measurement.js +149 -0
  245. package/dist/tools/next-measurement.js.map +1 -0
  246. package/dist/tools/object-cost-breakdown.d.ts.map +1 -1
  247. package/dist/tools/object-cost-breakdown.js +64 -0
  248. package/dist/tools/object-cost-breakdown.js.map +1 -1
  249. package/dist/tools/object-shape.d.ts.map +1 -1
  250. package/dist/tools/object-shape.js +53 -5
  251. package/dist/tools/object-shape.js.map +1 -1
  252. package/dist/tools/population-diff.d.ts +57 -0
  253. package/dist/tools/population-diff.d.ts.map +1 -0
  254. package/dist/tools/population-diff.js +338 -0
  255. package/dist/tools/population-diff.js.map +1 -0
  256. package/dist/tools/population-vs-owners.d.ts +12 -0
  257. package/dist/tools/population-vs-owners.d.ts.map +1 -0
  258. package/dist/tools/population-vs-owners.js +183 -0
  259. package/dist/tools/population-vs-owners.js.map +1 -0
  260. package/dist/tools/property-names.d.ts +29 -0
  261. package/dist/tools/property-names.d.ts.map +1 -0
  262. package/dist/tools/property-names.js +131 -0
  263. package/dist/tools/property-names.js.map +1 -0
  264. package/dist/tools/quick-diagnosis.d.ts.map +1 -1
  265. package/dist/tools/quick-diagnosis.js +7 -1
  266. package/dist/tools/quick-diagnosis.js.map +1 -1
  267. package/dist/tools/react-owners.d.ts +12 -0
  268. package/dist/tools/react-owners.d.ts.map +1 -0
  269. package/dist/tools/react-owners.js +167 -0
  270. package/dist/tools/react-owners.js.map +1 -0
  271. package/dist/tools/react-update-queues.d.ts +12 -0
  272. package/dist/tools/react-update-queues.d.ts.map +1 -0
  273. package/dist/tools/react-update-queues.js +173 -0
  274. package/dist/tools/react-update-queues.js.map +1 -0
  275. package/dist/tools/replicate.d.ts +49 -0
  276. package/dist/tools/replicate.d.ts.map +1 -0
  277. package/dist/tools/replicate.js +241 -0
  278. package/dist/tools/replicate.js.map +1 -0
  279. package/dist/tools/retainer-diff.d.ts +12 -0
  280. package/dist/tools/retainer-diff.d.ts.map +1 -0
  281. package/dist/tools/retainer-diff.js +168 -0
  282. package/dist/tools/retainer-diff.js.map +1 -0
  283. package/dist/tools/retainer-layers.d.ts +23 -0
  284. package/dist/tools/retainer-layers.d.ts.map +1 -0
  285. package/dist/tools/retainer-layers.js +179 -0
  286. package/dist/tools/retainer-layers.js.map +1 -0
  287. package/dist/tools/retainer-summary.d.ts +18 -0
  288. package/dist/tools/retainer-summary.d.ts.map +1 -1
  289. package/dist/tools/retainer-summary.js +210 -51
  290. package/dist/tools/retainer-summary.js.map +1 -1
  291. package/dist/tools/retainer-trace.d.ts.map +1 -1
  292. package/dist/tools/retainer-trace.js +14 -2
  293. package/dist/tools/retainer-trace.js.map +1 -1
  294. package/dist/tools/round-audit.d.ts +66 -0
  295. package/dist/tools/round-audit.d.ts.map +1 -0
  296. package/dist/tools/round-audit.js +258 -0
  297. package/dist/tools/round-audit.js.map +1 -0
  298. package/dist/tools/round-digest.d.ts +12 -0
  299. package/dist/tools/round-digest.d.ts.map +1 -0
  300. package/dist/tools/round-digest.js +190 -0
  301. package/dist/tools/round-digest.js.map +1 -0
  302. package/dist/tools/script-census.d.ts +12 -0
  303. package/dist/tools/script-census.d.ts.map +1 -0
  304. package/dist/tools/script-census.js +182 -0
  305. package/dist/tools/script-census.js.map +1 -0
  306. package/dist/tools/search-nodes.d.ts.map +1 -1
  307. package/dist/tools/search-nodes.js +5 -1
  308. package/dist/tools/search-nodes.js.map +1 -1
  309. package/dist/tools/search-strings.d.ts.map +1 -1
  310. package/dist/tools/search-strings.js +53 -7
  311. package/dist/tools/search-strings.js.map +1 -1
  312. package/dist/tools/sequence-analysis.d.ts +53 -0
  313. package/dist/tools/sequence-analysis.d.ts.map +1 -1
  314. package/dist/tools/sequence-analysis.js +313 -89
  315. package/dist/tools/sequence-analysis.js.map +1 -1
  316. package/dist/tools/server-status.d.ts.map +1 -1
  317. package/dist/tools/server-status.js +4 -1
  318. package/dist/tools/server-status.js.map +1 -1
  319. package/dist/tools/settle-check.d.ts +12 -0
  320. package/dist/tools/settle-check.d.ts.map +1 -0
  321. package/dist/tools/settle-check.js +188 -0
  322. package/dist/tools/settle-check.js.map +1 -0
  323. package/dist/tools/shape-histogram.d.ts.map +1 -1
  324. package/dist/tools/shape-histogram.js +9 -2
  325. package/dist/tools/shape-histogram.js.map +1 -1
  326. package/dist/tools/sliced-strings.d.ts.map +1 -1
  327. package/dist/tools/sliced-strings.js +2 -1
  328. package/dist/tools/sliced-strings.js.map +1 -1
  329. package/dist/tools/snapshots.d.ts.map +1 -1
  330. package/dist/tools/snapshots.js +24 -6
  331. package/dist/tools/snapshots.js.map +1 -1
  332. package/dist/tools/sparse-elements.d.ts +12 -0
  333. package/dist/tools/sparse-elements.d.ts.map +1 -0
  334. package/dist/tools/sparse-elements.js +215 -0
  335. package/dist/tools/sparse-elements.js.map +1 -0
  336. package/dist/tools/stale-collections.d.ts +17 -0
  337. package/dist/tools/stale-collections.d.ts.map +1 -1
  338. package/dist/tools/stale-collections.js +28 -0
  339. package/dist/tools/stale-collections.js.map +1 -1
  340. package/dist/tools/string-patterns.d.ts.map +1 -1
  341. package/dist/tools/string-patterns.js +7 -5
  342. package/dist/tools/string-patterns.js.map +1 -1
  343. package/dist/tools/tools-index.d.ts +12 -0
  344. package/dist/tools/tools-index.d.ts.map +1 -0
  345. package/dist/tools/tools-index.js +492 -0
  346. package/dist/tools/tools-index.js.map +1 -0
  347. package/dist/tools/trace-all.d.ts +42 -0
  348. package/dist/tools/trace-all.d.ts.map +1 -0
  349. package/dist/tools/trace-all.js +263 -0
  350. package/dist/tools/trace-all.js.map +1 -0
  351. package/dist/tools/unit-cost.d.ts +12 -0
  352. package/dist/tools/unit-cost.d.ts.map +1 -0
  353. package/dist/tools/unit-cost.js +219 -0
  354. package/dist/tools/unit-cost.js.map +1 -0
  355. package/dist/tools/verify-fix.d.ts +23 -0
  356. package/dist/tools/verify-fix.d.ts.map +1 -0
  357. package/dist/tools/verify-fix.js +219 -0
  358. package/dist/tools/verify-fix.js.map +1 -0
  359. package/dist/tools/weakmap-entries.d.ts.map +1 -1
  360. package/dist/tools/weakmap-entries.js +6 -1
  361. package/dist/tools/weakmap-entries.js.map +1 -1
  362. package/dist/tools/weakref-census.d.ts +15 -0
  363. package/dist/tools/weakref-census.d.ts.map +1 -0
  364. package/dist/tools/weakref-census.js +147 -0
  365. package/dist/tools/weakref-census.js.map +1 -0
  366. package/dist/tools/what-if.d.ts +12 -0
  367. package/dist/tools/what-if.d.ts.map +1 -0
  368. package/dist/tools/what-if.js +285 -0
  369. package/dist/tools/what-if.js.map +1 -0
  370. package/dist/utils.d.ts +238 -3
  371. package/dist/utils.d.ts.map +1 -1
  372. package/dist/utils.js +507 -15
  373. package/dist/utils.js.map +1 -1
  374. package/package.json +7 -6
@@ -0,0 +1,492 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall memory_lab
9
+ */
10
+ import { z } from 'zod';
11
+ import { listToolNames } from '../tool-registry.js';
12
+ import { errorResult, makeNamePatternTest, textResult } from '../utils.js';
13
+ const GROUPS = [
14
+ {
15
+ question: 'What is this heap actually made of?',
16
+ tools: [
17
+ [
18
+ 'memlab_script_census',
19
+ 'How much of the heap is retained JS SOURCE TEXT — and whether the same bundle is retained twice.',
20
+ ],
21
+ [
22
+ 'memlab_property_names',
23
+ 'Which property names exist at all; the cheapest way to confirm a field is present before probing for it.',
24
+ ],
25
+ [
26
+ 'memlab_async_census',
27
+ 'Pending async work: scheduler task queues (live vs cancelled), timer closures, unsettled Promises.',
28
+ ],
29
+ [
30
+ 'memlab_app_heap',
31
+ 'START HERE on an unfamiliar app: splits the heap into application data vs bundle source vs V8 machinery. On one app this showed ~55% of the heap was JS bundle source, which reframed every number that followed.',
32
+ ],
33
+ [
34
+ 'memlab_quick_diagnosis',
35
+ 'One call for summary + biggest objects + class histogram + duplicated strings.',
36
+ ],
37
+ [
38
+ 'memlab_snapshot_summary',
39
+ 'Node/edge counts and totals, when you only need the shape of the capture.',
40
+ ],
41
+ [
42
+ 'memlab_class_histogram',
43
+ 'Counts and sizes per class; `name_pattern` answers "is class X present?" in one row.',
44
+ ],
45
+ ['memlab_largest_objects', 'The single biggest retainers, ranked.'],
46
+ [
47
+ 'memlab_shape_histogram',
48
+ 'Groups plain objects by their property set — finds record types the class name hides behind `Object`.',
49
+ ],
50
+ [
51
+ 'memlab_identify',
52
+ 'Name a minified structure from its property shape — listener record, LRU node, React update record, undo entry.',
53
+ ],
54
+ [
55
+ 'memlab_object_cost_breakdown',
56
+ 'Where one class’s bytes actually go (self vs properties vs elements).',
57
+ ],
58
+ [
59
+ 'memlab_what_if',
60
+ 'If this set were freed, how many bytes actually come back — dominator-deduped, no double counting.',
61
+ ],
62
+ [
63
+ 'memlab_trace_all',
64
+ 'Retainer-trace an ENTIRE population and cluster the paths server-side — finds the minority path a 10-instance sample cannot.',
65
+ ],
66
+ [
67
+ 'memlab_retainer_diff',
68
+ 'Did the population grow along the same retention path, or did a NEW owner appear? The question a count diff cannot answer.',
69
+ ],
70
+ [
71
+ 'memlab_identity_diff',
72
+ 'Same objects, or just the same count? Matches a population across two captures by CONTENT — churn and retention need different fixes.',
73
+ ],
74
+ [
75
+ 'memlab_next_measurement',
76
+ 'What the loaded snapshots cannot support, and which capture would fix it. Run it before writing a conclusion.',
77
+ ],
78
+ [
79
+ 'memlab_app_config',
80
+ 'Read the feature flags the app was actually running with, out of the capture — "was the fix even enabled here?" without circular inference.',
81
+ ],
82
+ [
83
+ 'memlab_metric',
84
+ 'Record a measurement under a name and keep it ACROSS sessions — the only way a number measured today survives to be compared next week.',
85
+ ],
86
+ [
87
+ 'memlab_unit_cost',
88
+ 'Retained bytes per instance, AVERAGE and MARGINAL — the number a cap, an LRU size or an eviction policy is sized against.',
89
+ ],
90
+ ],
91
+ },
92
+ {
93
+ question: 'Is anything growing — and is it a leak?',
94
+ tools: [
95
+ [
96
+ 'memlab_ladder_probe',
97
+ 'ONE numeric probe across an ordered ladder, with the per-cycle rate and a linear fit — the cheapest way to test a metric, since each rung loads once for all probes.',
98
+ ],
99
+ [
100
+ 'memlab_census_diff',
101
+ 'Detached-DOM and listener census at TWO rungs, diffed per class and per callback in one call.',
102
+ ],
103
+ [
104
+ 'memlab_leak_report',
105
+ 'The ladder verdict: per-class growth across an ordered set of snapshots.',
106
+ ],
107
+ [
108
+ 'memlab_sequence_analysis',
109
+ 'Per-class trend across a ladder, with artifact families flagged.',
110
+ ],
111
+ [
112
+ 'memlab_collection_trend',
113
+ 'Entry counts of NAMED collections across a ladder, with growth per interaction cycle.',
114
+ ],
115
+ [
116
+ 'memlab_population_diff',
117
+ 'Whether two snapshots hold the same POPULATION or just the same count — equal totals are not identity.',
118
+ ],
119
+ [
120
+ 'memlab_react_update_queues',
121
+ 'The React eager-bailout family in one call: queue BREADTH vs chain LENGTH vs owning component. The breadth/length split is what separates a leak from "more hooks mounted".',
122
+ ],
123
+ [
124
+ 'memlab_settle_check',
125
+ 'Backlog or leak? Compares a busy rung against one captured after idle + GC — growth that comes back was work in flight.',
126
+ ],
127
+ [
128
+ 'memlab_growth_signals',
129
+ 'Single-snapshot signals that something is accumulating.',
130
+ ],
131
+ [
132
+ 'memlab_diff_snapshots',
133
+ 'Raw per-class deltas between two resident snapshots.',
134
+ ],
135
+ [
136
+ 'memlab_hypothesis',
137
+ 'State a leak hypothesis and have it checked against the ladder instead of arguing it.',
138
+ ],
139
+ [
140
+ 'memlab_verify_fix',
141
+ 'Did the fix work? Compares per-cycle growth RATES between a before ladder and an after ladder — from two sets of snapshot FILES, so no runtime gate is needed and an ungated or build-only fix is verified the same way.',
142
+ ],
143
+ [
144
+ 'memlab_ladder',
145
+ 'Name a ladder once and reference it as `ladder:<name>` from every trend tool.',
146
+ ],
147
+ ],
148
+ },
149
+ {
150
+ question: 'Who owns the growth / why is X retained?',
151
+ tools: [
152
+ [
153
+ 'memlab_react_owners',
154
+ 'Name the React COMPONENT behind a population of plain `Object`s. Fibers and hooks are all `Object` in a production bundle, so every class-name heuristic — including `helpers.owner` — walks past them.',
155
+ ],
156
+ [
157
+ 'memlab_population_vs_owners',
158
+ 'STRUCTURAL or ACCUMULATING? One record per live owner is a baseline; many records per owner is a leak.',
159
+ ],
160
+ [
161
+ 'memlab_chain_walk',
162
+ 'Walk a repeated linked structure (`.next` update queues, `.prev` closure chains, LRU lists) and report how deep it goes — use this instead of a hand-written loop, which cannot tell a cycle from a hop cap.',
163
+ ],
164
+ [
165
+ 'memlab_module_attribution',
166
+ 'Attribute bytes to the MODULE that owns them, by walking dominators up to the nearest module-registry export.',
167
+ ],
168
+ [
169
+ 'memlab_explain_delta',
170
+ 'WHERE a heap grew, attributed to the object that owns the new bytes rather than to what they are.',
171
+ ],
172
+ [
173
+ 'memlab_dominator_chain',
174
+ 'From one node up to the accountable application object.',
175
+ ],
176
+ [
177
+ 'memlab_dominator_attribution',
178
+ 'Given several candidate retainers, how much each one actually dominates — a zero refutes a hypothesis.',
179
+ ],
180
+ ['memlab_retainer_trace', 'The shortest retainer path for one node.'],
181
+ [
182
+ 'memlab_retainer_summary',
183
+ 'Retainer paths across many instances, clustered by shape.',
184
+ ],
185
+ ['memlab_referrer_summary', 'Who points at this, grouped by edge.'],
186
+ [
187
+ 'memlab_pinch_points',
188
+ 'Single objects whose release would free the most.',
189
+ ],
190
+ ['memlab_dominator_subtree', 'What one object holds, expanded downward.'],
191
+ [
192
+ 'memlab_retainer_layers',
193
+ 'The retention structure around a node, layer by layer.',
194
+ ],
195
+ ['memlab_trace_dominators', 'Dominator path for a set of nodes at once.'],
196
+ ],
197
+ },
198
+ {
199
+ question: 'Is it real, or a measurement artifact?',
200
+ tools: [
201
+ [
202
+ 'memlab_artifact_budget',
203
+ 'ONE number for how much of the heap is not the application — and, with a baseline, how much of the GROWTH was the app. `app_delta` is the number that should lead a report.',
204
+ ],
205
+ [
206
+ 'memlab_replicate',
207
+ 'Does the effect REPRODUCE across independently-driven runs? Refuses to call it real until it does — the guard against filing a one-off.',
208
+ ],
209
+ [
210
+ 'memlab_dev_artifacts',
211
+ 'Memory retained ONLY by dev/automation roots — DevTools, extensions, React Fast Refresh, the a11y cache. Run before calling anything a production leak.',
212
+ ],
213
+ [
214
+ 'memlab_explain_delta',
215
+ 'Counts the OTHER artifact family — V8 JIT warmup — which dev_artifacts does not. Read both.',
216
+ ],
217
+ [
218
+ 'memlab_check_health',
219
+ 'Prioritized triage that separates likely-real from likely-noise.',
220
+ ],
221
+ ],
222
+ },
223
+ {
224
+ question: 'Detached DOM and event listeners',
225
+ tools: [
226
+ [
227
+ 'memlab_dom_audit',
228
+ 'Budget the ATTACHED DOM and rank surfaces worth virtualizing. An OPTIMIZATION tool — these elements are correctly retained, there are simply too many.',
229
+ ],
230
+ [
231
+ 'memlab_detached_dom',
232
+ 'Detached nodes, with a pinned-vs-GC-eligible split; `group_by:"dominator"` groups by what a fix would actually free.',
233
+ ],
234
+ ['memlab_event_listener_leaks', 'Listeners that outlived their target.'],
235
+ ['memlab_event_registry', 'What is registered on what.'],
236
+ ],
237
+ },
238
+ {
239
+ question: 'Collections and caches',
240
+ tools: [
241
+ [
242
+ 'memlab_collection_diff',
243
+ 'WHICH collections grew across a ladder, without being told their names — censuses every Map/Set/Array and keys each by a stable `<Owner>.<property>` signature.',
244
+ ],
245
+ [
246
+ 'memlab_weakref_census',
247
+ 'Every WeakRef, split LIVE vs EMPTY, grouped by the shape of the holder.',
248
+ ],
249
+ [
250
+ 'memlab_cache_analysis',
251
+ 'Unbounded or oversized caches in one snapshot.',
252
+ ],
253
+ [
254
+ 'memlab_sparse_elements',
255
+ 'Integer-keyed objects and arrays whose elements backing store is mostly holes — waste charged to no class, so a histogram cannot see it.',
256
+ ],
257
+ [
258
+ 'memlab_id_space_audit',
259
+ 'Separate integer-keyed structures indexed by the SAME sparse id space — several small sparse findings that are really one re-keying fix.',
260
+ ],
261
+ [
262
+ 'memlab_stale_collections',
263
+ 'Collections holding entries nothing else references.',
264
+ ],
265
+ [
266
+ 'memlab_collection_trend',
267
+ 'The same collections tracked ACROSS a ladder.',
268
+ ],
269
+ [
270
+ 'memlab_map_entries',
271
+ 'Enumerate a Map/Set correctly (SMI gaps and browser slot typing handled).',
272
+ ],
273
+ ['memlab_weakmap_entries', 'Enumerate a WeakMap.'],
274
+ [
275
+ 'memlab_array_group_by',
276
+ 'Group an array’s elements by a property to see what is piling up.',
277
+ ],
278
+ [
279
+ 'memlab_property_distribution',
280
+ 'Cardinality and top values of one property across instances.',
281
+ ],
282
+ ],
283
+ },
284
+ {
285
+ question: 'Strings and duplication',
286
+ tools: [
287
+ [
288
+ 'memlab_intern_opportunities',
289
+ 'What an intern pool would actually reclaim, grouped by property x parent shape. Start here for an interning decision.',
290
+ ],
291
+ ['memlab_duplicated_strings', 'The raw per-value duplication table.'],
292
+ [
293
+ 'memlab_string_patterns',
294
+ 'Group strings by prefix to find families (URLs, ids, payloads).',
295
+ ],
296
+ ['memlab_sliced_strings', 'Substrings pinning huge parents.'],
297
+ [
298
+ 'memlab_duplicate_objects',
299
+ 'The same question for objects rather than strings.',
300
+ ],
301
+ ['memlab_search_strings', 'Find a string value in the heap.'],
302
+ ['memlab_get_string', 'Read one string node’s value.'],
303
+ ],
304
+ },
305
+ {
306
+ question: 'Inspect or find specific objects',
307
+ tools: [
308
+ [
309
+ 'memlab_find_nodes_by_class',
310
+ 'By exact class name, or by `name_pattern` regex/substring.',
311
+ ],
312
+ ['memlab_search_nodes', 'By name/type/size predicates.'],
313
+ ['memlab_find_by_property', 'By a property name/value.'],
314
+ ['memlab_find_by_shape', 'By property set.'],
315
+ ['memlab_match_object', 'By a structural pattern.'],
316
+ ['memlab_get_node', 'One node’s details.'],
317
+ ['memlab_object_shape', 'One object’s properties and their sizes.'],
318
+ ['memlab_get_references', 'Outgoing edges.'],
319
+ ['memlab_get_referrers', 'Incoming edges.'],
320
+ ['memlab_get_property', 'One property of one object.'],
321
+ ['memlab_get_value', 'A scalar value, where the format allows it.'],
322
+ [
323
+ 'memlab_closure_inspection',
324
+ 'What a closure captured, and what that costs.',
325
+ ],
326
+ ['memlab_global_variables', 'What is hanging off the global object.'],
327
+ ['memlab_aggregate', 'Sum/count over a node set.'],
328
+ ['memlab_for_each', 'Run one tool over many nodes.'],
329
+ ],
330
+ },
331
+ {
332
+ question: 'None of the above — ask the heap directly',
333
+ tools: [
334
+ [
335
+ 'memlab_eval',
336
+ 'Arbitrary JS over the snapshot, with indexed helpers (`byClass`, `iterByType`, `classCounts`, `entries`, `dominates`, `pathBetween`). Use `mode:"describe_env"` for the calling convention. This is the escape hatch when no fixed-shape tool matches the question.',
337
+ ],
338
+ [
339
+ 'memlab_eval_across',
340
+ 'The same eval program run against several snapshots at once — comparative questions without the switch-and-diff.',
341
+ ],
342
+ [
343
+ 'memlab_auto_investigate',
344
+ 'When you do not yet have a question: runs the standard deep-dive and reports what it found.',
345
+ ],
346
+ [
347
+ 'memlab_tools',
348
+ 'This index. Filter it with `question` or look a tool up with `tool`.',
349
+ ],
350
+ ],
351
+ },
352
+ {
353
+ question: 'Sharing a capture outside its trust boundary',
354
+ tools: [
355
+ [
356
+ 'memlab_anonymize_snapshot',
357
+ 'Rewrite a capture so it can be attached to a task or handed to a model, keeping it analyzable — and reporting the identifier-shaped text it could NOT classify. Also audits a capture someone else anonymized: one such file still carried 26,303 account handles as property names.',
358
+ ],
359
+ ],
360
+ },
361
+ {
362
+ question: 'Session, batching and write-ups',
363
+ tools: [
364
+ [
365
+ 'memlab_round_digest',
366
+ 'The verdict table for a finished round and nothing else — the audit verdict, the ladder shape, and the per-metric rate/fit/verdict rows, without the ~30 KB of prose.',
367
+ ],
368
+ [
369
+ 'memlab_round_audit',
370
+ 'Read a round’s run.json BEFORE analysing it, so a broken bring-up is caught before its numbers travel into a write-up.',
371
+ ],
372
+ [
373
+ 'memlab_load_snapshot',
374
+ 'Load a local path, a manifold:// URL, or a bare Nest filename.',
375
+ ],
376
+ [
377
+ 'memlab_snapshots',
378
+ 'List / switch / unload resident snapshots; set session output controls.',
379
+ ],
380
+ [
381
+ 'memlab_batch',
382
+ 'Several tools against ONE load — the load is the expensive part.',
383
+ ],
384
+ [
385
+ 'memlab_snapshot_header',
386
+ 'Node/edge counts WITHOUT loading the snapshot.',
387
+ ],
388
+ [
389
+ 'memlab_server_status',
390
+ 'Confirm the server is alive; returns instantly.',
391
+ ],
392
+ [
393
+ 'memlab_finding_index',
394
+ 'Record findings as you go so the write-up is not reconstructed from memory.',
395
+ ],
396
+ ['memlab_reports', 'Render the findings.'],
397
+ ['memlab_hunt_report', 'Render a leak-hunt run.'],
398
+ [
399
+ 'memlab_analyze_run',
400
+ 'Point at a run.json and get the WHOLE analysis protocol — trend, owner attribution, population diff, artifact classification, caveats — in one call.',
401
+ ],
402
+ ],
403
+ },
404
+ ];
405
+ export function registerToolsIndex(server) {
406
+ server.tool('memlab_tools', 'Index of every memlab tool, grouped by the QUESTION it answers ("what is this heap made of", "is anything growing", "why is X retained", "is it real or an artifact", …). Call this first when you are not sure which tool fits, or when you suspect the server has something better than the one you were about to use — it costs one call and lists tools whose schemas have not been fetched yet, which is otherwise impossible to discover under deferred tool loading. Pass `question` to filter to matching groups, or `tool` to find which group a tool belongs to.', {
407
+ question: z
408
+ .string()
409
+ .optional()
410
+ .describe('Filter to groups matching this text (case-insensitive regex, substring fallback) — e.g. "growing", "retained", "artifact", "string".'),
411
+ tool: z
412
+ .string()
413
+ .optional()
414
+ .describe('Show the group(s) containing this tool name (with or without the memlab_ prefix).'),
415
+ }, async ({ question, tool }) => {
416
+ try {
417
+ const registered = new Set(listToolNames());
418
+ const wanted = tool
419
+ ? tool.startsWith('memlab_')
420
+ ? tool
421
+ : `memlab_${tool}`
422
+ : null;
423
+ const matchesQuestion = makeNamePatternTest(question);
424
+ const indexed = new Set(GROUPS.flatMap(g => g.tools.map(([n]) => n)));
425
+ const uncategorized = [...registered].filter(n => !indexed.has(n));
426
+ let groups = GROUPS;
427
+ if (wanted != null) {
428
+ groups = groups.filter(g => g.tools.some(([n]) => n === wanted));
429
+ if (groups.length === 0) {
430
+ // This branch returns immediately, so the uncategorized list has to
431
+ // be rendered HERE. Pointing at the drift-guard section further
432
+ // down sent the reader to output this call never produces.
433
+ const parts = [
434
+ `\`${wanted}\` is not in the index${registered.has(wanted) ? ' (but it IS registered — the index is missing an entry)' : ' and is not a registered tool'}.`,
435
+ ];
436
+ if (uncategorized.length > 0) {
437
+ parts.push(`Registered but not categorized: ${uncategorized.map(n => `\`${n}\``).join(', ')}.`);
438
+ }
439
+ parts.push(`Registered tools: ${[...registered].join(', ')}`);
440
+ return textResult(parts.join('\n\n'));
441
+ }
442
+ }
443
+ if (question != null) {
444
+ groups = groups.filter(g => matchesQuestion(g.question) ||
445
+ g.tools.some(([n, w]) => matchesQuestion(n) || matchesQuestion(w)));
446
+ }
447
+ const lines = [
448
+ `# memlab tools by question (${registered.size} registered)`,
449
+ '',
450
+ ];
451
+ if (groups.length === 0) {
452
+ // Name BOTH filters when both were passed: `tool` narrows first, so
453
+ // "no group matches <question>" alone describes the wrong search and
454
+ // suggests re-running with no arguments when dropping one would do.
455
+ const filterDesc = wanted != null && question != null
456
+ ? `\`${wanted}\` and "${question}" together`
457
+ : question != null
458
+ ? `"${question}"`
459
+ : 'that filter';
460
+ lines.push(`No group matches ${filterDesc}. ` +
461
+ (wanted != null && question != null
462
+ ? `\`${wanted}\` is in the index, but not in a group matching "${question}" — drop one of the two, or call \`memlab_tools\` with no arguments for the full index.`
463
+ : 'Call `memlab_tools` with no arguments for the full index.'));
464
+ return textResult(lines.join('\n'));
465
+ }
466
+ for (const g of groups) {
467
+ lines.push(`## ${g.question}`, '');
468
+ for (const [name, when] of g.tools) {
469
+ // A name in the index that is no longer registered is worse than a
470
+ // missing one: it sends the caller after a tool that will fail.
471
+ const missing = registered.has(name) ? '' : ' _(not registered)_';
472
+ lines.push(`- \`${name}\`${missing} — ${when}`);
473
+ }
474
+ lines.push('');
475
+ }
476
+ // Drift guard. The index is hand-written for usefulness, so a newly
477
+ // added tool would otherwise be invisible here — which is the exact
478
+ // failure this tool exists to fix, reproduced one level up.
479
+ if (question == null && wanted == null) {
480
+ if (uncategorized.length > 0) {
481
+ lines.push('## Not yet categorized', '', `These are registered but missing from the index above: ${uncategorized.map(n => `\`${n}\``).join(', ')}. Their own descriptions are the only documentation.`, '');
482
+ }
483
+ }
484
+ lines.push('_A tool listed under several questions is genuinely useful for each. Where a group is ordered, the first entry is the one to try first._');
485
+ return textResult(lines.join('\n'));
486
+ }
487
+ catch (err) {
488
+ return errorResult(err);
489
+ }
490
+ });
491
+ }
492
+ //# sourceMappingURL=tools-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools-index.js","sourceRoot":"","sources":["../../src/tools/tools-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAE,UAAU,EAAC,MAAM,aAAa,CAAC;AAuBzE,MAAM,MAAM,GAAY;IACtB;QACE,QAAQ,EAAE,qCAAqC;QAC/C,KAAK,EAAE;YACL;gBACE,sBAAsB;gBACtB,kGAAkG;aACnG;YACD;gBACE,uBAAuB;gBACvB,0GAA0G;aAC3G;YACD;gBACE,qBAAqB;gBACrB,oGAAoG;aACrG;YACD;gBACE,iBAAiB;gBACjB,mNAAmN;aACpN;YACD;gBACE,wBAAwB;gBACxB,gFAAgF;aACjF;YACD;gBACE,yBAAyB;gBACzB,2EAA2E;aAC5E;YACD;gBACE,wBAAwB;gBACxB,sFAAsF;aACvF;YACD,CA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CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall memory_lab
9
+ */
10
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
11
+ import type { IHeapNode, IHeapSnapshot } from '@memlab/core';
12
+ import { type TraceStep } from './retainer-summary.js';
13
+ export interface TraceCluster {
14
+ key: string;
15
+ steps: TraceStep[];
16
+ count: number;
17
+ selfSize: number;
18
+ exampleIds: number[];
19
+ ids: number[];
20
+ idsTruncated: boolean;
21
+ }
22
+ /**
23
+ * Render a cluster's chain. When a path was truncated for grouping, its last
24
+ * step still carries the edge leading to the next hop, and that edge IS part
25
+ * of the grouping key — so suppressing it (which is correct for a complete
26
+ * path, whose last node is the target) renders two distinct clusters
27
+ * byte-identically. Show it, with a marker for the hops beyond.
28
+ */
29
+ export declare function renderClusterChain(steps: TraceStep[]): string;
30
+ export declare function selectPopulation(snapshot: IHeapSnapshot, sel: {
31
+ nodeIds?: number[];
32
+ className?: string;
33
+ shape?: string[];
34
+ }): IHeapNode[];
35
+ export declare function clusterByRetainerPath(nodes: IHeapNode[], frameworkFilter: boolean, maxTrace: number, maxDepth?: number): {
36
+ clusters: TraceCluster[];
37
+ traced: number;
38
+ noPath: number;
39
+ truncated: boolean;
40
+ };
41
+ export declare function registerTraceAll(server: McpServer): void;
42
+ //# sourceMappingURL=trace-all.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace-all.d.ts","sourceRoot":"","sources":["../../src/tools/trace-all.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG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