@yezack/chrome-devtools-mcp-108 0.0.0-stage → 1.10.2

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 (360) hide show
  1. package/FORK-NOTICE.md +45 -0
  2. package/LICENSE +202 -0
  3. package/README.md +45 -2
  4. package/build/src/BrowserManager.js +401 -0
  5. package/build/src/McpContext.js +642 -0
  6. package/build/src/McpPage.js +850 -0
  7. package/build/src/McpResponse.js +1086 -0
  8. package/build/src/SlimMcpResponse.js +19 -0
  9. package/build/src/TextSnapshot.js +315 -0
  10. package/build/src/ToolHandler.js +322 -0
  11. package/build/src/bin/check-latest-version.js +51 -0
  12. package/build/src/bin/chrome-devtools-mcp-main.js +77 -0
  13. package/build/src/bin/chrome-devtools-mcp.js +23 -0
  14. package/build/src/bin/chrome-devtools.js +222 -0
  15. package/build/src/collectors/PageCollector.js +291 -0
  16. package/build/src/collectors/ServiceWorkerCollector.js +171 -0
  17. package/build/src/config/browser-options.js +125 -0
  18. package/build/src/config/category-options.js +89 -0
  19. package/build/src/config/cli-commands.js +26 -0
  20. package/build/src/config/cli-options.js +1473 -0
  21. package/build/src/config/mcp-options.js +417 -0
  22. package/build/src/daemon/client.js +221 -0
  23. package/build/src/daemon/daemon.js +266 -0
  24. package/build/src/daemon/types.js +7 -0
  25. package/build/src/daemon/utils.js +136 -0
  26. package/build/src/devtools/DevToolsCommentBridge.js +91 -0
  27. package/build/src/devtools/DevtoolsUtils.js +307 -0
  28. package/build/src/devtools/McpHostBindingAdapter.js +165 -0
  29. package/build/src/devtools/issueDescriptions.js +42 -0
  30. package/build/src/formatters/CommentFormatter.js +82 -0
  31. package/build/src/formatters/ConsoleFormatter.js +321 -0
  32. package/build/src/formatters/CssFormatter.js +812 -0
  33. package/build/src/formatters/HeapSnapshotFormatter.js +185 -0
  34. package/build/src/formatters/IssueFormatter.js +193 -0
  35. package/build/src/formatters/NetworkFormatter.js +241 -0
  36. package/build/src/formatters/SnapshotFormatter.js +135 -0
  37. package/build/src/index.js +237 -0
  38. package/build/src/processors/ChunkedTraceParser.js +361 -0
  39. package/build/src/processors/HeapSnapshotManager.js +270 -0
  40. package/build/src/processors/PerformanceTrace.js +132 -0
  41. package/build/src/telemetry/ClearcutLogger.js +242 -0
  42. package/build/src/telemetry/WatchdogClient.js +61 -0
  43. package/build/src/telemetry/errors.js +18 -0
  44. package/build/src/telemetry/flagUtils.js +90 -0
  45. package/build/src/telemetry/metricsRegistry.js +85 -0
  46. package/build/src/telemetry/persistence.js +82 -0
  47. package/build/src/telemetry/transformation.js +233 -0
  48. package/build/src/telemetry/types.js +36 -0
  49. package/build/src/telemetry/watchdog/ClearcutSender.js +205 -0
  50. package/build/src/telemetry/watchdog/main.js +128 -0
  51. package/build/src/third_party/THIRD_PARTY_NOTICES +4077 -0
  52. package/build/src/third_party/bundled-packages.json +12 -0
  53. package/build/src/third_party/devtools-formatter-worker.js +15494 -0
  54. package/build/src/third_party/devtools-heap-snapshot-worker.js +10979 -0
  55. package/build/src/third_party/index.js +200978 -0
  56. package/build/src/third_party/issue-descriptions/CoepCoopSandboxedIframeCannotNavigateToCoopPage.md +4 -0
  57. package/build/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +8 -0
  58. package/build/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +18 -0
  59. package/build/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +7 -0
  60. package/build/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +10 -0
  61. package/build/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +5 -0
  62. package/build/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +5 -0
  63. package/build/src/third_party/issue-descriptions/LowTextContrast.md +5 -0
  64. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorRead.md +8 -0
  65. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +8 -0
  66. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +8 -0
  67. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +8 -0
  68. package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +9 -0
  69. package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +9 -0
  70. package/build/src/third_party/issue-descriptions/bounceTrackingMitigations.md +3 -0
  71. package/build/src/third_party/issue-descriptions/clientHintMetaTagAllowListInvalidOrigin.md +4 -0
  72. package/build/src/third_party/issue-descriptions/clientHintMetaTagModifiedHTML.md +4 -0
  73. package/build/src/third_party/issue-descriptions/connectionAllowlistEmbeddingRequirementNotSatisfied.md +26 -0
  74. package/build/src/third_party/issue-descriptions/connectionAllowlistIFrameAttributeLoosensEmbeddingRequirement.md +19 -0
  75. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowConnectionAllowlistFrom.md +21 -0
  76. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +12 -0
  77. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +12 -0
  78. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +8 -0
  79. package/build/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +12 -0
  80. package/build/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +7 -0
  81. package/build/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +10 -0
  82. package/build/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +12 -0
  83. package/build/src/third_party/issue-descriptions/cookieExcludeDomainNonAscii.md +11 -0
  84. package/build/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +8 -0
  85. package/build/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +7 -0
  86. package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutRead.md +6 -0
  87. package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +6 -0
  88. package/build/src/third_party/issue-descriptions/cookieWarnDomainNonAscii.md +11 -0
  89. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +4 -0
  90. package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +4 -0
  91. package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +6 -0
  92. package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutSet.md +6 -0
  93. package/build/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +6 -0
  94. package/build/src/third_party/issue-descriptions/corsDisabledScheme.md +7 -0
  95. package/build/src/third_party/issue-descriptions/corsDisallowedByMode.md +7 -0
  96. package/build/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +5 -0
  97. package/build/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +7 -0
  98. package/build/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +19 -0
  99. package/build/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +5 -0
  100. package/build/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +5 -0
  101. package/build/src/third_party/issue-descriptions/corsOriginMismatch.md +6 -0
  102. package/build/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +5 -0
  103. package/build/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +5 -0
  104. package/build/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +9 -0
  105. package/build/src/third_party/issue-descriptions/cspEvalViolation.md +9 -0
  106. package/build/src/third_party/issue-descriptions/cspInlineViolation.md +10 -0
  107. package/build/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +5 -0
  108. package/build/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +8 -0
  109. package/build/src/third_party/issue-descriptions/cspURLViolation.md +10 -0
  110. package/build/src/third_party/issue-descriptions/deprecation.md +3 -0
  111. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsEmptyList.md +1 -0
  112. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsHttpNotFound.md +1 -0
  113. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidContentType.md +1 -0
  114. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidResponse.md +1 -0
  115. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsNoResponse.md +1 -0
  116. package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsFetchFailed.md +1 -0
  117. package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -0
  118. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownHttpNotFound.md +1 -0
  119. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidContentType.md +1 -0
  120. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidResponse.md +1 -0
  121. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownNoResponse.md +1 -0
  122. package/build/src/third_party/issue-descriptions/emailVerificationRequestInvalidEmail.md +1 -0
  123. package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksHttpNotFound.md +1 -0
  124. package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksInvalidResponse.md +1 -0
  125. package/build/src/third_party/issue-descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -0
  126. package/build/src/third_party/issue-descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -0
  127. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -0
  128. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -0
  129. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -0
  130. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -0
  131. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -0
  132. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenNoResponse.md +1 -0
  133. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidAudience.md +1 -0
  134. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidIssuedAt.md +1 -0
  135. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidNonce.md +1 -0
  136. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidSdHash.md +1 -0
  137. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidTyp.md +1 -0
  138. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingAud.md +1 -0
  139. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingCnf.md +1 -0
  140. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingIat.md +1 -0
  141. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingNonce.md +1 -0
  142. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingSdHash.md +1 -0
  143. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbSignatureFailed.md +1 -0
  144. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmail.md +1 -0
  145. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmailVerified.md +1 -0
  146. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidHolderKey.md +1 -0
  147. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuedAt.md +1 -0
  148. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuer.md +1 -0
  149. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtJwksMissingKeys.md +1 -0
  150. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingCnf.md +1 -0
  151. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingEmail.md +1 -0
  152. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIat.md +1 -0
  153. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIss.md +1 -0
  154. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtSignatureFailed.md +1 -0
  155. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtUnsupportedHeaderAlg.md +1 -0
  156. package/build/src/third_party/issue-descriptions/emailVerificationRequestUserLoggedOut.md +1 -0
  157. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -0
  158. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -0
  159. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -0
  160. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -0
  161. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -0
  162. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -0
  163. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -0
  164. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -0
  165. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -0
  166. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -0
  167. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsBlockedByConnectionAllowlist.md +1 -0
  168. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +1 -0
  169. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +1 -0
  170. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +1 -0
  171. package/build/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +1 -0
  172. package/build/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +1 -0
  173. package/build/src/third_party/issue-descriptions/federatedAuthRequestConfigBlockedByConnectionAllowlist.md +1 -0
  174. package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +1 -0
  175. package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +1 -0
  176. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenBlockedByConnectionAllowlist.md +1 -0
  177. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +1 -0
  178. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +1 -0
  179. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +1 -0
  180. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +1 -0
  181. package/build/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +1 -0
  182. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -0
  183. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -0
  184. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +1 -0
  185. package/build/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +1 -0
  186. package/build/src/third_party/issue-descriptions/federatedAuthRequestWellKnownBlockedByConnectionAllowlist.md +1 -0
  187. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +1 -0
  188. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +1 -0
  189. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +1 -0
  190. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +1 -0
  191. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +1 -0
  192. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +1 -0
  193. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +1 -0
  194. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +1 -0
  195. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +1 -0
  196. package/build/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +7 -0
  197. package/build/src/third_party/issue-descriptions/genericBackUINavigationWouldSkipAd.md +4 -0
  198. package/build/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +8 -0
  199. package/build/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +5 -0
  200. package/build/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +5 -0
  201. package/build/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +5 -0
  202. package/build/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +5 -0
  203. package/build/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +5 -0
  204. package/build/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +5 -0
  205. package/build/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +5 -0
  206. package/build/src/third_party/issue-descriptions/genericFormLabelForNameError.md +5 -0
  207. package/build/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +5 -0
  208. package/build/src/third_party/issue-descriptions/genericFormModelContextMissingToolDescription.md +5 -0
  209. package/build/src/third_party/issue-descriptions/genericFormModelContextMissingToolName.md +5 -0
  210. package/build/src/third_party/issue-descriptions/genericFormModelContextParameterMissingName.md +5 -0
  211. package/build/src/third_party/issue-descriptions/genericFormModelContextParameterMissingTitleAndDescription.md +5 -0
  212. package/build/src/third_party/issue-descriptions/genericFormModelContextRequiredParameterMissingName.md +5 -0
  213. package/build/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +7 -0
  214. package/build/src/third_party/issue-descriptions/genericResponseWasBlockedByORB.md +4 -0
  215. package/build/src/third_party/issue-descriptions/heavyAd.md +10 -0
  216. package/build/src/third_party/issue-descriptions/lazyLoadImageZeroSize.md +7 -0
  217. package/build/src/third_party/issue-descriptions/mixedContent.md +5 -0
  218. package/build/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +5 -0
  219. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +7 -0
  220. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +9 -0
  221. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +9 -0
  222. package/build/src/third_party/issue-descriptions/permissionElementCspFrameAncestorsMissing.md +5 -0
  223. package/build/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +5 -0
  224. package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +5 -0
  225. package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +5 -0
  226. package/build/src/third_party/issue-descriptions/permissionElementGeolocationDeprecated.md +5 -0
  227. package/build/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +5 -0
  228. package/build/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +5 -0
  229. package/build/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +5 -0
  230. package/build/src/third_party/issue-descriptions/permissionElementInvalidType.md +5 -0
  231. package/build/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +5 -0
  232. package/build/src/third_party/issue-descriptions/permissionElementLowContrast.md +5 -0
  233. package/build/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +5 -0
  234. package/build/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +6 -0
  235. package/build/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +6 -0
  236. package/build/src/third_party/issue-descriptions/permissionElementPermissionsPolicyBlocked.md +5 -0
  237. package/build/src/third_party/issue-descriptions/permissionElementRegistrationFailed.md +5 -0
  238. package/build/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +5 -0
  239. package/build/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +5 -0
  240. package/build/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +5 -0
  241. package/build/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +7 -0
  242. package/build/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +3 -0
  243. package/build/src/third_party/issue-descriptions/propertyRuleInvalidNameIssue.md +3 -0
  244. package/build/src/third_party/issue-descriptions/propertyRuleIssue.md +7 -0
  245. package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +7 -0
  246. package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +7 -0
  247. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +3 -0
  248. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +3 -0
  249. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +3 -0
  250. package/build/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +3 -0
  251. package/build/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +7 -0
  252. package/build/src/third_party/issue-descriptions/sharedArrayBuffer.md +7 -0
  253. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -0
  254. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorDictionaryLoadFailure.md +3 -0
  255. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +3 -0
  256. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +1 -0
  257. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +1 -0
  258. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +1 -0
  259. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +3 -0
  260. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +3 -0
  261. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInsufficientResources.md +1 -0
  262. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidMatchField.md +1 -0
  263. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +1 -0
  264. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidTTLField.md +1 -0
  265. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +3 -0
  266. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNoMatchField.md +1 -0
  267. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonIntegerTTLField.md +1 -0
  268. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonListMatchDestField.md +1 -0
  269. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonSecureContext.md +3 -0
  270. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringIdField.md +1 -0
  271. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringInMatchDestList.md +1 -0
  272. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringMatchField.md +1 -0
  273. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonTokenTypeField.md +1 -0
  274. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorRequestAborted.md +1 -0
  275. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorShuttingDown.md +1 -0
  276. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorTooLongIdField.md +3 -0
  277. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorUnsupportedType.md +3 -0
  278. package/build/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +14 -0
  279. package/build/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +15 -0
  280. package/build/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +8 -0
  281. package/build/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +7 -0
  282. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +11 -0
  283. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +14 -0
  284. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +15 -0
  285. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +8 -0
  286. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +13 -0
  287. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +4 -0
  288. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +5 -0
  289. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +11 -0
  290. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +12 -0
  291. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +6 -0
  292. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +8 -0
  293. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +11 -0
  294. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +11 -0
  295. package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +10 -0
  296. package/build/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +5 -0
  297. package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +6 -0
  298. package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +11 -0
  299. package/build/src/third_party/issue-descriptions/stylesheetLateImport.md +4 -0
  300. package/build/src/third_party/issue-descriptions/stylesheetRequestFailed.md +3 -0
  301. package/build/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +3 -0
  302. package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +12 -0
  303. package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +17 -0
  304. package/build/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +14 -0
  305. package/build/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +15 -0
  306. package/build/src/third_party/issue-descriptions/webInstallManifestMissingId.md +3 -0
  307. package/build/src/third_party/issue-descriptions/webInstallManifestMissingNameOrShortName.md +3 -0
  308. package/build/src/third_party/issue-descriptions/webInstallManifestParsingOrNetworkError.md +3 -0
  309. package/build/src/third_party/issue-descriptions/webInstallNoManifest.md +3 -0
  310. package/build/src/third_party/issue-descriptions/webInstallStartUrlInvalid.md +3 -0
  311. package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +58435 -0
  312. package/build/src/tools/ToolDefinition.js +80 -0
  313. package/build/src/tools/categories.js +33 -0
  314. package/build/src/tools/comments.js +169 -0
  315. package/build/src/tools/console.js +104 -0
  316. package/build/src/tools/css.js +45 -0
  317. package/build/src/tools/emulation.js +84 -0
  318. package/build/src/tools/extensions.js +103 -0
  319. package/build/src/tools/input.js +652 -0
  320. package/build/src/tools/lighthouse.js +149 -0
  321. package/build/src/tools/memory.js +424 -0
  322. package/build/src/tools/network.js +128 -0
  323. package/build/src/tools/pages.js +363 -0
  324. package/build/src/tools/performance.js +212 -0
  325. package/build/src/tools/pwa.js +128 -0
  326. package/build/src/tools/screencast.js +119 -0
  327. package/build/src/tools/screenshot.js +277 -0
  328. package/build/src/tools/script.js +232 -0
  329. package/build/src/tools/slim/tools.js +96 -0
  330. package/build/src/tools/snapshot.js +63 -0
  331. package/build/src/tools/thirdPartyDeveloper.js +85 -0
  332. package/build/src/tools/tools.js +55 -0
  333. package/build/src/tools/webmcp.js +66 -0
  334. package/build/src/types.js +10 -0
  335. package/build/src/utils/WaitForHelper.js +316 -0
  336. package/build/src/utils/bytes.js +105 -0
  337. package/build/src/utils/check-for-updates.js +75 -0
  338. package/build/src/utils/files.js +57 -0
  339. package/build/src/utils/id.js +16 -0
  340. package/build/src/utils/keyboard.js +297 -0
  341. package/build/src/utils/logger.js +52 -0
  342. package/build/src/utils/pagination.js +50 -0
  343. package/build/src/utils/polyfill.js +11 -0
  344. package/build/src/utils/url.js +116 -0
  345. package/build/src/version.js +10 -0
  346. package/package.json +41 -4
  347. package/skills/a11y-debugging/SKILL.md +91 -0
  348. package/skills/a11y-debugging/references/a11y-snippets.md +92 -0
  349. package/skills/chrome-devtools/SKILL.md +74 -0
  350. package/skills/chrome-devtools-cli/SKILL.md +194 -0
  351. package/skills/chrome-devtools-cli/references/installation.md +14 -0
  352. package/skills/cookie-debugging/SKILL.md +149 -0
  353. package/skills/debug-optimize-lcp/SKILL.md +121 -0
  354. package/skills/debug-optimize-lcp/references/elements-and-size.md +27 -0
  355. package/skills/debug-optimize-lcp/references/lcp-breakdown.md +23 -0
  356. package/skills/debug-optimize-lcp/references/lcp-snippets.md +79 -0
  357. package/skills/debug-optimize-lcp/references/optimization-strategies.md +38 -0
  358. package/skills/memory-leak-debugging/SKILL.md +58 -0
  359. package/skills/memory-leak-debugging/references/common-leaks.md +33 -0
  360. package/skills/troubleshooting/SKILL.md +99 -0
