@chenpx976/chrome-devtools-mcp 0.0.0-stage → 1.13.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 (398) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +223 -2
  3. package/out/Default/gen/src/ArcBrowser.js +128 -0
  4. package/out/Default/gen/src/BrowserManager.js +562 -0
  5. package/out/Default/gen/src/LogpointManager.js +287 -0
  6. package/out/Default/gen/src/McpContext.js +1031 -0
  7. package/out/Default/gen/src/McpPage.js +1427 -0
  8. package/out/Default/gen/src/McpResponse.js +1350 -0
  9. package/out/Default/gen/src/McpWorker.js +66 -0
  10. package/out/Default/gen/src/NetworkOverrideManager.js +447 -0
  11. package/out/Default/gen/src/SlimMcpResponse.js +23 -0
  12. package/out/Default/gen/src/TextSnapshot.js +336 -0
  13. package/out/Default/gen/src/ToolHandler.js +531 -0
  14. package/out/Default/gen/src/bin/check-latest-version.js +53 -0
  15. package/out/Default/gen/src/bin/chrome-devtools-mcp-main.js +80 -0
  16. package/out/Default/gen/src/bin/chrome-devtools-mcp.js +23 -0
  17. package/out/Default/gen/src/bin/chrome-devtools.js +213 -0
  18. package/out/Default/gen/src/collectors/PageCollector.js +325 -0
  19. package/out/Default/gen/src/collectors/ServiceWorkerCollector.js +198 -0
  20. package/out/Default/gen/src/collectors/constants.js +7 -0
  21. package/out/Default/gen/src/config/ConfigLocator.js +70 -0
  22. package/out/Default/gen/src/config/ConfigParser.js +163 -0
  23. package/out/Default/gen/src/config/ConfigWatcher.js +94 -0
  24. package/out/Default/gen/src/config/ServerConfig.js +284 -0
  25. package/out/Default/gen/src/config/browser-options.js +135 -0
  26. package/out/Default/gen/src/config/category-options.js +84 -0
  27. package/out/Default/gen/src/config/cli-commands.js +208 -0
  28. package/out/Default/gen/src/config/cli-options.js +2090 -0
  29. package/out/Default/gen/src/config/mcp-options.js +371 -0
  30. package/out/Default/gen/src/config/puppeteer-options.js +69 -0
  31. package/out/Default/gen/src/config/tool-options.js +60 -0
  32. package/out/Default/gen/src/daemon/client.js +281 -0
  33. package/out/Default/gen/src/daemon/daemon.js +280 -0
  34. package/out/Default/gen/src/daemon/types.js +7 -0
  35. package/out/Default/gen/src/daemon/utils.js +173 -0
  36. package/out/Default/gen/src/devtools/DevToolsCommentBridge.js +151 -0
  37. package/out/Default/gen/src/devtools/DevtoolsUtils.js +413 -0
  38. package/out/Default/gen/src/devtools/McpHostBindingAdapter.js +164 -0
  39. package/out/Default/gen/src/devtools/issueDescriptions.js +42 -0
  40. package/out/Default/gen/src/formatters/CommentFormatter.js +73 -0
  41. package/out/Default/gen/src/formatters/ConsoleFormatter.js +363 -0
  42. package/out/Default/gen/src/formatters/CssFormatter.js +883 -0
  43. package/out/Default/gen/src/formatters/HeapSnapshotFormatter.js +239 -0
  44. package/out/Default/gen/src/formatters/IssueFormatter.js +194 -0
  45. package/out/Default/gen/src/formatters/LogpointFormatter.js +62 -0
  46. package/out/Default/gen/src/formatters/NetworkFormatter.js +295 -0
  47. package/out/Default/gen/src/formatters/NetworkOverridesFormatter.js +57 -0
  48. package/out/Default/gen/src/formatters/RemoteObjectFormatter.js +231 -0
  49. package/out/Default/gen/src/formatters/SnapshotFormatter.js +172 -0
  50. package/out/Default/gen/src/formatters/WebAuthnFormatter.js +56 -0
  51. package/out/Default/gen/src/formatters/constants.js +8 -0
  52. package/out/Default/gen/src/index.js +434 -0
  53. package/out/Default/gen/src/processors/ChunkedTraceParser.js +361 -0
  54. package/out/Default/gen/src/processors/HeapSnapshotManager.js +595 -0
  55. package/out/Default/gen/src/processors/PerformanceTrace.js +132 -0
  56. package/out/Default/gen/src/telemetry/ClearcutLogger.js +271 -0
  57. package/out/Default/gen/src/telemetry/WatchdogClient.js +60 -0
  58. package/out/Default/gen/src/telemetry/errors.js +18 -0
  59. package/out/Default/gen/src/telemetry/flagUtils.js +89 -0
  60. package/out/Default/gen/src/telemetry/metricsRegistry.js +85 -0
  61. package/out/Default/gen/src/telemetry/persistence.js +82 -0
  62. package/out/Default/gen/src/telemetry/transformation.js +229 -0
  63. package/out/Default/gen/src/telemetry/types.js +36 -0
  64. package/out/Default/gen/src/telemetry/watchdog/ClearcutSender.js +213 -0
  65. package/out/Default/gen/src/telemetry/watchdog/main.js +142 -0
  66. package/out/Default/gen/src/third_party/THIRD_PARTY_NOTICES +3774 -0
  67. package/out/Default/gen/src/third_party/browser.js +808 -0
  68. package/out/Default/gen/src/third_party/bundled-packages.json +11 -0
  69. package/out/Default/gen/src/third_party/cli.js +139 -0
  70. package/out/Default/gen/src/third_party/devtools-formatter-worker.js +125 -0
  71. package/out/Default/gen/src/third_party/devtools-heap-snapshot-worker.js +111 -0
  72. package/out/Default/gen/src/third_party/index.js +128 -0
  73. package/out/Default/gen/src/third_party/issue-descriptions/CoepCoopSandboxedIframeCannotNavigateToCoopPage.md +4 -0
  74. package/out/Default/gen/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +8 -0
  75. package/out/Default/gen/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +18 -0
  76. package/out/Default/gen/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +7 -0
  77. package/out/Default/gen/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +10 -0
  78. package/out/Default/gen/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +5 -0
  79. package/out/Default/gen/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +5 -0
  80. package/out/Default/gen/src/third_party/issue-descriptions/LowTextContrast.md +5 -0
  81. package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorRead.md +8 -0
  82. package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +8 -0
  83. package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +8 -0
  84. package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +8 -0
  85. package/out/Default/gen/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +9 -0
  86. package/out/Default/gen/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +9 -0
  87. package/out/Default/gen/src/third_party/issue-descriptions/bounceTrackingMitigations.md +3 -0
  88. package/out/Default/gen/src/third_party/issue-descriptions/clientHintMetaTagAllowListInvalidOrigin.md +4 -0
  89. package/out/Default/gen/src/third_party/issue-descriptions/clientHintMetaTagModifiedHTML.md +4 -0
  90. package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistEmbeddingRequirementNotSatisfied.md +26 -0
  91. package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistIFrameAttributeLoosensEmbeddingRequirement.md +19 -0
  92. package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowConnectionAllowlistFrom.md +21 -0
  93. package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +12 -0
  94. package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +12 -0
  95. package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +8 -0
  96. package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +12 -0
  97. package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +7 -0
  98. package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +10 -0
  99. package/out/Default/gen/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +12 -0
  100. package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeDomainNonAscii.md +11 -0
  101. package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +8 -0
  102. package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +7 -0
  103. package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutRead.md +6 -0
  104. package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +6 -0
  105. package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnDomainNonAscii.md +11 -0
  106. package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +3 -0
  107. package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantReadOptOut.md +5 -0
  108. package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +3 -0
  109. package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantSetOptOut.md +5 -0
  110. package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +6 -0
  111. package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutSet.md +6 -0
  112. package/out/Default/gen/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +6 -0
  113. package/out/Default/gen/src/third_party/issue-descriptions/corsDisabledScheme.md +7 -0
  114. package/out/Default/gen/src/third_party/issue-descriptions/corsDisallowedByMode.md +7 -0
  115. package/out/Default/gen/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +5 -0
  116. package/out/Default/gen/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +7 -0
  117. package/out/Default/gen/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +19 -0
  118. package/out/Default/gen/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +5 -0
  119. package/out/Default/gen/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +5 -0
  120. package/out/Default/gen/src/third_party/issue-descriptions/corsOriginMismatch.md +6 -0
  121. package/out/Default/gen/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +5 -0
  122. package/out/Default/gen/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +5 -0
  123. package/out/Default/gen/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +9 -0
  124. package/out/Default/gen/src/third_party/issue-descriptions/cspEvalViolation.md +9 -0
  125. package/out/Default/gen/src/third_party/issue-descriptions/cspInlineViolation.md +10 -0
  126. package/out/Default/gen/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +5 -0
  127. package/out/Default/gen/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +8 -0
  128. package/out/Default/gen/src/third_party/issue-descriptions/cspURLViolation.md +10 -0
  129. package/out/Default/gen/src/third_party/issue-descriptions/deprecation.md +3 -0
  130. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsEmptyList.md +1 -0
  131. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsHttpNotFound.md +1 -0
  132. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidContentType.md +1 -0
  133. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidResponse.md +1 -0
  134. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsNoResponse.md +1 -0
  135. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestDnsFetchFailed.md +1 -0
  136. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -0
  137. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownHttpNotFound.md +1 -0
  138. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidContentType.md +1 -0
  139. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidResponse.md +1 -0
  140. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownNoResponse.md +1 -0
  141. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestInvalidEmail.md +1 -0
  142. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestJwksHttpNotFound.md +1 -0
  143. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestJwksInvalidResponse.md +1 -0
  144. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -0
  145. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -0
  146. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -0
  147. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -0
  148. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -0
  149. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -0
  150. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -0
  151. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenNoResponse.md +1 -0
  152. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidAudience.md +1 -0
  153. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidIssuedAt.md +1 -0
  154. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidNonce.md +1 -0
  155. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidSdHash.md +1 -0
  156. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidTyp.md +1 -0
  157. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingAud.md +1 -0
  158. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingCnf.md +1 -0
  159. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingIat.md +1 -0
  160. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingNonce.md +1 -0
  161. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingSdHash.md +1 -0
  162. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbSignatureFailed.md +1 -0
  163. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmail.md +1 -0
  164. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmailVerified.md +1 -0
  165. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidHolderKey.md +1 -0
  166. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuedAt.md +1 -0
  167. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuer.md +1 -0
  168. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtJwksMissingKeys.md +1 -0
  169. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingCnf.md +1 -0
  170. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingEmail.md +1 -0
  171. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIat.md +1 -0
  172. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIss.md +1 -0
  173. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtSignatureFailed.md +1 -0
  174. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtUnsupportedHeaderAlg.md +1 -0
  175. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestUserLoggedOut.md +1 -0
  176. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -0
  177. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -0
  178. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -0
  179. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -0
  180. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -0
  181. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -0
  182. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -0
  183. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -0
  184. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -0
  185. package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -0
  186. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsBlockedByConnectionAllowlist.md +1 -0
  187. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +1 -0
  188. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +1 -0
  189. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +1 -0
  190. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +1 -0
  191. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +1 -0
  192. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestConfigBlockedByConnectionAllowlist.md +1 -0
  193. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +1 -0
  194. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +1 -0
  195. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenBlockedByConnectionAllowlist.md +1 -0
  196. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +1 -0
  197. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +1 -0
  198. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +1 -0
  199. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +1 -0
  200. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +1 -0
  201. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -0
  202. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -0
  203. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +1 -0
  204. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +1 -0
  205. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestWellKnownBlockedByConnectionAllowlist.md +1 -0
  206. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +1 -0
  207. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +1 -0
  208. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +1 -0
  209. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +1 -0
  210. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +1 -0
  211. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +1 -0
  212. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +1 -0
  213. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +1 -0
  214. package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +1 -0
  215. package/out/Default/gen/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +7 -0
  216. package/out/Default/gen/src/third_party/issue-descriptions/genericBackUINavigationWouldSkipAd.md +4 -0
  217. package/out/Default/gen/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +8 -0
  218. package/out/Default/gen/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +5 -0
  219. package/out/Default/gen/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +5 -0
  220. package/out/Default/gen/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +5 -0
  221. package/out/Default/gen/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +5 -0
  222. package/out/Default/gen/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +5 -0
  223. package/out/Default/gen/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +5 -0
  224. package/out/Default/gen/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +5 -0
  225. package/out/Default/gen/src/third_party/issue-descriptions/genericFormLabelForNameError.md +5 -0
  226. package/out/Default/gen/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +5 -0
  227. package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextMissingToolDescription.md +5 -0
  228. package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextMissingToolName.md +5 -0
  229. package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextParameterMissingName.md +5 -0
  230. package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextParameterMissingTitleAndDescription.md +5 -0
  231. package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextRequiredParameterMissingName.md +5 -0
  232. package/out/Default/gen/src/third_party/issue-descriptions/genericGeolocationPromptWithoutUserGesture.md +5 -0
  233. package/out/Default/gen/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +7 -0
  234. package/out/Default/gen/src/third_party/issue-descriptions/genericResponseWasBlockedByORB.md +4 -0
  235. package/out/Default/gen/src/third_party/issue-descriptions/heavyAd.md +10 -0
  236. package/out/Default/gen/src/third_party/issue-descriptions/lazyLoadImageZeroSize.md +7 -0
  237. package/out/Default/gen/src/third_party/issue-descriptions/mixedContent.md +5 -0
  238. package/out/Default/gen/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +5 -0
  239. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +7 -0
  240. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +9 -0
  241. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +9 -0
  242. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementCspFrameAncestorsMissing.md +5 -0
  243. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +5 -0
  244. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +5 -0
  245. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +5 -0
  246. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementGeolocationDeprecated.md +5 -0
  247. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +5 -0
  248. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +5 -0
  249. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +5 -0
  250. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidType.md +5 -0
  251. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +5 -0
  252. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementLowContrast.md +5 -0
  253. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +5 -0
  254. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +6 -0
  255. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +6 -0
  256. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementPermissionsPolicyBlocked.md +5 -0
  257. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementRegistrationFailed.md +5 -0
  258. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +5 -0
  259. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +5 -0
  260. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +5 -0
  261. package/out/Default/gen/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +7 -0
  262. package/out/Default/gen/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +3 -0
  263. package/out/Default/gen/src/third_party/issue-descriptions/propertyRuleInvalidNameIssue.md +3 -0
  264. package/out/Default/gen/src/third_party/issue-descriptions/propertyRuleIssue.md +7 -0
  265. package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +7 -0
  266. package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +7 -0
  267. package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +3 -0
  268. package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +3 -0
  269. package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +3 -0
  270. package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +3 -0
  271. package/out/Default/gen/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +7 -0
  272. package/out/Default/gen/src/third_party/issue-descriptions/sharedArrayBuffer.md +7 -0
  273. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -0
  274. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorDictionaryLoadFailure.md +3 -0
  275. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +3 -0
  276. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +1 -0
  277. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +1 -0
  278. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +1 -0
  279. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +3 -0
  280. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +3 -0
  281. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInsufficientResources.md +1 -0
  282. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidMatchField.md +1 -0
  283. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +1 -0
  284. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidTTLField.md +1 -0
  285. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +3 -0
  286. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNoMatchField.md +1 -0
  287. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonIntegerTTLField.md +1 -0
  288. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonListMatchDestField.md +1 -0
  289. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonSecureContext.md +3 -0
  290. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringIdField.md +1 -0
  291. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringInMatchDestList.md +1 -0
  292. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringMatchField.md +1 -0
  293. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonTokenTypeField.md +1 -0
  294. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorRequestAborted.md +1 -0
  295. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorShuttingDown.md +1 -0
  296. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorTooLongIdField.md +3 -0
  297. package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorUnsupportedType.md +3 -0
  298. package/out/Default/gen/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +14 -0
  299. package/out/Default/gen/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +15 -0
  300. package/out/Default/gen/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +8 -0
  301. package/out/Default/gen/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +7 -0
  302. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +11 -0
  303. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +14 -0
  304. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +15 -0
  305. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +8 -0
  306. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +13 -0
  307. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +4 -0
  308. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +5 -0
  309. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +11 -0
  310. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +12 -0
  311. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +6 -0
  312. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +8 -0
  313. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +11 -0
  314. package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +11 -0
  315. package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +12 -0
  316. package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +5 -0
  317. package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +6 -0
  318. package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +11 -0
  319. package/out/Default/gen/src/third_party/issue-descriptions/stylesheetLateImport.md +4 -0
  320. package/out/Default/gen/src/third_party/issue-descriptions/stylesheetRequestFailed.md +3 -0
  321. package/out/Default/gen/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +3 -0
  322. package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +12 -0
  323. package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +17 -0
  324. package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +14 -0
  325. package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +15 -0
  326. package/out/Default/gen/src/third_party/issue-descriptions/webInstallManifestMissingId.md +3 -0
  327. package/out/Default/gen/src/third_party/issue-descriptions/webInstallManifestMissingNameOrShortName.md +3 -0
  328. package/out/Default/gen/src/third_party/issue-descriptions/webInstallManifestParsingOrNetworkError.md +3 -0
  329. package/out/Default/gen/src/third_party/issue-descriptions/webInstallNoManifest.md +3 -0
  330. package/out/Default/gen/src/third_party/issue-descriptions/webInstallStartUrlInvalid.md +3 -0
  331. package/out/Default/gen/src/third_party/lighthouse-devtools-mcp-bundle.js +60395 -0
  332. package/out/Default/gen/src/tools/ToolDefinition.js +180 -0
  333. package/out/Default/gen/src/tools/categories.js +37 -0
  334. package/out/Default/gen/src/tools/comments.js +230 -0
  335. package/out/Default/gen/src/tools/console.js +122 -0
  336. package/out/Default/gen/src/tools/css.js +54 -0
  337. package/out/Default/gen/src/tools/emulation.js +98 -0
  338. package/out/Default/gen/src/tools/extensions.js +108 -0
  339. package/out/Default/gen/src/tools/input.js +658 -0
  340. package/out/Default/gen/src/tools/lighthouse.js +279 -0
  341. package/out/Default/gen/src/tools/logpoints.js +51 -0
  342. package/out/Default/gen/src/tools/memory.js +531 -0
  343. package/out/Default/gen/src/tools/network.js +325 -0
  344. package/out/Default/gen/src/tools/pages.js +420 -0
  345. package/out/Default/gen/src/tools/performance.js +258 -0
  346. package/out/Default/gen/src/tools/pwa.js +152 -0
  347. package/out/Default/gen/src/tools/screencast.js +160 -0
  348. package/out/Default/gen/src/tools/screenshot.js +315 -0
  349. package/out/Default/gen/src/tools/script.js +319 -0
  350. package/out/Default/gen/src/tools/slim/tools.js +110 -0
  351. package/out/Default/gen/src/tools/snapshot.js +88 -0
  352. package/out/Default/gen/src/tools/thirdPartyDeveloper.js +73 -0
  353. package/out/Default/gen/src/tools/toolNames.js +10 -0
  354. package/out/Default/gen/src/tools/tools.js +72 -0
  355. package/out/Default/gen/src/tools/webauthn.js +51 -0
  356. package/out/Default/gen/src/tools/webmcp.js +55 -0
  357. package/out/Default/gen/src/types.js +21 -0
  358. package/out/Default/gen/src/utils/TaskRunner.js +151 -0
  359. package/out/Default/gen/src/utils/WaitForHelper.js +343 -0
  360. package/out/Default/gen/src/utils/bytes.js +95 -0
  361. package/out/Default/gen/src/utils/check-for-updates.js +81 -0
  362. package/out/Default/gen/src/utils/disclaimers.js +27 -0
  363. package/out/Default/gen/src/utils/errorHandling.js +23 -0
  364. package/out/Default/gen/src/utils/files.js +81 -0
  365. package/out/Default/gen/src/utils/id.js +16 -0
  366. package/out/Default/gen/src/utils/keyboard.js +307 -0
  367. package/out/Default/gen/src/utils/logger.js +145 -0
  368. package/out/Default/gen/src/utils/logpoint.js +44 -0
  369. package/out/Default/gen/src/utils/network.js +81 -0
  370. package/out/Default/gen/src/utils/pagination.js +50 -0
  371. package/out/Default/gen/src/utils/polyfill.js +11 -0
  372. package/out/Default/gen/src/utils/raceWithSignal.js +26 -0
  373. package/out/Default/gen/src/utils/resourceType.js +27 -0
  374. package/out/Default/gen/src/utils/text.js +43 -0
  375. package/out/Default/gen/src/utils/timeout.js +14 -0
  376. package/out/Default/gen/src/utils/url.js +311 -0
  377. package/out/Default/gen/src/version.js +11 -0
  378. package/package.json +125 -4
  379. package/skills/a11y-debugging/SKILL.md +86 -0
  380. package/skills/a11y-debugging/references/a11y-snippets.md +92 -0
  381. package/skills/arc-compatibility/SKILL.md +168 -0
  382. package/skills/arc-compatibility/SOURCES.md +216 -0
  383. package/skills/arc-compatibility/references/compatibility.md +113 -0
  384. package/skills/arc-compatibility/references/output-contract.md +62 -0
  385. package/skills/arc-compatibility/references/workflows.md +105 -0
  386. package/skills/chrome-devtools/SKILL.md +80 -0
  387. package/skills/chrome-devtools-cli/SKILL.md +208 -0
  388. package/skills/chrome-devtools-cli/references/installation.md +24 -0
  389. package/skills/cookie-debugging/SKILL.md +152 -0
  390. package/skills/debug-optimize-lcp/SKILL.md +121 -0
  391. package/skills/debug-optimize-lcp/references/elements-and-size.md +27 -0
  392. package/skills/debug-optimize-lcp/references/lcp-breakdown.md +23 -0
  393. package/skills/debug-optimize-lcp/references/lcp-snippets.md +79 -0
  394. package/skills/debug-optimize-lcp/references/optimization-strategies.md +38 -0
  395. package/skills/inspect-in-devtools/SKILL.md +82 -0
  396. package/skills/memory-leak-debugging/SKILL.md +58 -0
  397. package/skills/memory-leak-debugging/references/common-leaks.md +33 -0
  398. package/skills/troubleshooting/SKILL.md +107 -0
