chrome-devtools-mcp 1.5.0 → 1.7.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 (295) hide show
  1. package/README.md +41 -9
  2. package/build/src/HeapSnapshotManager.js +77 -28
  3. package/build/src/McpContext.js +233 -383
  4. package/build/src/McpPage.js +466 -41
  5. package/build/src/McpResponse.js +285 -331
  6. package/build/src/PageCollector.js +53 -122
  7. package/build/src/SlimMcpResponse.js +1 -1
  8. package/build/src/TextSnapshot.js +100 -21
  9. package/build/src/ToolHandler.js +31 -10
  10. package/build/src/WaitForHelper.js +140 -56
  11. package/build/src/bin/chrome-devtools-cli-options.js +63 -3
  12. package/build/src/bin/chrome-devtools-mcp-cli-options.js +16 -7
  13. package/build/src/bin/chrome-devtools-mcp-main.js +3 -3
  14. package/build/src/bin/chrome-devtools.js +19 -3
  15. package/build/src/browser.js +1 -1
  16. package/build/src/daemon/client.js +55 -3
  17. package/build/src/daemon/daemon.js +17 -12
  18. package/build/src/daemon/utils.js +19 -4
  19. package/build/src/devtools/DevtoolsUtils.js +9 -65
  20. package/build/src/{issue-descriptions.js → devtools/issueDescriptions.js} +2 -2
  21. package/build/src/formatters/HeapSnapshotFormatter.js +48 -11
  22. package/build/src/formatters/IssueFormatter.js +2 -2
  23. package/build/src/index.js +13 -3
  24. package/build/src/telemetry/ClearcutLogger.js +4 -1
  25. package/build/src/telemetry/WatchdogClient.js +1 -1
  26. package/build/src/telemetry/metricsRegistry.js +2 -9
  27. package/build/src/telemetry/persistence.js +1 -1
  28. package/build/src/telemetry/transformation.js +50 -0
  29. package/build/src/telemetry/watchdog/ClearcutSender.js +1 -1
  30. package/build/src/telemetry/watchdog/main.js +1 -1
  31. package/build/src/third_party/THIRD_PARTY_NOTICES +230 -287
  32. package/build/src/third_party/bundled-packages.json +4 -6
  33. package/build/src/third_party/devtools-formatter-worker.js +60 -19
  34. package/build/src/third_party/devtools-heap-snapshot-worker.js +383 -182
  35. package/build/src/third_party/index.js +30171 -11328
  36. package/build/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +2 -2
  37. package/build/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +3 -3
  38. package/build/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +2 -2
  39. package/build/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +1 -1
  40. package/build/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +1 -1
  41. package/build/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +2 -2
  42. package/build/src/third_party/issue-descriptions/LowTextContrast.md +1 -1
  43. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorRead.md +1 -1
  44. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +1 -1
  45. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +1 -1
  46. package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +1 -1
  47. package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +3 -3
  48. package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +3 -3
  49. package/build/src/third_party/issue-descriptions/bounceTrackingMitigations.md +1 -1
  50. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +2 -2
  51. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +2 -2
  52. package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +3 -3
  53. package/build/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +2 -2
  54. package/build/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +2 -2
  55. package/build/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +1 -1
  56. package/build/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +3 -3
  57. package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +1 -1
  58. package/build/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +1 -1
  59. package/build/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +1 -1
  60. package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +1 -1
  61. package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +1 -1
  62. package/build/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +1 -1
  63. package/build/src/third_party/issue-descriptions/corsDisabledScheme.md +2 -2
  64. package/build/src/third_party/issue-descriptions/corsDisallowedByMode.md +2 -2
  65. package/build/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +1 -1
  66. package/build/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +3 -3
  67. package/build/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +1 -1
  68. package/build/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +1 -1
  69. package/build/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +1 -1
  70. package/build/src/third_party/issue-descriptions/corsOriginMismatch.md +3 -3
  71. package/build/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +2 -2
  72. package/build/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +3 -3
  73. package/build/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +4 -3
  74. package/build/src/third_party/issue-descriptions/cspEvalViolation.md +4 -4
  75. package/build/src/third_party/issue-descriptions/cspInlineViolation.md +2 -2
  76. package/build/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +2 -2
  77. package/build/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +4 -4
  78. package/build/src/third_party/issue-descriptions/cspURLViolation.md +4 -4
  79. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsEmptyList.md +1 -1
  80. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsHttpNotFound.md +1 -1
  81. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidContentType.md +1 -1
  82. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidResponse.md +1 -1
  83. package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsNoResponse.md +1 -1
  84. package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsFetchFailed.md +1 -1
  85. package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -1
  86. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownHttpNotFound.md +1 -1
  87. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidContentType.md +1 -1
  88. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidResponse.md +1 -1
  89. package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownNoResponse.md +1 -1
  90. package/build/src/third_party/issue-descriptions/emailVerificationRequestInvalidEmail.md +1 -1
  91. package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksHttpNotFound.md +1 -1
  92. package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksInvalidResponse.md +1 -1
  93. package/build/src/third_party/issue-descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -1
  94. package/build/src/third_party/issue-descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -1
  95. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -1
  96. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -1
  97. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -1
  98. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -1
  99. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -1
  100. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenNoResponse.md +1 -1
  101. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidAudience.md +1 -1
  102. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidIssuedAt.md +1 -1
  103. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidNonce.md +1 -1
  104. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidSdHash.md +1 -1
  105. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidTyp.md +1 -1
  106. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingAud.md +1 -1
  107. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingCnf.md +1 -1
  108. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingIat.md +1 -1
  109. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingNonce.md +1 -1
  110. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingSdHash.md +1 -1
  111. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbSignatureFailed.md +1 -1
  112. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmail.md +1 -1
  113. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmailVerified.md +1 -1
  114. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidHolderKey.md +1 -1
  115. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuedAt.md +1 -1
  116. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuer.md +1 -1
  117. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtJwksMissingKeys.md +1 -1
  118. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingCnf.md +1 -1
  119. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingEmail.md +1 -1
  120. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIat.md +1 -1
  121. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIss.md +1 -1
  122. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtSignatureFailed.md +1 -1
  123. package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtUnsupportedHeaderAlg.md +1 -1
  124. package/build/src/third_party/issue-descriptions/emailVerificationRequestUserLoggedOut.md +1 -1
  125. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -1
  126. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -1
  127. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -1
  128. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -1
  129. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -1
  130. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -1
  131. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -1
  132. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -1
  133. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -1
  134. package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -1
  135. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +1 -1
  136. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +1 -1
  137. package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +1 -1
  138. package/build/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +1 -1
  139. package/build/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +1 -1
  140. package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +1 -1
  141. package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +1 -1
  142. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +1 -1
  143. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +1 -1
  144. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +1 -1
  145. package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +1 -1
  146. package/build/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +1 -1
  147. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -1
  148. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -1
  149. package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +1 -1
  150. package/build/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +1 -1
  151. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +1 -1
  152. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +1 -1
  153. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +1 -1
  154. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +1 -1
  155. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +1 -1
  156. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +1 -1
  157. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +1 -1
  158. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +1 -1
  159. package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +1 -1
  160. package/build/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +2 -2
  161. package/build/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +2 -2
  162. package/build/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +1 -1
  163. package/build/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +1 -1
  164. package/build/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +2 -2
  165. package/build/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +2 -2
  166. package/build/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +1 -1
  167. package/build/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +1 -1
  168. package/build/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +2 -2
  169. package/build/src/third_party/issue-descriptions/genericFormLabelForNameError.md +1 -1
  170. package/build/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +1 -1
  171. package/build/src/third_party/issue-descriptions/genericFormModelContextMissingToolName.md +1 -1
  172. package/build/src/third_party/issue-descriptions/genericFormModelContextParameterMissingName.md +1 -1
  173. package/build/src/third_party/issue-descriptions/genericFormModelContextRequiredParameterMissingName.md +1 -1
  174. package/build/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +2 -2
  175. package/build/src/third_party/issue-descriptions/heavyAd.md +1 -1
  176. package/build/src/third_party/issue-descriptions/lazyLoadImageZeroSize.md +7 -0
  177. package/build/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +3 -3
  178. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +1 -1
  179. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +1 -1
  180. package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +1 -1
  181. package/build/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +2 -2
  182. package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +2 -2
  183. package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +2 -2
  184. package/build/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +1 -1
  185. package/build/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +2 -2
  186. package/build/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +2 -2
  187. package/build/src/third_party/issue-descriptions/permissionElementInvalidType.md +2 -2
  188. package/build/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +2 -2
  189. package/build/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +1 -1
  190. package/build/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +2 -2
  191. package/build/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +2 -2
  192. package/build/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +2 -2
  193. package/build/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +1 -1
  194. package/build/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +2 -2
  195. package/build/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +1 -1
  196. package/build/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +1 -1
  197. package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +1 -1
  198. package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +1 -1
  199. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +1 -1
  200. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +1 -1
  201. package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +1 -1
  202. package/build/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +1 -1
  203. package/build/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +3 -3
  204. package/build/src/third_party/issue-descriptions/sharedArrayBuffer.md +1 -1
  205. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -1
  206. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +1 -1
  207. package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +1 -1
  208. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +1 -1
  209. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +1 -1
  210. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +1 -1
  211. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +2 -2
  212. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +1 -1
  213. package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +2 -2
  214. package/build/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +4 -4
  215. package/build/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +4 -4
  216. package/build/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +1 -1
  217. package/build/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +2 -2
  218. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +2 -2
  219. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +4 -4
  220. package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +4 -4
  221. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +1 -1
  222. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +2 -2
  223. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +1 -1
  224. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +1 -1
  225. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +2 -2
  226. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +5 -5
  227. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +3 -3
  228. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +2 -2
  229. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +2 -2
  230. package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +2 -2
  231. package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +4 -4
  232. package/build/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +3 -3
  233. package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +2 -2
  234. package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +2 -2
  235. package/build/src/third_party/issue-descriptions/stylesheetLateImport.md +1 -1
  236. package/build/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +1 -1
  237. package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +2 -2
  238. package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +3 -3
  239. package/build/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +2 -2
  240. package/build/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +1 -1
  241. package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +3177 -6340
  242. package/build/src/tools/emulation.js +2 -2
  243. package/build/src/tools/extensions.js +1 -1
  244. package/build/src/tools/input.js +213 -112
  245. package/build/src/tools/lighthouse.js +1 -1
  246. package/build/src/tools/memory.js +49 -4
  247. package/build/src/tools/network.js +5 -5
  248. package/build/src/tools/pages.js +22 -89
  249. package/build/src/tools/performance.js +62 -41
  250. package/build/src/tools/screenshot.js +152 -77
  251. package/build/src/tools/script.js +95 -28
  252. package/build/src/tools/snapshot.js +2 -2
  253. package/build/src/tools/thirdPartyDeveloper.js +1 -1
  254. package/build/src/tools/webmcp.js +1 -1
  255. package/build/src/trace-processing/parse.js +1 -1
  256. package/build/src/{logger.js → utils/logger.js} +1 -1
  257. package/build/src/utils/polyfill.js +11 -0
  258. package/build/src/utils/url.js +43 -0
  259. package/build/src/version.js +1 -1
  260. package/package.json +23 -15
  261. package/skills/memory-leak-debugging/SKILL.md +23 -19
  262. package/skills/memory-leak-debugging/references/common-leaks.md +1 -1
  263. package/build/src/Mutex.js +0 -38
  264. package/build/src/devtools/DevToolsConnectionAdapter.js +0 -70
  265. package/build/src/polyfill.js +0 -8
  266. package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeRead.md +0 -8
  267. package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeSet.md +0 -8
  268. package/build/src/third_party/issue-descriptions/SameSiteExcludeNavigationContextDowngrade.md +0 -8
  269. package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeRead.md +0 -8
  270. package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeSet.md +0 -8
  271. package/build/src/third_party/issue-descriptions/SameSiteWarnStrictLaxDowngradeStrict.md +0 -8
  272. package/build/src/third_party/issue-descriptions/arInsecureContext.md +0 -7
  273. package/build/src/third_party/issue-descriptions/arInvalidInfoHeader.md +0 -5
  274. package/build/src/third_party/issue-descriptions/arInvalidRegisterOsSourceHeader.md +0 -5
  275. package/build/src/third_party/issue-descriptions/arInvalidRegisterOsTriggerHeader.md +0 -5
  276. package/build/src/third_party/issue-descriptions/arInvalidRegisterSourceHeader.md +0 -5
  277. package/build/src/third_party/issue-descriptions/arInvalidRegisterTriggerHeader.md +0 -5
  278. package/build/src/third_party/issue-descriptions/arNavigationRegistrationUniqueScopeAlreadySet.md +0 -5
  279. package/build/src/third_party/issue-descriptions/arNavigationRegistrationWithoutTransientUserActivation.md +0 -6
  280. package/build/src/third_party/issue-descriptions/arNoRegisterOsSourceHeader.md +0 -5
  281. package/build/src/third_party/issue-descriptions/arNoRegisterOsTriggerHeader.md +0 -5
  282. package/build/src/third_party/issue-descriptions/arNoRegisterSourceHeader.md +0 -5
  283. package/build/src/third_party/issue-descriptions/arNoRegisterTriggerHeader.md +0 -5
  284. package/build/src/third_party/issue-descriptions/arNoWebOrOsSupport.md +0 -4
  285. package/build/src/third_party/issue-descriptions/arOsSourceIgnored.md +0 -18
  286. package/build/src/third_party/issue-descriptions/arOsTriggerIgnored.md +0 -19
  287. package/build/src/third_party/issue-descriptions/arPermissionPolicyDisabled.md +0 -8
  288. package/build/src/third_party/issue-descriptions/arSourceAndTriggerHeaders.md +0 -9
  289. package/build/src/third_party/issue-descriptions/arSourceIgnored.md +0 -13
  290. package/build/src/third_party/issue-descriptions/arTriggerIgnored.md +0 -12
  291. package/build/src/third_party/issue-descriptions/arUntrustworthyReportingOrigin.md +0 -10
  292. package/build/src/third_party/issue-descriptions/arWebAndOsHeaders.md +0 -11
  293. package/build/src/utils/types.js +0 -7
  294. package/skills/memory-leak-debugging/references/compare_snapshots.js +0 -109
  295. package/skills/memory-leak-debugging/references/memlab.md +0 -29
