chrome-devtools-mcp 1.6.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/README.md +73 -22
  2. package/build/src/McpContext.js +121 -44
  3. package/build/src/McpPage.js +230 -14
  4. package/build/src/McpResponse.js +209 -283
  5. package/build/src/SlimMcpResponse.js +1 -1
  6. package/build/src/TextSnapshot.js +80 -19
  7. package/build/src/ToolHandler.js +80 -15
  8. package/build/src/bin/chrome-devtools-mcp-main.js +3 -3
  9. package/build/src/bin/chrome-devtools.js +47 -32
  10. package/build/src/browser.js +3 -1
  11. package/build/src/{PageCollector.js → collectors/PageCollector.js} +15 -10
  12. package/build/src/{ServiceWorkerCollector.js → collectors/ServiceWorkerCollector.js} +1 -1
  13. package/build/src/{bin/chrome-devtools-cli-options.js → config/cli-options.js} +414 -23
  14. package/build/src/{bin/chrome-devtools-mcp-cli-options.js → config/mcp-options.js} +74 -9
  15. package/build/src/daemon/client.js +33 -2
  16. package/build/src/daemon/daemon.js +17 -13
  17. package/build/src/daemon/utils.js +18 -3
  18. package/build/src/devtools/DevtoolsUtils.js +9 -16
  19. package/build/src/formatters/ConsoleFormatter.js +43 -10
  20. package/build/src/formatters/HeapSnapshotFormatter.js +58 -13
  21. package/build/src/formatters/IssueFormatter.js +1 -1
  22. package/build/src/formatters/NetworkFormatter.js +7 -7
  23. package/build/src/index.js +34 -5
  24. package/build/src/{HeapSnapshotManager.js → processors/HeapSnapshotManager.js} +82 -27
  25. package/build/src/{trace-processing/parse.js → processors/PerformanceTrace.js} +1 -1
  26. package/build/src/telemetry/ClearcutLogger.js +16 -1
  27. package/build/src/telemetry/flagUtils.js +4 -3
  28. package/build/src/telemetry/transformation.js +30 -0
  29. package/build/src/telemetry/types.js +4 -0
  30. package/build/src/third_party/THIRD_PARTY_NOTICES +235 -113
  31. package/build/src/third_party/bundled-packages.json +6 -7
  32. package/build/src/third_party/devtools-formatter-worker.js +60 -19
  33. package/build/src/third_party/devtools-heap-snapshot-worker.js +657 -224
  34. package/build/src/third_party/index.js +62484 -43814
  35. package/build/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +2 -2
  36. package/build/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +3 -3
  37. package/build/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +2 -2
  38. package/build/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +1 -1
  39. package/build/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +1 -1
  40. package/build/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +2 -2
  41. package/build/src/third_party/issue-descriptions/LowTextContrast.md +1 -1
  42. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorRead.md +1 -1
  43. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +1 -1
  44. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +1 -1
  45. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +1 -1
  46. package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +3 -3
  47. package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +3 -3
  48. package/build/src/third_party/issue-descriptions/bounceTrackingMitigations.md +1 -1
  49. package/build/src/third_party/issue-descriptions/connectionAllowlistEmbeddingRequirementNotSatisfied.md +26 -0
  50. package/build/src/third_party/issue-descriptions/connectionAllowlistIFrameAttributeLoosensEmbeddingRequirement.md +19 -0
  51. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowConnectionAllowlistFrom.md +21 -0
  52. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +2 -2
  53. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +2 -2
  54. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +3 -3
  55. package/build/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +2 -2
  56. package/build/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +2 -2
  57. package/build/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +1 -1
  58. package/build/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +3 -3
  59. package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +1 -1
  60. package/build/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +1 -1
  61. package/build/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +1 -1
  62. package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +1 -1
  63. package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +1 -1
  64. package/build/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +1 -1
  65. package/build/src/third_party/issue-descriptions/corsDisabledScheme.md +2 -2
  66. package/build/src/third_party/issue-descriptions/corsDisallowedByMode.md +2 -2
  67. package/build/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +1 -1
  68. package/build/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +3 -3
  69. package/build/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +1 -1
  70. package/build/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +1 -1
  71. package/build/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +1 -1
  72. package/build/src/third_party/issue-descriptions/corsOriginMismatch.md +3 -3
  73. package/build/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +2 -2
  74. package/build/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +3 -3
  75. package/build/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +4 -3
  76. package/build/src/third_party/issue-descriptions/cspEvalViolation.md +4 -4
  77. package/build/src/third_party/issue-descriptions/cspInlineViolation.md +2 -2
  78. package/build/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +2 -2
  79. package/build/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +4 -4
  80. package/build/src/third_party/issue-descriptions/cspURLViolation.md +4 -4
  81. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsEmptyList.md +1 -1
  82. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsHttpNotFound.md +1 -1
  83. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidContentType.md +1 -1
  84. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidResponse.md +1 -1
  85. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsNoResponse.md +1 -1
  86. package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsFetchFailed.md +1 -1
  87. package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -1
  88. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownHttpNotFound.md +1 -1
  89. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidContentType.md +1 -1
  90. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidResponse.md +1 -1
  91. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownNoResponse.md +1 -1
  92. package/build/src/third_party/issue-descriptions/emailVerificationRequestInvalidEmail.md +1 -1
  93. package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksHttpNotFound.md +1 -1
  94. package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksInvalidResponse.md +1 -1
  95. package/build/src/third_party/issue-descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -1
  96. package/build/src/third_party/issue-descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -1
  97. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -1
  98. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -1
  99. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -1
  100. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -1
  101. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -1
  102. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenNoResponse.md +1 -1
  103. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidAudience.md +1 -1
  104. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidIssuedAt.md +1 -1
  105. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidNonce.md +1 -1
  106. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidSdHash.md +1 -1
  107. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidTyp.md +1 -1
  108. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingAud.md +1 -1
  109. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingCnf.md +1 -1
  110. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingIat.md +1 -1
  111. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingNonce.md +1 -1
  112. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingSdHash.md +1 -1
  113. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbSignatureFailed.md +1 -1
  114. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmail.md +1 -1
  115. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmailVerified.md +1 -1
  116. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidHolderKey.md +1 -1
  117. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuedAt.md +1 -1
  118. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuer.md +1 -1
  119. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtJwksMissingKeys.md +1 -1
  120. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingCnf.md +1 -1
  121. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingEmail.md +1 -1
  122. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIat.md +1 -1
  123. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIss.md +1 -1
  124. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtSignatureFailed.md +1 -1
  125. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtUnsupportedHeaderAlg.md +1 -1
  126. package/build/src/third_party/issue-descriptions/emailVerificationRequestUserLoggedOut.md +1 -1
  127. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -1
  128. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -1
  129. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -1
  130. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -1
  131. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -1
  132. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -1
  133. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -1
  134. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -1
  135. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -1
  136. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -1
  137. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsBlockedByConnectionAllowlist.md +1 -0
  138. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +1 -1
  139. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +1 -1
  140. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +1 -1
  141. package/build/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +1 -1
  142. package/build/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +1 -1
  143. package/build/src/third_party/issue-descriptions/federatedAuthRequestConfigBlockedByConnectionAllowlist.md +1 -0
  144. package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +1 -1
  145. package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +1 -1
  146. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenBlockedByConnectionAllowlist.md +1 -0
  147. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +1 -1
  148. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +1 -1
  149. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +1 -1
  150. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +1 -1
  151. package/build/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +1 -1
  152. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -1
  153. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -1
  154. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +1 -1
  155. package/build/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +1 -1
  156. package/build/src/third_party/issue-descriptions/federatedAuthRequestWellKnownBlockedByConnectionAllowlist.md +1 -0
  157. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +1 -1
  158. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +1 -1
  159. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +1 -1
  160. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +1 -1
  161. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +1 -1
  162. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +1 -1
  163. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +1 -1
  164. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +1 -1
  165. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +1 -1
  166. package/build/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +2 -2
  167. package/build/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +2 -2
  168. package/build/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +1 -1
  169. package/build/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +1 -1
  170. package/build/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +2 -2
  171. package/build/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +2 -2
  172. package/build/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +1 -1
  173. package/build/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +1 -1
  174. package/build/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +2 -2
  175. package/build/src/third_party/issue-descriptions/genericFormLabelForNameError.md +1 -1
  176. package/build/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +1 -1
  177. package/build/src/third_party/issue-descriptions/genericFormModelContextMissingToolName.md +1 -1
  178. package/build/src/third_party/issue-descriptions/genericFormModelContextParameterMissingName.md +1 -1
  179. package/build/src/third_party/issue-descriptions/genericFormModelContextRequiredParameterMissingName.md +1 -1
  180. package/build/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +2 -2
  181. package/build/src/third_party/issue-descriptions/heavyAd.md +1 -1
  182. package/build/src/third_party/issue-descriptions/lazyLoadImageZeroSize.md +7 -0
  183. package/build/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +3 -3
  184. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +1 -1
  185. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +1 -1
  186. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +1 -1
  187. package/build/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +2 -2
  188. package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +2 -2
  189. package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +2 -2
  190. package/build/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +1 -1
  191. package/build/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +2 -2
  192. package/build/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +2 -2
  193. package/build/src/third_party/issue-descriptions/permissionElementInvalidType.md +2 -2
  194. package/build/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +2 -2
  195. package/build/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +1 -1
  196. package/build/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +2 -2
  197. package/build/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +2 -2
  198. package/build/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +2 -2
  199. package/build/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +1 -1
  200. package/build/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +2 -2
  201. package/build/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +1 -1
  202. package/build/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +1 -1
  203. package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +1 -1
  204. package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +1 -1
  205. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +1 -1
  206. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +1 -1
  207. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +1 -1
  208. package/build/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +1 -1
  209. package/build/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +3 -3
  210. package/build/src/third_party/issue-descriptions/sharedArrayBuffer.md +1 -1
  211. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -1
  212. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +1 -1
  213. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +1 -1
  214. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +1 -1
  215. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +1 -1
  216. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +1 -1
  217. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +2 -2
  218. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +1 -1
  219. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +2 -2
  220. package/build/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +4 -4
  221. package/build/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +4 -4
  222. package/build/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +1 -1
  223. package/build/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +2 -2
  224. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +2 -2
  225. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +4 -4
  226. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +4 -4
  227. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +1 -1
  228. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +2 -2
  229. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +1 -1
  230. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +1 -1
  231. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +2 -2
  232. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +5 -5
  233. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +3 -3
  234. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +2 -2
  235. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +2 -2
  236. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +2 -2
  237. package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +4 -4
  238. package/build/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +3 -3
  239. package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +2 -2
  240. package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +2 -2
  241. package/build/src/third_party/issue-descriptions/stylesheetLateImport.md +1 -1
  242. package/build/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +1 -1
  243. package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +2 -2
  244. package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +3 -3
  245. package/build/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +2 -2
  246. package/build/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +1 -1
  247. package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +1125 -1027
  248. package/build/src/tools/categories.js +3 -0
  249. package/build/src/tools/console.js +9 -3
  250. package/build/src/tools/emulation.js +2 -2
  251. package/build/src/tools/extensions.js +7 -5
  252. package/build/src/tools/input.js +222 -120
  253. package/build/src/tools/lighthouse.js +3 -1
  254. package/build/src/tools/memory.js +144 -17
  255. package/build/src/tools/network.js +6 -3
  256. package/build/src/tools/pages.js +13 -16
  257. package/build/src/tools/performance.js +57 -46
  258. package/build/src/tools/pwa.js +128 -0
  259. package/build/src/tools/screencast.js +6 -4
  260. package/build/src/tools/screenshot.js +192 -84
  261. package/build/src/tools/script.js +118 -34
  262. package/build/src/tools/slim/tools.js +3 -3
  263. package/build/src/tools/snapshot.js +5 -3
  264. package/build/src/tools/thirdPartyDeveloper.js +2 -2
  265. package/build/src/tools/tools.js +2 -0
  266. package/build/src/tools/webmcp.js +2 -2
  267. package/build/src/utils/WaitForHelper.js +299 -0
  268. package/build/src/utils/bytes.js +105 -0
  269. package/build/src/utils/logger.js +25 -11
  270. package/build/src/utils/polyfill.js +6 -3
  271. package/build/src/utils/url.js +43 -0
  272. package/build/src/version.js +1 -1
  273. package/package.json +37 -25
  274. package/skills/a11y-debugging/SKILL.md +2 -0
  275. package/skills/chrome-devtools/SKILL.md +5 -4
  276. package/skills/chrome-devtools-cli/SKILL.md +109 -64
  277. package/skills/debug-optimize-lcp/SKILL.md +9 -9
  278. package/skills/memory-leak-debugging/SKILL.md +14 -18
  279. package/skills/memory-leak-debugging/references/common-leaks.md +1 -1
  280. package/skills/troubleshooting/SKILL.md +1 -0
  281. package/build/src/WaitForHelper.js +0 -200
  282. package/build/src/devtools/DevToolsConnectionAdapter.js +0 -70
  283. package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeRead.md +0 -8
  284. package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeSet.md +0 -8
  285. package/build/src/third_party/issue-descriptions/SameSiteExcludeNavigationContextDowngrade.md +0 -8
  286. package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeRead.md +0 -8
  287. package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeSet.md +0 -8
  288. package/build/src/third_party/issue-descriptions/SameSiteWarnStrictLaxDowngradeStrict.md +0 -8
  289. package/build/src/third_party/issue-descriptions/arInsecureContext.md +0 -7
  290. package/build/src/third_party/issue-descriptions/arInvalidInfoHeader.md +0 -5
  291. package/build/src/third_party/issue-descriptions/arInvalidRegisterOsSourceHeader.md +0 -5
  292. package/build/src/third_party/issue-descriptions/arInvalidRegisterOsTriggerHeader.md +0 -5
  293. package/build/src/third_party/issue-descriptions/arInvalidRegisterSourceHeader.md +0 -5
  294. package/build/src/third_party/issue-descriptions/arInvalidRegisterTriggerHeader.md +0 -5
  295. package/build/src/third_party/issue-descriptions/arNavigationRegistrationUniqueScopeAlreadySet.md +0 -5
  296. package/build/src/third_party/issue-descriptions/arNavigationRegistrationWithoutTransientUserActivation.md +0 -6
  297. package/build/src/third_party/issue-descriptions/arNoRegisterOsSourceHeader.md +0 -5
  298. package/build/src/third_party/issue-descriptions/arNoRegisterOsTriggerHeader.md +0 -5
  299. package/build/src/third_party/issue-descriptions/arNoRegisterSourceHeader.md +0 -5
  300. package/build/src/third_party/issue-descriptions/arNoRegisterTriggerHeader.md +0 -5
  301. package/build/src/third_party/issue-descriptions/arNoWebOrOsSupport.md +0 -4
  302. package/build/src/third_party/issue-descriptions/arOsSourceIgnored.md +0 -18
  303. package/build/src/third_party/issue-descriptions/arOsTriggerIgnored.md +0 -19
  304. package/build/src/third_party/issue-descriptions/arPermissionPolicyDisabled.md +0 -8
  305. package/build/src/third_party/issue-descriptions/arSourceAndTriggerHeaders.md +0 -9
  306. package/build/src/third_party/issue-descriptions/arSourceIgnored.md +0 -13
  307. package/build/src/third_party/issue-descriptions/arTriggerIgnored.md +0 -12
  308. package/build/src/third_party/issue-descriptions/arUntrustworthyReportingOrigin.md +0 -10
  309. package/build/src/third_party/issue-descriptions/arWebAndOsHeaders.md +0 -11
  310. package/build/src/utils/Mutex.js +0 -38
  311. package/build/src/utils/string.js +0 -37
  312. package/skills/memory-leak-debugging/references/compare_snapshots.js +0 -109
  313. package/skills/memory-leak-debugging/references/memlab.md +0 -29