@@ -0,0 +1,1086 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { CommentFormatter, } from './formatters/CommentFormatter.js';
7
+ import { ConsoleFormatter } from './formatters/ConsoleFormatter.js';
8
+ import { CssFormatter, resolveContainerQueries, } from './formatters/CssFormatter.js';
9
+ import { HeapSnapshotFormatter, isEdgeLike, isNodeLike, } from './formatters/HeapSnapshotFormatter.js';
10
+ import { IssueFormatter } from './formatters/IssueFormatter.js';
11
+ import { NetworkFormatter } from './formatters/NetworkFormatter.js';
12
+ import { SnapshotFormatter } from './formatters/SnapshotFormatter.js';
13
+ import { UncaughtError } from './collectors/PageCollector.js';
14
+ import { TextSnapshot } from './TextSnapshot.js';
15
+ import { DevTools, getToonEncode, getGcfEncode } from './third_party/index.js';
16
+ import { handleDialog, listPages } from './tools/pages.js';
17
+ import { getInsightOutput, getTraceSummary, } from './processors/PerformanceTrace.js';
18
+ import { stableIdSymbol } from './utils/id.js';
19
+ import { paginate } from './utils/pagination.js';
20
+ const { formatBytesToKb } = DevTools.I18n.ByteUtilities;
21
+ export class McpResponse {
22
+ #includePages = false;
23
+ #includeExtensionServiceWorkers = false;
24
+ #includeExtensionPages = false;
25
+ #snapshotParams;
26
+ #attachedNetworkRequestId;
27
+ #attachedNetworkRequestOptions;
28
+ #attachedConsoleMessageId;
29
+ #attachedTraceSummary;
30
+ #attachedTraceInsight;
31
+ #attachedLighthouseResult;
32
+ #textResponseLines = [];
33
+ #images = [];
34
+ #heapSnapshotOptions;
35
+ #networkRequestsOptions;
36
+ #consoleDataOptions;
37
+ #cssStylesData;
38
+ #listExtensions;
39
+ #listThirdPartyDeveloperTools;
40
+ #listWebMcpTools;
41
+ #devToolsData;
42
+ #tabId;
43
+ #args;
44
+ #page;
45
+ #redactNetworkHeaders = true;
46
+ #error;
47
+ #attachedWaitForResult;
48
+ #reconnectNotice = false;
49
+ #devToolsComments;
50
+ get #deviceScope() {
51
+ return this.#page?.viewport?.isMobile ? 'PHONE' : 'DESKTOP';
52
+ }
53
+ constructor(args) {
54
+ this.#args = args;
55
+ }
56
+ setPage(page) {
57
+ this.#page = page;
58
+ }
59
+ setRedactNetworkHeaders(value) {
60
+ this.#redactNetworkHeaders = value;
61
+ }
62
+ /**
63
+ * Surfaces a one-time note that the browser reconnected and page ids changed.
64
+ * Set by the tool handler when the context reports a pending reconnect notice.
65
+ */
66
+ setReconnectNotice() {
67
+ this.#reconnectNotice = true;
68
+ }
69
+ attachDevToolsData(data) {
70
+ this.#devToolsData = data;
71
+ }
72
+ setTabId(tabId) {
73
+ this.#tabId = tabId;
74
+ }
75
+ setIncludePages(value) {
76
+ this.#includePages = value;
77
+ if (this.#args.categoryExtensions) {
78
+ this.#includeExtensionServiceWorkers = value;
79
+ this.#includeExtensionPages = value;
80
+ }
81
+ }
82
+ includeSnapshot(params) {
83
+ this.#snapshotParams = params ?? {
84
+ verbose: false,
85
+ };
86
+ }
87
+ setListExtensions() {
88
+ this.#listExtensions = true;
89
+ }
90
+ setListThirdPartyDeveloperTools() {
91
+ this.#listThirdPartyDeveloperTools = true;
92
+ }
93
+ setListWebMcpTools() {
94
+ this.#listWebMcpTools = true;
95
+ }
96
+ setIncludeNetworkRequests(value, options) {
97
+ if (!value) {
98
+ this.#networkRequestsOptions = undefined;
99
+ return;
100
+ }
101
+ this.#networkRequestsOptions = {
102
+ include: value,
103
+ pagination: options?.pageSize !== undefined || options?.pageIdx !== undefined
104
+ ? {
105
+ pageSize: options.pageSize,
106
+ pageIdx: options.pageIdx,
107
+ }
108
+ : undefined,
109
+ resourceTypes: options?.resourceTypes,
110
+ includePreservedRequests: options?.includePreservedRequests,
111
+ networkRequestIdInDevToolsUI: options?.networkRequestIdInDevToolsUI,
112
+ };
113
+ }
114
+ setIncludeConsoleData(value, options) {
115
+ if (!value) {
116
+ this.#consoleDataOptions = undefined;
117
+ return;
118
+ }
119
+ this.#consoleDataOptions = {
120
+ include: value,
121
+ pagination: options?.pageSize !== undefined || options?.pageIdx !== undefined
122
+ ? {
123
+ pageSize: options.pageSize,
124
+ pageIdx: options.pageIdx,
125
+ }
126
+ : undefined,
127
+ types: options?.types,
128
+ includePreservedMessages: options?.includePreservedMessages,
129
+ includeStackTraces: options?.includeStackTraces,
130
+ serviceWorkerId: options?.serviceWorkerId,
131
+ };
132
+ }
133
+ setIncludeCssStyles(matchedStyles, options) {
134
+ this.#cssStylesData = {
135
+ matchedStyles,
136
+ options,
137
+ };
138
+ }
139
+ setError(error) {
140
+ this.#error = error;
141
+ }
142
+ attachNetworkRequest(reqId, options) {
143
+ this.#attachedNetworkRequestId = reqId;
144
+ this.#attachedNetworkRequestOptions = options;
145
+ }
146
+ attachConsoleMessage(msgid) {
147
+ this.#attachedConsoleMessageId = msgid;
148
+ }
149
+ attachTraceSummary(result) {
150
+ this.#attachedTraceSummary = result;
151
+ }
152
+ attachTraceInsight(trace, insightSetId, insightName) {
153
+ this.#attachedTraceInsight = {
154
+ trace,
155
+ insightSetId,
156
+ insightName,
157
+ };
158
+ }
159
+ attachLighthouseResult(result) {
160
+ this.#attachedLighthouseResult = result;
161
+ }
162
+ get includePages() {
163
+ return this.#includePages;
164
+ }
165
+ get attachedTraceSummary() {
166
+ return this.#attachedTraceSummary;
167
+ }
168
+ get attachedTracedInsight() {
169
+ return this.#attachedTraceInsight;
170
+ }
171
+ get attachedLighthouseResult() {
172
+ return this.#attachedLighthouseResult;
173
+ }
174
+ get includeNetworkRequests() {
175
+ return this.#networkRequestsOptions?.include ?? false;
176
+ }
177
+ get includeConsoleData() {
178
+ return this.#consoleDataOptions?.include ?? false;
179
+ }
180
+ get attachedNetworkRequestId() {
181
+ return this.#attachedNetworkRequestId;
182
+ }
183
+ get networkRequestsPageIdx() {
184
+ return this.#networkRequestsOptions?.pagination?.pageIdx;
185
+ }
186
+ get consoleMessagesPageIdx() {
187
+ return this.#consoleDataOptions?.pagination?.pageIdx;
188
+ }
189
+ get consoleMessagesTypes() {
190
+ return this.#consoleDataOptions?.types;
191
+ }
192
+ get error() {
193
+ return this.#error;
194
+ }
195
+ appendResponseLine(value) {
196
+ this.#textResponseLines.push(value);
197
+ }
198
+ attachWaitForResult(result) {
199
+ this.#attachedWaitForResult = result;
200
+ }
201
+ setDevToolsComments(threads) {
202
+ this.#devToolsComments = threads;
203
+ }
204
+ get devToolsComments() {
205
+ return this.#devToolsComments;
206
+ }
207
+ setHeapSnapshotAggregates(aggregateData, options) {
208
+ this.#heapSnapshotOptions = {
209
+ ...this.#heapSnapshotOptions,
210
+ include: true,
211
+ aggregateData,
212
+ pagination: options,
213
+ };
214
+ }
215
+ setHeapSnapshotStats(stats, staticData, nativeContextSizes, retainedByContextSummary) {
216
+ this.#heapSnapshotOptions = {
217
+ ...this.#heapSnapshotOptions,
218
+ include: true,
219
+ stats,
220
+ staticData,
221
+ nativeContextSizes,
222
+ retainedByContextSummary,
223
+ };
224
+ }
225
+ setHeapSnapshotNodes(nodes, options) {
226
+ this.#heapSnapshotOptions = {
227
+ ...this.#heapSnapshotOptions,
228
+ include: true,
229
+ nodes,
230
+ pagination: options,
231
+ };
232
+ }
233
+ setHeapSnapshotDuplicateStrings(duplicateStrings, options) {
234
+ this.#heapSnapshotOptions = {
235
+ ...this.#heapSnapshotOptions,
236
+ include: true,
237
+ duplicateStrings,
238
+ pagination: options,
239
+ };
240
+ }
241
+ setHeapSnapshotRetainingPaths(retainingPaths) {
242
+ this.#heapSnapshotOptions = {
243
+ ...this.#heapSnapshotOptions,
244
+ include: true,
245
+ retainingPaths,
246
+ };
247
+ }
248
+ setHeapSnapshotDominators(dominators) {
249
+ this.#heapSnapshotOptions = {
250
+ ...this.#heapSnapshotOptions,
251
+ include: true,
252
+ dominators,
253
+ };
254
+ }
255
+ setHeapSnapshotClassDiffs(classDiffs) {
256
+ this.#heapSnapshotOptions = {
257
+ ...this.#heapSnapshotOptions,
258
+ include: true,
259
+ classDiffs,
260
+ };
261
+ }
262
+ setHeapSnapshotDetailedClassDiff(detailedClassDiff) {
263
+ this.#heapSnapshotOptions = {
264
+ ...this.#heapSnapshotOptions,
265
+ include: true,
266
+ detailedClassDiff,
267
+ };
268
+ }
269
+ setHeapSnapshotObjectDetails(objectInfo) {
270
+ this.#heapSnapshotOptions = {
271
+ ...this.#heapSnapshotOptions,
272
+ include: true,
273
+ objectInfo,
274
+ };
275
+ }
276
+ attachImage(value) {
277
+ this.#images.push(value);
278
+ }
279
+ get responseLines() {
280
+ return this.#textResponseLines;
281
+ }
282
+ get images() {
283
+ return this.#images;
284
+ }
285
+ get snapshotParams() {
286
+ return this.#snapshotParams;
287
+ }
288
+ get listWebMcpTools() {
289
+ return this.#listWebMcpTools;
290
+ }
291
+ async #handleSnapshot(context) {
292
+ if (this.#includePages) {
293
+ await context.createPagesSnapshot();
294
+ }
295
+ if (!this.#snapshotParams) {
296
+ return undefined;
297
+ }
298
+ if (!this.#page) {
299
+ throw new Error('Response must have a page');
300
+ }
301
+ this.#page.textSnapshot = await TextSnapshot.create(this.#page, {
302
+ verbose: this.#snapshotParams.verbose,
303
+ devtoolsData: this.#devToolsData,
304
+ });
305
+ const formatter = new SnapshotFormatter(this.#page.textSnapshot);
306
+ if (this.#snapshotParams.filePath) {
307
+ const result = await context.saveFile(new TextEncoder().encode(formatter.toString()), this.#snapshotParams.filePath, '.txt');
308
+ return result.filename;
309
+ }
310
+ else {
311
+ return formatter;
312
+ }
313
+ }
314
+ async #handleAttachedNetworkRequest(context) {
315
+ if (!this.#attachedNetworkRequestId) {
316
+ return undefined;
317
+ }
318
+ if (!this.#page) {
319
+ throw new Error(`Response must have an McpPage`);
320
+ }
321
+ const request = this.#page.getNetworkRequestById(this.#attachedNetworkRequestId);
322
+ return await NetworkFormatter.from(request, {
323
+ requestId: this.#attachedNetworkRequestId,
324
+ requestIdResolver: req => this.getNetworkRequestStableId(req),
325
+ fetchData: true,
326
+ requestFilePath: this.#attachedNetworkRequestOptions?.requestFilePath,
327
+ responseFilePath: this.#attachedNetworkRequestOptions?.responseFilePath,
328
+ saveFile: (data, filename, extension) => context.saveFile(data, filename, extension),
329
+ redactNetworkHeaders: this.#redactNetworkHeaders,
330
+ });
331
+ }
332
+ async #handleAttachedConsoleMessage() {
333
+ if (!this.#attachedConsoleMessageId) {
334
+ return undefined;
335
+ }
336
+ if (!this.#page) {
337
+ throw new Error(`Response must have an McpPage`);
338
+ }
339
+ const message = this.#page.getConsoleMessageById(this.#attachedConsoleMessageId);
340
+ const consoleMessageStableId = this.#attachedConsoleMessageId;
341
+ if ('args' in message || message instanceof UncaughtError) {
342
+ const consoleMessage = message;
343
+ return await ConsoleFormatter.from(consoleMessage, {
344
+ id: consoleMessageStableId,
345
+ fetchDetailedData: true,
346
+ devTools: this.#page.devtoolsUniverse,
347
+ });
348
+ }
349
+ else if (message instanceof DevTools.AggregatedIssue) {
350
+ const formatter = new IssueFormatter(message, {
351
+ id: consoleMessageStableId,
352
+ requestIdResolver: this.#page.resolveCdpRequestId.bind(this.#page),
353
+ elementIdResolver: this.#page.textSnapshot?.resolveCdpElementId.bind(this.#page.textSnapshot),
354
+ });
355
+ if (!formatter.isValid()) {
356
+ throw new Error("Can't provide details for the msgid " + consoleMessageStableId);
357
+ }
358
+ return formatter;
359
+ }
360
+ else {
361
+ return undefined;
362
+ }
363
+ }
364
+ async #handleThirdPartyDevelopeTools() {
365
+ if (this.#args.categoryExperimentalThirdParty &&
366
+ this.#listThirdPartyDeveloperTools &&
367
+ this.#page) {
368
+ return await this.#page.getToolGroups();
369
+ }
370
+ return undefined;
371
+ }
372
+ async #handleWebMCP() {
373
+ if (this.#args.categoryExperimentalWebmcp &&
374
+ this.#listWebMcpTools &&
375
+ this.#page) {
376
+ return this.#page.getWebMcpTools();
377
+ }
378
+ return undefined;
379
+ }
380
+ async #handleConsoleList(context) {
381
+ if (!this.#consoleDataOptions?.include) {
382
+ return undefined;
383
+ }
384
+ let messages;
385
+ let page;
386
+ if (this.#consoleDataOptions.serviceWorkerId) {
387
+ messages = context.getServiceWorkerConsoleData(this.#consoleDataOptions.serviceWorkerId);
388
+ }
389
+ else {
390
+ page = this.#page;
391
+ if (!page) {
392
+ throw new Error(`Response must have an McpPage`);
393
+ }
394
+ messages = page.getConsoleData(this.#consoleDataOptions.includePreservedMessages);
395
+ }
396
+ if (this.#consoleDataOptions.types?.length) {
397
+ const normalizedTypes = new Set(this.#consoleDataOptions.types);
398
+ messages = messages.filter(message => {
399
+ if ('type' in message) {
400
+ return normalizedTypes.has(message.type());
401
+ }
402
+ if (message instanceof DevTools.AggregatedIssue) {
403
+ return normalizedTypes.has('issue');
404
+ }
405
+ return normalizedTypes.has('error');
406
+ });
407
+ }
408
+ return (await Promise.all(messages.map(async (item) => {
409
+ const consoleMessageStableId = this.getConsoleMessageStableId(item);
410
+ if ('args' in item || item instanceof UncaughtError) {
411
+ const consoleMessage = item;
412
+ return await ConsoleFormatter.from(consoleMessage, {
413
+ id: consoleMessageStableId,
414
+ fetchDetailedData: false,
415
+ fetchStackTrace: this.#consoleDataOptions?.includeStackTraces,
416
+ devTools: page ? page.devtoolsUniverse : undefined,
417
+ });
418
+ }
419
+ if (item instanceof DevTools.AggregatedIssue) {
420
+ const formatter = new IssueFormatter(item, {
421
+ id: consoleMessageStableId,
422
+ });
423
+ if (!formatter.isValid()) {
424
+ return null;
425
+ }
426
+ return formatter;
427
+ }
428
+ return null;
429
+ }))).filter(item => item !== null);
430
+ }
431
+ async #handleNetworkRequestList(context) {
432
+ if (!this.#networkRequestsOptions?.include) {
433
+ return undefined;
434
+ }
435
+ if (!this.#page) {
436
+ throw new Error(`Response must have an McpPage`);
437
+ }
438
+ let requests = this.#page.getNetworkRequests(this.#networkRequestsOptions?.includePreservedRequests);
439
+ // Apply resource type filtering if specified
440
+ if (this.#networkRequestsOptions.resourceTypes?.length) {
441
+ const normalizedTypes = new Set(this.#networkRequestsOptions.resourceTypes);
442
+ requests = requests.filter(request => {
443
+ const type = request.resourceType();
444
+ return normalizedTypes.has(type);
445
+ });
446
+ }
447
+ return await Promise.all(requests.map(request => NetworkFormatter.from(request, {
448
+ requestId: this.getNetworkRequestStableId(request),
449
+ selectedInDevToolsUI: this.getNetworkRequestStableId(request) ===
450
+ this.#networkRequestsOptions?.networkRequestIdInDevToolsUI,
451
+ fetchData: false,
452
+ saveFile: (data, filename, extension) => context.saveFile(data, filename, extension),
453
+ redactNetworkHeaders: this.#redactNetworkHeaders,
454
+ })));
455
+ }
456
+ async #handleComments() {
457
+ const comments = this.#devToolsComments;
458
+ if (!comments) {
459
+ return undefined;
460
+ }
461
+ const page = this.#page;
462
+ return await CommentFormatter.from(comments, {
463
+ resolveBackendNodeId: page
464
+ ? (id) => page.resolveBackendNodeId(id)
465
+ : undefined,
466
+ resolveCdpRequestId: page
467
+ ? (id) => page.resolveCdpRequestId(id)
468
+ : undefined,
469
+ });
470
+ }
471
+ async handle(context, dataFormat = 'default') {
472
+ const [snapshot, detailedNetworkRequest, detailedConsoleMessage, thirdPartyDeveloperTools, webmcpTools, consoleMessages, networkRequests, comments,] = await Promise.all([
473
+ this.#handleSnapshot(context),
474
+ this.#handleAttachedNetworkRequest(context),
475
+ this.#handleAttachedConsoleMessage(),
476
+ this.#handleThirdPartyDevelopeTools(),
477
+ this.#handleWebMCP(),
478
+ this.#handleConsoleList(context),
479
+ this.#handleNetworkRequestList(context),
480
+ this.#handleComments(),
481
+ ]);
482
+ if (this.#includeExtensionServiceWorkers) {
483
+ await context.createExtensionServiceWorkersSnapshot();
484
+ }
485
+ let extensions;
486
+ if (this.#listExtensions) {
487
+ extensions = await context.listExtensions();
488
+ }
489
+ return this.format(context, {
490
+ detailedConsoleMessage,
491
+ consoleMessages,
492
+ snapshot,
493
+ detailedNetworkRequest,
494
+ networkRequests,
495
+ traceInsight: this.#attachedTraceInsight,
496
+ traceSummary: this.#attachedTraceSummary,
497
+ extensions,
498
+ lighthouseResult: this.#attachedLighthouseResult,
499
+ thirdPartyDeveloperTools,
500
+ webmcpTools,
501
+ comments,
502
+ errorMessage: this.#error?.message,
503
+ }, dataFormat);
504
+ }
505
+ getConsoleMessageStableId(message) {
506
+ return message[stableIdSymbol] ?? -1;
507
+ }
508
+ getNetworkRequestStableId(request) {
509
+ return request[stableIdSymbol] ?? -1;
510
+ }
511
+ async format(context, data, dataFormat = 'default') {
512
+ const structuredContent = {};
513
+ // Resolve the compact encoder based on the chosen format
514
+ let compactEncode;
515
+ if (dataFormat === 'toon') {
516
+ try {
517
+ compactEncode = await getToonEncode();
518
+ }
519
+ catch {
520
+ throw new Error('The `@toon-format/toon` package is required to use --experimentalDataFormat=toon. ' +
521
+ 'Make sure the peer dependency is installed:\n' +
522
+ '- For npx: npx --package chrome-devtools-mcp@latest --package @toon-format/toon@latest chrome-devtools-mcp --experimentalDataFormat=toon\n' +
523
+ '- For npm: npm install @toon-format/toon (add -g if installed globally)');
524
+ }
525
+ }
526
+ else if (dataFormat === 'gcf') {
527
+ try {
528
+ compactEncode = await getGcfEncode();
529
+ }
530
+ catch {
531
+ throw new Error('The `@blackwell-systems/gcf` package is required to use --experimentalDataFormat=gcf. ' +
532
+ 'Make sure the peer dependency is installed:\n' +
533
+ '- For npx: npx --package chrome-devtools-mcp@latest --package @blackwell-systems/gcf@latest chrome-devtools-mcp --experimentalDataFormat=gcf\n' +
534
+ '- For npm: npm install @blackwell-systems/gcf (add -g if installed globally)');
535
+ }
536
+ }
537
+ const response = [];
538
+ if (this.#reconnectNotice) {
539
+ structuredContent.reconnected = true;
540
+ response.push(`Note: the browser was restarted or reconnected since the last call. Page ids have changed. Call ${listPages(this.#args).name} to see open pages.`);
541
+ }
542
+ if (this.#textResponseLines.length) {
543
+ structuredContent.message = this.#textResponseLines.join('\n');
544
+ response.push(...this.#textResponseLines);
545
+ }
546
+ if (this.#attachedWaitForResult) {
547
+ if (this.#attachedWaitForResult.navigatedToUrl) {
548
+ response.push(`Page navigated to ${this.#attachedWaitForResult.navigatedToUrl}.`);
549
+ structuredContent.navigatedToUrl =
550
+ this.#attachedWaitForResult.navigatedToUrl;
551
+ }
552
+ }
553
+ const networkConditions = this.#page?.networkConditions;
554
+ if (networkConditions) {
555
+ const timeout = this.#page.pptrPage.getDefaultNavigationTimeout();
556
+ response.push(`Emulating network conditions: ${networkConditions}`);
557
+ response.push(`Default navigation timeout set to ${timeout} ms`);
558
+ structuredContent.networkConditions = networkConditions;
559
+ structuredContent.navigationTimeout = timeout;
560
+ }
561
+ const geolocation = this.#page?.geolocation;
562
+ if (geolocation) {
563
+ response.push(`Emulating geolocation: latitude=${geolocation.latitude}, longitude=${geolocation.longitude}`);
564
+ structuredContent.geolocation = geolocation;
565
+ }
566
+ const viewport = this.#page?.viewport;
567
+ if (viewport) {
568
+ response.push(`Emulating viewport: ${JSON.stringify(viewport)}`);
569
+ structuredContent.viewport = viewport;
570
+ }
571
+ const userAgent = this.#page?.userAgent;
572
+ if (userAgent) {
573
+ response.push(`Emulating user agent: ${userAgent}`);
574
+ structuredContent.userAgent = userAgent;
575
+ }
576
+ const cpuThrottlingRate = this.#page?.cpuThrottlingRate ?? 1;
577
+ if (cpuThrottlingRate > 1) {
578
+ response.push(`Emulating CPU throttling: ${cpuThrottlingRate}x slowdown`);
579
+ structuredContent.cpuThrottlingRate = cpuThrottlingRate;
580
+ }
581
+ const colorScheme = this.#page?.colorScheme;
582
+ if (colorScheme) {
583
+ response.push(`Emulating color scheme: ${colorScheme}`);
584
+ structuredContent.colorScheme = colorScheme;
585
+ }
586
+ const dialog = this.#page?.getDialog();
587
+ if (dialog) {
588
+ const defaultValueIfNeeded = dialog.type() === 'prompt'
589
+ ? ` (default value: "${dialog.defaultValue()}")`
590
+ : '';
591
+ response.push(`# Open dialog
592
+ ${dialog.type()}: ${dialog.message()}${defaultValueIfNeeded}.
593
+ Call ${handleDialog(this.#args).name} to handle it before continuing.`);
594
+ structuredContent.dialog = {
595
+ type: dialog.type(),
596
+ message: dialog.message(),
597
+ defaultValue: dialog.defaultValue(),
598
+ };
599
+ }
600
+ if (this.#includePages) {
601
+ const allPages = context.getPages();
602
+ const { regularPages, extensionPages } = allPages.reduce((acc, mcpPage) => {
603
+ if (mcpPage.pptrPage.url().startsWith('chrome-extension://')) {
604
+ acc.extensionPages.push(mcpPage);
605
+ }
606
+ else {
607
+ acc.regularPages.push(mcpPage);
608
+ }
609
+ return acc;
610
+ }, { regularPages: [], extensionPages: [] });
611
+ const selectionFallback = context.getSelectedPageFallback();
612
+ if (selectionFallback) {
613
+ let selectedPageId;
614
+ try {
615
+ selectedPageId = context.getSelectedMcpPage().id;
616
+ }
617
+ catch {
618
+ selectedPageId = undefined;
619
+ }
620
+ response.push(`Note: the previously selected page ${selectionFallback.wasClosed ? 'was closed' : 'is no longer listed'}.${selectedPageId !== undefined ? ` Page ${selectedPageId} is now selected.` : ''}`);
621
+ }
622
+ if (regularPages.length) {
623
+ const parts = [`## Pages`];
624
+ const structuredPages = [];
625
+ for (const mcpPage of regularPages) {
626
+ const isolatedContextName = mcpPage.isolatedContextName;
627
+ const contextLabel = isolatedContextName
628
+ ? ` isolatedContext=${isolatedContextName}`
629
+ : '';
630
+ const title = await fetchPageTitle(mcpPage.pptrPage);
631
+ const pageLabel = title
632
+ ? `${truncateTitle(title)} (${mcpPage.pptrPage.url()})`
633
+ : mcpPage.pptrPage.url();
634
+ parts.push(`${mcpPage.id}: ${pageLabel}${context.isPageSelected(mcpPage) ? ' [selected]' : ''}${contextLabel}`);
635
+ structuredPages.push(createStructuredPage(mcpPage, context, title));
636
+ }
637
+ response.push(...parts);
638
+ structuredContent.pages = structuredPages;
639
+ }
640
+ if (this.#includeExtensionPages) {
641
+ if (extensionPages.length) {
642
+ response.push(`## Extension Pages`);
643
+ const structuredExtensionPages = [];
644
+ for (const mcpPage of extensionPages) {
645
+ const isolatedContextName = mcpPage.isolatedContextName;
646
+ const contextLabel = isolatedContextName
647
+ ? ` isolatedContext=${isolatedContextName}`
648
+ : '';
649
+ const title = await fetchPageTitle(mcpPage.pptrPage);
650
+ const pageLabel = title
651
+ ? `${truncateTitle(title)} (${mcpPage.pptrPage.url()})`
652
+ : mcpPage.pptrPage.url();
653
+ response.push(`${mcpPage.id}: ${pageLabel}${context.isPageSelected(mcpPage) ? ' [selected]' : ''}${contextLabel}`);
654
+ structuredExtensionPages.push(createStructuredPage(mcpPage, context, title));
655
+ }
656
+ structuredContent.extensionPages = structuredExtensionPages;
657
+ }
658
+ }
659
+ }
660
+ if (this.#includeExtensionServiceWorkers) {
661
+ if (context.getExtensionServiceWorkers().length) {
662
+ response.push(`## Extension Service Workers`);
663
+ }
664
+ for (const extensionServiceWorker of context.getExtensionServiceWorkers()) {
665
+ response.push(`${extensionServiceWorker.id}: ${extensionServiceWorker.url}`);
666
+ }
667
+ structuredContent.extensionServiceWorkers = context
668
+ .getExtensionServiceWorkers()
669
+ .map(extensionServiceWorker => {
670
+ return {
671
+ id: extensionServiceWorker.id,
672
+ url: extensionServiceWorker.url,
673
+ };
674
+ });
675
+ }
676
+ if (this.#tabId) {
677
+ structuredContent.tabId = this.#tabId;
678
+ }
679
+ if (data.traceSummary) {
680
+ const summary = getTraceSummary(data.traceSummary, this.#deviceScope);
681
+ response.push(summary);
682
+ structuredContent.traceSummary = summary;
683
+ structuredContent.traceInsights = [];
684
+ for (const insightSet of data.traceSummary.insights?.values() ?? []) {
685
+ for (const [insightName, model] of Object.entries(insightSet.model)) {
686
+ structuredContent.traceInsights.push({
687
+ insightName,
688
+ insightKey: typeof model === 'object' &&
689
+ model !== null &&
690
+ 'insightKey' in model
691
+ ? model.insightKey
692
+ : undefined,
693
+ });
694
+ }
695
+ }
696
+ }
697
+ if (data.traceInsight) {
698
+ const insightOutput = getInsightOutput(data.traceInsight.trace, data.traceInsight.insightSetId, data.traceInsight.insightName, this.#deviceScope);
699
+ if ('error' in insightOutput) {
700
+ response.push(insightOutput.error);
701
+ }
702
+ else {
703
+ response.push(insightOutput.output);
704
+ }
705
+ }
706
+ if (data.lighthouseResult) {
707
+ structuredContent.lighthouseResult = data.lighthouseResult;
708
+ const { summary, reports } = data.lighthouseResult;
709
+ response.push('## Lighthouse Audit Results');
710
+ response.push(`Mode: ${summary.mode}`);
711
+ response.push(`Device: ${summary.device}`);
712
+ response.push(`URL: ${summary.url}`);
713
+ response.push('### Category Scores');
714
+ for (const score of summary.scores) {
715
+ response.push(`- ${score.title}: ${(score.score ?? 0) * 100} (${score.id})`);
716
+ }
717
+ response.push('### Audit Summary');
718
+ response.push(`Passed: ${summary.audits.passed}`);
719
+ response.push(`Failed: ${summary.audits.failed}`);
720
+ response.push(`Total Timing: ${summary.timing.total}ms`);
721
+ response.push('### Reports');
722
+ for (const report of reports) {
723
+ response.push(`- ${report}`);
724
+ }
725
+ }
726
+ if (data.snapshot) {
727
+ if (typeof data.snapshot === 'string') {
728
+ response.push(`Saved snapshot to ${data.snapshot}.`);
729
+ structuredContent.snapshotFilePath = data.snapshot;
730
+ }
731
+ else {
732
+ structuredContent.snapshot = data.snapshot.toJSON();
733
+ response.push('## Latest page snapshot');
734
+ response.push(compactEncode
735
+ ? compactEncode(structuredContent.snapshot)
736
+ : data.snapshot.toString());
737
+ }
738
+ }
739
+ if (this.#heapSnapshotOptions?.include) {
740
+ response.push('## Heap Snapshot Data');
741
+ const stats = this.#heapSnapshotOptions.stats;
742
+ const staticData = this.#heapSnapshotOptions.staticData;
743
+ if (stats) {
744
+ response.push(`Statistics: ${JSON.stringify(stats, null, 2)}`);
745
+ structuredContent.heapSnapshot = structuredContent.heapSnapshot || {};
746
+ structuredContent.heapSnapshot.stats = stats;
747
+ }
748
+ if (staticData) {
749
+ response.push(`Static Data: ${JSON.stringify(staticData, null, 2)}`);
750
+ structuredContent.heapSnapshot = structuredContent.heapSnapshot || {};
751
+ structuredContent.heapSnapshot.staticData = staticData;
752
+ }
753
+ const nativeContextSizes = this.#heapSnapshotOptions.nativeContextSizes;
754
+ if (nativeContextSizes) {
755
+ response.push('### Native Contexts');
756
+ response.push(HeapSnapshotFormatter.formatNativeContextSizes(nativeContextSizes));
757
+ structuredContent.heapSnapshot = structuredContent.heapSnapshot || {};
758
+ structuredContent.heapSnapshot.nativeContextSizes = nativeContextSizes;
759
+ }
760
+ const retainedByContextSummary = this.#heapSnapshotOptions.retainedByContextSummary;
761
+ if (retainedByContextSummary) {
762
+ response.push('### Retained by Context Summary');
763
+ response.push(HeapSnapshotFormatter.formatRetainedByContextSummary(retainedByContextSummary));
764
+ structuredContent.heapSnapshot = structuredContent.heapSnapshot || {};
765
+ structuredContent.heapSnapshot.retainedByContextSummary =
766
+ retainedByContextSummary;
767
+ }
768
+ const aggregateData = this.#heapSnapshotOptions.aggregateData;
769
+ if (aggregateData) {
770
+ const sortedEntries = HeapSnapshotFormatter.sort(aggregateData.aggregates);
771
+ const paginationData = this.#dataWithPagination(sortedEntries, this.#heapSnapshotOptions.pagination);
772
+ response.push(`Objects: ${aggregateData.objectCount}`);
773
+ response.push(`Total shallow size: ${formatBytesToKb(aggregateData.totalSelfSize)}`);
774
+ structuredContent.heapSnapshot = structuredContent.heapSnapshot || {};
775
+ structuredContent.heapSnapshot.aggregateStats = {
776
+ objectCount: aggregateData.objectCount,
777
+ totalSelfSize: aggregateData.totalSelfSize,
778
+ };
779
+ structuredContent.pagination = paginationData.pagination;
780
+ response.push(...paginationData.info);
781
+ const paginatedRecord = Object.fromEntries(paginationData.items);
782
+ const formatter = new HeapSnapshotFormatter(paginatedRecord);
783
+ structuredContent.heapSnapshotData = formatter.toJSON();
784
+ response.push(compactEncode
785
+ ? compactEncode(structuredContent.heapSnapshotData)
786
+ : formatter.toString());
787
+ }
788
+ const nodes = this.#heapSnapshotOptions.nodes;
789
+ if (nodes) {
790
+ let items = Array.from(nodes.items);
791
+ const firstItem = nodes.items[0];
792
+ if (firstItem) {
793
+ if (isNodeLike(firstItem)) {
794
+ items = items
795
+ .filter(isNodeLike)
796
+ .sort((a, b) => b.retainedSize - a.retainedSize);
797
+ }
798
+ else if (isEdgeLike(firstItem)) {
799
+ items = items.filter(isEdgeLike);
800
+ }
801
+ }
802
+ const paginationData = this.#dataWithPagination(items, this.#heapSnapshotOptions.pagination);
803
+ response.push(HeapSnapshotFormatter.formatNodes(paginationData.items));
804
+ structuredContent.pagination = paginationData.pagination;
805
+ response.push(...paginationData.info);
806
+ structuredContent.heapSnapshotNodes = paginationData.items;
807
+ }
808
+ const retainingPaths = this.#heapSnapshotOptions.retainingPaths;
809
+ if (retainingPaths) {
810
+ response.push('### Retaining Paths');
811
+ const { paths, limitsReached } = retainingPaths;
812
+ if (paths.length === 0) {
813
+ response.push('No retaining paths found.');
814
+ }
815
+ else {
816
+ response.push(HeapSnapshotFormatter.formatRetainingPaths(paths));
817
+ }
818
+ const reached = Object.entries(limitsReached)
819
+ .filter(([, hit]) => hit)
820
+ .map(([limit]) => limit);
821
+ if (reached.length > 0) {
822
+ response.push(`Note: results are truncated, the following limits were reached: ${reached.join(', ')}.`);
823
+ }
824
+ structuredContent.heapSnapshotRetainingPaths =
825
+ retainingPaths;
826
+ }
827
+ const dominators = this.#heapSnapshotOptions.dominators;
828
+ if (dominators) {
829
+ response.push('### Dominator Chain');
830
+ if (dominators.length === 0) {
831
+ response.push('No dominators found.');
832
+ }
833
+ else {
834
+ response.push(HeapSnapshotFormatter.formatDominators(dominators));
835
+ }
836
+ structuredContent.heapSnapshotDominators = dominators;
837
+ }
838
+ const classDiffs = this.#heapSnapshotOptions.classDiffs;
839
+ if (classDiffs) {
840
+ response.push('### Heap Snapshot Diff');
841
+ response.push(compactEncode
842
+ ? compactEncode(classDiffs)
843
+ : HeapSnapshotFormatter.formatDiffSummary(classDiffs));
844
+ structuredContent.heapSnapshotClassDiffs = classDiffs;
845
+ }
846
+ const detailedClassDiff = this.#heapSnapshotOptions.detailedClassDiff;
847
+ if (detailedClassDiff) {
848
+ response.push('### Heap Snapshot Detailed Diff');
849
+ response.push(compactEncode
850
+ ? compactEncode(detailedClassDiff)
851
+ : HeapSnapshotFormatter.formatDiffDetails(detailedClassDiff));
852
+ structuredContent.heapSnapshotDetailedClassDiff = detailedClassDiff;
853
+ }
854
+ const duplicateStrings = this.#heapSnapshotOptions.duplicateStrings;
855
+ if (duplicateStrings) {
856
+ response.push('### Duplicate Strings');
857
+ const paginationData = this.#dataWithPagination(duplicateStrings, this.#heapSnapshotOptions.pagination);
858
+ structuredContent.pagination = paginationData.pagination;
859
+ response.push(...paginationData.info);
860
+ const formatted = HeapSnapshotFormatter.formatDuplicateStrings(paginationData.items);
861
+ response.push(formatted);
862
+ structuredContent.heapSnapshotDuplicateStrings = paginationData.items;
863
+ }
864
+ const objectInfo = this.#heapSnapshotOptions.objectInfo;
865
+ if (objectInfo) {
866
+ response.push('### Object Details');
867
+ response.push(compactEncode
868
+ ? compactEncode(objectInfo)
869
+ : HeapSnapshotFormatter.formatObjectInfo(objectInfo));
870
+ structuredContent.heapSnapshotObjectDetails = objectInfo;
871
+ }
872
+ }
873
+ if (data.detailedNetworkRequest) {
874
+ response.push(data.detailedNetworkRequest.toStringDetailed());
875
+ structuredContent.networkRequest =
876
+ data.detailedNetworkRequest.toJSONDetailed();
877
+ }
878
+ if (data.detailedConsoleMessage) {
879
+ response.push(data.detailedConsoleMessage.toStringDetailed());
880
+ structuredContent.consoleMessage =
881
+ data.detailedConsoleMessage.toJSONDetailed();
882
+ }
883
+ if (data.extensions) {
884
+ const extensionArray = Array.from(data.extensions.values());
885
+ structuredContent.extensions = extensionArray;
886
+ response.push('## Extensions');
887
+ if (extensionArray.length === 0) {
888
+ response.push('No extensions installed.');
889
+ }
890
+ else {
891
+ const extensionsMessage = extensionArray
892
+ .map(extension => {
893
+ return `id=${extension.id} "${extension.name}" v${extension.version} ${extension.enabled ? 'Enabled' : 'Disabled'}`;
894
+ })
895
+ .join('\n');
896
+ response.push(extensionsMessage);
897
+ }
898
+ }
899
+ const thirdPartyDeveloperTools = data.thirdPartyDeveloperTools;
900
+ if (thirdPartyDeveloperTools?.length) {
901
+ structuredContent.thirdPartyDeveloperTools = thirdPartyDeveloperTools;
902
+ response.push('## Third-party developer tools');
903
+ for (const toolGroup of thirdPartyDeveloperTools) {
904
+ response.push(`${toolGroup.name}: ${toolGroup.description}`);
905
+ response.push('Available tools:');
906
+ const toolDefinitionsMessage = toolGroup.tools
907
+ .map(tool => {
908
+ return `name="${tool.name}", description="${tool.description}", inputSchema=${JSON.stringify(tool.inputSchema)}`;
909
+ })
910
+ .join('\n');
911
+ response.push(toolDefinitionsMessage);
912
+ }
913
+ }
914
+ if (this.#listWebMcpTools && data.webmcpTools) {
915
+ structuredContent.webmcpTools = data.webmcpTools.map(({ name, description, inputSchema, annotations }) => ({
916
+ name,
917
+ description,
918
+ inputSchema,
919
+ annotations,
920
+ }));
921
+ response.push('## WebMCP tools');
922
+ if (data.webmcpTools.length === 0) {
923
+ response.push('No WebMCP tools available.');
924
+ }
925
+ else {
926
+ const webmcpToolsMessage = data.webmcpTools
927
+ .map(tool => {
928
+ return `name="${tool.name}", description="${tool.description}", inputSchema=${JSON.stringify(tool.inputSchema)}, annotations=${JSON.stringify(tool.annotations)}`;
929
+ })
930
+ .join('\n');
931
+ response.push(webmcpToolsMessage);
932
+ }
933
+ }
934
+ if (this.#networkRequestsOptions?.include && data.networkRequests) {
935
+ const requests = data.networkRequests;
936
+ response.push('## Network requests');
937
+ if (requests.length) {
938
+ const paginationData = this.#dataWithPagination(requests, this.#networkRequestsOptions.pagination);
939
+ structuredContent.pagination = paginationData.pagination;
940
+ response.push(...paginationData.info);
941
+ if (data.networkRequests) {
942
+ structuredContent.networkRequests = paginationData.items.map(i => i.toJSON());
943
+ response.push(...(compactEncode
944
+ ? [compactEncode(structuredContent.networkRequests)]
945
+ : paginationData.items.map(i => i.toString())));
946
+ }
947
+ }
948
+ else {
949
+ response.push('No requests found.');
950
+ }
951
+ }
952
+ if (this.#consoleDataOptions?.include) {
953
+ const messages = data.consoleMessages ?? [];
954
+ response.push('## Console messages');
955
+ if (messages.length) {
956
+ const grouped = ConsoleFormatter.groupConsecutive(messages);
957
+ const paginationData = this.#dataWithPagination(grouped, this.#consoleDataOptions.pagination);
958
+ structuredContent.pagination = paginationData.pagination;
959
+ structuredContent.consoleMessages = paginationData.items.map(item => item.toJSON());
960
+ response.push(...paginationData.info);
961
+ if (compactEncode) {
962
+ response.push(compactEncode(structuredContent.consoleMessages));
963
+ }
964
+ else {
965
+ response.push(...paginationData.items.map(item => item.toString()));
966
+ }
967
+ if (structuredContent.consoleMessages.some(message => 'stackTrace' in message)) {
968
+ response.push('Note: stack trace line and column numbers use 1-based indexing');
969
+ }
970
+ }
971
+ else {
972
+ response.push('<no console messages found>');
973
+ }
974
+ }
975
+ if (data.comments) {
976
+ const commentsJson = data.comments.toJSON();
977
+ structuredContent.comments = commentsJson;
978
+ response.push(compactEncode ? compactEncode(commentsJson) : data.comments.toString());
979
+ }
980
+ if (this.#cssStylesData) {
981
+ const resolveUid = (backendNodeId) => this.#page?.textSnapshot?.resolveCdpElementId(backendNodeId);
982
+ const containerDetails = await resolveContainerQueries(this.#cssStylesData.matchedStyles, resolveUid);
983
+ const options = {
984
+ ...this.#cssStylesData.options,
985
+ resolveUid,
986
+ containerDetails,
987
+ };
988
+ const allRules = CssFormatter.collectRules(this.#cssStylesData.matchedStyles, options);
989
+ let rules = allRules;
990
+ const hasPagination = this.#cssStylesData.options.pageSize !== undefined ||
991
+ this.#cssStylesData.options.pageIdx !== undefined;
992
+ if (hasPagination) {
993
+ const paginationData = this.#dataWithPagination(allRules, this.#cssStylesData.options);
994
+ structuredContent.pagination = paginationData.pagination;
995
+ response.push(...paginationData.info);
996
+ rules = paginationData.items;
997
+ }
998
+ const formatter = new CssFormatter(this.#cssStylesData.matchedStyles, options, rules);
999
+ structuredContent.matchedStyles = formatter.toJSON();
1000
+ if (compactEncode) {
1001
+ response.push(compactEncode(structuredContent.matchedStyles));
1002
+ }
1003
+ else {
1004
+ response.push(formatter.toString());
1005
+ }
1006
+ }
1007
+ if (data.errorMessage) {
1008
+ response.push(`Error: ${data.errorMessage}`);
1009
+ structuredContent.errorMessage = data.errorMessage;
1010
+ }
1011
+ const text = {
1012
+ type: 'text',
1013
+ text: response.join('\n'),
1014
+ };
1015
+ const images = this.#images.map(imageData => {
1016
+ return {
1017
+ type: 'image',
1018
+ ...imageData,
1019
+ };
1020
+ });
1021
+ return {
1022
+ content: [text, ...images],
1023
+ structuredContent,
1024
+ };
1025
+ }
1026
+ #dataWithPagination(data, pagination) {
1027
+ const response = [];
1028
+ const paginationResult = paginate(data, pagination);
1029
+ if (paginationResult.invalidPage) {
1030
+ response.push('Invalid page number provided. Showing first page.');
1031
+ }
1032
+ const { startIndex, endIndex, currentPage, totalPages } = paginationResult;
1033
+ response.push(`Showing ${startIndex + 1}-${endIndex} of ${data.length} (Page ${currentPage + 1} of ${totalPages}).`);
1034
+ if (pagination) {
1035
+ if (paginationResult.hasNextPage) {
1036
+ response.push(`Next page: ${currentPage + 1}`);
1037
+ }
1038
+ if (paginationResult.hasPreviousPage) {
1039
+ response.push(`Previous page: ${currentPage - 1}`);
1040
+ }
1041
+ }
1042
+ return {
1043
+ info: response,
1044
+ items: paginationResult.items,
1045
+ pagination: {
1046
+ currentPage: paginationResult.currentPage,
1047
+ totalPages: paginationResult.totalPages,
1048
+ hasNextPage: paginationResult.hasNextPage,
1049
+ hasPreviousPage: paginationResult.hasPreviousPage,
1050
+ startIndex: paginationResult.startIndex,
1051
+ endIndex: paginationResult.endIndex,
1052
+ invalidPage: paginationResult.invalidPage,
1053
+ },
1054
+ };
1055
+ }
1056
+ resetResponseLineForTesting() {
1057
+ this.#textResponseLines = [];
1058
+ }
1059
+ }
1060
+ function truncateTitle(title, maxLength = 50) {
1061
+ if (title.length <= maxLength) {
1062
+ return title;
1063
+ }
1064
+ return title.slice(0, maxLength - 3) + '...';
1065
+ }
1066
+ async function fetchPageTitle(page) {
1067
+ return Promise.race([
1068
+ page.title().catch(() => ''),
1069
+ new Promise(resolve => setTimeout(() => resolve(''), 1000)),
1070
+ ]);
1071
+ }
1072
+ function createStructuredPage(mcpPage, context, rawTitle) {
1073
+ const isolatedContextName = mcpPage.isolatedContextName;
1074
+ const title = truncateTitle(rawTitle);
1075
+ const entry = {
1076
+ id: mcpPage.id,
1077
+ url: mcpPage.pptrPage.url(),
1078
+ title,
1079
+ selected: context.isPageSelected(mcpPage),
1080
+ };
1081
+ if (isolatedContextName) {
1082
+ entry.isolatedContext = isolatedContextName;
1083
+ }
1084
+ return entry;
1085
+ }
1086
+ //# sourceMappingURL=McpResponse.js.map