@@ -3,7 +3,59 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import { logger } from './logger.js';
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 { logger } from './utils/logger.js';
7
59
  export class WaitForHelper {
8
60
  #abortController = new AbortController();
9
61
  #page;
@@ -11,7 +63,9 @@ export class WaitForHelper {
11
63
  #stableDomFor;
12
64
  #expectNavigationIn;
13
65
  #navigationTimeout;
14
- #dialogOpened = false;
66
+ #dialogHandled = false;
67
+ /** Track all dialogs as they pause the renderer. */
68
+ #dialogDetected = false;
15
69
  #initialUrl;
16
70
  constructor(page, cpuTimeoutMultiplier, networkTimeoutMultiplier) {
17
71
  this.#stableDomTimeout = 3000 * cpuTimeoutMultiplier;
@@ -27,49 +81,67 @@ export class WaitForHelper {
27
81
  * for the DOM to be stable before returning.
28
82
  */
29
83
  async waitForStableDom() {
30
- const stableDomObserver = await this.#page.evaluateHandle(timeout => {
31
- let timeoutId;
32
- function callback() {
33
- clearTimeout(timeoutId);
34
- timeoutId = setTimeout(() => {
35
- domObserver.resolver.resolve();
36
- domObserver.observer.disconnect();
37
- }, timeout);
84
+ const env_1 = { stack: [], error: void 0, hasError: false };
85
+ try {
86
+ // Bound the setup evaluation against the stable-DOM timeout. Without this
87
+ // cap a paused renderer (e.g. an open dialog) would make evaluateHandle
88
+ // hang until protocolTimeout (default 180s) while the tool mutex is held.
89
+ const stableDomObserver = __addDisposableResource(env_1, await Promise.race([
90
+ this.#page.evaluateHandle(timeout => {
91
+ let timeoutId;
92
+ function callback() {
93
+ clearTimeout(timeoutId);
94
+ timeoutId = setTimeout(() => {
95
+ domObserver.resolver.resolve();
96
+ domObserver.observer.disconnect();
97
+ }, timeout);
98
+ }
99
+ const domObserver = {
100
+ resolver: Promise.withResolvers(),
101
+ observer: new MutationObserver(callback),
102
+ };
103
+ // It's possible that the DOM is not gonna change so we
104
+ // need to start the timeout initially.
105
+ callback();
106
+ domObserver.observer.observe(document.body, {
107
+ childList: true,
108
+ subtree: true,
109
+ attributes: true,
110
+ });
111
+ return domObserver;
112
+ }, this.#stableDomFor),
113
+ this.timeout(this.#stableDomTimeout),
114
+ ]).catch(() => undefined), false);
115
+ if (!stableDomObserver) {
116
+ return;
38
117
  }
39
- const domObserver = {
40
- resolver: Promise.withResolvers(),
41
- observer: new MutationObserver(callback),
42
- };
43
- // It's possible that the DOM is not gonna change so we
44
- // need to start the timeout initially.
45
- callback();
46
- domObserver.observer.observe(document.body, {
47
- childList: true,
48
- subtree: true,
49
- attributes: true,
118
+ this.#abortController.signal.addEventListener('abort', async () => {
119
+ try {
120
+ await stableDomObserver.evaluate(observer => {
121
+ observer.observer.disconnect();
122
+ observer.resolver.resolve();
123
+ });
124
+ }
125
+ catch {
126
+ // Ignored cleanup errors
127
+ }
50
128
  });
51
- return domObserver;
52
- }, this.#stableDomFor);
53
- this.#abortController.signal.addEventListener('abort', async () => {
54
- try {
55
- await stableDomObserver.evaluate(observer => {
56
- observer.observer.disconnect();
57
- observer.resolver.resolve();
58
- });
59
- await stableDomObserver.dispose();
60
- }
61
- catch {
62
- // Ignored cleanup errors
63
- }
64
- });
65
- return Promise.race([
66
- stableDomObserver.evaluate(async (observer) => {
67
- return await observer.resolver.promise;
68
- }),
69
- this.timeout(this.#stableDomTimeout).then(() => {
70
- throw new Error('Timeout');
71
- }),
72
- ]);
129
+ return Promise.race([
130
+ stableDomObserver.evaluate(async (observer) => {
131
+ return await observer.resolver.promise;
132
+ }),
133
+ this.timeout(this.#stableDomTimeout).then(() => {
134
+ throw new Error('Timeout');
135
+ }),
136
+ ]);
137
+ }
138
+ catch (e_1) {
139
+ env_1.error = e_1;
140
+ env_1.hasError = true;
141
+ }
142
+ finally {
143
+ __disposeResources(env_1);
144
+ }
73
145
  }