@@ -0,0 +1,128 @@
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 { defineTool } from './ToolDefinition.js';
9
+ const manifestIdSchema = zod
10
+ .string()
11
+ .describe('The manifest ID of the web app: the resolved `id` member of its manifest. ' +
12
+ 'If `id` is omitted, it defaults to the resolved `start_url` ' +
13
+ '(e.g. "https://example.com/"). See https://w3c.github.io/manifest/#id-member.');
14
+ const displayModeSchema = zod
15
+ .enum(['standalone', 'browser'])
16
+ .optional()
17
+ .describe('Optional user display mode preference applied after install. ' +
18
+ '"standalone" opens the app in its own window; "browser" opens it as a ' +
19
+ 'tab. Installs via the PWA CDP domain default to "browser" because they ' +
20
+ 'do not simulate the install dialog, so pass "standalone" to get an ' +
21
+ 'app-window experience.');
22
+ export const installPwa = defineTool({
23
+ name: 'install_pwa',
24
+ description: 'Installs a Progressive Web App (PWA) identified by its manifest ID. ' +
25
+ 'This installs through the PWA CDP domain without a user gesture or install ' +
26
+ 'dialog. DevTools installs default to browser display mode.',
27
+ annotations: {
28
+ category: ToolCategory.PWA,
29
+ readOnlyHint: false,
30
+ },
31
+ schema: {
32
+ manifestId: manifestIdSchema,
33
+ installUrlOrBundleUrl: zod
34
+ .string()
35
+ .describe('The location of the app or bundle. For a normal site this is the page ' +
36
+ 'URL; for an Isolated Web App it can be a file:// or http(s):// ' +
37
+ 'signed web bundle.'),
38
+ displayMode: displayModeSchema,
39
+ },
40
+ blockedByDialog: false,
41
+ // We do not validate file paths for remote browser instances
42
+ // because they are on the remote host and not accessed by the MCP server.
43
+ verifyFilesSchema: {
44
+ installUrlOrBundleUrl: {
45
+ local: true,
46
+ remote: false,
47
+ },
48
+ },
49
+ handler: async (request, response, context) => {
50
+ const { manifestId, installUrlOrBundleUrl, displayMode } = request.params;
51
+ await context.installPWA({
52
+ manifestId,
53
+ installUrlOrBundleUrl,
54
+ displayMode,
55
+ });
56
+ response.appendResponseLine(`Installed PWA with manifest ID: ${manifestId}`);
57
+ if (displayMode) {
58
+ response.appendResponseLine(`Display mode set to: ${displayMode}`);
59
+ }
60
+ },
61
+ });
62
+ export const uninstallPwa = defineTool({
63
+ name: 'uninstall_pwa',
64
+ description: 'Uninstalls a Progressive Web App identified by its manifest ID and ' +
65
+ 'closes any open app windows.',
66
+ annotations: {
67
+ category: ToolCategory.PWA,
68
+ readOnlyHint: false,
69
+ },
70
+ schema: {
71
+ manifestId: manifestIdSchema,
72
+ },
73
+ blockedByDialog: false,
74
+ verifyFilesSchema: {},
75
+ handler: async (request, response, context) => {
76
+ const { manifestId } = request.params;
77
+ await context.uninstallPWA({ manifestId });
78
+ response.appendResponseLine(`Uninstalled PWA with manifest ID: ${manifestId}`);
79
+ response.setIncludePages(true);
80
+ },
81
+ });
82
+ export const launchPwa = defineTool({
83
+ name: 'launch_pwa',
84
+ description: 'Launches an installed Progressive Web App using its saved display mode. ' +
85
+ 'Optionally opens a specific URL within the same app instead of the default ' +
86
+ 'start URL.',
87
+ annotations: {
88
+ category: ToolCategory.PWA,
89
+ readOnlyHint: false,
90
+ },
91
+ schema: {
92
+ manifestId: manifestIdSchema,
93
+ url: zod
94
+ .string()
95
+ .optional()
96
+ .describe('Optional URL within the app to open instead of the default start URL.'),
97
+ },
98
+ blockedByDialog: false,
99
+ verifyFilesSchema: {},
100
+ handler: async (request, response, context) => {
101
+ const { manifestId, url } = request.params;
102
+ const page = await context.launchPWA({ manifestId, url });
103
+ response.appendResponseLine(`Launched PWA with manifest ID: ${manifestId} (${page.url()})`);
104
+ response.setIncludePages(true);
105
+ },
106
+ });
107
+ export const getOsAppState = defineTool({
108
+ name: 'get_os_app_state',
109
+ description: 'Returns the OS integration state (badge count and registered file ' +
110
+ 'handlers) for an installed web app, identified by its manifest ID.',
111
+ annotations: {
112
+ category: ToolCategory.PWA,
113
+ readOnlyHint: true,
114
+ },
115
+ schema: {
116
+ manifestId: manifestIdSchema,
117
+ },
118
+ blockedByDialog: false,
119
+ verifyFilesSchema: {},
120
+ handler: async (request, response, context) => {
121
+ const { manifestId } = request.params;
122
+ const state = await context.getPWAState({ manifestId });
123
+ response.appendResponseLine(`OS app state for manifest ID: ${manifestId}`);
124
+ response.appendResponseLine(`Badge count: ${state.badgeCount}`);
125
+ response.appendResponseLine(`File handlers: ${JSON.stringify(state.fileHandlers)}`);
126
+ },
127
+ });
128
+ //# sourceMappingURL=pwa.js.map
@@ -16,7 +16,7 @@ async function generateTempFilePath() {
16
16
  const supportedExtensions = ['.webm', '.mp4'];
17
17
  export const startScreencast = definePageTool(args => ({
18
18
  name: 'screencast_start',
19
- description: `Starts recording a screencast (video) of the selected page in specified format.`,
19
+ description: `Starts recording a screencast (video) of the target page in specified format.`,
20
20
  annotations: {
21
21
  category: ToolCategory.DEBUGGING,
22
22
  readOnlyHint: false,
@@ -29,7 +29,9 @@ export const startScreencast = definePageTool(args => ({
29
29
  .describe(`Output file path (${supportedExtensions.join(',')} are supported). Uses mkdtemp to generate a unique path if not provided.`),
30
30
  },
31
31
  blockedByDialog: false,
32
- verifyFilesSchema: ['filePath'],
32
+ verifyFilesSchema: {
33
+ filePath: true,
34
+ },
33
35
  handler: async (request, response, context) => {
34
36
  if (context.getScreenRecorder() !== null) {
35
37
  response.appendResponseLine('Error: a screencast recording is already in progress. Use screencast_stop to stop it before starting a new one.');
@@ -89,7 +91,7 @@ export const startScreencast = definePageTool(args => ({
89
91
  }));
90
92
  export const stopScreencast = definePageTool({
91
93
  name: 'screencast_stop',
92
- description: 'Stops the active screencast recording on the selected page.',
94
+ description: 'Stops the active screencast recording on the target page.',
93
95
  annotations: {
94
96
  category: ToolCategory.DEBUGGING,
95
97
  readOnlyHint: false,
@@ -97,7 +99,7 @@ export const stopScreencast = definePageTool({
97
99
  },
98
100
  schema: {},
99
101
  blockedByDialog: false,
100
- verifyFilesSchema: [],
102
+ verifyFilesSchema: {},
101
103
  handler: async (_request, response, context) => {
102
104
  const data = context.getScreenRecorder();
103
105
  if (!data) {
@@ -3,39 +3,132 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
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
+ });
6
58
  import { zod } from '../third_party/index.js';
7
59
  import { ToolCategory } from './categories.js';
8
60
  import { definePageTool } from './ToolDefinition.js';
9
61
  async function getSourceBox(page, element, fullPage) {
10
62
  if (element) {
11
- const box = await element.boundingBox();
12
- return box ?? undefined;
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;
13
71
  }
14
72
  if (fullPage) {
15
73
  const dims = await page.evaluate(() => ({
16
74
  width: Math.max(document.documentElement.scrollWidth, document.body?.scrollWidth ?? 0),
17
75
  height: Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight ?? 0),
76
+ devicePixelRatio: window.devicePixelRatio,
18
77
  }));
19
78
  if (dims.width <= 0 || dims.height <= 0) {
20
79
  return undefined;
21
80
  }
22
- return { x: 0, y: 0, width: dims.width, height: dims.height };
81
+ return {
82
+ x: 0,
83
+ y: 0,
84
+ width: dims.width,
85
+ height: dims.height,
86
+ devicePixelRatio: dims.devicePixelRatio,
87
+ };
23
88
  }
24
89
  const viewport = page.viewport();
25
- if (!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) {
26
108
  return undefined;
27
109
  }
28
- return { x: 0, y: 0, width: viewport.width, height: viewport.height };
110
+ return {
111
+ x: 0,
112
+ y: 0,
113
+ width: dims.width,
114
+ height: dims.height,
115
+ devicePixelRatio: dims.devicePixelRatio,
116
+ };
29
117
  }
30
118
  function computeDownscaleClip(box, maxWidth, maxHeight) {
31
- const widthScale = maxWidth !== undefined ? Math.min(1, maxWidth / box.width) : 1;
32
- const heightScale = maxHeight !== undefined ? Math.min(1, maxHeight / box.height) : 1;
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;
33
125
  const scale = Math.min(widthScale, heightScale);
34
126
  if (scale >= 1) {
35
127
  return undefined;
36
128
  }
37
129
  // Skip degenerate sub-pixel results.
38
- if (Math.round(box.width * scale) < 1 || Math.round(box.height * scale) < 1) {
130
+ if (Math.round(box.width * box.devicePixelRatio * scale) < 1 ||
131
+ Math.round(box.height * box.devicePixelRatio * scale) < 1) {
39
132
  return undefined;
40
133
  }
41
134
  return {
@@ -82,86 +175,101 @@ export const screenshot = definePageTool(args => {
82
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.'),
83
176
  },
84
177
  blockedByDialog: true,
85
- verifyFilesSchema: ['filePath'],
178
+ verifyFilesSchema: {
179
+ filePath: true,
180
+ },
86
181
  handler: async (request, response, context) => {
87
- if (request.params.uid && request.params.fullPage) {
88
- throw new Error('Providing both "uid" and "fullPage" is not allowed.');
89
- }
90
- const page = request.page.pptrPage;
91
- const element = request.params.uid
92
- ? await request.page.getElementByUid(request.params.uid)
93
- : undefined;
94
- const format = request.params.format;
95
- const quality = format === 'png'
96
- ? undefined
97
- : (request.params.quality ?? screenshotQuality);
98
- const fullPage = request.params.fullPage ?? false;
99
- // Compute a downscale clip when --screenshot-max-width or
100
- // --screenshot-max-height is set and the source exceeds either bound.
101
- // The smaller scale factor wins so both bounds are respected while
102
- // preserving aspect ratio.
103
- let clip;
104
- if (screenshotMaxWidth !== undefined ||
105
- screenshotMaxHeight !== undefined) {
106
- const box = await getSourceBox(page, element, fullPage);
107
- if (box) {
108
- clip = computeDownscaleClip(box, screenshotMaxWidth, screenshotMaxHeight);
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
+ });
109
265
  }
110
266
  }
111
- let screenshot;
112
- if (clip) {
113
- // page.screenshot with clip lets the CDP scale param downscale the
114
- // capture for viewport, full-page and element shots alike. We rely on
115
- // Puppeteer's default of captureBeyondViewport=true when a clip is
116
- // present so element/full-page captures below the fold still work.
117
- screenshot = await page.screenshot({
118
- type: format,
119
- quality,
120
- optimizeForSpeed: true,
121
- clip,
122
- });
123
- }
124
- else if (element) {
125
- screenshot = await element.screenshot({
126
- type: format,
127
- quality,
128
- optimizeForSpeed: true,
129
- });
130
- }
131
- else {
132
- screenshot = await page.screenshot({
133
- type: format,
134
- fullPage,
135
- quality,
136
- optimizeForSpeed: true,
137
- });
138
- }
139
- if (request.params.uid) {
140
- response.appendResponseLine(`Took a screenshot of node with uid "${request.params.uid}".`);
141
- }
142
- else if (fullPage) {
143
- response.appendResponseLine('Took a screenshot of the full current page.');
144
- }
145
- else {
146
- response.appendResponseLine("Took a screenshot of the current page's viewport.");
147
- }
148
- // Narrow `format` at the point of use: in the factory form of
149
- // definePageTool TS widens the Schema generic, which loses the literal
150
- // union from zod.enum on request.params.format.
151
- const extension = format === 'jpeg' ? '.jpeg' : format === 'webp' ? '.webp' : '.png';
152
- if (request.params.filePath) {
153
- const result = await context.saveFile(screenshot, request.params.filePath, extension);
154
- response.appendResponseLine(`Saved screenshot to ${result.filename}.`);
155
- }
156
- else if (screenshot.length >= 2_000_000) {
157
- const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot${extension}`);
158
- response.appendResponseLine(`Saved screenshot to ${filepath}.`);
267
+ catch (e_1) {
268
+ env_1.error = e_1;
269
+ env_1.hasError = true;
159
270
  }
160
- else {
161
- response.attachImage({
162
- mimeType: `image/${format}`,
163
- data: Buffer.from(screenshot).toString('base64'),
164
- });
271
+ finally {
272
+ __disposeResources(env_1);
165
273
  }
166
274
  },
167
275
  };