@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.
- package/LICENSE +202 -0
- package/README.md +223 -2
- package/out/Default/gen/src/ArcBrowser.js +128 -0
- package/out/Default/gen/src/BrowserManager.js +562 -0
- package/out/Default/gen/src/LogpointManager.js +287 -0
- package/out/Default/gen/src/McpContext.js +1031 -0
- package/out/Default/gen/src/McpPage.js +1427 -0
- package/out/Default/gen/src/McpResponse.js +1350 -0
- package/out/Default/gen/src/McpWorker.js +66 -0
- package/out/Default/gen/src/NetworkOverrideManager.js +447 -0
- package/out/Default/gen/src/SlimMcpResponse.js +23 -0
- package/out/Default/gen/src/TextSnapshot.js +336 -0
- package/out/Default/gen/src/ToolHandler.js +531 -0
- package/out/Default/gen/src/bin/check-latest-version.js +53 -0
- package/out/Default/gen/src/bin/chrome-devtools-mcp-main.js +80 -0
- package/out/Default/gen/src/bin/chrome-devtools-mcp.js +23 -0
- package/out/Default/gen/src/bin/chrome-devtools.js +213 -0
- package/out/Default/gen/src/collectors/PageCollector.js +325 -0
- package/out/Default/gen/src/collectors/ServiceWorkerCollector.js +198 -0
- package/out/Default/gen/src/collectors/constants.js +7 -0
- package/out/Default/gen/src/config/ConfigLocator.js +70 -0
- package/out/Default/gen/src/config/ConfigParser.js +163 -0
- package/out/Default/gen/src/config/ConfigWatcher.js +94 -0
- package/out/Default/gen/src/config/ServerConfig.js +284 -0
- package/out/Default/gen/src/config/browser-options.js +135 -0
- package/out/Default/gen/src/config/category-options.js +84 -0
- package/out/Default/gen/src/config/cli-commands.js +208 -0
- package/out/Default/gen/src/config/cli-options.js +2090 -0
- package/out/Default/gen/src/config/mcp-options.js +371 -0
- package/out/Default/gen/src/config/puppeteer-options.js +69 -0
- package/out/Default/gen/src/config/tool-options.js +60 -0
- package/out/Default/gen/src/daemon/client.js +281 -0
- package/out/Default/gen/src/daemon/daemon.js +280 -0
- package/out/Default/gen/src/daemon/types.js +7 -0
- package/out/Default/gen/src/daemon/utils.js +173 -0
- package/out/Default/gen/src/devtools/DevToolsCommentBridge.js +151 -0
- package/out/Default/gen/src/devtools/DevtoolsUtils.js +413 -0
- package/out/Default/gen/src/devtools/McpHostBindingAdapter.js +164 -0
- package/out/Default/gen/src/devtools/issueDescriptions.js +42 -0
- package/out/Default/gen/src/formatters/CommentFormatter.js +73 -0
- package/out/Default/gen/src/formatters/ConsoleFormatter.js +363 -0
- package/out/Default/gen/src/formatters/CssFormatter.js +883 -0
- package/out/Default/gen/src/formatters/HeapSnapshotFormatter.js +239 -0
- package/out/Default/gen/src/formatters/IssueFormatter.js +194 -0
- package/out/Default/gen/src/formatters/LogpointFormatter.js +62 -0
- package/out/Default/gen/src/formatters/NetworkFormatter.js +295 -0
- package/out/Default/gen/src/formatters/NetworkOverridesFormatter.js +57 -0
- package/out/Default/gen/src/formatters/RemoteObjectFormatter.js +231 -0
- package/out/Default/gen/src/formatters/SnapshotFormatter.js +172 -0
- package/out/Default/gen/src/formatters/WebAuthnFormatter.js +56 -0
- package/out/Default/gen/src/formatters/constants.js +8 -0
- package/out/Default/gen/src/index.js +434 -0
- package/out/Default/gen/src/processors/ChunkedTraceParser.js +361 -0
- package/out/Default/gen/src/processors/HeapSnapshotManager.js +595 -0
- package/out/Default/gen/src/processors/PerformanceTrace.js +132 -0
- package/out/Default/gen/src/telemetry/ClearcutLogger.js +271 -0
- package/out/Default/gen/src/telemetry/WatchdogClient.js +60 -0
- package/out/Default/gen/src/telemetry/errors.js +18 -0
- package/out/Default/gen/src/telemetry/flagUtils.js +89 -0
- package/out/Default/gen/src/telemetry/metricsRegistry.js +85 -0
- package/out/Default/gen/src/telemetry/persistence.js +82 -0
- package/out/Default/gen/src/telemetry/transformation.js +229 -0
- package/out/Default/gen/src/telemetry/types.js +36 -0
- package/out/Default/gen/src/telemetry/watchdog/ClearcutSender.js +213 -0
- package/out/Default/gen/src/telemetry/watchdog/main.js +142 -0
- package/out/Default/gen/src/third_party/THIRD_PARTY_NOTICES +3774 -0
- package/out/Default/gen/src/third_party/browser.js +808 -0
- package/out/Default/gen/src/third_party/bundled-packages.json +11 -0
- package/out/Default/gen/src/third_party/cli.js +139 -0
- package/out/Default/gen/src/third_party/devtools-formatter-worker.js +125 -0
- package/out/Default/gen/src/third_party/devtools-heap-snapshot-worker.js +111 -0
- package/out/Default/gen/src/third_party/index.js +128 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CoepCoopSandboxedIframeCannotNavigateToCoopPage.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +18 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +10 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/LowTextContrast.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorRead.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/bounceTrackingMitigations.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/clientHintMetaTagAllowListInvalidOrigin.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/clientHintMetaTagModifiedHTML.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistEmbeddingRequirementNotSatisfied.md +26 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistIFrameAttributeLoosensEmbeddingRequirement.md +19 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowConnectionAllowlistFrom.md +21 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +10 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeDomainNonAscii.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutRead.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnDomainNonAscii.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantReadOptOut.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnMetadataGrantSetOptOut.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutSet.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsDisabledScheme.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsDisallowedByMode.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +19 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsOriginMismatch.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cspEvalViolation.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cspInlineViolation.md +10 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/cspURLViolation.md +10 -0
- package/out/Default/gen/src/third_party/issue-descriptions/deprecation.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsEmptyList.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidContentType.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestAccountsNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestDnsFetchFailed.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidContentType.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestInvalidEmail.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestJwksHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestJwksInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidAudience.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidIssuedAt.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidNonce.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidSdHash.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidTyp.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingAud.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingCnf.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingIat.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingNonce.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingSdHash.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbSignatureFailed.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmail.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmailVerified.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidHolderKey.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuedAt.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuer.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtJwksMissingKeys.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingCnf.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingEmail.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIat.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIss.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtSignatureFailed.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtUnsupportedHeaderAlg.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestUserLoggedOut.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsBlockedByConnectionAllowlist.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestConfigBlockedByConnectionAllowlist.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenBlockedByConnectionAllowlist.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthRequestWellKnownBlockedByConnectionAllowlist.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericBackUINavigationWouldSkipAd.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormLabelForNameError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextMissingToolDescription.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextMissingToolName.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextParameterMissingName.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextParameterMissingTitleAndDescription.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericFormModelContextRequiredParameterMissingName.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericGeolocationPromptWithoutUserGesture.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/genericResponseWasBlockedByORB.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/heavyAd.md +10 -0
- package/out/Default/gen/src/third_party/issue-descriptions/lazyLoadImageZeroSize.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/mixedContent.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +9 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementCspFrameAncestorsMissing.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementGeolocationDeprecated.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidType.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementLowContrast.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementPermissionsPolicyBlocked.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementRegistrationFailed.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/propertyRuleInvalidNameIssue.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/propertyRuleIssue.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedArrayBuffer.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorDictionaryLoadFailure.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInsufficientResources.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidMatchField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidTTLField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNoMatchField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonIntegerTTLField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonListMatchDestField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonSecureContext.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringIdField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringInMatchDestList.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringMatchField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonTokenTypeField.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorRequestAborted.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorShuttingDown.md +1 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorTooLongIdField.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sharedDictionaryWriteErrorUnsupportedType.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +14 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +15 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +7 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +14 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +15 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +13 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +8 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +5 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +6 -0
- package/out/Default/gen/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +11 -0
- package/out/Default/gen/src/third_party/issue-descriptions/stylesheetLateImport.md +4 -0
- package/out/Default/gen/src/third_party/issue-descriptions/stylesheetRequestFailed.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +12 -0
- package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +17 -0
- package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +14 -0
- package/out/Default/gen/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +15 -0
- package/out/Default/gen/src/third_party/issue-descriptions/webInstallManifestMissingId.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/webInstallManifestMissingNameOrShortName.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/webInstallManifestParsingOrNetworkError.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/webInstallNoManifest.md +3 -0
- package/out/Default/gen/src/third_party/issue-descriptions/webInstallStartUrlInvalid.md +3 -0
- package/out/Default/gen/src/third_party/lighthouse-devtools-mcp-bundle.js +60395 -0
- package/out/Default/gen/src/tools/ToolDefinition.js +180 -0
- package/out/Default/gen/src/tools/categories.js +37 -0
- package/out/Default/gen/src/tools/comments.js +230 -0
- package/out/Default/gen/src/tools/console.js +122 -0
- package/out/Default/gen/src/tools/css.js +54 -0
- package/out/Default/gen/src/tools/emulation.js +98 -0
- package/out/Default/gen/src/tools/extensions.js +108 -0
- package/out/Default/gen/src/tools/input.js +658 -0
- package/out/Default/gen/src/tools/lighthouse.js +279 -0
- package/out/Default/gen/src/tools/logpoints.js +51 -0
- package/out/Default/gen/src/tools/memory.js +531 -0
- package/out/Default/gen/src/tools/network.js +325 -0
- package/out/Default/gen/src/tools/pages.js +420 -0
- package/out/Default/gen/src/tools/performance.js +258 -0
- package/out/Default/gen/src/tools/pwa.js +152 -0
- package/out/Default/gen/src/tools/screencast.js +160 -0
- package/out/Default/gen/src/tools/screenshot.js +315 -0
- package/out/Default/gen/src/tools/script.js +319 -0
- package/out/Default/gen/src/tools/slim/tools.js +110 -0
- package/out/Default/gen/src/tools/snapshot.js +88 -0
- package/out/Default/gen/src/tools/thirdPartyDeveloper.js +73 -0
- package/out/Default/gen/src/tools/toolNames.js +10 -0
- package/out/Default/gen/src/tools/tools.js +72 -0
- package/out/Default/gen/src/tools/webauthn.js +51 -0
- package/out/Default/gen/src/tools/webmcp.js +55 -0
- package/out/Default/gen/src/types.js +21 -0
- package/out/Default/gen/src/utils/TaskRunner.js +151 -0
- package/out/Default/gen/src/utils/WaitForHelper.js +343 -0
- package/out/Default/gen/src/utils/bytes.js +95 -0
- package/out/Default/gen/src/utils/check-for-updates.js +81 -0
- package/out/Default/gen/src/utils/disclaimers.js +27 -0
- package/out/Default/gen/src/utils/errorHandling.js +23 -0
- package/out/Default/gen/src/utils/files.js +81 -0
- package/out/Default/gen/src/utils/id.js +16 -0
- package/out/Default/gen/src/utils/keyboard.js +307 -0
- package/out/Default/gen/src/utils/logger.js +145 -0
- package/out/Default/gen/src/utils/logpoint.js +44 -0
- package/out/Default/gen/src/utils/network.js +81 -0
- package/out/Default/gen/src/utils/pagination.js +50 -0
- package/out/Default/gen/src/utils/polyfill.js +11 -0
- package/out/Default/gen/src/utils/raceWithSignal.js +26 -0
- package/out/Default/gen/src/utils/resourceType.js +27 -0
- package/out/Default/gen/src/utils/text.js +43 -0
- package/out/Default/gen/src/utils/timeout.js +14 -0
- package/out/Default/gen/src/utils/url.js +311 -0
- package/out/Default/gen/src/version.js +11 -0
- package/package.json +125 -4
- package/skills/a11y-debugging/SKILL.md +86 -0
- package/skills/a11y-debugging/references/a11y-snippets.md +92 -0
- package/skills/arc-compatibility/SKILL.md +168 -0
- package/skills/arc-compatibility/SOURCES.md +216 -0
- package/skills/arc-compatibility/references/compatibility.md +113 -0
- package/skills/arc-compatibility/references/output-contract.md +62 -0
- package/skills/arc-compatibility/references/workflows.md +105 -0
- package/skills/chrome-devtools/SKILL.md +80 -0
- package/skills/chrome-devtools-cli/SKILL.md +208 -0
- package/skills/chrome-devtools-cli/references/installation.md +24 -0
- package/skills/cookie-debugging/SKILL.md +152 -0
- package/skills/debug-optimize-lcp/SKILL.md +121 -0
- package/skills/debug-optimize-lcp/references/elements-and-size.md +27 -0
- package/skills/debug-optimize-lcp/references/lcp-breakdown.md +23 -0
- package/skills/debug-optimize-lcp/references/lcp-snippets.md +79 -0
- package/skills/debug-optimize-lcp/references/optimization-strategies.md +38 -0
- package/skills/inspect-in-devtools/SKILL.md +82 -0
- package/skills/memory-leak-debugging/SKILL.md +58 -0
- package/skills/memory-leak-debugging/references/common-leaks.md +33 -0
- package/skills/troubleshooting/SKILL.md +107 -0
|
@@ -0,0 +1,1031 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
7
|
+
if (value !== null && value !== void 0) {
|
|
8
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
9
|
+
var dispose, inner;
|
|
10
|
+
if (async) {
|
|
11
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
12
|
+
dispose = value[Symbol.asyncDispose];
|
|
13
|
+
}
|
|
14
|
+
if (dispose === void 0) {
|
|
15
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
16
|
+
dispose = value[Symbol.dispose];
|
|
17
|
+
if (async) inner = dispose;
|
|
18
|
+
}
|
|
19
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
20
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
21
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
22
|
+
}
|
|
23
|
+
else if (async) {
|
|
24
|
+
env.stack.push({ async: true });
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
29
|
+
return function (env) {
|
|
30
|
+
function fail(e) {
|
|
31
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
32
|
+
env.hasError = true;
|
|
33
|
+
}
|
|
34
|
+
var r, s = 0;
|
|
35
|
+
function next() {
|
|
36
|
+
while (r = env.stack.pop()) {
|
|
37
|
+
try {
|
|
38
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
39
|
+
if (r.dispose) {
|
|
40
|
+
var result = r.dispose.call(r.value);
|
|
41
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
42
|
+
}
|
|
43
|
+
else s |= 1;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
fail(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
50
|
+
if (env.hasError) throw env.error;
|
|
51
|
+
}
|
|
52
|
+
return next();
|
|
53
|
+
};
|
|
54
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
55
|
+
var e = new Error(message);
|
|
56
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
57
|
+
});
|
|
58
|
+
import fs from 'node:fs/promises';
|
|
59
|
+
import os from 'node:os';
|
|
60
|
+
import path from 'node:path';
|
|
61
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
62
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
63
|
+
import { createArcPage } from './ArcBrowser.js';
|
|
64
|
+
import { overrideDevToolsGlobals } from './devtools/DevtoolsUtils.js';
|
|
65
|
+
import { McpPage } from './McpPage.js';
|
|
66
|
+
import { ServiceWorkerCollector } from './collectors/ServiceWorkerCollector.js';
|
|
67
|
+
import { Mutex } from './third_party/index.js';
|
|
68
|
+
import { Locator, } from './third_party/browser.js';
|
|
69
|
+
import { ToolCategory } from './tools/categories.js';
|
|
70
|
+
import { CLOSE_PAGE_ERROR, isCapabilityEnabled, } from './tools/ToolDefinition.js';
|
|
71
|
+
import { McpWorker } from './McpWorker.js';
|
|
72
|
+
import { fileUrlToPathWithPosixFallback, getTempFilePath, resolveCanonicalPath, } from './utils/files.js';
|
|
73
|
+
import { escapeForLog, redactUrlForLogging } from './utils/logger.js';
|
|
74
|
+
import { fetchWithValidatedRedirects, validateUrlNotBlocked, } from './utils/network.js';
|
|
75
|
+
import { isAllowedUrl } from './utils/url.js';
|
|
76
|
+
function hasOptionChanged(gate, previousArgs, nextArgs) {
|
|
77
|
+
return gate.options.some(option => !isDeepStrictEqual(nextArgs[option], previousArgs[option]));
|
|
78
|
+
}
|
|
79
|
+
const FEATURE_CONTROLLERS = [
|
|
80
|
+
{
|
|
81
|
+
gate: { options: ['blockedUrlPattern', 'allowedUrlPattern'] },
|
|
82
|
+
onChange: context => context.syncNetworkRestrictions(),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
gate: { options: ['sourceMaps'] },
|
|
86
|
+
onChange: context => context.syncSourceMaps(),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
gate: { options: ['experimentalIncludeAllPages'] },
|
|
90
|
+
onChange: context => context.createPagesSnapshot(),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
gate: { category: ToolCategory.DEBUGGING },
|
|
94
|
+
onDisable: context => context.releaseScreencasts(),
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
gate: { category: ToolCategory.MEMORY, conditions: ['memoryDebugging'] },
|
|
98
|
+
onDisable: context => context.releaseHeapSnapshots(),
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
gate: { category: ToolCategory.PERFORMANCE },
|
|
102
|
+
onDisable: context => context.releasePerformanceTrace(),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
gate: { category: ToolCategory.DEBUGGING, conditions: ['devtoolsComments'] },
|
|
106
|
+
onDisable: context => context.releaseDevToolsComments(),
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
// Page ids are handed out from a process-wide counter so they stay unique
|
|
110
|
+
// across all contexts, in particular across browser reconnects. An id issued
|
|
111
|
+
// before a reconnect then fails to resolve instead of hitting an unrelated
|
|
112
|
+
// page of the reconnected browser.
|
|
113
|
+
let nextPageId = 1;
|
|
114
|
+
export class McpContext {
|
|
115
|
+
logger;
|
|
116
|
+
#browser;
|
|
117
|
+
// Initialization of #browser, settles once its browser-dependent state is
|
|
118
|
+
// ready.
|
|
119
|
+
#browserReady;
|
|
120
|
+
// Whether a browser connection was established before, so that switching to
|
|
121
|
+
// a new browser surfaces a reconnect notice.
|
|
122
|
+
#hasConnected = false;
|
|
123
|
+
// Maps LLM-provided isolatedContext name → Puppeteer BrowserContext.
|
|
124
|
+
#isolatedContexts = new Map();
|
|
125
|
+
// Auto-generated name counter for when no name is provided.
|
|
126
|
+
#nextIsolatedContextId = 1;
|
|
127
|
+
// Cached McpWorker per target, reused across snapshots (mirrors #mcpPages) so
|
|
128
|
+
// referential identity holds and workers can carry per-worker state later.
|
|
129
|
+
#workers = new Map();
|
|
130
|
+
#mcpPages = new Map();
|
|
131
|
+
/**
|
|
132
|
+
* Queue for the browser-wide state (page list, selected page, trace
|
|
133
|
+
* state). Every page queue is a child of it, so a task on it waits for
|
|
134
|
+
* every page task and blocks later page tasks.
|
|
135
|
+
*/
|
|
136
|
+
taskQueue;
|
|
137
|
+
#taskRunner;
|
|
138
|
+
#pageTaskQueues = new Map();
|
|
139
|
+
/**
|
|
140
|
+
* Serializes `createPagesSnapshot()`. Two tasks on different page queues
|
|
141
|
+
* can call it at the same time.
|
|
142
|
+
*/
|
|
143
|
+
#pagesSnapshotMutex = new Mutex();
|
|
144
|
+
#selectedPage;
|
|
145
|
+
#selectedPageFallback;
|
|
146
|
+
#selectedPageFallbackRead = false;
|
|
147
|
+
#serviceWorkerCollector;
|
|
148
|
+
#reconnectNotice = false;
|
|
149
|
+
#traceResults = [];
|
|
150
|
+
#locatorClass;
|
|
151
|
+
#config;
|
|
152
|
+
#options;
|
|
153
|
+
#heapSnapshotManager;
|
|
154
|
+
#roots = undefined;
|
|
155
|
+
constructor(logger, options, locatorClass) {
|
|
156
|
+
overrideDevToolsGlobals({
|
|
157
|
+
loadResource: (url) => {
|
|
158
|
+
return this.loadResource(url);
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
this.logger = logger;
|
|
162
|
+
this.#locatorClass = locatorClass;
|
|
163
|
+
this.#taskRunner = options.taskRunner;
|
|
164
|
+
this.taskQueue = options.taskRunner.createQueue();
|
|
165
|
+
this.#config = options.config;
|
|
166
|
+
this.#options = options;
|
|
167
|
+
this.#heapSnapshotManager = options.heapSnapshotManager;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The browser of the current connection. Throws if no browser connection was
|
|
171
|
+
* established yet, see {@link McpContext.ensureBrowser}.
|
|
172
|
+
*/
|
|
173
|
+
get browser() {
|
|
174
|
+
if (!this.#browser) {
|
|
175
|
+
throw new Error('Not connected to a browser.');
|
|
176
|
+
}
|
|
177
|
+
return this.#browser;
|
|
178
|
+
}
|
|
179
|
+
#allMcpPages() {
|
|
180
|
+
const pages = new Set(this.#mcpPages.values());
|
|
181
|
+
if (this.#selectedPage) {
|
|
182
|
+
pages.add(this.#selectedPage);
|
|
183
|
+
}
|
|
184
|
+
return pages;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Synchronizes browser/page state and releases state of capabilities that
|
|
188
|
+
* transitioned from enabled to disabled after a config reload.
|
|
189
|
+
*/
|
|
190
|
+
async onConfigChanged(previousArgs) {
|
|
191
|
+
const nextArgs = this.#config.resolved;
|
|
192
|
+
for (const controller of FEATURE_CONTROLLERS) {
|
|
193
|
+
if ('onChange' in controller) {
|
|
194
|
+
if (hasOptionChanged(controller.gate, previousArgs, nextArgs)) {
|
|
195
|
+
await controller.onChange(this);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else if (isCapabilityEnabled(controller.gate, previousArgs) &&
|
|
199
|
+
!isCapabilityEnabled(controller.gate, nextArgs)) {
|
|
200
|
+
await controller.onDisable(this);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Applies updated URL allowlist/blocklist rules to the connected browser and
|
|
206
|
+
* clears incompatible page network throttling state.
|
|
207
|
+
*/
|
|
208
|
+
async syncNetworkRestrictions() {
|
|
209
|
+
const { blockedUrlPattern, allowedUrlPattern } = this.#config.resolved;
|
|
210
|
+
if (blockedUrlPattern || allowedUrlPattern) {
|
|
211
|
+
for (const mcpPage of this.#allMcpPages()) {
|
|
212
|
+
await mcpPage.clearNetworkConditions();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (this.#browser) {
|
|
216
|
+
await this.#browser.restrictNetwork({
|
|
217
|
+
blocklist: blockedUrlPattern,
|
|
218
|
+
allowlist: allowedUrlPattern,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Synchronizes the DevTools source maps setting across all pages.
|
|
224
|
+
*/
|
|
225
|
+
syncSourceMaps() {
|
|
226
|
+
for (const mcpPage of this.#allMcpPages()) {
|
|
227
|
+
mcpPage.syncSourceMaps();
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Stops and saves active screencast recordings across all pages when
|
|
232
|
+
* screencast tools are disabled.
|
|
233
|
+
*/
|
|
234
|
+
async releaseScreencasts() {
|
|
235
|
+
for (const mcpPage of this.#allMcpPages()) {
|
|
236
|
+
const screenRecorderData = mcpPage.getScreenRecorder();
|
|
237
|
+
if (!screenRecorderData) {
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
const { recorder, filePath } = screenRecorderData;
|
|
241
|
+
mcpPage.setScreenRecorder(null);
|
|
242
|
+
try {
|
|
243
|
+
await recorder.stop();
|
|
244
|
+
this.logger?.(`The screencast recording was stopped and saved to ${filePath} because screencast tools were disabled.`);
|
|
245
|
+
}
|
|
246
|
+
catch (err) {
|
|
247
|
+
this.logger?.('Failed to stop the screencast recording', err);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Closes all loaded heap snapshots when memory tools are disabled.
|
|
253
|
+
*/
|
|
254
|
+
releaseHeapSnapshots() {
|
|
255
|
+
if (this.#heapSnapshotManager.hasSnapshots()) {
|
|
256
|
+
this.#heapSnapshotManager.dispose();
|
|
257
|
+
this.logger?.('Loaded heap snapshots were closed because memory tools were disabled.');
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Discards recorded performance traces and stops any running trace when
|
|
262
|
+
* performance tools are disabled.
|
|
263
|
+
*/
|
|
264
|
+
async releasePerformanceTrace() {
|
|
265
|
+
this.#traceResults = [];
|
|
266
|
+
for (const mcpPage of this.#allMcpPages()) {
|
|
267
|
+
if (!mcpPage.isRunningPerformanceTrace()) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
mcpPage.setIsRunningPerformanceTrace(false);
|
|
271
|
+
try {
|
|
272
|
+
await mcpPage.pptrPage.tracing.stop();
|
|
273
|
+
}
|
|
274
|
+
catch (err) {
|
|
275
|
+
this.logger?.('Failed to stop the performance trace', err);
|
|
276
|
+
}
|
|
277
|
+
this.logger?.('The running performance trace was discarded because performance tools were disabled.');
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Disposes DevTools comment bridges across all pages when DevTools comment
|
|
282
|
+
* tools are disabled.
|
|
283
|
+
*/
|
|
284
|
+
releaseDevToolsComments() {
|
|
285
|
+
for (const mcpPage of this.#allMcpPages()) {
|
|
286
|
+
mcpPage.disposeCommentBridge();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Returns the browser, establishing the connection if needed. If the browser
|
|
291
|
+
* changed since the last call (e.g. after a reconnect), all
|
|
292
|
+
* browser-dependent state is rebuilt for the new browser.
|
|
293
|
+
*/
|
|
294
|
+
async ensureBrowser() {
|
|
295
|
+
const browser = await this.#options.getBrowser();
|
|
296
|
+
if (browser === this.#browser && this.#browserReady) {
|
|
297
|
+
// Joins a still pending initialization instead of handing out
|
|
298
|
+
// half-initialized state.
|
|
299
|
+
await this.#browserReady;
|
|
300
|
+
return browser;
|
|
301
|
+
}
|
|
302
|
+
this.#resetBrowserState();
|
|
303
|
+
this.#browser = browser;
|
|
304
|
+
const ready = this.#initBrowserState(browser);
|
|
305
|
+
this.#browserReady = ready;
|
|
306
|
+
try {
|
|
307
|
+
await ready;
|
|
308
|
+
return browser;
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
// Leave no half-initialized state behind, the next call starts over. If
|
|
312
|
+
// a later call already installed another browser, its state is left
|
|
313
|
+
// intact.
|
|
314
|
+
if (this.#browserReady === ready) {
|
|
315
|
+
this.#resetBrowserState();
|
|
316
|
+
}
|
|
317
|
+
throw err;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
async #initBrowserState(browser) {
|
|
321
|
+
const collector = new ServiceWorkerCollector(browser);
|
|
322
|
+
this.#serviceWorkerCollector = collector;
|
|
323
|
+
// All listeners are registered synchronously, before the first await. If
|
|
324
|
+
// this call hangs and is abandoned by the tool-call timeout, a later call
|
|
325
|
+
// that installs a different browser removes them in #resetBrowserState().
|
|
326
|
+
browser.on('targetcreated', this.#onTargetCreated);
|
|
327
|
+
browser.on('targetdestroyed', this.#onTargetDestroyed);
|
|
328
|
+
await Promise.all([
|
|
329
|
+
collector.init(this.createWorkersSnapshot()),
|
|
330
|
+
this.createPagesSnapshot(),
|
|
331
|
+
]);
|
|
332
|
+
// The state now belongs to the browser of a later call, leave it intact.
|
|
333
|
+
if (this.#browser !== browser) {
|
|
334
|
+
throw new Error('Browser was replaced while initializing.');
|
|
335
|
+
}
|
|
336
|
+
if (this.#hasConnected) {
|
|
337
|
+
this.#reconnectNotice = true;
|
|
338
|
+
}
|
|
339
|
+
this.#hasConnected = true;
|
|
340
|
+
}
|
|
341
|
+
#resetBrowserState() {
|
|
342
|
+
this.#browser?.off('targetcreated', this.#onTargetCreated);
|
|
343
|
+
this.#browser?.off('targetdestroyed', this.#onTargetDestroyed);
|
|
344
|
+
this.#serviceWorkerCollector?.dispose();
|
|
345
|
+
for (const mcpPage of this.#allMcpPages()) {
|
|
346
|
+
this.#disposeMcpPage(mcpPage);
|
|
347
|
+
}
|
|
348
|
+
this.#mcpPages.clear();
|
|
349
|
+
this.#workers.clear();
|
|
350
|
+
// Isolated contexts are intentionally not closed here.
|
|
351
|
+
// Either the entire browser will be closed or we disconnect
|
|
352
|
+
// without destroying browser state.
|
|
353
|
+
this.#isolatedContexts.clear();
|
|
354
|
+
this.#nextIsolatedContextId = 1;
|
|
355
|
+
this.#selectedPage = undefined;
|
|
356
|
+
this.#selectedPageFallback = undefined;
|
|
357
|
+
this.#selectedPageFallbackRead = false;
|
|
358
|
+
this.#traceResults = [];
|
|
359
|
+
this.#serviceWorkerCollector = undefined;
|
|
360
|
+
this.#browser = undefined;
|
|
361
|
+
this.#browserReady = undefined;
|
|
362
|
+
}
|
|
363
|
+
dispose() {
|
|
364
|
+
this.#resetBrowserState();
|
|
365
|
+
}
|
|
366
|
+
#onTargetCreated = (target) => {
|
|
367
|
+
try {
|
|
368
|
+
if (!this.#isPageTarget(target)) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
this.#createMcpPage(target);
|
|
372
|
+
}
|
|
373
|
+
catch (err) {
|
|
374
|
+
this.logger?.('Error handling targetcreated', err);
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
#onTargetDestroyed = (target) => {
|
|
378
|
+
try {
|
|
379
|
+
const mcpPage = this.#mcpPages.get(target);
|
|
380
|
+
if (mcpPage) {
|
|
381
|
+
this.#disposeMcpPage(mcpPage);
|
|
382
|
+
this.#mcpPages.delete(target);
|
|
383
|
+
}
|
|
384
|
+
this.#workers.delete(target);
|
|
385
|
+
}
|
|
386
|
+
catch (err) {
|
|
387
|
+
this.logger?.('Error handling targetdestroyed', err);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
static create(logger, opts,
|
|
391
|
+
/* Let tests use unbundled Locator class to avoid overly strict checks within puppeteer that fail when mixing bundled and unbundled class instances */
|
|
392
|
+
locatorClass = Locator) {
|
|
393
|
+
return new McpContext(logger, opts, locatorClass);
|
|
394
|
+
}
|
|
395
|
+
static resetPageIdsForTesting() {
|
|
396
|
+
nextPageId = 1;
|
|
397
|
+
}
|
|
398
|
+
static resetWorkerIdsForTesting() {
|
|
399
|
+
McpWorker.resetIdsForTesting();
|
|
400
|
+
}
|
|
401
|
+
roots() {
|
|
402
|
+
return [
|
|
403
|
+
...(this.#roots ?? []),
|
|
404
|
+
{
|
|
405
|
+
uri: pathToFileURL(os.tmpdir()).href,
|
|
406
|
+
name: 'temp',
|
|
407
|
+
},
|
|
408
|
+
];
|
|
409
|
+
}
|
|
410
|
+
setRoots(roots) {
|
|
411
|
+
this.#roots = roots;
|
|
412
|
+
}
|
|
413
|
+
async validatePath(filePath) {
|
|
414
|
+
if (filePath === undefined) {
|
|
415
|
+
return undefined;
|
|
416
|
+
}
|
|
417
|
+
let canonicalPath;
|
|
418
|
+
try {
|
|
419
|
+
canonicalPath = await resolveCanonicalPath(filePath);
|
|
420
|
+
}
|
|
421
|
+
catch (err) {
|
|
422
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
423
|
+
console.error(`[MCP Context] Error resolving real path for ${escapeForLog(filePath)}: ${escapeForLog(errMsg)}`);
|
|
424
|
+
throw new Error(`Access denied: Cannot resolve base path for ${escapeForLog(filePath)}.`);
|
|
425
|
+
}
|
|
426
|
+
// If the client never negotiated roots and the operator has explicitly
|
|
427
|
+
// opted into unrestricted access via --allow-unrestricted-paths, restore
|
|
428
|
+
// the previous permissive behavior and skip validation.
|
|
429
|
+
if (this.#roots === undefined &&
|
|
430
|
+
this.#config.resolved.allowUnrestrictedPaths) {
|
|
431
|
+
// Canonical path might not exist yet so we fallback to
|
|
432
|
+
// path.resolve(filePath). Consumers should not follow symlinks.
|
|
433
|
+
return canonicalPath || path.resolve(filePath);
|
|
434
|
+
}
|
|
435
|
+
// roots() always returns at least the temp directory, even if the
|
|
436
|
+
// connecting client never negotiated the optional `roots` capability.
|
|
437
|
+
// Path validation must not be skipped just because no workspace roots
|
|
438
|
+
// were configured.
|
|
439
|
+
const roots = this.roots();
|
|
440
|
+
let allowed = false;
|
|
441
|
+
const resolvedRoots = await Promise.allSettled(roots.map(async (root) => {
|
|
442
|
+
const rootPathUri = root.uri;
|
|
443
|
+
const rootPath = path.resolve(fileUrlToPathWithPosixFallback(rootPathUri));
|
|
444
|
+
return await fs.realpath(rootPath);
|
|
445
|
+
}));
|
|
446
|
+
for (let i = 0; i < roots.length; i++) {
|
|
447
|
+
const root = roots[i];
|
|
448
|
+
const result = resolvedRoots[i];
|
|
449
|
+
if (result.status === 'fulfilled') {
|
|
450
|
+
const canonicalRoot = result.value;
|
|
451
|
+
// A filesystem root such as `/` or `C:\` already ends with the
|
|
452
|
+
// separator; appending another one would match no path below it.
|
|
453
|
+
const rootPrefix = canonicalRoot.endsWith(path.sep)
|
|
454
|
+
? canonicalRoot
|
|
455
|
+
: canonicalRoot + path.sep;
|
|
456
|
+
if (canonicalPath === canonicalRoot ||
|
|
457
|
+
canonicalPath.startsWith(rootPrefix)) {
|
|
458
|
+
allowed = true;
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
const rootErr = result.reason;
|
|
464
|
+
const errMsg = rootErr instanceof Error ? rootErr.message : String(rootErr);
|
|
465
|
+
console.warn(`[MCP Context] Could not resolve configured root ${escapeForLog(root.uri)}: ${escapeForLog(errMsg)}`);
|
|
466
|
+
// Skip this root if it cannot be resolved.
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (!allowed) {
|
|
470
|
+
throw new Error(`Access denied: path ${escapeForLog(filePath)} (canonical: ${escapeForLog(canonicalPath)}) is not within any of the configured workspace roots.`);
|
|
471
|
+
}
|
|
472
|
+
return canonicalPath || path.resolve(filePath);
|
|
473
|
+
}
|
|
474
|
+
async ensureExtension(filePath, extension) {
|
|
475
|
+
const resolved = await this.validatePath(filePath);
|
|
476
|
+
const currentExtension = path.extname(resolved);
|
|
477
|
+
const outputPath = `${resolved.slice(0, resolved.length - currentExtension.length)}${extension}`;
|
|
478
|
+
return outputPath;
|
|
479
|
+
}
|
|
480
|
+
async newPage(background, isolatedContextName) {
|
|
481
|
+
const browser = this.browser;
|
|
482
|
+
let page;
|
|
483
|
+
if (this.#config.resolved.arc) {
|
|
484
|
+
page = await createArcPage(browser, { background, isolatedContextName });
|
|
485
|
+
if (this.#browser !== browser || !browser.connected) {
|
|
486
|
+
await page.close().catch(() => { });
|
|
487
|
+
throw new Error('Arc connection changed while creating a tab.');
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
else if (isolatedContextName !== undefined) {
|
|
491
|
+
let ctx = this.#isolatedContexts.get(isolatedContextName);
|
|
492
|
+
if (!ctx) {
|
|
493
|
+
ctx = await this.browser.createBrowserContext();
|
|
494
|
+
this.#isolatedContexts.set(isolatedContextName, ctx);
|
|
495
|
+
}
|
|
496
|
+
page = await ctx.newPage({ background });
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
page = await this.browser.newPage({ background });
|
|
500
|
+
}
|
|
501
|
+
const mcpPage = this.#createMcpPage(page.target());
|
|
502
|
+
await mcpPage.init({ emulateFocus: true });
|
|
503
|
+
this.selectPage(mcpPage);
|
|
504
|
+
await this.createPagesSnapshot();
|
|
505
|
+
return mcpPage;
|
|
506
|
+
}
|
|
507
|
+
async closePage(pageId) {
|
|
508
|
+
const page = this.getPageById(pageId);
|
|
509
|
+
if (this.#mcpPages.size === 1) {
|
|
510
|
+
throw new Error(CLOSE_PAGE_ERROR);
|
|
511
|
+
}
|
|
512
|
+
this.#mcpPages.delete(page.target);
|
|
513
|
+
await page.close();
|
|
514
|
+
}
|
|
515
|
+
async installPWA(options) {
|
|
516
|
+
try {
|
|
517
|
+
return await this.browser.installPWA(options);
|
|
518
|
+
}
|
|
519
|
+
catch (error) {
|
|
520
|
+
if (error instanceof Error &&
|
|
521
|
+
error.message.includes("Couldn't fetch install info")) {
|
|
522
|
+
return await this.browser.installPWA(options);
|
|
523
|
+
}
|
|
524
|
+
throw error;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
uninstallPWA(options) {
|
|
528
|
+
return this.browser.uninstallPWA(options);
|
|
529
|
+
}
|
|
530
|
+
async launchPWA(options) {
|
|
531
|
+
const page = await this.browser.launchPWA(options);
|
|
532
|
+
if (!page.url() || page.url() === 'about:blank') {
|
|
533
|
+
await page
|
|
534
|
+
.waitForNavigation({
|
|
535
|
+
timeout: this.#options.navigationTimeout ?? 10_000,
|
|
536
|
+
})
|
|
537
|
+
.catch(() => {
|
|
538
|
+
// Ignore timeout if navigation already completed or failed.
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
return page;
|
|
542
|
+
}
|
|
543
|
+
getPWAState(options) {
|
|
544
|
+
return this.browser.getPWAState(options);
|
|
545
|
+
}
|
|
546
|
+
isRunningPerformanceTrace() {
|
|
547
|
+
for (const mcpPage of this.#allMcpPages()) {
|
|
548
|
+
if (mcpPage.isRunningPerformanceTrace()) {
|
|
549
|
+
return true;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return false;
|
|
553
|
+
}
|
|
554
|
+
isCruxEnabled() {
|
|
555
|
+
return this.#config.resolved.performanceCrux;
|
|
556
|
+
}
|
|
557
|
+
getPages() {
|
|
558
|
+
return Array.from(this.#mcpPages.values());
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Fetches current target info for all targets from the browser, keyed by
|
|
562
|
+
* target id. Unlike Puppeteer's cached target info, this reflects title
|
|
563
|
+
* changes, which Chrome does not report via `Target.targetInfoChanged`.
|
|
564
|
+
* Returns an empty map if the browser cannot be queried.
|
|
565
|
+
*/
|
|
566
|
+
async getTargetInfos() {
|
|
567
|
+
try {
|
|
568
|
+
// @ts-expect-error use existing browser connection (internal Puppeteer API).
|
|
569
|
+
const connection = this.browser._connection;
|
|
570
|
+
const { targetInfos } = await connection.send('Target.getTargets');
|
|
571
|
+
return new Map(targetInfos.map(info => [info.targetId, info]));
|
|
572
|
+
}
|
|
573
|
+
catch (err) {
|
|
574
|
+
this.logger?.('Failed to fetch target infos', err);
|
|
575
|
+
return new Map();
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
getSelectedMcpPage() {
|
|
579
|
+
const page = this.#selectedPage;
|
|
580
|
+
if (!page) {
|
|
581
|
+
throw new Error('No page selected');
|
|
582
|
+
}
|
|
583
|
+
if (page.isClosed()) {
|
|
584
|
+
throw new Error('The selected page has been closed. Call list_pages to see open pages.');
|
|
585
|
+
}
|
|
586
|
+
return page;
|
|
587
|
+
}
|
|
588
|
+
getSelectedMcpPageUrl(page) {
|
|
589
|
+
let targetPage = page;
|
|
590
|
+
if (!targetPage) {
|
|
591
|
+
try {
|
|
592
|
+
targetPage = this.getSelectedMcpPage();
|
|
593
|
+
}
|
|
594
|
+
catch {
|
|
595
|
+
return undefined;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
if (targetPage && !targetPage.isClosed()) {
|
|
599
|
+
return targetPage.url();
|
|
600
|
+
}
|
|
601
|
+
return undefined;
|
|
602
|
+
}
|
|
603
|
+
async getDevToolsData(page) {
|
|
604
|
+
const targetPage = page ?? this.#selectedPage;
|
|
605
|
+
if (!targetPage) {
|
|
606
|
+
return undefined;
|
|
607
|
+
}
|
|
608
|
+
let timeoutId;
|
|
609
|
+
const timeoutPromise = new Promise(resolve => {
|
|
610
|
+
timeoutId = setTimeout(() => resolve(undefined), 500);
|
|
611
|
+
});
|
|
612
|
+
const dataPromise = targetPage.getDevToolsData();
|
|
613
|
+
try {
|
|
614
|
+
return await Promise.race([dataPromise, timeoutPromise]);
|
|
615
|
+
}
|
|
616
|
+
catch {
|
|
617
|
+
return undefined;
|
|
618
|
+
}
|
|
619
|
+
finally {
|
|
620
|
+
clearTimeout(timeoutId);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Returns true once after the browser connection was re-established with a
|
|
625
|
+
* new browser, so the next response can surface a note. Cleared on first
|
|
626
|
+
* call.
|
|
627
|
+
*/
|
|
628
|
+
consumeReconnectNotice() {
|
|
629
|
+
const notice = this.#reconnectNotice;
|
|
630
|
+
this.#reconnectNotice = false;
|
|
631
|
+
return notice;
|
|
632
|
+
}
|
|
633
|
+
getPageById(pageId) {
|
|
634
|
+
const page = this.#mcpPages.values().find(mcpPage => mcpPage.id === pageId);
|
|
635
|
+
if (!page) {
|
|
636
|
+
throw new Error('No page found');
|
|
637
|
+
}
|
|
638
|
+
return page;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* The queue for tasks on page `pageId`. The queue exists before the page
|
|
642
|
+
* does, so a tool call can enter it before the browser connects. It is a
|
|
643
|
+
* child of {@link taskQueue}.
|
|
644
|
+
*/
|
|
645
|
+
pageTaskQueue(pageId) {
|
|
646
|
+
let queue = this.#pageTaskQueues.get(pageId);
|
|
647
|
+
if (!queue) {
|
|
648
|
+
queue = this.#taskRunner.createQueue(this.taskQueue);
|
|
649
|
+
this.#pageTaskQueues.set(pageId, queue);
|
|
650
|
+
}
|
|
651
|
+
return queue;
|
|
652
|
+
}
|
|
653
|
+
#disposeMcpPage(mcpPage) {
|
|
654
|
+
mcpPage.dispose();
|
|
655
|
+
this.#pageTaskQueues
|
|
656
|
+
.get(mcpPage.id)
|
|
657
|
+
?.dispose(new Error(`Page ${mcpPage.id} is closed.`));
|
|
658
|
+
this.#pageTaskQueues.delete(mcpPage.id);
|
|
659
|
+
}
|
|
660
|
+
isPageSelected(page) {
|
|
661
|
+
return this.#selectedPage === page;
|
|
662
|
+
}
|
|
663
|
+
selectPage(newPage) {
|
|
664
|
+
this.#selectedPageFallback = undefined;
|
|
665
|
+
this.#selectedPageFallbackRead = false;
|
|
666
|
+
this.#selectPage(newPage);
|
|
667
|
+
}
|
|
668
|
+
#selectPage(newPage) {
|
|
669
|
+
if (this.#selectedPage &&
|
|
670
|
+
this.#selectedPage !== newPage &&
|
|
671
|
+
!this.#mcpPages.has(this.#selectedPage.target)) {
|
|
672
|
+
this.#disposeMcpPage(this.#selectedPage);
|
|
673
|
+
}
|
|
674
|
+
this.#selectedPage = newPage;
|
|
675
|
+
newPage.updateTimeouts();
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Returns details about the last page snapshot automatically replacing the
|
|
679
|
+
* selection because the selected page disappeared from the page list, or
|
|
680
|
+
* `undefined` if the snapshot left the selection intact. Cleared on the next
|
|
681
|
+
* createPagesSnapshot() call after it has been read, or when selectPage() is
|
|
682
|
+
* called explicitly.
|
|
683
|
+
*/
|
|
684
|
+
getSelectedPageFallback() {
|
|
685
|
+
this.#selectedPageFallbackRead = true;
|
|
686
|
+
return this.#selectedPageFallback;
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Creates a snapshot of the tracked workers. Today this is limited to
|
|
690
|
+
* extension service workers; the McpWorker abstraction lets dedicated and
|
|
691
|
+
* shared workers join the same snapshot later without changing consumers.
|
|
692
|
+
*/
|
|
693
|
+
createWorkersSnapshot() {
|
|
694
|
+
const serviceWorkers = this.browser.targets().filter(target => {
|
|
695
|
+
return (target.type() === 'service_worker' &&
|
|
696
|
+
target.url().includes('chrome-extension://'));
|
|
697
|
+
});
|
|
698
|
+
// Reuse the existing McpWorker for a target; only mint one (and an id) for
|
|
699
|
+
// targets seen for the first time.
|
|
700
|
+
for (const target of serviceWorkers) {
|
|
701
|
+
if (!this.#workers.has(target)) {
|
|
702
|
+
this.#workers.set(target, McpWorker.create('service_worker', target));
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
// Prune workers whose target is gone (mirrors #mcpPages pruning).
|
|
706
|
+
const currentTargets = new Set(serviceWorkers);
|
|
707
|
+
for (const target of this.#workers.keys()) {
|
|
708
|
+
if (!currentTargets.has(target)) {
|
|
709
|
+
this.#workers.delete(target);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return Array.from(this.#workers.values());
|
|
713
|
+
}
|
|
714
|
+
#getServiceWorkerExtensionId(serviceWorkerId) {
|
|
715
|
+
const worker = this.getWorkerById(serviceWorkerId);
|
|
716
|
+
if (worker?.type !== 'service_worker') {
|
|
717
|
+
throw new Error(`Service worker ${serviceWorkerId} not found. Call list_pages to get the current sw-N IDs.`);
|
|
718
|
+
}
|
|
719
|
+
return new URL(worker.url).hostname;
|
|
720
|
+
}
|
|
721
|
+
getServiceWorkerConsoleData(serviceWorkerId) {
|
|
722
|
+
const extensionId = this.#getServiceWorkerExtensionId(serviceWorkerId);
|
|
723
|
+
return this.#serviceWorkerCollector?.console.getData(extensionId) ?? [];
|
|
724
|
+
}
|
|
725
|
+
getServiceWorkerConsoleMessageById(serviceWorkerId, msgid) {
|
|
726
|
+
const extensionId = this.#getServiceWorkerExtensionId(serviceWorkerId);
|
|
727
|
+
if (!this.#serviceWorkerCollector) {
|
|
728
|
+
throw new Error('Service worker console data is not available.');
|
|
729
|
+
}
|
|
730
|
+
return this.#serviceWorkerCollector.console.getById(extensionId, msgid);
|
|
731
|
+
}
|
|
732
|
+
getServiceWorkerNetworkData(serviceWorkerId) {
|
|
733
|
+
const extensionId = this.#getServiceWorkerExtensionId(serviceWorkerId);
|
|
734
|
+
return this.#serviceWorkerCollector?.network.getData(extensionId) ?? [];
|
|
735
|
+
}
|
|
736
|
+
getServiceWorkerNetworkRequestById(serviceWorkerId, reqid) {
|
|
737
|
+
const extensionId = this.#getServiceWorkerExtensionId(serviceWorkerId);
|
|
738
|
+
if (!this.#serviceWorkerCollector) {
|
|
739
|
+
throw new Error('Service worker network data is not available.');
|
|
740
|
+
}
|
|
741
|
+
return this.#serviceWorkerCollector.network.getById(extensionId, reqid);
|
|
742
|
+
}
|
|
743
|
+
#getBrowserContextToNameMap() {
|
|
744
|
+
// Build a reverse lookup from BrowserContext instance → name.
|
|
745
|
+
const contextToName = new Map();
|
|
746
|
+
for (const [name, ctx] of this.#isolatedContexts) {
|
|
747
|
+
contextToName.set(ctx, name);
|
|
748
|
+
}
|
|
749
|
+
const defaultCtx = this.browser.defaultBrowserContext();
|
|
750
|
+
// Auto-discover BrowserContexts not in our mapping (e.g., externally
|
|
751
|
+
// created incognito contexts) and assign generated names.
|
|
752
|
+
const knownContexts = new Set(this.#isolatedContexts.values());
|
|
753
|
+
for (const ctx of this.browser.browserContexts()) {
|
|
754
|
+
if (ctx !== defaultCtx && !ctx.closed && !knownContexts.has(ctx)) {
|
|
755
|
+
const name = `isolated-context-${this.#nextIsolatedContextId++}`;
|
|
756
|
+
this.#isolatedContexts.set(name, ctx);
|
|
757
|
+
contextToName.set(ctx, name);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
return contextToName;
|
|
761
|
+
}
|
|
762
|
+
#createMcpPage(target) {
|
|
763
|
+
let mcpPage = this.#mcpPages.get(target) ??
|
|
764
|
+
(this.#selectedPage?.target === target ? this.#selectedPage : undefined);
|
|
765
|
+
if (!mcpPage) {
|
|
766
|
+
mcpPage = new McpPage(target, nextPageId++, {
|
|
767
|
+
config: this.#config,
|
|
768
|
+
locatorClass: this.#locatorClass,
|
|
769
|
+
isolatedContextName: this.#getBrowserContextToNameMap().get(target.browserContext()),
|
|
770
|
+
navigationTimeout: this.#options.navigationTimeout,
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
this.#mcpPages.set(target, mcpPage);
|
|
774
|
+
return mcpPage;
|
|
775
|
+
}
|
|
776
|
+
async createPagesSnapshot() {
|
|
777
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
778
|
+
try {
|
|
779
|
+
if (!this.#browser) {
|
|
780
|
+
return [];
|
|
781
|
+
}
|
|
782
|
+
const guard = __addDisposableResource(env_1, await this.#pagesSnapshotMutex.acquire(), false);
|
|
783
|
+
const allTargets = this.#fetchPageTargets();
|
|
784
|
+
for (const target of allTargets) {
|
|
785
|
+
this.#createMcpPage(target);
|
|
786
|
+
}
|
|
787
|
+
// Prune orphaned #mcpPages entries (targets that no longer exist).
|
|
788
|
+
const currentTargets = new Set(allTargets);
|
|
789
|
+
for (const [target, mcpPage] of this.#mcpPages) {
|
|
790
|
+
if (!currentTargets.has(target)) {
|
|
791
|
+
if (mcpPage !== this.#selectedPage || mcpPage.isClosed()) {
|
|
792
|
+
this.#disposeMcpPage(mcpPage);
|
|
793
|
+
}
|
|
794
|
+
this.#mcpPages.delete(target);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
const pages = Array.from(this.#mcpPages.values());
|
|
798
|
+
// Only fall back when the selected page is actually gone or no longer
|
|
799
|
+
// counts as a page, e.g. a background page after
|
|
800
|
+
// experimentalIncludeAllPages was turned off. Gating on `isClosed()`
|
|
801
|
+
// instead of `pages` membership avoids silently swapping a live page that
|
|
802
|
+
// is momentarily missing from the snapshot.
|
|
803
|
+
if (this.#selectedPageFallbackRead) {
|
|
804
|
+
this.#selectedPageFallback = undefined;
|
|
805
|
+
this.#selectedPageFallbackRead = false;
|
|
806
|
+
}
|
|
807
|
+
if (!this.#selectedPage ||
|
|
808
|
+
this.#selectedPage.isClosed() ||
|
|
809
|
+
!this.#isPageTarget(this.#selectedPage.target)) {
|
|
810
|
+
if (pages[0]) {
|
|
811
|
+
// Record the automatic change so the response can surface it. Skipped on
|
|
812
|
+
// first connect, when there was no prior selection to replace.
|
|
813
|
+
if (this.#selectedPage) {
|
|
814
|
+
this.#selectedPageFallback = {
|
|
815
|
+
wasClosed: this.#selectedPage.isClosed(),
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
this.#selectPage(pages[0]);
|
|
819
|
+
}
|
|
820
|
+
else if (this.#selectedPage) {
|
|
821
|
+
const wasClosed = Boolean(this.#selectedPage.isClosed());
|
|
822
|
+
if (!wasClosed) {
|
|
823
|
+
this.#disposeMcpPage(this.#selectedPage);
|
|
824
|
+
}
|
|
825
|
+
this.#selectedPage = undefined;
|
|
826
|
+
this.#selectedPageFallback = { wasClosed };
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
if (!this.#config.resolved.arc &&
|
|
830
|
+
this.#selectedPage &&
|
|
831
|
+
!this.#selectedPage.isClosed()) {
|
|
832
|
+
// Arc can suspend tabs, so enumeration must defer attachment to page tools.
|
|
833
|
+
await this.#selectedPage.init({ emulateFocus: false });
|
|
834
|
+
}
|
|
835
|
+
return pages;
|
|
836
|
+
}
|
|
837
|
+
catch (e_1) {
|
|
838
|
+
env_1.error = e_1;
|
|
839
|
+
env_1.hasError = true;
|
|
840
|
+
}
|
|
841
|
+
finally {
|
|
842
|
+
__disposeResources(env_1);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
#isPageTarget(target) {
|
|
846
|
+
const existingMcpPage = this.#mcpPages.get(target) ??
|
|
847
|
+
(this.#selectedPage?.target === target ? this.#selectedPage : undefined);
|
|
848
|
+
const url = existingMcpPage ? existingMcpPage.url() : target.url();
|
|
849
|
+
if (!this.#config.resolved.experimentalDevtools &&
|
|
850
|
+
url.startsWith('devtools://')) {
|
|
851
|
+
return false;
|
|
852
|
+
}
|
|
853
|
+
if (!isAllowedUrl(url, {
|
|
854
|
+
categoryExtensions: this.#config.resolved.categoryExtensions,
|
|
855
|
+
})) {
|
|
856
|
+
return false;
|
|
857
|
+
}
|
|
858
|
+
const type = target.type();
|
|
859
|
+
if (type === 'page') {
|
|
860
|
+
return true;
|
|
861
|
+
}
|
|
862
|
+
if (this.#config.resolved.experimentalIncludeAllPages &&
|
|
863
|
+
(type === 'background_page' || type === 'webview')) {
|
|
864
|
+
return true;
|
|
865
|
+
}
|
|
866
|
+
if (this.#config.resolved.experimentalDevtools &&
|
|
867
|
+
type === 'other' &&
|
|
868
|
+
url.startsWith('devtools://')) {
|
|
869
|
+
return true;
|
|
870
|
+
}
|
|
871
|
+
return false;
|
|
872
|
+
}
|
|
873
|
+
#fetchPageTargets() {
|
|
874
|
+
return this.browser.targets().filter(target => this.#isPageTarget(target));
|
|
875
|
+
}
|
|
876
|
+
getWorkers() {
|
|
877
|
+
return Array.from(this.#workers.values());
|
|
878
|
+
}
|
|
879
|
+
getWorkerById(id) {
|
|
880
|
+
return this.#workers.values().find(worker => worker.id === id);
|
|
881
|
+
}
|
|
882
|
+
async #writeFile(filepath, data) {
|
|
883
|
+
const resolved = await this.validatePath(filepath);
|
|
884
|
+
try {
|
|
885
|
+
await fs.mkdir(path.dirname(resolved), { recursive: true });
|
|
886
|
+
// Open the file with flags to:
|
|
887
|
+
// - O_WRONLY: Write-only
|
|
888
|
+
// - O_CREAT: Create if it doesn't exist
|
|
889
|
+
// - O_TRUNC: Truncate to zero length if it exists
|
|
890
|
+
// - O_NOFOLLOW: DO NOT follow symlinks.
|
|
891
|
+
// - 0o600: Permissions: read/write for owner, no permissions for others.
|
|
892
|
+
await fs.writeFile(resolved, data, {
|
|
893
|
+
flag: fs.constants.O_WRONLY |
|
|
894
|
+
fs.constants.O_CREAT |
|
|
895
|
+
fs.constants.O_TRUNC |
|
|
896
|
+
fs.constants.O_NOFOLLOW,
|
|
897
|
+
mode: 0o600,
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
catch (err) {
|
|
901
|
+
throw new Error(`Could not write ${escapeForLog(filepath)}`, {
|
|
902
|
+
cause: err,
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
async saveTemporaryFile(data, filename) {
|
|
907
|
+
const filepath = await getTempFilePath(filename);
|
|
908
|
+
await this.#writeFile(filepath, data);
|
|
909
|
+
return { filepath };
|
|
910
|
+
}
|
|
911
|
+
async saveFile(data, clientProvidedFilePath, extension) {
|
|
912
|
+
const filePath = await this.ensureExtension(clientProvidedFilePath, extension);
|
|
913
|
+
await this.#writeFile(filePath, data);
|
|
914
|
+
return { filename: filePath };
|
|
915
|
+
}
|
|
916
|
+
storeTraceRecording(result) {
|
|
917
|
+
// Clear the trace results because we only consume the latest trace currently.
|
|
918
|
+
this.#traceResults = [];
|
|
919
|
+
this.#traceResults.push(result);
|
|
920
|
+
}
|
|
921
|
+
recordedTraces() {
|
|
922
|
+
return this.#traceResults;
|
|
923
|
+
}
|
|
924
|
+
async installExtension(extensionPath) {
|
|
925
|
+
const id = await Promise.race([
|
|
926
|
+
this.browser.installExtension(extensionPath),
|
|
927
|
+
new Promise((_, rej) => setTimeout(() => rej(new Error('Timeout installing extension')), 30000)),
|
|
928
|
+
]);
|
|
929
|
+
return id;
|
|
930
|
+
}
|
|
931
|
+
async uninstallExtension(id) {
|
|
932
|
+
await Promise.race([
|
|
933
|
+
this.browser.uninstallExtension(id),
|
|
934
|
+
new Promise((_, rej) => setTimeout(() => rej(new Error('Timeout uninstalling extension')), 30000)),
|
|
935
|
+
]);
|
|
936
|
+
}
|
|
937
|
+
async triggerExtensionAction(id) {
|
|
938
|
+
const extensions = await this.browser.extensions();
|
|
939
|
+
const extension = extensions.get(id);
|
|
940
|
+
if (!extension) {
|
|
941
|
+
throw new Error(`Extension with ID ${id} not found.`);
|
|
942
|
+
}
|
|
943
|
+
const page = this.getSelectedMcpPage().pptrPage;
|
|
944
|
+
await extension.triggerAction(page);
|
|
945
|
+
}
|
|
946
|
+
listExtensions() {
|
|
947
|
+
return this.browser.extensions();
|
|
948
|
+
}
|
|
949
|
+
async getExtension(id) {
|
|
950
|
+
const pptrExtensions = await this.browser.extensions();
|
|
951
|
+
return pptrExtensions.get(id);
|
|
952
|
+
}
|
|
953
|
+
async getHeapSnapshotAggregates(filePath, filterName, objectId) {
|
|
954
|
+
return await this.#heapSnapshotManager.getAggregates(filePath, filterName, objectId);
|
|
955
|
+
}
|
|
956
|
+
async getHeapSnapshotDuplicateStrings(filePath) {
|
|
957
|
+
return await this.#heapSnapshotManager.getDuplicateStrings(filePath);
|
|
958
|
+
}
|
|
959
|
+
async queryHeapSnapshotObjects(filePath, options) {
|
|
960
|
+
return await this.#heapSnapshotManager.queryObjects(filePath, options);
|
|
961
|
+
}
|
|
962
|
+
async getHeapSnapshotStats(filePath) {
|
|
963
|
+
return await this.#heapSnapshotManager.getStats(filePath);
|
|
964
|
+
}
|
|
965
|
+
async getHeapSnapshotStaticData(filePath) {
|
|
966
|
+
return await this.#heapSnapshotManager.getStaticData(filePath);
|
|
967
|
+
}
|
|
968
|
+
async getHeapSnapshotNativeContextSizes(filePath) {
|
|
969
|
+
return await this.#heapSnapshotManager.getNativeContextSizes(filePath);
|
|
970
|
+
}
|
|
971
|
+
async getHeapSnapshotRetainedByContextSummary(filePath) {
|
|
972
|
+
return await this.#heapSnapshotManager.getRetainedByContextSummary(filePath);
|
|
973
|
+
}
|
|
974
|
+
async getHeapSnapshotNodesById(filePath, id, filterName, objectId) {
|
|
975
|
+
return await this.#heapSnapshotManager.getNodesById(filePath, id, filterName, objectId);
|
|
976
|
+
}
|
|
977
|
+
async getHeapSnapshotRetainers(filePath, nodeId) {
|
|
978
|
+
return await this.#heapSnapshotManager.getRetainers(filePath, nodeId);
|
|
979
|
+
}
|
|
980
|
+
async getHeapSnapshotObjectDetails(filePath, nodeId) {
|
|
981
|
+
return await this.#heapSnapshotManager.getObjectInfo(filePath, nodeId);
|
|
982
|
+
}
|
|
983
|
+
async analyzeHeapSnapshotContexts(filePath) {
|
|
984
|
+
return await this.#heapSnapshotManager.analyzeContexts(filePath);
|
|
985
|
+
}
|
|
986
|
+
async closeHeapSnapshot(filePath) {
|
|
987
|
+
return await this.#heapSnapshotManager.disposeSnapshot(filePath);
|
|
988
|
+
}
|
|
989
|
+
async getHeapSnapshotRetainingPaths(filePath, nodeId, maxDepth, maxNodes, maxSiblings) {
|
|
990
|
+
return await this.#heapSnapshotManager.getRetainingPaths(filePath, nodeId, maxDepth, maxNodes, maxSiblings);
|
|
991
|
+
}
|
|
992
|
+
async getHeapSnapshotDominators(filePath, nodeId) {
|
|
993
|
+
return await this.#heapSnapshotManager.getDominatorsOf(filePath, nodeId);
|
|
994
|
+
}
|
|
995
|
+
async #loadNetworkResource(url) {
|
|
996
|
+
const response = await fetchWithValidatedRedirects(url, {
|
|
997
|
+
policy: this.#config.resolved,
|
|
998
|
+
});
|
|
999
|
+
if (!response.ok) {
|
|
1000
|
+
throw new Error('Failed to load resource: ' +
|
|
1001
|
+
redactUrlForLogging(response.url || url.href));
|
|
1002
|
+
}
|
|
1003
|
+
return await response.text();
|
|
1004
|
+
}
|
|
1005
|
+
async loadResource(path) {
|
|
1006
|
+
const url = new URL(path);
|
|
1007
|
+
validateUrlNotBlocked(url, this.#config.resolved.blockedUrlPattern);
|
|
1008
|
+
switch (url.protocol) {
|
|
1009
|
+
case 'https:':
|
|
1010
|
+
case 'http:': {
|
|
1011
|
+
return await this.#loadNetworkResource(url);
|
|
1012
|
+
}
|
|
1013
|
+
case 'file:': {
|
|
1014
|
+
const resolved = await this.validatePath(fileURLToPath(url));
|
|
1015
|
+
return await fs.readFile(resolved, 'utf-8');
|
|
1016
|
+
}
|
|
1017
|
+
default:
|
|
1018
|
+
throw new Error(`Unsupported protocol for: ${url}`);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
async getHeapSnapshotEdges(filePath, nodeId, options) {
|
|
1022
|
+
return await this.#heapSnapshotManager.getEdges(filePath, nodeId, options);
|
|
1023
|
+
}
|
|
1024
|
+
async getHeapSnapshotClassDiffs(baseFilePath, currentFilePath) {
|
|
1025
|
+
return await this.#heapSnapshotManager.getClassDiffs(baseFilePath, currentFilePath);
|
|
1026
|
+
}
|
|
1027
|
+
async getHeapSnapshotDetailedClassDiff(baseFilePath, currentFilePath, classIndex) {
|
|
1028
|
+
return await this.#heapSnapshotManager.getDetailedClassDiff(baseFilePath, currentFilePath, classIndex);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
//# sourceMappingURL=McpContext.js.map
|