@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,277 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
7
+ if (value !== null && value !== void 0) {
8
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
9
+ var dispose, inner;
10
+ if (async) {
11
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
12
+ dispose = value[Symbol.asyncDispose];
13
+ }
14
+ if (dispose === void 0) {
15
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
16
+ dispose = value[Symbol.dispose];
17
+ if (async) inner = dispose;
18
+ }
19
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
20
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
21
+ env.stack.push({ value: value, dispose: dispose, async: async });
22
+ }
23
+ else if (async) {
24
+ env.stack.push({ async: true });
25
+ }
26
+ return value;
27
+ };
28
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
29
+ return function (env) {
30
+ function fail(e) {
31
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
32
+ env.hasError = true;
33
+ }
34
+ var r, s = 0;
35
+ function next() {
36
+ while (r = env.stack.pop()) {
37
+ try {
38
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
39
+ if (r.dispose) {
40
+ var result = r.dispose.call(r.value);
41
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
42
+ }
43
+ else s |= 1;
44
+ }
45
+ catch (e) {
46
+ fail(e);
47
+ }
48
+ }
49
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
50
+ if (env.hasError) throw env.error;
51
+ }
52
+ return next();
53
+ };
54
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
55
+ var e = new Error(message);
56
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
57
+ });
58
+ import { zod } from '../third_party/index.js';
59
+ import { ToolCategory } from './categories.js';
60
+ import { definePageTool } from './ToolDefinition.js';
61
+ async function getSourceBox(page, element, fullPage) {
62
+ if (element) {
63
+ const viewport = page.viewport();
64
+ const [box, devicePixelRatio] = await Promise.all([
65
+ element.boundingBox(),
66
+ viewport
67
+ ? (viewport.deviceScaleFactor ?? 1)
68
+ : page.evaluate(() => window.devicePixelRatio),
69
+ ]);
70
+ return box ? { ...box, devicePixelRatio } : undefined;
71
+ }
72
+ if (fullPage) {
73
+ const dims = await page.evaluate(() => ({
74
+ width: Math.max(document.documentElement.scrollWidth, document.body?.scrollWidth ?? 0),
75
+ height: Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight ?? 0),
76
+ devicePixelRatio: window.devicePixelRatio,
77
+ }));
78
+ if (dims.width <= 0 || dims.height <= 0) {
79
+ return undefined;
80
+ }
81
+ return {
82
+ x: 0,
83
+ y: 0,
84
+ width: dims.width,
85
+ height: dims.height,
86
+ devicePixelRatio: dims.devicePixelRatio,
87
+ };
88
+ }
89
+ const viewport = page.viewport();
90
+ if (viewport) {
91
+ return {
92
+ x: 0,
93
+ y: 0,
94
+ width: viewport.width,
95
+ height: viewport.height,
96
+ devicePixelRatio: viewport.deviceScaleFactor ?? 1,
97
+ };
98
+ }
99
+ // The browser is launched and connected with `defaultViewport: null`, so
100
+ // `page.viewport()` stays null until something emulates one. Fall back to the
101
+ // window's own dimensions, which is the area a viewport screenshot captures.
102
+ const dims = await page.evaluate(() => ({
103
+ width: window.innerWidth,
104
+ height: window.innerHeight,
105
+ devicePixelRatio: window.devicePixelRatio,
106
+ }));
107
+ if (dims.width <= 0 || dims.height <= 0) {
108
+ return undefined;
109
+ }
110
+ return {
111
+ x: 0,
112
+ y: 0,
113
+ width: dims.width,
114
+ height: dims.height,
115
+ devicePixelRatio: dims.devicePixelRatio,
116
+ };
117
+ }
118
+ function computeDownscaleClip(box, maxWidth, maxHeight) {
119
+ const widthScale = maxWidth !== undefined
120
+ ? Math.min(1, maxWidth / (box.width * box.devicePixelRatio))
121
+ : 1;
122
+ const heightScale = maxHeight !== undefined
123
+ ? Math.min(1, maxHeight / (box.height * box.devicePixelRatio))
124
+ : 1;
125
+ const scale = Math.min(widthScale, heightScale);
126
+ if (scale >= 1) {
127
+ return undefined;
128
+ }
129
+ // Skip degenerate sub-pixel results.
130
+ if (Math.round(box.width * box.devicePixelRatio * scale) < 1 ||
131
+ Math.round(box.height * box.devicePixelRatio * scale) < 1) {
132
+ return undefined;
133
+ }
134
+ return {
135
+ x: box.x,
136
+ y: box.y,
137
+ width: box.width,
138
+ height: box.height,
139
+ scale,
140
+ };
141
+ }
142
+ export const screenshot = definePageTool((args) => {
143
+ const { screenshotFormat, screenshotQuality, screenshotMaxWidth, screenshotMaxHeight, } = args;
144
+ const defaultFormat = screenshotFormat ?? 'png';
145
+ return {
146
+ name: 'take_screenshot',
147
+ description: `Take a screenshot of the page or element.`,
148
+ annotations: {
149
+ category: ToolCategory.DEBUGGING,
150
+ // Not read-only due to filePath param.
151
+ readOnlyHint: false,
152
+ },
153
+ schema: {
154
+ format: zod
155
+ .enum(['png', 'jpeg', 'webp'])
156
+ .default(defaultFormat)
157
+ .describe(`Type of format to save the screenshot as. Default is "${defaultFormat}"`),
158
+ quality: zod
159
+ .number()
160
+ .min(0)
161
+ .max(100)
162
+ .optional()
163
+ .describe('Compression quality for JPEG and WebP formats (0-100). Higher values mean better quality but larger file sizes. Ignored for PNG format.'),
164
+ uid: zod
165
+ .string()
166
+ .optional()
167
+ .describe('The uid of an element on the page from the page content snapshot. If omitted, takes a page screenshot.'),
168
+ fullPage: zod
169
+ .boolean()
170
+ .optional()
171
+ .describe('If set to true takes a screenshot of the full page instead of the currently visible viewport. Incompatible with uid.'),
172
+ filePath: zod
173
+ .string()
174
+ .optional()
175
+ .describe('The absolute path, or a path relative to the current working directory, to save the screenshot to instead of attaching it to the response.'),
176
+ },
177
+ blockedByDialog: true,
178
+ verifyFilesSchema: {
179
+ filePath: true,
180
+ },
181
+ handler: async (request, response, context) => {
182
+ const env_1 = { stack: [], error: void 0, hasError: false };
183
+ try {
184
+ if (request.params.uid && request.params.fullPage) {
185
+ throw new Error('Providing both "uid" and "fullPage" is not allowed.');
186
+ }
187
+ const page = request.page.pptrPage;
188
+ const element = __addDisposableResource(env_1, request.params.uid
189
+ ? await request.page.getElementByUid(request.params.uid)
190
+ : undefined, false);
191
+ const format = request.params.format;
192
+ const quality = format === 'png'
193
+ ? undefined
194
+ : (request.params.quality ?? screenshotQuality);
195
+ const fullPage = request.params.fullPage ?? false;
196
+ // `getElementByUid` mints a fresh ElementHandle per call, so dispose it
197
+ // once the capture is done to avoid leaking a remote object for the life
198
+ // of the page's execution context.
199
+ let screenshot;
200
+ // Compute a downscale clip when --screenshot-max-width or
201
+ // --screenshot-max-height is set and the source exceeds either bound.
202
+ // The smaller scale factor wins so both bounds are respected while
203
+ // preserving aspect ratio.
204
+ let clip;
205
+ if (screenshotMaxWidth !== undefined ||
206
+ screenshotMaxHeight !== undefined) {
207
+ const box = await getSourceBox(page, element, fullPage);
208
+ if (box) {
209
+ clip = computeDownscaleClip(box, screenshotMaxWidth, screenshotMaxHeight);
210
+ }
211
+ }
212
+ if (clip) {
213
+ // page.screenshot with clip lets the CDP scale param downscale the
214
+ // capture for viewport, full-page and element shots alike. We rely on
215
+ // Puppeteer's default of captureBeyondViewport=true when a clip is
216
+ // present so element/full-page captures below the fold still work.
217
+ screenshot = await page.screenshot({
218
+ type: format,
219
+ quality,
220
+ optimizeForSpeed: true,
221
+ clip,
222
+ });
223
+ }
224
+ else if (element) {
225
+ screenshot = await element.screenshot({
226
+ type: format,
227
+ quality,
228
+ optimizeForSpeed: true,
229
+ });
230
+ }
231
+ else {
232
+ screenshot = await page.screenshot({
233
+ type: format,
234
+ fullPage,
235
+ quality,
236
+ optimizeForSpeed: true,
237
+ });
238
+ }
239
+ if (request.params.uid) {
240
+ response.appendResponseLine(`Took a screenshot of node with uid "${request.params.uid}".`);
241
+ }
242
+ else if (fullPage) {
243
+ response.appendResponseLine('Took a screenshot of the full current page.');
244
+ }
245
+ else {
246
+ response.appendResponseLine("Took a screenshot of the current page's viewport.");
247
+ }
248
+ // Narrow `format` at the point of use: in the factory form of
249
+ // definePageTool TS widens the Schema generic, which loses the literal
250
+ // union from zod.enum on request.params.format.
251
+ const extension = format === 'jpeg' ? '.jpeg' : format === 'webp' ? '.webp' : '.png';
252
+ if (request.params.filePath) {
253
+ const result = await context.saveFile(screenshot, request.params.filePath, extension);
254
+ response.appendResponseLine(`Saved screenshot to ${result.filename}.`);
255
+ }
256
+ else if (screenshot.length >= 2_000_000) {
257
+ const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot${extension}`);
258
+ response.appendResponseLine(`Saved screenshot to ${filepath}.`);
259
+ }
260
+ else {
261
+ response.attachImage({
262
+ mimeType: `image/${format}`,
263
+ data: Buffer.from(screenshot).toString('base64'),
264
+ });
265
+ }
266
+ }
267
+ catch (e_1) {
268
+ env_1.error = e_1;
269
+ env_1.hasError = true;
270
+ }
271
+ finally {
272
+ __disposeResources(env_1);
273
+ }
274
+ },
275
+ };
276
+ });
277
+ //# sourceMappingURL=screenshot.js.map
@@ -0,0 +1,232 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
7
+ if (value !== null && value !== void 0) {
8
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
9
+ var dispose, inner;
10
+ if (async) {
11
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
12
+ dispose = value[Symbol.asyncDispose];
13
+ }
14
+ if (dispose === void 0) {
15
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
16
+ dispose = value[Symbol.dispose];
17
+ if (async) inner = dispose;
18
+ }
19
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
20
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
21
+ env.stack.push({ value: value, dispose: dispose, async: async });
22
+ }
23
+ else if (async) {
24
+ env.stack.push({ async: true });
25
+ }
26
+ return value;
27
+ };
28
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
29
+ return function (env) {
30
+ function fail(e) {
31
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
32
+ env.hasError = true;
33
+ }
34
+ var r, s = 0;
35
+ function next() {
36
+ while (r = env.stack.pop()) {
37
+ try {
38
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
39
+ if (r.dispose) {
40
+ var result = r.dispose.call(r.value);
41
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
42
+ }
43
+ else s |= 1;
44
+ }
45
+ catch (e) {
46
+ fail(e);
47
+ }
48
+ }
49
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
50
+ if (env.hasError) throw env.error;
51
+ }
52
+ return next();
53
+ };
54
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
55
+ var e = new Error(message);
56
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
57
+ });
58
+ import { zod } from '../third_party/index.js';
59
+ import { ToolCategory } from './categories.js';
60
+ import { defineTool, pageIdSchema } from './ToolDefinition.js';
61
+ export const evaluateScript = defineTool((cliArgs) => {
62
+ return {
63
+ name: 'evaluate_script',
64
+ description: `Evaluate a JavaScript function inside the target page${cliArgs.categoryExtensions ? ' or service worker' : ''}. Returns the response as JSON, so returned values have to be JSON-serializable.`,
65
+ annotations: {
66
+ category: ToolCategory.DEBUGGING,
67
+ readOnlyHint: false,
68
+ conditions: ['javascriptEvaluation'],
69
+ },
70
+ schema: {
71
+ ...(cliArgs.pageIdRouting
72
+ ? cliArgs.categoryExtensions
73
+ ? {
74
+ pageId: zod
75
+ .number()
76
+ .optional()
77
+ .describe('Targets a specific page by ID. Required when not evaluating in a service worker.'),
78
+ }
79
+ : pageIdSchema
80
+ : {}),
81
+ function: zod.string().describe(`A JavaScript function declaration to be executed by the tool in the target page.
82
+ Example without arguments: \`() => document.title\` or \`async () => await fetch("example.com")\`.
83
+ Example with arguments: \`(el) => el.innerText\`
84
+ `),
85
+ args: zod
86
+ .array(zod
87
+ .string()
88
+ .describe('The uid of an element on the page from the page content snapshot'))
89
+ .optional()
90
+ .describe(`An optional list of arguments to pass to the function.`),
91
+ filePath: zod
92
+ .string()
93
+ .optional()
94
+ .describe('The absolute or relative path to a file to save the script output to. If omitted, the output is returned inline.'),
95
+ dialogAction: zod
96
+ .string()
97
+ .optional()
98
+ .describe('Handle dialogs while execution. "accept", "dismiss", or string for response of window.prompt. Defaults to accept.'),
99
+ waitForStableDom: zod
100
+ .boolean()
101
+ .optional()
102
+ .describe('Whether to wait for the DOM to settle. Pass false if the script only reads data. Defaults to true.'),
103
+ ...(cliArgs.categoryExtensions
104
+ ? {
105
+ serviceWorkerId: zod
106
+ .string()
107
+ .optional()
108
+ .describe(`The optional service worker id to evaluate the script in. If provided, 'pageId' should be omitted. Note: 'args' (element UIDs) cannot be used when evaluating in a service worker.`),
109
+ }
110
+ : {}),
111
+ },
112
+ blockedByDialog: true,
113
+ verifyFilesSchema: {
114
+ filePath: true,
115
+ },
116
+ handler: async (request, response, context) => {
117
+ const env_1 = { stack: [], error: void 0, hasError: false };
118
+ try {
119
+ const { serviceWorkerId, args: uidArgs, function: fnString, pageId, dialogAction, filePath, waitForStableDom, } = request.params;
120
+ if (cliArgs.categoryExtensions && serviceWorkerId) {
121
+ if (uidArgs && uidArgs.length > 0) {
122
+ throw new Error('args (element uids) cannot be used when evaluating in a service worker.');
123
+ }
124
+ if (pageId) {
125
+ throw new Error('specify either a pageId or a serviceWorkerId.');
126
+ }
127
+ const worker = await getWebWorker(context, serviceWorkerId);
128
+ const result = await context
129
+ .getSelectedMcpPage()
130
+ .waitForEventsAfterAction(async () => {
131
+ await performEvaluation(worker, fnString, [], response, {
132
+ filePath,
133
+ context,
134
+ });
135
+ },
136
+ // Service workers cannot interact with the DOM, so never wait for it.
137
+ { handleDialog: dialogAction ?? 'accept', waitForStableDom: false });
138
+ if (result.dialogHandled) {
139
+ context.getSelectedMcpPage().clearDialog();
140
+ }
141
+ response.attachWaitForResult(result);
142
+ return;
143
+ }
144
+ if (cliArgs.categoryExtensions && cliArgs.pageIdRouting && !pageId) {
145
+ throw new Error('specify either a pageId or a serviceWorkerId.');
146
+ }
147
+ const mcpPage = cliArgs.pageIdRouting && request.params.pageId
148
+ ? context.getPageById(request.params.pageId)
149
+ : context.getSelectedMcpPage();
150
+ const page = mcpPage.pptrPage;
151
+ const args = [];
152
+ const stack = __addDisposableResource(env_1, new DisposableStack(), false);
153
+ const frames = new Set();
154
+ for (const uid of uidArgs ?? []) {
155
+ const handle = await mcpPage.getElementByUid(uid);
156
+ frames.add(handle.frame);
157
+ stack.use(handle);
158
+ args.push(handle);
159
+ }
160
+ const evaluatable = await getPageOrFrame(page, frames);
161
+ const result = await mcpPage.waitForEventsAfterAction(async () => {
162
+ await performEvaluation(evaluatable, fnString, args, response, {
163
+ filePath,
164
+ context,
165
+ });
166
+ }, { handleDialog: dialogAction ?? 'accept', waitForStableDom });
167
+ response.attachWaitForResult(result);
168
+ }
169
+ catch (e_1) {
170
+ env_1.error = e_1;
171
+ env_1.hasError = true;
172
+ }
173
+ finally {
174
+ __disposeResources(env_1);
175
+ }
176
+ },
177
+ };
178
+ });
179
+ const performEvaluation = async (evaluatable, fnString, args, response, options) => {
180
+ const env_2 = { stack: [], error: void 0, hasError: false };
181
+ try {
182
+ const fn = __addDisposableResource(env_2, await evaluatable.evaluateHandle(`(${fnString})`), false);
183
+ const result = await evaluatable.evaluate(async (fn, ...args) => {
184
+ // @ts-expect-error no types for function fn
185
+ return JSON.stringify(await fn(...args));
186
+ }, fn, ...args);
187
+ if (options?.filePath) {
188
+ const data = new TextEncoder().encode(result ?? 'undefined');
189
+ const { filename } = await options.context.saveFile(data, options.filePath, '.json');
190
+ response.appendResponseLine(`Script ran on page. Output saved to ${filename}.`);
191
+ }
192
+ else {
193
+ response.appendResponseLine('Script ran on page and returned:');
194
+ response.appendResponseLine('```json');
195
+ response.appendResponseLine(`${result}`);
196
+ response.appendResponseLine('```');
197
+ }
198
+ }
199
+ catch (e_2) {
200
+ env_2.error = e_2;
201
+ env_2.hasError = true;
202
+ }
203
+ finally {
204
+ __disposeResources(env_2);
205
+ }
206
+ };
207
+ const getPageOrFrame = async (page, frames) => {
208
+ let pageOrFrame;
209
+ // We can't evaluate the element handle across frames
210
+ if (frames.size > 1) {
211
+ throw new Error("Elements from different frames can't be evaluated together.");
212
+ }
213
+ else {
214
+ pageOrFrame = [...frames.values()][0] ?? page;
215
+ }
216
+ return pageOrFrame;
217
+ };
218
+ const getWebWorker = async (context, serviceWorkerId) => {
219
+ const serviceWorkers = context.getExtensionServiceWorkers();
220
+ const serviceWorker = serviceWorkers.find((sw) => context.getExtensionServiceWorkerId(sw) === serviceWorkerId);
221
+ if (serviceWorker && serviceWorker.target) {
222
+ const worker = await serviceWorker.target.worker();
223
+ if (!worker) {
224
+ throw new Error('Service worker target not found.');
225
+ }
226
+ return worker;
227
+ }
228
+ else {
229
+ throw new Error('Service worker not found.');
230
+ }
231
+ };
232
+ //# sourceMappingURL=script.js.map
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { zod } from '../../third_party/index.js';
7
+ import { ToolCategory } from '../categories.js';
8
+ import { definePageTool } from '../ToolDefinition.js';
9
+ import { validateUrl } from '../../utils/url.js';
10
+ export const screenshot = definePageTool(() => ({
11
+ name: 'screenshot',
12
+ description: `Takes a screenshot`,
13
+ annotations: {
14
+ category: ToolCategory.DEBUGGING,
15
+ // Not read-only due to filePath param.
16
+ readOnlyHint: false,
17
+ },
18
+ schema: {},
19
+ blockedByDialog: true,
20
+ verifyFilesSchema: {},
21
+ handler: async (request, response, context) => {
22
+ const page = request.page;
23
+ const screenshot = await page.pptrPage.screenshot({
24
+ type: 'png',
25
+ optimizeForSpeed: true,
26
+ });
27
+ const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot.png`);
28
+ response.appendResponseLine(filepath);
29
+ },
30
+ }));
31
+ export const navigate = definePageTool((args) => {
32
+ return {
33
+ name: 'navigate',
34
+ description: `Loads a URL`,
35
+ annotations: {
36
+ category: ToolCategory.NAVIGATION,
37
+ readOnlyHint: false,
38
+ },
39
+ schema: {
40
+ url: zod.string().describe('URL to navigate to'),
41
+ },
42
+ blockedByDialog: false,
43
+ verifyFilesSchema: {},
44
+ handler: async (request, response) => {
45
+ validateUrl(request.params.url, {
46
+ javascriptEvaluation: args?.javascriptEvaluation,
47
+ categoryExtensions: args?.categoryExtensions,
48
+ });
49
+ const page = request.page;
50
+ const options = {
51
+ timeout: 30_000,
52
+ };
53
+ const dialogHandler = (dialog) => {
54
+ if (dialog.type() === 'beforeunload') {
55
+ response.appendResponseLine(`Accepted a beforeunload dialog.`);
56
+ void dialog.accept();
57
+ // We are not going to report the dialog like regular dialogs.
58
+ page.clearDialog();
59
+ }
60
+ };
61
+ page.pptrPage.on('dialog', dialogHandler);
62
+ try {
63
+ await page.pptrPage.goto(request.params.url, options);
64
+ response.appendResponseLine(`Navigated to ${page.pptrPage.url()}.`);
65
+ }
66
+ finally {
67
+ page.pptrPage.off('dialog', dialogHandler);
68
+ }
69
+ },
70
+ };
71
+ });
72
+ export const evaluate = definePageTool(() => ({
73
+ name: 'evaluate',
74
+ description: `Evaluates a JavaScript script`,
75
+ annotations: {
76
+ category: ToolCategory.DEBUGGING,
77
+ readOnlyHint: false,
78
+ conditions: ['javascriptEvaluation'],
79
+ },
80
+ schema: {
81
+ script: zod.string().describe(`JS script to run on the page`),
82
+ },
83
+ blockedByDialog: true,
84
+ verifyFilesSchema: {},
85
+ handler: async (request, response) => {
86
+ const page = request.page;
87
+ try {
88
+ const result = await page.pptrPage.evaluate(request.params.script);
89
+ response.appendResponseLine(JSON.stringify(result));
90
+ }
91
+ catch (err) {
92
+ response.appendResponseLine(String(err.message));
93
+ }
94
+ },
95
+ }));
96
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { zod } from '../third_party/index.js';
7
+ import { ToolCategory } from './categories.js';
8
+ import { definePageTool, timeoutSchema } from './ToolDefinition.js';
9
+ export const takeSnapshot = definePageTool(() => ({
10
+ name: 'take_snapshot',
11
+ description: `Take a text snapshot of the target page based on the a11y tree. The snapshot lists page elements along with a unique
12
+ identifier (uid). Always use the latest snapshot. Prefer taking a snapshot over taking a screenshot. The snapshot indicates the element selected
13
+ in the DevTools Elements panel (if any).`,
14
+ annotations: {
15
+ category: ToolCategory.DEBUGGING,
16
+ // Not read-only due to filePath param.
17
+ readOnlyHint: false,
18
+ },
19
+ schema: {
20
+ verbose: zod
21
+ .boolean()
22
+ .optional()
23
+ .describe('Whether to include all possible information available in the full a11y tree. Default is false.'),
24
+ filePath: zod
25
+ .string()
26
+ .optional()
27
+ .describe('The absolute path, or a path relative to the current working directory, to save the snapshot to instead of attaching it to the response.'),
28
+ },
29
+ blockedByDialog: true,
30
+ verifyFilesSchema: {
31
+ filePath: true,
32
+ },
33
+ handler: async (request, response) => {
34
+ response.includeSnapshot({
35
+ verbose: request.params.verbose ?? false,
36
+ filePath: request.params.filePath,
37
+ });
38
+ },
39
+ }));
40
+ export const waitFor = definePageTool(() => ({
41
+ name: 'wait_for',
42
+ description: `Wait for the specified text to appear on the selected page.`,
43
+ annotations: {
44
+ category: ToolCategory.NAVIGATION,
45
+ readOnlyHint: true,
46
+ },
47
+ schema: {
48
+ text: zod
49
+ .array(zod.string())
50
+ .min(1)
51
+ .describe('Non-empty list of texts. Resolves when any value appears on the page.'),
52
+ ...timeoutSchema,
53
+ },
54
+ blockedByDialog: true,
55
+ verifyFilesSchema: {},
56
+ handler: async (request, response) => {
57
+ const page = request.page;
58
+ await page.waitForTextOnPage(request.params.text, request.params.timeout);
59
+ response.appendResponseLine(`Element matching one of ${JSON.stringify(request.params.text)} found.`);
60
+ response.includeSnapshot();
61
+ },
62
+ }));
63
+ //# sourceMappingURL=snapshot.js.map