74
146
  async waitForNavigationStarted() {
75
147
  // Currently Puppeteer does not have API
@@ -110,24 +182,35 @@ export class WaitForHelper {
110
182
  if (this.#abortController.signal.aborted) {
111
183
  throw new Error("Can't re-use a WaitForHelper");
112
184
  }
113
- if (options?.handleDialog) {
114
- const dialogHandler = (dialog) => {
115
- this.#dialogOpened = true;
116
- if (options.handleDialog === 'dismiss') {
185
+ const dialogHandler = (dialog) => {
186
+ this.#dialogDetected = true;
187
+ if (!options?.handleDialog) {
188
+ return;
189
+ }
190
+ let actionToTake;
191
+ if (typeof options.handleDialog === 'object') {
192
+ actionToTake = options.handleDialog[dialog.type()];
193
+ }
194
+ else {
195
+ actionToTake = options.handleDialog;
196
+ }
197
+ if (actionToTake) {
198
+ this.#dialogHandled = true;
199
+ if (actionToTake === 'dismiss') {
117
200
  void dialog.dismiss();
118
201
  }
119
- else if (options.handleDialog === 'accept') {
202
+ else if (actionToTake === 'accept') {
120
203
  void dialog.accept();
121
204
  }
122
205
  else {
123
- void dialog.accept(options.handleDialog);
206
+ void dialog.accept(actionToTake);
124
207
  }
125
- };
126
- this.#page.on('dialog', dialogHandler);
127
- this.#abortController.signal.addEventListener('abort', () => {
128
- this.#page.off('dialog', dialogHandler);
129
- });
130
- }
208
+ }
209
+ };
210
+ this.#page.on('dialog', dialogHandler);
211
+ this.#abortController.signal.addEventListener('abort', () => {
212
+ this.#page.off('dialog', dialogHandler);
213
+ });
131
214
  const navigationFinished = this.waitForNavigationStarted()