@@ -0,0 +1,281 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { spawn } from 'node:child_process';
7
+ import fs from 'node:fs';
8
+ import net from 'node:net';
9
+ import path from 'node:path';
10
+ import { PipeTransport } from '../third_party/cli.js';
11
+ import { getErrorMessage } from '../utils/errorHandling.js';
12
+ import { getTempFilePath } from '../utils/files.js';
13
+ import { logger, puppeteerLogger, redactDaemonArgsForLogging, } from '../utils/logger.js';
14
+ import { DAEMON_SCRIPT_PATH, getDaemonPid, getSocketPath, getPidFilePath, isDaemonRunning, } from './utils.js';
15
+ const FILE_TIMEOUT = 10_000;
16
+ const READY_CHECK_INTERVAL = 100;
17
+ const READY_CHECK_COMMAND_TIMEOUT = 1_000;
18
+ function delay(ms) {
19
+ return new Promise(resolve => {
20
+ setTimeout(resolve, ms);
21
+ });
22
+ }
23
+ async function waitFor(check, timeoutMessage) {
24
+ const deadline = Date.now() + FILE_TIMEOUT;
25
+ while (Date.now() < deadline) {
26
+ if (check()) {
27
+ return;
28
+ }
29
+ const timeLeft = deadline - Date.now();
30
+ if (timeLeft > 0) {
31
+ await delay(Math.min(READY_CHECK_INTERVAL, timeLeft));
32
+ }
33
+ }
34
+ if (check()) {
35
+ return;
36
+ }
37
+ throw new Error(timeoutMessage);
38
+ }
39
+ /**
40
+ * Waits for a file to be created and populated.
41
+ */
42
+ async function waitForFile(filePath) {
43
+ await waitFor(() => {
44
+ if (!fs.existsSync(filePath)) {
45
+ return false;
46
+ }
47
+ try {
48
+ return fs.statSync(filePath).size > 0;
49
+ }
50
+ catch {
51
+ return false;
52
+ }
53
+ }, `Timeout: file ${filePath} not found within ${FILE_TIMEOUT}ms`);
54
+ }
55
+ async function waitForDaemonReady(sessionId) {
56
+ const deadline = Date.now() + FILE_TIMEOUT;
57
+ let lastError;
58
+ while (Date.now() < deadline) {
59
+ try {
60
+ const response = await sendCommand({ method: 'status' }, sessionId, READY_CHECK_COMMAND_TIMEOUT);
61
+ if (response.success) {
62
+ return;
63
+ }
64
+ lastError = new Error(String(response.error));
65
+ }
66
+ catch (error) {
67
+ lastError = error;
68
+ }
69
+ const timeLeft = deadline - Date.now();
70
+ if (timeLeft > 0) {
71
+ await delay(Math.min(READY_CHECK_INTERVAL, timeLeft));
72
+ }
73
+ }
74
+ throw new Error(`Timeout: daemon not ready within ${FILE_TIMEOUT}ms`, lastError === undefined ? undefined : { cause: lastError });
75
+ }
76
+ export async function startDaemon(mcpArgs = [], sessionId) {
77
+ if (isDaemonRunning(sessionId)) {
78
+ logger?.('Daemon is already running');
79
+ await waitForDaemonReady(sessionId);
80
+ return;
81
+ }
82
+ const pidFilePath = getPidFilePath(sessionId);
83
+ if (fs.existsSync(pidFilePath)) {
84
+ if (process.platform !== 'win32') {
85
+ const pidDir = path.dirname(pidFilePath);
86
+ if (fs.lstatSync(pidDir).isSymbolicLink() ||
87
+ fs.lstatSync(pidFilePath).isSymbolicLink()) {
88
+ throw new Error(`Refusing to remove daemon PID file through a symbolic link: ${pidFilePath}`);
89
+ }
90
+ }
91
+ fs.unlinkSync(pidFilePath);
92
+ }
93
+ logger?.('Starting daemon...', ...redactDaemonArgsForLogging(mcpArgs));
94
+ const child = spawn(process.execPath, [DAEMON_SCRIPT_PATH, ...mcpArgs], {
95
+ detached: true,
96
+ stdio: 'ignore',
97
+ env: { ...process.env, CHROME_DEVTOOLS_MCP_SESSION_ID: sessionId },
98
+ cwd: process.cwd(),
99
+ windowsHide: true,
100
+ });
101
+ child.unref();
102
+ await waitForFile(pidFilePath);
103
+ await waitForDaemonReady(sessionId);
104
+ }
105
+ const SEND_COMMAND_TIMEOUT = 60_000; // ms
106
+ const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
107
+ // Allow browser connection (up to TOOL_CALL_TIMEOUT_MS) and response construction.
108
+ const RESPONSE_GRACE_MS = 60_000;
109
+ function getCommandResponseTimeout(command) {
110
+ if (command.method !== 'invoke_tool') {
111
+ return SEND_COMMAND_TIMEOUT;
112
+ }
113
+ const toolTimeout = command.args?.timeout;
114
+ if (typeof toolTimeout !== 'number' ||
115
+ !Number.isFinite(toolTimeout) ||
116
+ toolTimeout <= 0) {
117
+ return SEND_COMMAND_TIMEOUT;
118
+ }
119
+ return Math.min(toolTimeout + RESPONSE_GRACE_MS, MAX_TIMER_DELAY_MS);
120
+ }
121
+ /**
122
+ * `sendCommand` opens a socket connection sends a single command and disconnects.
123
+ */
124
+ export async function sendCommand(command, sessionId, timeout = getCommandResponseTimeout(command)) {
125
+ // Before connecting and sending, verify the daemon is still alive.
126
+ if (!isDaemonRunning(sessionId)) {
127
+ throw new Error('Daemon is not running.');
128
+ }
129
+ const socketPath = getSocketPath(sessionId);
130
+ const socket = net.createConnection({
131
+ path: socketPath,
132
+ });
133
+ return await new Promise((resolve, reject) => {
134
+ const timer = setTimeout(() => {
135
+ socket.destroy();
136
+ reject(new Error('Timeout waiting for daemon response'));
137
+ }, timeout);
138
+ const transport = new PipeTransport(socket, socket, puppeteerLogger);
139
+ transport.onmessage = async (message) => {
140
+ clearTimeout(timer);
141
+ logger?.('onmessage', message);
142
+ socket.end();
143
+ resolve(JSON.parse(message));
144
+ };
145
+ socket.on('error', error => {
146
+ clearTimeout(timer);
147
+ logger?.('Socket error:', error);
148
+ reject(error);
149
+ });
150
+ socket.on('close', () => {
151
+ clearTimeout(timer);
152
+ logger?.('Socket closed:');
153
+ reject(new Error('Socket closed'));
154
+ });
155
+ logger?.('Sending message', command);
156
+ transport.send(JSON.stringify(command));
157
+ });
158
+ }
159
+ export async function stopDaemon(sessionId) {
160
+ if (!isDaemonRunning(sessionId)) {
161
+ logger?.('Daemon is not running');
162
+ return;
163
+ }
164
+ const pid = getDaemonPid(sessionId);
165
+ const pidFilePath = getPidFilePath(sessionId);
166
+ try {
167
+ await sendCommand({ method: 'stop' }, sessionId);
168
+ }
169
+ catch (error) {
170
+ logger?.('Failed to stop daemon via socket, sending SIGTERM:', error);
171
+ if (pid) {
172
+ try {
173
+ process.kill(pid, 'SIGTERM');
174
+ }
175
+ catch {
176
+ // Ignore if process already exited.
177
+ }
178
+ }
179
+ }
180
+ try {
181
+ await waitFor(() => !isDaemonRunning(sessionId), `Timeout: daemon (pid ${pid}) did not exit within ${FILE_TIMEOUT}ms`);
182
+ fs.rmSync(pidFilePath, { force: true });
183
+ }
184
+ catch (error) {
185
+ if (pid) {
186
+ try {
187
+ process.kill(pid, 'SIGKILL');
188
+ }
189
+ catch (killError) {
190
+ if (!(killError instanceof Error &&
191
+ 'code' in killError &&
192
+ killError.code === 'ESRCH')) {
193
+ throw new Error(`Failed to stop daemon (pid ${pid}): ${getErrorMessage(killError)}`, { cause: killError });
194
+ }
195
+ }
196
+ }
197
+ try {
198
+ fs.unlinkSync(pidFilePath);
199
+ }
200
+ catch {
201
+ // Ignore if file already removed.
202
+ }
203
+ if (isDaemonRunning(sessionId)) {
204
+ throw error;
205
+ }
206
+ }
207
+ }
208
+ export async function verifyDaemonVersion(sessionId, cliVersion) {
209
+ if (!isDaemonRunning(sessionId)) {
210
+ return undefined;
211
+ }
212
+ try {
213
+ const response = await sendCommand({ method: 'status' }, sessionId);
214
+ if (response.success) {
215
+ const data = JSON.parse(response.result);
216
+ if (data?.version && data.version !== cliVersion) {
217
+ return `Warning: Daemon server version (${data.version}) does not match CLI version (${cliVersion}). Run 'chrome-devtools start' to update and restart the daemon.`;
218
+ }
219
+ }
220
+ }
221
+ catch {
222
+ // Suppress communication failures during check; command execution handles unreachable daemon errors.
223
+ }
224
+ return undefined;
225
+ }
226
+ export async function handleResponse(response, format) {
227
+ if (response.isError) {
228
+ if (format === 'md') {
229
+ const chunks = [];
230
+ for (const content of response.content) {
231
+ if (content.type === 'text') {
232
+ chunks.push(content.text);
233
+ }
234
+ }
235
+ return chunks.join(' ');
236
+ }
237
+ return JSON.stringify(response.content);
238
+ }
239
+ const chunks = [];
240
+ const images = [];
241
+ for (const content of response.content) {
242
+ if (content.type === 'text') {
243
+ chunks.push(content.text);
244
+ }
245
+ else if (content.type === 'image') {
246
+ const imageData = content.data;
247
+ const mimeType = content.mimeType;
248
+ let extension = '.png';
249
+ switch (mimeType) {
250
+ case 'image/jpg':
251
+ case 'image/jpeg':
252
+ extension = '.jpeg';
253
+ break;
254
+ case 'image/webp':
255
+ extension = '.webp';
256
+ break;
257
+ }
258
+ const data = Buffer.from(imageData, 'base64');
259
+ const name = crypto.randomUUID();
260
+ const filepath = await getTempFilePath(`${name}${extension}`);
261
+ fs.writeFileSync(filepath, data);
262
+ images.push({ filePath: filepath, mimeType });
263
+ chunks.push(`Saved to ${filepath}.`);
264
+ }
265
+ else {
266
+ throw new Error('Not supported response content type');
267
+ }
268
+ }
269
+ if (format === 'json') {
270
+ if (response.structuredContent) {
271
+ const structuredContent = {
272
+ ...response.structuredContent,
273
+ ...(images.length ? { images } : {}),
274
+ };
275
+ return JSON.stringify(structuredContent);
276
+ }
277
+ // Fall-through to text for backward compatibility.
278
+ }
279
+ return format === 'md' ? chunks.join(' ') : JSON.stringify(chunks);
280
+ }
281
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,280 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @license
4
+ * Copyright 2026 Google LLC
5
+ * SPDX-License-Identifier: Apache-2.0
6
+ */
7
+ import '../utils/polyfill.js';
8
+ import fs, { constants, openSync, writeSync, closeSync } from 'node:fs';
9
+ import { createServer } from 'node:net';
10
+ import os from 'node:os';
11
+ import path from 'node:path';
12
+ import process from 'node:process';
13
+ import { BrowserManager } from '../BrowserManager.js';
14
+ import { mcpOptions } from '../config/mcp-options.js';
15
+ import { ConfigParser } from '../config/ConfigParser.js';
16
+ import { McpServer } from '../index.js';
17
+ import { ClearcutLogger } from '../telemetry/ClearcutLogger.js';
18
+ import { computeFlagUsage } from '../telemetry/flagUtils.js';
19
+ import { PipeTransport } from '../third_party/index.js';
20
+ import { logger, puppeteerLogger, saveLogsToFile } from '../utils/logger.js';
21
+ import { setupUnhandledRejectionHandler } from '../utils/errorHandling.js';
22
+ import { VERSION } from '../version.js';
23
+ import { DAEMON_CLIENT_NAME, getPidFilePath, getSocketPath, IS_WINDOWS, isDaemonRunning, assertValidSessionId, } from './utils.js';
24
+ const sessionId = process.env.CHROME_DEVTOOLS_MCP_SESSION_ID || '';
25
+ assertValidSessionId(sessionId);
26
+ logger?.(`Daemon sessionId: ${sessionId}`);
27
+ if (isDaemonRunning(sessionId)) {
28
+ logger?.('Another daemon process is running.');
29
+ process.exit(1);
30
+ }
31
+ const pidFilePath = getPidFilePath(sessionId);
32
+ const pidDir = path.dirname(pidFilePath);
33
+ const currentUserUid = os.userInfo().uid;
34
+ try {
35
+ fs.mkdirSync(pidDir, { recursive: true, mode: 0o700 });
36
+ if (os.platform() !== 'win32') {
37
+ // POSIX specific checks
38
+ try {
39
+ const stats = fs.lstatSync(pidDir);
40
+ // 1. Reject symlinked runtime directories before checking ownership.
41
+ if (stats.isSymbolicLink()) {
42
+ console.error(`[MCP Daemon] Critical error: PID directory ${pidDir} must not be a symbolic link. Possible tampering.`);
43
+ process.exit(1);
44
+ }
45
+ // 2. Check Ownership: Ensure the directory is owned by the current user.
46
+ if (stats.uid !== currentUserUid) {
47
+ console.error(`[MCP Daemon] Critical error: PID directory ${pidDir} is not owned by the current user (Expected: ${currentUserUid}, Found: ${stats.uid}). Possible tampering.`);
48
+ process.exit(1);
49
+ }
50
+ // 3. Check Permissions: Ensure the directory is not group or world-writable.
51
+ // Mode is a number, e.g., 0o700. We check if bits for group/world write are set.
52
+ const mode = stats.mode;
53
+ if (mode & constants.S_IWGRP || mode & constants.S_IWOTH) {
54
+ console.error(`[MCP Daemon] Critical error: PID directory ${pidDir} has insecure permissions (Mode: ${mode.toString(8)}). It should not be writable by group or others.`);
55
+ process.exit(1);
56
+ }
57
+ }
58
+ catch (statErr) {
59
+ console.error(`[MCP Daemon] Critical error stating PID directory ${pidDir}:`, statErr);
60
+ process.exit(1);
61
+ }
62
+ }
63
+ }
64
+ catch (err) {
65
+ console.error(`[MCP Daemon] Critical error creating/validating PID directory: ${pidDir}`, err);
66
+ process.exit(1);
67
+ }
68
+ let fd = -1;
69
+ try {
70
+ // Open the file with flags to:
71
+ // - O_WRONLY: Write-only
72
+ // - O_CREAT: Create if it doesn't exist
73
+ // - O_TRUNC: Truncate to zero length if it exists
74
+ // - O_NOFOLLOW: DO NOT follow symlinks.
75
+ // - 0o600: Permissions: read/write for owner, no permissions for others.
76
+ fd = openSync(pidFilePath, constants.O_WRONLY |
77
+ constants.O_CREAT |
78
+ constants.O_TRUNC |
79
+ constants.O_NOFOLLOW, 0o600);
80
+ writeSync(fd, process.pid.toString());
81
+ }
82
+ catch (err) {
83
+ console.error(`[MCP Daemon] Critical error writing PID file: ${pidFilePath}`, err);
84
+ // If openSync fails due to O_NOFOLLOW on a symlink, the error will be caught here.
85
+ process.exit(1);
86
+ }
87
+ finally {
88
+ if (fd !== -1) {
89
+ try {
90
+ closeSync(fd);
91
+ }
92
+ catch (err) {
93
+ console.error(`[MCP Daemon] Error closing PID file: ${pidFilePath}`, err);
94
+ }
95
+ }
96
+ }
97
+ logger?.(`Writing ${process.pid.toString()} to ${pidFilePath}`);
98
+ const socketPath = getSocketPath(sessionId);
99
+ const startDate = new Date();
100
+ const mcpServerArgs = process.argv.slice(2);
101
+ let mcpServer = null;
102
+ let server = null;
103
+ async function setupMCPServer() {
104
+ logger?.(`Starting Chrome DevTools MCP Server v${VERSION}`);
105
+ const configParser = new ConfigParser(VERSION);
106
+ const serverConfig = configParser.parseConfig();
107
+ const args = serverConfig.resolved;
108
+ const logFile = args.logFile ? saveLogsToFile(args.logFile) : undefined;
109
+ const browserManager = new BrowserManager(serverConfig, {
110
+ logFile,
111
+ });
112
+ mcpServer = await McpServer.from(serverConfig, {
113
+ browserManager,
114
+ logFile,
115
+ });
116
+ if (args.watchConfig) {
117
+ mcpServer.watchConfig();
118
+ }
119
+ ClearcutLogger.get()?.setClientName(DAEMON_CLIENT_NAME);
120
+ void ClearcutLogger.get()?.logDailyActiveIfNeeded();
121
+ void ClearcutLogger.get()?.logServerStart(computeFlagUsage(args, mcpOptions));
122
+ }
123
+ async function handleRequest(msg) {
124
+ try {
125
+ if (msg.method === 'invoke_tool') {
126
+ await started;
127
+ if (!mcpServer) {
128
+ throw new Error('MCP server not initialized');
129
+ }
130
+ const { tool, args } = msg;
131
+ const result = await mcpServer.callTool(tool, args);
132
+ return {
133
+ success: true,
134
+ result: JSON.stringify(result),
135
+ };
136
+ }
137
+ if (msg.method === 'stop') {
138
+ // Ensure we are not interrupting in-progress starting.
139
+ await started;
140
+ // Trigger cleanup asynchronously.
141
+ setImmediate(() => {
142
+ void cleanup();
143
+ });
144
+ return {
145
+ success: true,
146
+ message: 'stopping',
147
+ };
148
+ }
149
+ if (msg.method === 'status') {
150
+ await started;
151
+ const statusResult = {
152
+ pid: process.pid,
153
+ socketPath,
154
+ startDate: startDate.toISOString(),
155
+ version: VERSION,
156
+ args: mcpServerArgs,
157
+ };
158
+ return {
159
+ success: true,
160
+ result: JSON.stringify(statusResult),
161
+ };
162
+ }
163
+ {
164
+ return {
165
+ success: false,
166
+ error: `Unknown method: ${JSON.stringify(msg, null, 2)}`,
167
+ };
168
+ }
169
+ }
170
+ catch (error) {
171
+ const errorMessage = error instanceof Error ? error.message : String(error);
172
+ return {
173
+ success: false,
174
+ error: errorMessage,
175
+ };
176
+ }
177
+ }
178
+ async function startSocketServer() {
179
+ // Remove existing socket file if it exists (only on non-Windows)
180
+ if (!IS_WINDOWS) {
181
+ try {
182
+ fs.unlinkSync(socketPath);
183
+ }
184
+ catch {
185
+ // ignore errors.
186
+ }
187
+ }
188
+ return await new Promise((resolve, reject) => {
189
+ server = createServer(socket => {
190
+ const transport = new PipeTransport(socket, socket, puppeteerLogger);
191
+ transport.onmessage = async (message) => {
192
+ logger?.('onmessage', message);
193
+ const response = await handleRequest(JSON.parse(message));
194
+ transport.send(JSON.stringify(response));
195
+ socket.end();
196
+ };
197
+ socket.on('error', error => {
198
+ logger?.('Socket error:', error);
199
+ });
200
+ });
201
+ server.listen({
202
+ path: socketPath,
203
+ readableAll: false,
204
+ writableAll: false,
205
+ }, async () => {
206
+ console.log(`Daemon server listening on ${socketPath}`);
207
+ try {
208
+ await setupMCPServer();
209
+ resolve();
210
+ }
211
+ catch (err) {
212
+ reject(err);
213
+ }
214
+ });
215
+ server.on('error', error => {
216
+ logger?.('Server error:', error);
217
+ reject(error);
218
+ });
219
+ });
220
+ }
221
+ let isCleaningUp = false;
222
+ async function cleanup(exitCode = 0) {
223
+ if (isCleaningUp) {
224
+ return;
225
+ }
226
+ isCleaningUp = true;
227
+ console.log('Cleaning up daemon...');
228
+ try {
229
+ await mcpServer?.close();
230
+ }
231
+ catch (error) {
232
+ logger?.('Error closing MCP server:', error);
233
+ }
234
+ const activeServer = server;
235
+ if (activeServer) {
236
+ await new Promise(resolve => {
237
+ activeServer.close(() => resolve());
238
+ });
239
+ }
240
+ if (!IS_WINDOWS) {
241
+ try {
242
+ fs.unlinkSync(socketPath);
243
+ }
244
+ catch {
245
+ // ignore errors
246
+ }
247
+ }
248
+ logger?.(`unlinking ${pidFilePath}`);
249
+ try {
250
+ fs.unlinkSync(pidFilePath);
251
+ }
252
+ catch {
253
+ // ignore errors
254
+ }
255
+ process.exit(exitCode);
256
+ }
257
+ // Handle shutdown signals
258
+ process.on('SIGTERM', () => {
259
+ void cleanup();
260
+ });
261
+ process.on('SIGINT', () => {
262
+ void cleanup();
263
+ });
264
+ process.on('SIGHUP', () => {
265
+ void cleanup();
266
+ });
267
+ // Handle uncaught errors
268
+ process.on('uncaughtException', error => {
269
+ logger?.('Uncaught exception:', error);
270
+ void cleanup(1);
271
+ });
272
+ setupUnhandledRejectionHandler(() => {
273
+ void cleanup(1);
274
+ });
275
+ // Start the server
276
+ const started = startSocketServer().catch(error => {
277
+ logger?.('Failed to start daemon server:', error);
278
+ void cleanup(1);
279
+ });
280
+ //# sourceMappingURL=daemon.js.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map