chrome-devtools-mcp 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -9
- package/build/src/HeapSnapshotManager.js +77 -28
- package/build/src/McpContext.js +233 -383
- package/build/src/McpPage.js +466 -41
- package/build/src/McpResponse.js +285 -331
- package/build/src/PageCollector.js +53 -122
- package/build/src/SlimMcpResponse.js +1 -1
- package/build/src/TextSnapshot.js +100 -21
- package/build/src/ToolHandler.js +31 -10
- package/build/src/WaitForHelper.js +140 -56
- package/build/src/bin/chrome-devtools-cli-options.js +63 -3
- package/build/src/bin/chrome-devtools-mcp-cli-options.js +16 -7
- package/build/src/bin/chrome-devtools-mcp-main.js +3 -3
- package/build/src/bin/chrome-devtools.js +19 -3
- package/build/src/browser.js +1 -1
- package/build/src/daemon/client.js +55 -3
- package/build/src/daemon/daemon.js +17 -12
- package/build/src/daemon/utils.js +19 -4
- package/build/src/devtools/DevtoolsUtils.js +9 -65
- package/build/src/{issue-descriptions.js → devtools/issueDescriptions.js} +2 -2
- package/build/src/formatters/HeapSnapshotFormatter.js +48 -11
- package/build/src/formatters/IssueFormatter.js +2 -2
- package/build/src/index.js +13 -3
- package/build/src/telemetry/ClearcutLogger.js +4 -1
- package/build/src/telemetry/WatchdogClient.js +1 -1
- package/build/src/telemetry/metricsRegistry.js +2 -9
- package/build/src/telemetry/persistence.js +1 -1
- package/build/src/telemetry/transformation.js +50 -0
- package/build/src/telemetry/watchdog/ClearcutSender.js +1 -1
- package/build/src/telemetry/watchdog/main.js +1 -1
- package/build/src/third_party/THIRD_PARTY_NOTICES +230 -287
- package/build/src/third_party/bundled-packages.json +4 -6
- package/build/src/third_party/devtools-formatter-worker.js +60 -19
- package/build/src/third_party/devtools-heap-snapshot-worker.js +383 -182
- package/build/src/third_party/index.js +30171 -11328
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +2 -2
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +3 -3
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +2 -2
- package/build/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +1 -1
- package/build/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +1 -1
- package/build/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +2 -2
- package/build/src/third_party/issue-descriptions/LowTextContrast.md +1 -1
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorRead.md +1 -1
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +1 -1
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +1 -1
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +1 -1
- package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +3 -3
- package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +3 -3
- package/build/src/third_party/issue-descriptions/bounceTrackingMitigations.md +1 -1
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +2 -2
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +2 -2
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +3 -3
- package/build/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +2 -2
- package/build/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +2 -2
- package/build/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +1 -1
- package/build/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +3 -3
- package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +1 -1
- package/build/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +1 -1
- package/build/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +1 -1
- package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +1 -1
- package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +1 -1
- package/build/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +1 -1
- package/build/src/third_party/issue-descriptions/corsDisabledScheme.md +2 -2
- package/build/src/third_party/issue-descriptions/corsDisallowedByMode.md +2 -2
- package/build/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +3 -3
- package/build/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +1 -1
- package/build/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +1 -1
- package/build/src/third_party/issue-descriptions/corsOriginMismatch.md +3 -3
- package/build/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +2 -2
- package/build/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +3 -3
- package/build/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +4 -3
- package/build/src/third_party/issue-descriptions/cspEvalViolation.md +4 -4
- package/build/src/third_party/issue-descriptions/cspInlineViolation.md +2 -2
- package/build/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +2 -2
- package/build/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +4 -4
- package/build/src/third_party/issue-descriptions/cspURLViolation.md +4 -4
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsEmptyList.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidContentType.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsFetchFailed.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidContentType.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestInvalidEmail.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidAudience.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidIssuedAt.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidNonce.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidSdHash.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidTyp.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingAud.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingCnf.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingIat.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingNonce.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingSdHash.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbSignatureFailed.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmail.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmailVerified.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidHolderKey.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuedAt.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuer.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtJwksMissingKeys.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingCnf.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingEmail.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIat.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIss.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtSignatureFailed.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtUnsupportedHeaderAlg.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestUserLoggedOut.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +1 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +1 -1
- package/build/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +2 -2
- package/build/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +2 -2
- package/build/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +2 -2
- package/build/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +2 -2
- package/build/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +2 -2
- package/build/src/third_party/issue-descriptions/genericFormLabelForNameError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormModelContextMissingToolName.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormModelContextParameterMissingName.md +1 -1
- package/build/src/third_party/issue-descriptions/genericFormModelContextRequiredParameterMissingName.md +1 -1
- package/build/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +2 -2
- package/build/src/third_party/issue-descriptions/heavyAd.md +1 -1
- package/build/src/third_party/issue-descriptions/lazyLoadImageZeroSize.md +7 -0
- package/build/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +3 -3
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementInvalidType.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +1 -1
- package/build/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +2 -2
- package/build/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +1 -1
- package/build/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +1 -1
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +1 -1
- package/build/src/third_party/issue-descriptions/selectivePermissionsIntervention.md +3 -3
- package/build/src/third_party/issue-descriptions/sharedArrayBuffer.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +2 -2
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +1 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +2 -2
- package/build/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +4 -4
- package/build/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +4 -4
- package/build/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +1 -1
- package/build/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +4 -4
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +4 -4
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +1 -1
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +1 -1
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +1 -1
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +5 -5
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +3 -3
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +2 -2
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +2 -2
- package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +4 -4
- package/build/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +3 -3
- package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +2 -2
- package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +2 -2
- package/build/src/third_party/issue-descriptions/stylesheetLateImport.md +1 -1
- package/build/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +1 -1
- package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +2 -2
- package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +3 -3
- package/build/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +2 -2
- package/build/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +1 -1
- package/build/src/third_party/lighthouse-devtools-mcp-bundle.js +3177 -6340
- package/build/src/tools/emulation.js +2 -2
- package/build/src/tools/extensions.js +1 -1
- package/build/src/tools/input.js +213 -112
- package/build/src/tools/lighthouse.js +1 -1
- package/build/src/tools/memory.js +49 -4
- package/build/src/tools/network.js +5 -5
- package/build/src/tools/pages.js +22 -89
- package/build/src/tools/performance.js +62 -41
- package/build/src/tools/screenshot.js +152 -77
- package/build/src/tools/script.js +95 -28
- package/build/src/tools/snapshot.js +2 -2
- package/build/src/tools/thirdPartyDeveloper.js +1 -1
- package/build/src/tools/webmcp.js +1 -1
- package/build/src/trace-processing/parse.js +1 -1
- package/build/src/{logger.js → utils/logger.js} +1 -1
- package/build/src/utils/polyfill.js +11 -0
- package/build/src/utils/url.js +43 -0
- package/build/src/version.js +1 -1
- package/package.json +23 -15
- package/skills/memory-leak-debugging/SKILL.md +23 -19
- package/skills/memory-leak-debugging/references/common-leaks.md +1 -1
- package/build/src/Mutex.js +0 -38
- package/build/src/devtools/DevToolsConnectionAdapter.js +0 -70
- package/build/src/polyfill.js +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeRead.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteExcludeContextDowngradeSet.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteExcludeNavigationContextDowngrade.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeRead.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteWarnCrossDowngradeSet.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteWarnStrictLaxDowngradeStrict.md +0 -8
- package/build/src/third_party/issue-descriptions/arInsecureContext.md +0 -7
- package/build/src/third_party/issue-descriptions/arInvalidInfoHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arInvalidRegisterOsSourceHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arInvalidRegisterOsTriggerHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arInvalidRegisterSourceHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arInvalidRegisterTriggerHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arNavigationRegistrationUniqueScopeAlreadySet.md +0 -5
- package/build/src/third_party/issue-descriptions/arNavigationRegistrationWithoutTransientUserActivation.md +0 -6
- package/build/src/third_party/issue-descriptions/arNoRegisterOsSourceHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arNoRegisterOsTriggerHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arNoRegisterSourceHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arNoRegisterTriggerHeader.md +0 -5
- package/build/src/third_party/issue-descriptions/arNoWebOrOsSupport.md +0 -4
- package/build/src/third_party/issue-descriptions/arOsSourceIgnored.md +0 -18
- package/build/src/third_party/issue-descriptions/arOsTriggerIgnored.md +0 -19
- package/build/src/third_party/issue-descriptions/arPermissionPolicyDisabled.md +0 -8
- package/build/src/third_party/issue-descriptions/arSourceAndTriggerHeaders.md +0 -9
- package/build/src/third_party/issue-descriptions/arSourceIgnored.md +0 -13
- package/build/src/third_party/issue-descriptions/arTriggerIgnored.md +0 -12
- package/build/src/third_party/issue-descriptions/arUntrustworthyReportingOrigin.md +0 -10
- package/build/src/third_party/issue-descriptions/arWebAndOsHeaders.md +0 -11
- package/build/src/utils/types.js +0 -7
- package/skills/memory-leak-debugging/references/compare_snapshots.js +0 -109
- package/skills/memory-leak-debugging/references/memlab.md +0 -29
package/build/src/McpContext.js
CHANGED
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import fs from 'node:fs/promises';
|
|
7
|
-
import fsPromises from 'node:fs/promises';
|
|
8
7
|
import os from 'node:os';
|
|
9
8
|
import path from 'node:path';
|
|
10
9
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
11
|
-
import { overrideDevToolsGlobals
|
|
10
|
+
import { overrideDevToolsGlobals } from './devtools/DevtoolsUtils.js';
|
|
12
11
|
import { HeapSnapshotManager } from './HeapSnapshotManager.js';
|
|
13
12
|
import { McpPage } from './McpPage.js';
|
|
14
|
-
import { NetworkCollector, ConsoleCollector, } from './PageCollector.js';
|
|
15
13
|
import { ServiceWorkerConsoleCollector } from './ServiceWorkerCollector.js';
|
|
16
|
-
import { Locator,
|
|
14
|
+
import { Locator, } from './third_party/index.js';
|
|
17
15
|
import { listPages } from './tools/pages.js';
|
|
18
16
|
import { CLOSE_PAGE_ERROR } from './tools/ToolDefinition.js';
|
|
19
17
|
import { getTempFilePath, resolveCanonicalPath } from './utils/files.js';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
// Page ids are handed out from a process-wide counter so they stay unique
|
|
19
|
+
// across all contexts, in particular across browser reconnects. An id issued
|
|
20
|
+
// before a reconnect then fails to resolve instead of hitting an unrelated
|
|
21
|
+
// page of the reconnected browser.
|
|
22
|
+
let nextPageId = 1;
|
|
23
23
|
export class McpContext {
|
|
24
24
|
browser;
|
|
25
25
|
logger;
|
|
@@ -27,17 +27,14 @@ export class McpContext {
|
|
|
27
27
|
#isolatedContexts = new Map();
|
|
28
28
|
// Auto-generated name counter for when no name is provided.
|
|
29
29
|
#nextIsolatedContextId = 1;
|
|
30
|
-
#pages = [];
|
|
31
30
|
#extensionServiceWorkers = [];
|
|
32
31
|
#mcpPages = new Map();
|
|
33
32
|
#selectedPage;
|
|
34
|
-
#
|
|
35
|
-
#consoleCollector;
|
|
36
|
-
#devtoolsUniverseManager;
|
|
33
|
+
#selectedPageFallback;
|
|
37
34
|
#serviceWorkerConsoleCollector;
|
|
38
35
|
#isRunningTrace = false;
|
|
39
36
|
#screenRecorderData = null;
|
|
40
|
-
#
|
|
37
|
+
#reconnectNotice = false;
|
|
41
38
|
#extensionPages = new WeakMap();
|
|
42
39
|
#extensionServiceWorkerMap = new WeakMap();
|
|
43
40
|
#nextExtensionServiceWorkerId = 1;
|
|
@@ -46,6 +43,7 @@ export class McpContext {
|
|
|
46
43
|
#options;
|
|
47
44
|
#heapSnapshotManager = new HeapSnapshotManager();
|
|
48
45
|
#roots = undefined;
|
|
46
|
+
#allowUnrestrictedPaths;
|
|
49
47
|
constructor(browser, logger, options, locatorClass) {
|
|
50
48
|
overrideDevToolsGlobals({
|
|
51
49
|
loadResource: (url) => {
|
|
@@ -56,36 +54,22 @@ export class McpContext {
|
|
|
56
54
|
this.logger = logger;
|
|
57
55
|
this.#locatorClass = locatorClass;
|
|
58
56
|
this.#options = options;
|
|
59
|
-
this.#
|
|
60
|
-
this.#
|
|
61
|
-
return {
|
|
62
|
-
console: event => {
|
|
63
|
-
collect(event);
|
|
64
|
-
},
|
|
65
|
-
uncaughtError: event => {
|
|
66
|
-
collect(event);
|
|
67
|
-
},
|
|
68
|
-
devtoolsAggregatedIssue: event => {
|
|
69
|
-
collect(event);
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
});
|
|
57
|
+
this.#allowUnrestrictedPaths = options.allowUnrestrictedPaths ?? false;
|
|
58
|
+
this.#reconnectNotice = options.reconnected ?? false;
|
|
73
59
|
this.#serviceWorkerConsoleCollector = new ServiceWorkerConsoleCollector(this.browser);
|
|
74
|
-
this.#devtoolsUniverseManager = new UniverseManager(this.browser);
|
|
75
60
|
}
|
|
76
61
|
async #init() {
|
|
77
|
-
|
|
62
|
+
await this.createPagesSnapshot();
|
|
78
63
|
const workers = await this.createExtensionServiceWorkersSnapshot();
|
|
79
|
-
await this.#networkCollector.init(pages);
|
|
80
|
-
await this.#consoleCollector.init(pages);
|
|
81
|
-
await this.#devtoolsUniverseManager.init(pages);
|
|
82
64
|
await this.#serviceWorkerConsoleCollector.init(workers);
|
|
65
|
+
this.browser.on('targetcreated', this.#onTargetCreated);
|
|
66
|
+
this.browser.on('targetdestroyed', this.#onTargetDestroyed);
|
|
83
67
|
}
|
|
84
68
|
dispose() {
|
|
85
|
-
this
|
|
86
|
-
this
|
|
87
|
-
this.#devtoolsUniverseManager.dispose();
|
|
69
|
+
this.browser.off('targetcreated', this.#onTargetCreated);
|
|
70
|
+
this.browser.off('targetdestroyed', this.#onTargetDestroyed);
|
|
88
71
|
this.#serviceWorkerConsoleCollector.dispose();
|
|
72
|
+
this.#heapSnapshotManager.dispose();
|
|
89
73
|
for (const mcpPage of this.#mcpPages.values()) {
|
|
90
74
|
mcpPage.dispose();
|
|
91
75
|
}
|
|
@@ -95,6 +79,40 @@ export class McpContext {
|
|
|
95
79
|
// without destroying browser state.
|
|
96
80
|
this.#isolatedContexts.clear();
|
|
97
81
|
}
|
|
82
|
+
#onTargetCreated = async (target) => {
|
|
83
|
+
try {
|
|
84
|
+
const page = await target.page();
|
|
85
|
+
if (!page) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
void this.#createMcpPage(page);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
this.logger?.('Error handling targetcreated', err);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
#onTargetDestroyed = (target) => {
|
|
95
|
+
try {
|
|
96
|
+
let foundPage;
|
|
97
|
+
for (const page of this.#mcpPages.keys()) {
|
|
98
|
+
if (page.target() === target) {
|
|
99
|
+
foundPage = page;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!foundPage) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const mcpPage = this.#mcpPages.get(foundPage);
|
|
107
|
+
if (mcpPage) {
|
|
108
|
+
mcpPage.dispose();
|
|
109
|
+
this.#mcpPages.delete(foundPage);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch (err) {
|
|
113
|
+
this.logger?.('Error handling targetdestroyed', err);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
98
116
|
static async from(browser, logger, opts,
|
|
99
117
|
/* Let tests use unbundled Locator class to avoid overly strict checks within puppeteer that fail when mixing bundled and unbundled class instances */
|
|
100
118
|
locatorClass = Locator) {
|
|
@@ -102,12 +120,12 @@ export class McpContext {
|
|
|
102
120
|
await context.#init();
|
|
103
121
|
return context;
|
|
104
122
|
}
|
|
123
|
+
static resetPageIdsForTesting() {
|
|
124
|
+
nextPageId = 1;
|
|
125
|
+
}
|
|
105
126
|
roots() {
|
|
106
|
-
if (this.#roots === undefined) {
|
|
107
|
-
return undefined;
|
|
108
|
-
}
|
|
109
127
|
return [
|
|
110
|
-
...this.#roots,
|
|
128
|
+
...(this.#roots ?? []),
|
|
111
129
|
{
|
|
112
130
|
uri: pathToFileURL(os.tmpdir()).href,
|
|
113
131
|
name: 'temp',
|
|
@@ -121,10 +139,17 @@ export class McpContext {
|
|
|
121
139
|
if (filePath === undefined) {
|
|
122
140
|
return;
|
|
123
141
|
}
|
|
124
|
-
|
|
125
|
-
|
|
142
|
+
// If the client never negotiated roots and the operator has explicitly
|
|
143
|
+
// opted into unrestricted access via --allow-unrestricted-paths, restore
|
|
144
|
+
// the previous permissive behavior and skip validation.
|
|
145
|
+
if (this.#roots === undefined && this.#allowUnrestrictedPaths) {
|
|
126
146
|
return;
|
|
127
147
|
}
|
|
148
|
+
// roots() always returns at least the temp directory, even if the
|
|
149
|
+
// connecting client never negotiated the optional `roots` capability.
|
|
150
|
+
// Path validation must not be skipped just because no workspace roots
|
|
151
|
+
// were configured.
|
|
152
|
+
const roots = this.roots();
|
|
128
153
|
let canonicalPath;
|
|
129
154
|
try {
|
|
130
155
|
canonicalPath = await resolveCanonicalPath(filePath);
|
|
@@ -135,18 +160,24 @@ export class McpContext {
|
|
|
135
160
|
throw new Error(`Access denied: Cannot resolve base path for ${filePath}.`);
|
|
136
161
|
}
|
|
137
162
|
let allowed = false;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
163
|
+
const resolvedRoots = await Promise.allSettled(roots.map(async (root) => {
|
|
164
|
+
const rootPathUri = root.uri;
|
|
165
|
+
const rootPath = path.resolve(fileURLToPath(rootPathUri));
|
|
166
|
+
return await fs.realpath(rootPath);
|
|
167
|
+
}));
|
|
168
|
+
for (let i = 0; i < roots.length; i++) {
|
|
169
|
+
const root = roots[i];
|
|
170
|
+
const result = resolvedRoots[i];
|
|
171
|
+
if (result.status === 'fulfilled') {
|
|
172
|
+
const canonicalRoot = result.value;
|
|
143
173
|
if (canonicalPath === canonicalRoot ||
|
|
144
174
|
canonicalPath.startsWith(canonicalRoot + path.sep)) {
|
|
145
175
|
allowed = true;
|
|
146
176
|
break;
|
|
147
177
|
}
|
|
148
178
|
}
|
|
149
|
-
|
|
179
|
+
else {
|
|
180
|
+
const rootErr = result.reason;
|
|
150
181
|
const errMsg = rootErr instanceof Error ? rootErr.message : String(rootErr);
|
|
151
182
|
console.warn(`[MCP Context] Could not resolve configured root ${root.uri}: ${errMsg}`);
|
|
152
183
|
// Skip this root if it cannot be resolved.
|
|
@@ -163,36 +194,6 @@ export class McpContext {
|
|
|
163
194
|
await this.validatePath(outputPath);
|
|
164
195
|
return outputPath;
|
|
165
196
|
}
|
|
166
|
-
resolveCdpRequestId(page, cdpRequestId) {
|
|
167
|
-
if (!cdpRequestId) {
|
|
168
|
-
this.logger?.('no network request');
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
const request = this.#networkCollector.find(page.pptrPage, request => {
|
|
172
|
-
// @ts-expect-error id is internal.
|
|
173
|
-
return request.id === cdpRequestId;
|
|
174
|
-
});
|
|
175
|
-
if (!request) {
|
|
176
|
-
this.logger?.('no network request for ' + cdpRequestId);
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
return this.#networkCollector.getIdForResource(request);
|
|
180
|
-
}
|
|
181
|
-
getNetworkRequests(page, includePreservedRequests) {
|
|
182
|
-
return this.#networkCollector.getData(page.pptrPage, includePreservedRequests);
|
|
183
|
-
}
|
|
184
|
-
getConsoleData(page, includePreservedMessages) {
|
|
185
|
-
return this.#consoleCollector.getData(page.pptrPage, includePreservedMessages);
|
|
186
|
-
}
|
|
187
|
-
getDevToolsUniverse(page) {
|
|
188
|
-
return this.#devtoolsUniverseManager.get(page.pptrPage);
|
|
189
|
-
}
|
|
190
|
-
getConsoleMessageStableId(message) {
|
|
191
|
-
return this.#consoleCollector.getIdForResource(message);
|
|
192
|
-
}
|
|
193
|
-
getConsoleMessageById(page, id) {
|
|
194
|
-
return this.#consoleCollector.getById(page.pptrPage, id);
|
|
195
|
-
}
|
|
196
197
|
async newPage(background, isolatedContextName) {
|
|
197
198
|
let page;
|
|
198
199
|
if (isolatedContextName !== undefined) {
|
|
@@ -206,14 +207,13 @@ export class McpContext {
|
|
|
206
207
|
else {
|
|
207
208
|
page = await this.browser.newPage({ background });
|
|
208
209
|
}
|
|
210
|
+
const mcpPage = await this.#createMcpPage(page);
|
|
209
211
|
await this.createPagesSnapshot();
|
|
210
|
-
this.selectPage(
|
|
211
|
-
|
|
212
|
-
this.#consoleCollector.addPage(page);
|
|
213
|
-
return this.#getMcpPage(page);
|
|
212
|
+
this.selectPage(mcpPage);
|
|
213
|
+
return mcpPage;
|
|
214
214
|
}
|
|
215
215
|
async closePage(pageId) {
|
|
216
|
-
if (this.#
|
|
216
|
+
if (this.#mcpPages.size === 1) {
|
|
217
217
|
throw new Error(CLOSE_PAGE_ERROR);
|
|
218
218
|
}
|
|
219
219
|
const page = this.getPageById(pageId);
|
|
@@ -223,118 +223,9 @@ export class McpContext {
|
|
|
223
223
|
}
|
|
224
224
|
await page.pptrPage.close({ runBeforeUnload: false });
|
|
225
225
|
}
|
|
226
|
-
getNetworkRequestById(page, reqid) {
|
|
227
|
-
return this.#networkCollector.getById(page.pptrPage, reqid);
|
|
228
|
-
}
|
|
229
|
-
async restoreEmulation(page) {
|
|
230
|
-
const currentSetting = page.emulationSettings;
|
|
231
|
-
await this.emulate(currentSetting, page.pptrPage);
|
|
232
|
-
}
|
|
233
226
|
get #hasNetworkBlockOrAllowlist() {
|
|
234
227
|
return !!(this.#options.allowList || this.#options.blocklist);
|
|
235
228
|
}
|
|
236
|
-
async emulate(options, targetPage) {
|
|
237
|
-
const page = targetPage ?? this.getSelectedPptrPage();
|
|
238
|
-
const mcpPage = this.#getMcpPage(page);
|
|
239
|
-
const newSettings = { ...mcpPage.emulationSettings };
|
|
240
|
-
// Skip network emulation if blocklist/allowlist is configured, as it conflicts with blocking rules in Puppeteer.
|
|
241
|
-
if (this.#hasNetworkBlockOrAllowlist) {
|
|
242
|
-
if (options.networkConditions !== undefined) {
|
|
243
|
-
throw new Error('Network throttling is not supported when network blocking (allowlist/blocklist) is configured.');
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
else if (!options.networkConditions) {
|
|
247
|
-
await page.emulateNetworkConditions(null);
|
|
248
|
-
delete newSettings.networkConditions;
|
|
249
|
-
}
|
|
250
|
-
else if (options.networkConditions === 'Offline') {
|
|
251
|
-
await page.emulateNetworkConditions({
|
|
252
|
-
offline: true,
|
|
253
|
-
download: 0,
|
|
254
|
-
upload: 0,
|
|
255
|
-
latency: 0,
|
|
256
|
-
});
|
|
257
|
-
newSettings.networkConditions = 'Offline';
|
|
258
|
-
}
|
|
259
|
-
else if (options.networkConditions in PredefinedNetworkConditions) {
|
|
260
|
-
const networkCondition = PredefinedNetworkConditions[options.networkConditions];
|
|
261
|
-
await page.emulateNetworkConditions(networkCondition);
|
|
262
|
-
newSettings.networkConditions = options.networkConditions;
|
|
263
|
-
}
|
|
264
|
-
const secondarySession = this.getDevToolsUniverse(mcpPage)?.session;
|
|
265
|
-
if (!options.cpuThrottlingRate) {
|
|
266
|
-
await page.emulateCPUThrottling(1);
|
|
267
|
-
if (secondarySession) {
|
|
268
|
-
await secondarySession.send('Emulation.setCPUThrottlingRate', {
|
|
269
|
-
rate: 1,
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
delete newSettings.cpuThrottlingRate;
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
await page.emulateCPUThrottling(options.cpuThrottlingRate);
|
|
276
|
-
if (secondarySession) {
|
|
277
|
-
await secondarySession.send('Emulation.setCPUThrottlingRate', {
|
|
278
|
-
rate: options.cpuThrottlingRate,
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
newSettings.cpuThrottlingRate = options.cpuThrottlingRate;
|
|
282
|
-
}
|
|
283
|
-
if (!options.geolocation) {
|
|
284
|
-
await page.setGeolocation({ latitude: 0, longitude: 0 });
|
|
285
|
-
delete newSettings.geolocation;
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
await page.setGeolocation(options.geolocation);
|
|
289
|
-
newSettings.geolocation = options.geolocation;
|
|
290
|
-
}
|
|
291
|
-
if (!options.userAgent) {
|
|
292
|
-
await page.setUserAgent({ userAgent: undefined });
|
|
293
|
-
delete newSettings.userAgent;
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
await page.setUserAgent({ userAgent: options.userAgent });
|
|
297
|
-
newSettings.userAgent = options.userAgent;
|
|
298
|
-
}
|
|
299
|
-
if (!options.colorScheme || options.colorScheme === 'auto') {
|
|
300
|
-
await page.emulateMediaFeatures([
|
|
301
|
-
{ name: 'prefers-color-scheme', value: '' },
|
|
302
|
-
]);
|
|
303
|
-
delete newSettings.colorScheme;
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
await page.emulateMediaFeatures([
|
|
307
|
-
{ name: 'prefers-color-scheme', value: options.colorScheme },
|
|
308
|
-
]);
|
|
309
|
-
newSettings.colorScheme = options.colorScheme;
|
|
310
|
-
}
|
|
311
|
-
if (!options.viewport) {
|
|
312
|
-
delete newSettings.viewport;
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
const defaults = {
|
|
316
|
-
deviceScaleFactor: 1,
|
|
317
|
-
isMobile: false,
|
|
318
|
-
hasTouch: false,
|
|
319
|
-
isLandscape: false,
|
|
320
|
-
};
|
|
321
|
-
newSettings.viewport = { ...defaults, ...options.viewport };
|
|
322
|
-
}
|
|
323
|
-
if (options.extraHttpHeaders !== undefined) {
|
|
324
|
-
await page.setExtraHTTPHeaders(options.extraHttpHeaders);
|
|
325
|
-
newSettings.extraHttpHeaders = options.extraHttpHeaders;
|
|
326
|
-
if (Object.keys(options.extraHttpHeaders).length === 0) {
|
|
327
|
-
delete newSettings.extraHttpHeaders;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
mcpPage.emulationSettings = Object.keys(newSettings).length
|
|
331
|
-
? newSettings
|
|
332
|
-
: {};
|
|
333
|
-
this.#updateSelectedPageTimeouts();
|
|
334
|
-
// This should happen after updating the page timeouts.
|
|
335
|
-
// Setting the viewport can trigger a reload which we don't want to timeout.
|
|
336
|
-
await page.setViewport(newSettings.viewport ?? null);
|
|
337
|
-
}
|
|
338
229
|
setIsRunningPerformanceTrace(x) {
|
|
339
230
|
this.#isRunningTrace = x;
|
|
340
231
|
}
|
|
@@ -350,7 +241,10 @@ export class McpContext {
|
|
|
350
241
|
isCruxEnabled() {
|
|
351
242
|
return this.#options.performanceCrux;
|
|
352
243
|
}
|
|
353
|
-
|
|
244
|
+
getPages() {
|
|
245
|
+
return Array.from(this.#mcpPages.values());
|
|
246
|
+
}
|
|
247
|
+
getSelectedMcpPage() {
|
|
354
248
|
const page = this.#selectedPage;
|
|
355
249
|
if (!page) {
|
|
356
250
|
throw new Error('No page selected');
|
|
@@ -358,11 +252,37 @@ export class McpContext {
|
|
|
358
252
|
if (page.pptrPage.isClosed()) {
|
|
359
253
|
throw new Error(`The selected page has been closed. Call ${listPages().name} to see open pages.`);
|
|
360
254
|
}
|
|
361
|
-
return page
|
|
255
|
+
return page;
|
|
362
256
|
}
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
257
|
+
async getDevToolsData(page) {
|
|
258
|
+
const targetPage = page ?? this.#selectedPage;
|
|
259
|
+
if (!targetPage) {
|
|
260
|
+
return undefined;
|
|
261
|
+
}
|
|
262
|
+
let timeoutId;
|
|
263
|
+
const timeoutPromise = new Promise(resolve => {
|
|
264
|
+
timeoutId = setTimeout(() => resolve(undefined), 500);
|
|
265
|
+
});
|
|
266
|
+
const dataPromise = targetPage.getDevToolsData();
|
|
267
|
+
try {
|
|
268
|
+
return await Promise.race([dataPromise, timeoutPromise]);
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
finally {
|
|
274
|
+
clearTimeout(timeoutId);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Returns true once if this context was created by reconnecting after the
|
|
279
|
+
* previous browser connection was lost, so the next response can surface a
|
|
280
|
+
* note. Cleared on first call.
|
|
281
|
+
*/
|
|
282
|
+
consumeReconnectNotice() {
|
|
283
|
+
const notice = this.#reconnectNotice;
|
|
284
|
+
this.#reconnectNotice = false;
|
|
285
|
+
return notice;
|
|
366
286
|
}
|
|
367
287
|
getPageById(pageId) {
|
|
368
288
|
const page = this.#mcpPages.values().find(mcpPage => mcpPage.id === pageId);
|
|
@@ -371,55 +291,27 @@ export class McpContext {
|
|
|
371
291
|
}
|
|
372
292
|
return page;
|
|
373
293
|
}
|
|
374
|
-
getPageId(page) {
|
|
375
|
-
return this.#mcpPages.get(page)?.id;
|
|
376
|
-
}
|
|
377
|
-
#getMcpPage(page) {
|
|
378
|
-
const mcpPage = this.#mcpPages.get(page);
|
|
379
|
-
if (!mcpPage) {
|
|
380
|
-
throw new Error('No McpPage found for the given page.');
|
|
381
|
-
}
|
|
382
|
-
return mcpPage;
|
|
383
|
-
}
|
|
384
|
-
#getSelectedMcpPage() {
|
|
385
|
-
return this.#getMcpPage(this.getSelectedPptrPage());
|
|
386
|
-
}
|
|
387
294
|
isPageSelected(page) {
|
|
388
|
-
return this.#selectedPage
|
|
295
|
+
return this.#selectedPage === page;
|
|
389
296
|
}
|
|
390
297
|
selectPage(newPage) {
|
|
391
298
|
this.#selectedPage = newPage;
|
|
392
|
-
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
// Increased in case we throttle the network requests or the CPU
|
|
403
|
-
const networkMultiplier = getNetworkMultiplierFromString(page.networkConditions);
|
|
404
|
-
page.pptrPage.setDefaultNavigationTimeout(NAVIGATION_TIMEOUT * networkMultiplier * cpuMultiplier);
|
|
405
|
-
}
|
|
406
|
-
// Linear scan over per-page snapshots. The page count is small (typically
|
|
407
|
-
// 2-10) so a reverse index isn't worthwhile given the uid-reuse lifecycle
|
|
408
|
-
// complexity it would introduce.
|
|
409
|
-
getAXNodeByUid(uid) {
|
|
410
|
-
for (const mcpPage of this.#mcpPages.values()) {
|
|
411
|
-
const node = mcpPage.textSnapshot?.idToNode.get(uid);
|
|
412
|
-
if (node) {
|
|
413
|
-
return node;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
return undefined;
|
|
299
|
+
newPage.updateTimeouts();
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Returns details about the last page snapshot automatically replacing the
|
|
303
|
+
* selection because the selected page disappeared from the page list, or
|
|
304
|
+
* `undefined` if the snapshot left the selection intact. Recomputed on every
|
|
305
|
+
* createPagesSnapshot() call.
|
|
306
|
+
*/
|
|
307
|
+
getSelectedPageFallback() {
|
|
308
|
+
return this.#selectedPageFallback;
|
|
417
309
|
}
|
|
418
310
|
/**
|
|
419
311
|
* Creates a snapshot of the extension service workers.
|
|
420
312
|
*/
|
|
421
313
|
async createExtensionServiceWorkersSnapshot() {
|
|
422
|
-
const allTargets =
|
|
314
|
+
const allTargets = this.browser.targets();
|
|
423
315
|
const serviceWorkers = allTargets.filter(target => {
|
|
424
316
|
return (target.type() === 'service_worker' &&
|
|
425
317
|
target.url().includes('chrome-extension://'));
|
|
@@ -441,74 +333,13 @@ export class McpContext {
|
|
|
441
333
|
getServiceWorkerConsoleData(extensionId) {
|
|
442
334
|
return this.#serviceWorkerConsoleCollector.getData(extensionId);
|
|
443
335
|
}
|
|
444
|
-
|
|
445
|
-
const { pages: allPages, isolatedContextNames } = await this.#getAllPages();
|
|
446
|
-
for (const page of allPages) {
|
|
447
|
-
let mcpPage = this.#mcpPages.get(page);
|
|
448
|
-
if (!mcpPage) {
|
|
449
|
-
mcpPage = new McpPage(page, this.#nextPageId++);
|
|
450
|
-
this.#mcpPages.set(page, mcpPage);
|
|
451
|
-
// We emulate a focused page for all pages to support multi-agent workflows.
|
|
452
|
-
void page.emulateFocusedPage(true).catch(error => {
|
|
453
|
-
this.logger?.('Error turning on focused page emulation', error);
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
mcpPage.isolatedContextName = isolatedContextNames.get(page);
|
|
457
|
-
}
|
|
458
|
-
// Prune orphaned #mcpPages entries (pages that no longer exist).
|
|
459
|
-
const currentPages = new Set(allPages);
|
|
460
|
-
for (const [page, mcpPage] of this.#mcpPages) {
|
|
461
|
-
if (!currentPages.has(page)) {
|
|
462
|
-
mcpPage.dispose();
|
|
463
|
-
this.#mcpPages.delete(page);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
this.#pages = allPages.filter(page => {
|
|
467
|
-
return (this.#options.experimentalDevToolsDebugging ||
|
|
468
|
-
!page.url().startsWith('devtools://'));
|
|
469
|
-
});
|
|
470
|
-
if ((!this.#selectedPage ||
|
|
471
|
-
this.#pages.indexOf(this.#selectedPage.pptrPage) === -1) &&
|
|
472
|
-
this.#pages[0]) {
|
|
473
|
-
this.selectPage(this.#getMcpPage(this.#pages[0]));
|
|
474
|
-
}
|
|
475
|
-
await this.detectOpenDevToolsWindows();
|
|
476
|
-
return this.#pages;
|
|
477
|
-
}
|
|
478
|
-
async #getAllPages() {
|
|
479
|
-
const defaultCtx = this.browser.defaultBrowserContext();
|
|
480
|
-
const allPages = await this.browser.pages(this.#options.experimentalIncludeAllPages);
|
|
481
|
-
const allTargets = this.browser.targets();
|
|
482
|
-
const extensionTargets = allTargets.filter(target => {
|
|
483
|
-
return (target.url().startsWith('chrome-extension://') &&
|
|
484
|
-
target.type() === 'page');
|
|
485
|
-
});
|
|
486
|
-
for (const target of extensionTargets) {
|
|
487
|
-
// Right now target.page() returns null for popup and side panel pages.
|
|
488
|
-
let page = await target.page();
|
|
489
|
-
if (!page) {
|
|
490
|
-
// We need to cache pages instances for targets because target.asPage()
|
|
491
|
-
// returns a new page instance every time.
|
|
492
|
-
page = this.#extensionPages.get(target) ?? null;
|
|
493
|
-
if (!page) {
|
|
494
|
-
try {
|
|
495
|
-
page = await target.asPage();
|
|
496
|
-
this.#extensionPages.set(target, page);
|
|
497
|
-
}
|
|
498
|
-
catch (e) {
|
|
499
|
-
this.logger?.('Failed to get page for extension target', e);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
if (page && !allPages.includes(page)) {
|
|
504
|
-
allPages.push(page);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
336
|
+
#getBrowserContextToNameMap() {
|
|
507
337
|
// Build a reverse lookup from BrowserContext instance → name.
|
|
508
338
|
const contextToName = new Map();
|
|
509
339
|
for (const [name, ctx] of this.#isolatedContexts) {
|
|
510
340
|
contextToName.set(ctx, name);
|
|
511
341
|
}
|
|
342
|
+
const defaultCtx = this.browser.defaultBrowserContext();
|
|
512
343
|
// Auto-discover BrowserContexts not in our mapping (e.g., externally
|
|
513
344
|
// created incognito contexts) and assign generated names.
|
|
514
345
|
const knownContexts = new Set(this.#isolatedContexts.values());
|
|
@@ -519,40 +350,76 @@ export class McpContext {
|
|
|
519
350
|
contextToName.set(ctx, name);
|
|
520
351
|
}
|
|
521
352
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
353
|
+
return contextToName;
|
|
354
|
+
}
|
|
355
|
+
async #createMcpPage(page) {
|
|
356
|
+
let mcpPage = this.#mcpPages.get(page);
|
|
357
|
+
if (!mcpPage) {
|
|
358
|
+
mcpPage = new McpPage(page, nextPageId++, {
|
|
359
|
+
locatorClass: this.#locatorClass,
|
|
360
|
+
hasNetworkBlockOrAllowlist: this.#hasNetworkBlockOrAllowlist,
|
|
361
|
+
isolatedContextName: this.#getBrowserContextToNameMap().get(page.browserContext()),
|
|
362
|
+
});
|
|
363
|
+
this.#mcpPages.set(page, mcpPage);
|
|
364
|
+
await mcpPage.init();
|
|
530
365
|
}
|
|
531
|
-
return
|
|
366
|
+
return mcpPage;
|
|
532
367
|
}
|
|
533
|
-
async
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
368
|
+
async createPagesSnapshot() {
|
|
369
|
+
const allPages = await this.#fetchBrowserPages();
|
|
370
|
+
await Promise.allSettled(allPages.map(page => this.#createMcpPage(page)));
|
|
371
|
+
// Prune orphaned #mcpPages entries (pages that no longer exist).
|
|
372
|
+
const currentPages = new Set(allPages);
|
|
373
|
+
for (const [page, mcpPage] of this.#mcpPages) {
|
|
374
|
+
if (!currentPages.has(page)) {
|
|
375
|
+
mcpPage.dispose();
|
|
376
|
+
this.#mcpPages.delete(page);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
const pages = Array.from(this.#mcpPages.values());
|
|
380
|
+
// Only fall back when the selected page is actually gone. Gating on
|
|
381
|
+
// `isClosed()` instead of `pages` membership avoids silently swapping a
|
|
382
|
+
// live page that is momentarily missing from the snapshot.
|
|
383
|
+
this.#selectedPageFallback = undefined;
|
|
384
|
+
if ((!this.#selectedPage || this.#selectedPage.pptrPage.isClosed()) &&
|
|
385
|
+
pages[0]) {
|
|
386
|
+
// Record the automatic change so the response can surface it. Skipped on
|
|
387
|
+
// first connect, when there was no prior selection to replace.
|
|
388
|
+
if (this.#selectedPage) {
|
|
389
|
+
this.#selectedPageFallback = {
|
|
390
|
+
wasClosed: this.#selectedPage.pptrPage.isClosed(),
|
|
391
|
+
};
|
|
540
392
|
}
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
393
|
+
this.selectPage(pages[0]);
|
|
394
|
+
}
|
|
395
|
+
return pages.map(p => p.pptrPage);
|
|
396
|
+
}
|
|
397
|
+
async #fetchBrowserPages() {
|
|
398
|
+
const allPages = (await this.browser.pages(this.#options.experimentalIncludeAllPages)).filter(page => {
|
|
399
|
+
return (this.#options.experimentalDevToolsDebugging ||
|
|
400
|
+
!page.url().startsWith('devtools://'));
|
|
401
|
+
});
|
|
402
|
+
const allTargets = this.browser.targets();
|
|
403
|
+
const extensionTargets = allTargets.filter(target => {
|
|
404
|
+
return (target.url().startsWith('chrome-extension://') &&
|
|
405
|
+
target.type() === 'page');
|
|
406
|
+
});
|
|
407
|
+
await Promise.allSettled(extensionTargets.map(async (target) => {
|
|
544
408
|
try {
|
|
545
|
-
|
|
546
|
-
|
|
409
|
+
let page = await target.page();
|
|
410
|
+
if (!page) {
|
|
411
|
+
page = await target.asPage();
|
|
547
412
|
}
|
|
548
|
-
|
|
549
|
-
|
|
413
|
+
this.#extensionPages.set(target, page);
|
|
414
|
+
if (page && !allPages.includes(page)) {
|
|
415
|
+
allPages.push(page);
|
|
550
416
|
}
|
|
551
417
|
}
|
|
552
|
-
catch {
|
|
553
|
-
|
|
418
|
+
catch (e) {
|
|
419
|
+
this.logger?.('Failed to get page for extension target', e);
|
|
554
420
|
}
|
|
555
421
|
}));
|
|
422
|
+
return allPages;
|
|
556
423
|
}
|
|
557
424
|
getExtensionServiceWorkers() {
|
|
558
425
|
return this.#extensionServiceWorkers;
|
|
@@ -560,34 +427,37 @@ export class McpContext {
|
|
|
560
427
|
getExtensionServiceWorkerId(extensionServiceWorker) {
|
|
561
428
|
return this.#extensionServiceWorkerMap.get(extensionServiceWorker.target);
|
|
562
429
|
}
|
|
563
|
-
|
|
564
|
-
return this.#pages;
|
|
565
|
-
}
|
|
566
|
-
getIsolatedContextName(page) {
|
|
567
|
-
return this.#mcpPages.get(page)?.isolatedContextName;
|
|
568
|
-
}
|
|
569
|
-
async saveTemporaryFile(data, filename) {
|
|
570
|
-
const filepath = await getTempFilePath(filename);
|
|
430
|
+
async #writeFile(filepath, data) {
|
|
571
431
|
await this.validatePath(filepath);
|
|
572
432
|
try {
|
|
573
|
-
await fs.
|
|
433
|
+
await fs.mkdir(path.dirname(filepath), { recursive: true });
|
|
434
|
+
// Open the file with flags to:
|
|
435
|
+
// - O_WRONLY: Write-only
|
|
436
|
+
// - O_CREAT: Create if it doesn't exist
|
|
437
|
+
// - O_TRUNC: Truncate to zero length if it exists
|
|
438
|
+
// - O_NOFOLLOW: DO NOT follow symlinks.
|
|
439
|
+
// - 0o600: Permissions: read/write for owner, no permissions for others.
|
|
440
|
+
await fs.writeFile(filepath, data, {
|
|
441
|
+
flag: fs.constants.O_WRONLY |
|
|
442
|
+
fs.constants.O_CREAT |
|
|
443
|
+
fs.constants.O_TRUNC |
|
|
444
|
+
fs.constants.O_NOFOLLOW,
|
|
445
|
+
mode: 0o600,
|
|
446
|
+
});
|
|
574
447
|
}
|
|
575
448
|
catch (err) {
|
|
576
|
-
throw new Error(
|
|
449
|
+
throw new Error(`Could not write ${filepath}`, { cause: err });
|
|
577
450
|
}
|
|
451
|
+
}
|
|
452
|
+
async saveTemporaryFile(data, filename) {
|
|
453
|
+
const filepath = await getTempFilePath(filename);
|
|
454
|
+
await this.#writeFile(filepath, data);
|
|
578
455
|
return { filepath };
|
|
579
456
|
}
|
|
580
457
|
async saveFile(data, clientProvidedFilePath, extension) {
|
|
581
458
|
const filePath = await this.ensureExtension(clientProvidedFilePath, extension);
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
await fs.writeFile(filePath, data);
|
|
585
|
-
return { filename: filePath };
|
|
586
|
-
}
|
|
587
|
-
catch (err) {
|
|
588
|
-
this.logger?.(err);
|
|
589
|
-
throw new Error('Could not save a file', { cause: err });
|
|
590
|
-
}
|
|
459
|
+
await this.#writeFile(filePath, data);
|
|
460
|
+
return { filename: filePath };
|
|
591
461
|
}
|
|
592
462
|
storeTraceRecording(result) {
|
|
593
463
|
// Clear the trace results because we only consume the latest trace currently.
|
|
@@ -597,44 +467,18 @@ export class McpContext {
|
|
|
597
467
|
recordedTraces() {
|
|
598
468
|
return this.#traceResults;
|
|
599
469
|
}
|
|
600
|
-
getNetworkRequestStableId(request) {
|
|
601
|
-
return this.#networkCollector.getIdForResource(request);
|
|
602
|
-
}
|
|
603
|
-
waitForTextOnPage(text, timeout, targetPage) {
|
|
604
|
-
const page = targetPage ?? this.getSelectedPptrPage();
|
|
605
|
-
const frames = page.frames();
|
|
606
|
-
let locator = this.#locatorClass.race(frames.flatMap(frame => text.flatMap(value => [
|
|
607
|
-
frame.locator(`aria/${value}`),
|
|
608
|
-
frame.locator(`text/${value}`),
|
|
609
|
-
])));
|
|
610
|
-
if (timeout) {
|
|
611
|
-
locator = locator.setTimeout(timeout);
|
|
612
|
-
}
|
|
613
|
-
return locator.wait();
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* We need to ignore favicon request as they make our test flaky
|
|
617
|
-
*/
|
|
618
|
-
async setUpNetworkCollectorForTesting() {
|
|
619
|
-
this.#networkCollector = new NetworkCollector(this.browser, collect => {
|
|
620
|
-
return {
|
|
621
|
-
request: req => {
|
|
622
|
-
if (req.url().includes('favicon.ico')) {
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
collect(req);
|
|
626
|
-
},
|
|
627
|
-
};
|
|
628
|
-
});
|
|
629
|
-
const { pages } = await this.#getAllPages();
|
|
630
|
-
await this.#networkCollector.init(pages);
|
|
631
|
-
}
|
|
632
470
|
async installExtension(extensionPath) {
|
|
633
|
-
const id = await
|
|
471
|
+
const id = await Promise.race([
|
|
472
|
+
this.browser.installExtension(extensionPath),
|
|
473
|
+
new Promise((_, rej) => setTimeout(() => rej(new Error('Timeout installing extension')), 30000)),
|
|
474
|
+
]);
|
|
634
475
|
return id;
|
|
635
476
|
}
|
|
636
477
|
async uninstallExtension(id) {
|
|
637
|
-
await
|
|
478
|
+
await Promise.race([
|
|
479
|
+
this.browser.uninstallExtension(id),
|
|
480
|
+
new Promise((_, rej) => setTimeout(() => rej(new Error('Timeout uninstalling extension')), 30000)),
|
|
481
|
+
]);
|
|
638
482
|
}
|
|
639
483
|
async triggerExtensionAction(id) {
|
|
640
484
|
const extensions = await this.browser.extensions();
|
|
@@ -642,7 +486,7 @@ export class McpContext {
|
|
|
642
486
|
if (!extension) {
|
|
643
487
|
throw new Error(`Extension with ID ${id} not found.`);
|
|
644
488
|
}
|
|
645
|
-
const page = this.
|
|
489
|
+
const page = this.getSelectedMcpPage().pptrPage;
|
|
646
490
|
await extension.triggerAction(page);
|
|
647
491
|
}
|
|
648
492
|
listExtensions() {
|
|
@@ -652,8 +496,8 @@ export class McpContext {
|
|
|
652
496
|
const pptrExtensions = await this.browser.extensions();
|
|
653
497
|
return pptrExtensions.get(id);
|
|
654
498
|
}
|
|
655
|
-
async getHeapSnapshotAggregates(filePath) {
|
|
656
|
-
return await this.#heapSnapshotManager.getAggregates(filePath);
|
|
499
|
+
async getHeapSnapshotAggregates(filePath, filterName, objectId) {
|
|
500
|
+
return await this.#heapSnapshotManager.getAggregates(filePath, filterName, objectId);
|
|
657
501
|
}
|
|
658
502
|
async getHeapSnapshotDuplicateStrings(filePath) {
|
|
659
503
|
return await this.#heapSnapshotManager.getDuplicateStrings(filePath);
|
|
@@ -664,14 +508,20 @@ export class McpContext {
|
|
|
664
508
|
async getHeapSnapshotStaticData(filePath) {
|
|
665
509
|
return await this.#heapSnapshotManager.getStaticData(filePath);
|
|
666
510
|
}
|
|
667
|
-
async
|
|
668
|
-
return await this.#heapSnapshotManager.
|
|
511
|
+
async getHeapSnapshotNativeContextSizes(filePath) {
|
|
512
|
+
return await this.#heapSnapshotManager.getNativeContextSizes(filePath);
|
|
513
|
+
}
|
|
514
|
+
async getHeapSnapshotNodesById(filePath, id, filterName, objectId) {
|
|
515
|
+
return await this.#heapSnapshotManager.getNodesById(filePath, id, filterName, objectId);
|
|
669
516
|
}
|
|
670
517
|
async getHeapSnapshotRetainers(filePath, nodeId) {
|
|
671
518
|
return await this.#heapSnapshotManager.getRetainers(filePath, nodeId);
|
|
672
519
|
}
|
|
520
|
+
async getHeapSnapshotObjectDetails(filePath, nodeId) {
|
|
521
|
+
return await this.#heapSnapshotManager.getObjectInfo(filePath, nodeId);
|
|
522
|
+
}
|
|
673
523
|
async closeHeapSnapshot(filePath) {
|
|
674
|
-
return this.#heapSnapshotManager.
|
|
524
|
+
return this.#heapSnapshotManager.disposeSnapshot(filePath);
|
|
675
525
|
}
|
|
676
526
|
hasHeapSnapshots() {
|
|
677
527
|
return this.#heapSnapshotManager.hasSnapshots();
|
|
@@ -720,7 +570,7 @@ export class McpContext {
|
|
|
720
570
|
}
|
|
721
571
|
case 'file:': {
|
|
722
572
|
await this.validatePath(fileURLToPath(url));
|
|
723
|
-
return await
|
|
573
|
+
return await fs.readFile(url, 'utf-8');
|
|
724
574
|
}
|
|
725
575
|
default:
|
|
726
576
|
throw new Error(`Unsupported protocol for: ${url}`);
|