132
215
  .then(navigationStated => {
133
216
  if (navigationStated) {
@@ -149,7 +232,7 @@ export class WaitForHelper {
149
232
  }
150
233
  try {
151
234
  await navigationFinished;
152
- if (this.#dialogOpened) {
235
+ if (this.#dialogDetected) {
153
236
  return this.#getResult();
154
237
  }
155
238
  // Wait for stable dom after navigation so we execute in
@@ -170,6 +253,7 @@ export class WaitForHelper {
170
253
  ...(urlAfterAction !== this.#initialUrl
171
254
  ? { navigatedToUrl: urlAfterAction }
172
255
  : {}),
256
+ dialogHandled: this.#dialogHandled,
173
257
  };
174
258
  }
175
259
  }
@@ -298,6 +298,27 @@ export const commands = {
298
298
  description: 'The ID for the class, obtained from details.',
299
299
  required: true,
300
300
  },
301
+ filterName: {
302
+ name: 'filterName',
303
+ type: 'string',
304
+ description: 'An optional filter to apply to the nodes.',
305
+ required: false,
306
+ enum: [
307
+ 'objectsRetainedByDetachedDomNodes',
308
+ 'objectsRetainedByConsole',
309
+ 'objectsRetainedByEventHandlers',
310
+ 'objectsRetainedByContexts',
311
+ 'sharedNativeContext',
312
+ 'noNativeContext',
313
+ 'attributedToSpecificNativeContext',
314
+ ],
315
+ },
316
+ objectId: {
317
+ name: 'objectId',
318
+ type: 'number',
319
+ description: 'The object ID (nodeId) of the specific native context to filter by when filterName is attributedToSpecificNativeContext.',
320
+ required: false,
321
+ },
301
322
  pageIdx: {
302
323
  name: 'pageIdx',
303
324
  type: 'number',
@@ -322,6 +343,27 @@ export const commands = {
322
343
  description: 'A path to a .heapsnapshot file to read.',
323
344
  required: true,
324
345
  },
346
+ filterName: {
347
+ name: 'filterName',
348
+ type: 'string',
349
+ description: 'An optional filter to apply to the aggregates.',
350
+ required: false,
351
+ enum: [
352
+ 'objectsRetainedByDetachedDomNodes',
353
+ 'objectsRetainedByConsole',
354
+ 'objectsRetainedByEventHandlers',
355
+ 'objectsRetainedByContexts',
356
+ 'sharedNativeContext',
357
+ 'noNativeContext',
358
+ 'attributedToSpecificNativeContext',
359
+ ],
360
+ },
361
+ objectId: {
362
+ name: 'objectId',
363
+ type: 'number',
364
+ description: 'The object ID (nodeId) of the specific native context to filter by when filterName is attributedToSpecificNativeContext.',
365
+ required: false,
366
+ },
325
367
  pageIdx: {
326
368
  name: 'pageIdx',
327
369
  type: 'number',
@@ -408,6 +450,24 @@ export const commands = {
408
450
  },
409
451
  },
410
452
  },
453
+ get_heapsnapshot_object_details: {
454
+ description: 'Loads a memory heapsnapshot and returns detailed information about a specific object by its node ID, including size, type, distance, and DOM detachedness. (requires flag: --memoryDebugging=true)',
455
+ category: 'Memory',
456
+ args: {
457
+ filePath: {
458
+ name: 'filePath',
459
+ type: 'string',
460
+ description: 'A path to a .heapsnapshot file to read.',
461
+ required: true,
462
+ },
463
+ nodeId: {
464
+ name: 'nodeId',
465
+ type: 'number',
466
+ description: 'The node ID to get object details for.',
467
+ required: true,
468
+ },
469
+ },
470
+ },
411
471
  get_heapsnapshot_retainers: {
412
472
  description: 'Loads a memory heapsnapshot and returns retainers for a specific node ID. (requires flag: --memoryDebugging=true)',
413
473
  category: 'Memory',
@@ -475,7 +535,7 @@ export const commands = {
475
535
  },
476
536
  },
477
537
  get_heapsnapshot_summary: {
478
- description: 'Loads a memory heapsnapshot and returns snapshot summary stats. (requires flag: --memoryDebugging=true)',
538
+ description: 'Loads a memory heapsnapshot and returns snapshot summary stats, including native contexts and their sizes. (requires flag: --memoryDebugging=true)',
479
539
  category: 'Memory',
480
540
  args: {
481
541
  filePath: {
@@ -635,7 +695,7 @@ export const commands = {
635
695
  args: {},
636
696
  },
637
697
  list_network_requests: {
638
- description: 'List all requests for the currently selected page since the last navigation.',
698
+ description: 'Lists the most recent requests for the currently selected page since the last navigation.',
639
699
  category: 'Network',
640
700
  args: {
641
701
  pageSize: {
@@ -703,7 +763,7 @@ export const commands = {
703
763
  type: 'string',
704
764
  description: 'Whether to auto accept or beforeunload dialogs triggered by this navigation. Default is accept.',
705
765
  required: false,
706
- enum: ['accept', 'decline'],
766
+ enum: ['accept', 'dismiss'],
707
767
  },
708
768
  initScript: {
709
769
  name: 'initScript',
@@ -157,18 +157,19 @@ export const cliOptions = {
157
157
  },
158
158
  experimentalToonFormat: {
159
159
  type: 'boolean',
160
- describe: 'Whether to format structured data in text response using Token-Oriented Object Notation (requires @toon-format/toon). If running via npx, use: npx --package chrome-devtools-mcp@latest --package @toon-format/toon@latest chrome-devtools-mcp --experimentalToonFormat',
160
+ describe: 'Deprecated: use --experimentalDataFormat=toon instead. Whether to format structured data using TOON (requires @toon-format/toon).',
161
+ hidden: true,
162
+ },
163
+ experimentalDataFormat: {
164
+ type: 'string',
165
+ describe: 'Override format for structured data in text responses. Default uses built-in formatters. "toon" (requires @toon-format/toon) or "gcf" (requires @blackwell-systems/gcf) replace structured content with the specified encoding.',
166
+ choices: ['default', 'toon', 'gcf'],
161
167
  hidden: true,
162
168
  },
163
169
  experimentalIncludeAllPages: {
164
170
  type: 'boolean',
165
171
  describe: 'Whether to include all kinds of pages such as webviews or background pages as pages.',
166
172
  },
167
- experimentalNavigationAllowlist: {
168
- type: 'boolean',
169
- describe: 'Whether to enable navigation allowlist tool parameter.',
170
- hidden: true,
171
- },
172
173
  experimentalInteropTools: {
173
174
  type: 'boolean',
174
175
  describe: 'Whether to enable interoperability tools',
@@ -185,7 +186,7 @@ export const cliOptions = {
185
186
  },
186
187
  categoryExperimentalWebmcp: {
187
188
  type: 'boolean',
188
- describe: 'Set to true to enable debugging WebMCP tools. Requires Chrome 149+ with the following flags: `--enable-features=WebMCP,DevToolsWebMCPSupport`',
189
+ describe: 'Set to true to enable debugging WebMCP tools. Requires Chrome 150+ with the following flag: `--enable-features=WebMCP`',
189
190
  },
190
191
  chromeArg: {
191
192
  type: 'array',
@@ -314,6 +315,14 @@ export const cliOptions = {
314
315
  describe: 'If true, redacts some of the network headers considered sensitive before returning to the client.',
315
316
  default: false,
316
317
  },
318
+ allowUnrestrictedPaths: {
319
+ type: 'boolean',
320
+ default: false,
321
+ describe: 'If set, disables the default path restriction that applies when the MCP client does not negotiate ' +
322
+ 'the roots capability. By default, file-writing tools are restricted to the OS temp directory when ' +
323
+ 'no roots are configured. Use this only when connecting a trusted local client that does not implement ' +
324
+ 'MCP roots and requires access to paths outside the temp directory.',
325
+ },
317
326
  };
318
327
  export function parseArguments(version, argv = process.argv, env = process.env) {
319
328
  const yargsInstance = yargs(hideBin(argv))
@@ -3,15 +3,15 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- import '../polyfill.js';
6
+ import '../utils/polyfill.js';
7
7
  import process from 'node:process';
8
8
  import { closeBrowser } from '../browser.js';
9
9
  import { createMcpServer, logDisclaimers } from '../index.js';
10
- import { logger, saveLogsToFile } from '../logger.js';
11
10
  import { ClearcutLogger } from '../telemetry/ClearcutLogger.js';
12
11
  import { computeFlagUsage } from '../telemetry/flagUtils.js';
13
12
  import { StdioServerTransport } from '../third_party/index.js';
14
13
  import { checkForUpdates } from '../utils/check-for-updates.js';
14
+ import { logger, saveLogsToFile } from '../utils/logger.js';
15
15
  import { VERSION } from '../version.js';
16
16
  import { cliOptions, parseArguments } from './chrome-devtools-mcp-cli-options.js';
17
17
  await checkForUpdates('Run `npm install chrome-devtools-mcp@latest` to update.');
@@ -40,7 +40,7 @@ async function shutdown(reason) {
40
40
  setTimeout(() => {
41
41
  logger?.('Shutdown timeout exceeded, forcing exit');
42
42
  process.exit(0);
43
- }, 10000).unref();
43
+ }, 5000).unref();
44
44
  await closeBrowser();
45
45
  process.exit(0);
46
46
  }
@@ -6,8 +6,8 @@
6
6
  */
7
7
  process.title = 'chrome-devtools';
8
8
  import process from 'node:process';
9
- import { startDaemon, stopDaemon, sendCommand, handleResponse, } from '../daemon/client.js';
10
- import { isDaemonRunning, serializeArgs } from '../daemon/utils.js';
9
+ import { startDaemon, stopDaemon, sendCommand, handleResponse, verifyDaemonVersion, } from '../daemon/client.js';
10
+ import { isDaemonRunning, serializeArgs, assertValidSessionId, } from '../daemon/utils.js';
11
11
  import { logDisclaimers } from '../index.js';
12
12
  import { hideBin, yargs } from '../third_party/index.js';
13
13
  import { checkForUpdates } from '../utils/check-for-updates.js';
@@ -51,6 +51,10 @@ const y = yargs(hideBin(process.argv))
51
51
  description: 'Session ID for daemon scoping',
52
52
  default: '',
53
53
  hidden: true,
54
+ coerce: (sessionId) => {
55
+ assertValidSessionId(sessionId);
56
+ return sessionId;
57
+ },
54
58
  })
55
59
  .demandCommand()
56
60
  .version(VERSION)
@@ -108,6 +112,9 @@ y.command('status', 'Checks if chrome-devtools-mcp is running', y => y, async (a
108
112
  const data = JSON.parse(response.result);
109
113
  console.log(`pid=${data.pid} socket=${data.socketPath} start-date=${data.startDate} version=${data.version}`);
110
114
  console.log(`args=${JSON.stringify(data.args)}`);
115
+ if (data.version !== VERSION) {
116
+ console.warn(`Warning: Daemon server version (${data.version}) does not match CLI version (${VERSION}). Run 'chrome-devtools start' to update and restart the daemon.`);
117
+ }
111
118
  }
112
119
  else {
113
120
  console.error('Error:', response.error);
@@ -181,8 +188,11 @@ for (const [commandName, commandDef] of Object.entries(commands)) {
181
188
  }, async (argv) => {
182
189
  const sessionId = argv.sessionId;
183
190
  try {
191
+ const versionWarningPromise = isDaemonRunning(sessionId)
192
+ ? verifyDaemonVersion(sessionId, VERSION)
193
+ : Promise.resolve(undefined);
184
194
  if (!isDaemonRunning(sessionId)) {
185
- await start([], sessionId);
195
+ await start(serializeArgs(cliOptions, argv), sessionId);
186
196
  }
187
197
  const commandArgs = {};
188
198
  for (const argName of Object.keys(args)) {
@@ -200,6 +210,12 @@ for (const [commandName, commandDef] of Object.entries(commands)) {
200
210
  }
201
211
  else {
202
212
  console.error('Error:', response.error);
213
+ }
214
+ const versionWarning = await versionWarningPromise;
215
+ if (versionWarning) {
216
+ console.warn(versionWarning);
217
+ }
218
+ if (!response.success) {
203
219
  process.exit(1);
204
220
  }
205
221
  }
@@ -7,8 +7,8 @@ import { execSync } from 'node:child_process';
7
7
  import fs from 'node:fs';
8
8
  import os from 'node:os';
9
9
  import path from 'node:path';
10
- import { logger } from './logger.js';
11
10
  import { puppeteer } from './third_party/index.js';
11
+ import { logger } from './utils/logger.js';
12
12
  let browser;
13
13
  let browserMode;
14
14
  function makeTargetFilter(enableExtensions = false) {
@@ -6,11 +6,13 @@
6
6
  import { spawn } from 'node:child_process';
7
7
  import fs from 'node:fs';
8
8
  import net from 'node:net';
9
- import { logger } from '../logger.js';
10
9
  import { PipeTransport } from '../third_party/index.js';
11
10
  import { getTempFilePath } from '../utils/files.js';
11
+ import { logger } from '../utils/logger.js';
12
12
  import { DAEMON_SCRIPT_PATH, getSocketPath, getPidFilePath, isDaemonRunning, } from './utils.js';
13
13
  const FILE_TIMEOUT = 10_000;
14
+ const READY_CHECK_INTERVAL = 100;
15
+ const READY_CHECK_COMMAND_TIMEOUT = 1_000;
14
16
  /**
15
17
  * Waits for a file to be created and populated (removed = false) or removed (removed = true).
16
18
  */
@@ -48,9 +50,36 @@ function waitForFile(filePath, removed = false) {
48
50
  });
49
51
  });
50
52
  }
53
+ function delay(ms) {
54
+ return new Promise(resolve => {
55
+ setTimeout(resolve, ms);
56
+ });
57
+ }
58
+ async function waitForDaemonReady(sessionId) {
59
+ const deadline = Date.now() + FILE_TIMEOUT;
60
+ let lastError;
61
+ while (Date.now() < deadline) {
62
+ try {
63
+ const response = await sendCommand({ method: 'status' }, sessionId, READY_CHECK_COMMAND_TIMEOUT);
64
+ if (response.success) {
65
+ return;
66
+ }
67
+ lastError = new Error(String(response.error));
68
+ }
69
+ catch (error) {
70
+ lastError = error;
71
+ }
72
+ const timeLeft = deadline - Date.now();
73
+ if (timeLeft > 0) {
74
+ await delay(Math.min(READY_CHECK_INTERVAL, timeLeft));
75
+ }
76
+ }
77
+ throw new Error(`Timeout: daemon not ready within ${FILE_TIMEOUT}ms`, lastError === undefined ? undefined : { cause: lastError });
78
+ }
51
79
  export async function startDaemon(mcpArgs = [], sessionId) {
52
80
  if (isDaemonRunning(sessionId)) {
53
81
  logger?.('Daemon is already running');
82
+ await waitForDaemonReady(sessionId);
54
83
  return;
55
84
  }
56
85
  const pidFilePath = getPidFilePath(sessionId);
@@ -67,12 +96,17 @@ export async function startDaemon(mcpArgs = [], sessionId) {
67
96
  });
68
97
  child.unref();
69
98
  await waitForFile(pidFilePath);
99
+ await waitForDaemonReady(sessionId);
70
100
  }
71
101
  const SEND_COMMAND_TIMEOUT = 60_000; // ms
72
102
  /**
73
103
  * `sendCommand` opens a socket connection sends a single command and disconnects.
74
104
  */
75
- export async function sendCommand(command, sessionId) {
105
+ export async function sendCommand(command, sessionId, timeout = SEND_COMMAND_TIMEOUT) {
106
+ // Before connecting and sending, verify the daemon is still alive.
107
+ if (!isDaemonRunning(sessionId)) {
108
+ throw new Error('Daemon is not running.');
109
+ }
76
110
  const socketPath = getSocketPath(sessionId);
77
111
  const socket = net.createConnection({
78
112
  path: socketPath,
@@ -81,7 +115,7 @@ export async function sendCommand(command, sessionId) {
81
115
  const timer = setTimeout(() => {
82
116
  socket.destroy();
83
117
  reject(new Error('Timeout waiting for daemon response'));
84
- }, SEND_COMMAND_TIMEOUT);
118
+ }, timeout);
85
119
  const transport = new PipeTransport(socket, socket);
86
120
  transport.onmessage = async (message) => {
87
121
  clearTimeout(timer);
@@ -111,6 +145,24 @@ export async function stopDaemon(sessionId) {
111
145
  await sendCommand({ method: 'stop' }, sessionId);
112
146
  await waitForFile(pidFilePath, /*removed=*/ true);
113
147
  }
148
+ export async function verifyDaemonVersion(sessionId, cliVersion) {
149
+ if (!isDaemonRunning(sessionId)) {
150
+ return undefined;
151
+ }
152
+ try {
153
+ const response = await sendCommand({ method: 'status' }, sessionId);
154
+ if (response.success) {
155
+ const data = JSON.parse(response.result);
156
+ if (data?.version && data.version !== cliVersion) {
157
+ return `Warning: Daemon server version (${data.version}) does not match CLI version (${cliVersion}). Run 'chrome-devtools start' to update and restart the daemon.`;
158
+ }
159
+ }
160
+ }
161
+ catch {
162
+ // Suppress communication failures during check; command execution handles unreachable daemon errors.
163
+ }
164
+ return undefined;
165
+ }
114
166
  export async function handleResponse(response, format) {
115
167
  if (response.isError) {
116
168
  return JSON.stringify(response.content);