chrome-devtools-mcp 1.6.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -22
- package/build/src/McpContext.js +121 -44
- package/build/src/McpPage.js +230 -14
- package/build/src/McpResponse.js +209 -283
- package/build/src/SlimMcpResponse.js +1 -1
- package/build/src/TextSnapshot.js +80 -19
- package/build/src/ToolHandler.js +80 -15
- package/build/src/bin/chrome-devtools-mcp-main.js +3 -3
- package/build/src/bin/chrome-devtools.js +47 -32
- package/build/src/browser.js +3 -1
- package/build/src/{PageCollector.js → collectors/PageCollector.js} +15 -10
- package/build/src/{ServiceWorkerCollector.js → collectors/ServiceWorkerCollector.js} +1 -1
- package/build/src/{bin/chrome-devtools-cli-options.js → config/cli-options.js} +414 -23
- package/build/src/{bin/chrome-devtools-mcp-cli-options.js → config/mcp-options.js} +74 -9
- package/build/src/daemon/client.js +33 -2
- package/build/src/daemon/daemon.js +17 -13
- package/build/src/daemon/utils.js +18 -3
- package/build/src/devtools/DevtoolsUtils.js +9 -16
- package/build/src/formatters/ConsoleFormatter.js +43 -10
- package/build/src/formatters/HeapSnapshotFormatter.js +58 -13
- package/build/src/formatters/IssueFormatter.js +1 -1
- package/build/src/formatters/NetworkFormatter.js +7 -7
- package/build/src/index.js +34 -5
- package/build/src/{HeapSnapshotManager.js → processors/HeapSnapshotManager.js} +82 -27
- package/build/src/{trace-processing/parse.js → processors/PerformanceTrace.js} +1 -1
- package/build/src/telemetry/ClearcutLogger.js +16 -1
- package/build/src/telemetry/flagUtils.js +4 -3
- package/build/src/telemetry/transformation.js +30 -0
- package/build/src/telemetry/types.js +4 -0
- package/build/src/third_party/THIRD_PARTY_NOTICES +235 -113
- package/build/src/third_party/bundled-packages.json +6 -7
- package/build/src/third_party/devtools-formatter-worker.js +60 -19
- package/build/src/third_party/devtools-heap-snapshot-worker.js +657 -224
- package/build/src/third_party/index.js +62484 -43814
- 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/connectionAllowlistEmbeddingRequirementNotSatisfied.md +26 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistIFrameAttributeLoosensEmbeddingRequirement.md +19 -0
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowConnectionAllowlistFrom.md +21 -0
- 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/federatedAuthRequestAccountsBlockedByConnectionAllowlist.md +1 -0
- 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/federatedAuthRequestConfigBlockedByConnectionAllowlist.md +1 -0
- 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/federatedAuthRequestIdTokenBlockedByConnectionAllowlist.md +1 -0
- 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/federatedAuthRequestWellKnownBlockedByConnectionAllowlist.md +1 -0
- 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 +1125 -1027
- package/build/src/tools/categories.js +3 -0
- package/build/src/tools/console.js +9 -3
- package/build/src/tools/emulation.js +2 -2
- package/build/src/tools/extensions.js +7 -5
- package/build/src/tools/input.js +222 -120
- package/build/src/tools/lighthouse.js +3 -1
- package/build/src/tools/memory.js +144 -17
- package/build/src/tools/network.js +6 -3
- package/build/src/tools/pages.js +13 -16
- package/build/src/tools/performance.js +57 -46
- package/build/src/tools/pwa.js +128 -0
- package/build/src/tools/screencast.js +6 -4
- package/build/src/tools/screenshot.js +192 -84
- package/build/src/tools/script.js +118 -34
- package/build/src/tools/slim/tools.js +3 -3
- package/build/src/tools/snapshot.js +5 -3
- package/build/src/tools/thirdPartyDeveloper.js +2 -2
- package/build/src/tools/tools.js +2 -0
- package/build/src/tools/webmcp.js +2 -2
- package/build/src/utils/WaitForHelper.js +299 -0
- package/build/src/utils/bytes.js +105 -0
- package/build/src/utils/logger.js +25 -11
- package/build/src/utils/polyfill.js +6 -3
- package/build/src/utils/url.js +43 -0
- package/build/src/version.js +1 -1
- package/package.json +37 -25
- package/skills/a11y-debugging/SKILL.md +2 -0
- package/skills/chrome-devtools/SKILL.md +5 -4
- package/skills/chrome-devtools-cli/SKILL.md +109 -64
- package/skills/debug-optimize-lcp/SKILL.md +9 -9
- package/skills/memory-leak-debugging/SKILL.md +14 -18
- package/skills/memory-leak-debugging/references/common-leaks.md +1 -1
- package/skills/troubleshooting/SKILL.md +1 -0
- package/build/src/WaitForHelper.js +0 -200
- package/build/src/devtools/DevToolsConnectionAdapter.js +0 -70
- 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/Mutex.js +0 -38
- package/build/src/utils/string.js +0 -37
- package/skills/memory-leak-debugging/references/compare_snapshots.js +0 -109
- package/skills/memory-leak-debugging/references/memlab.md +0 -29
|
@@ -3,20 +3,81 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
7
|
+
if (value !== null && value !== void 0) {
|
|
8
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
9
|
+
var dispose, inner;
|
|
10
|
+
if (async) {
|
|
11
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
12
|
+
dispose = value[Symbol.asyncDispose];
|
|
13
|
+
}
|
|
14
|
+
if (dispose === void 0) {
|
|
15
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
16
|
+
dispose = value[Symbol.dispose];
|
|
17
|
+
if (async) inner = dispose;
|
|
18
|
+
}
|
|
19
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
20
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
21
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
22
|
+
}
|
|
23
|
+
else if (async) {
|
|
24
|
+
env.stack.push({ async: true });
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
29
|
+
return function (env) {
|
|
30
|
+
function fail(e) {
|
|
31
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
32
|
+
env.hasError = true;
|
|
33
|
+
}
|
|
34
|
+
var r, s = 0;
|
|
35
|
+
function next() {
|
|
36
|
+
while (r = env.stack.pop()) {
|
|
37
|
+
try {
|
|
38
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
39
|
+
if (r.dispose) {
|
|
40
|
+
var result = r.dispose.call(r.value);
|
|
41
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
42
|
+
}
|
|
43
|
+
else s |= 1;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
fail(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
50
|
+
if (env.hasError) throw env.error;
|
|
51
|
+
}
|
|
52
|
+
return next();
|
|
53
|
+
};
|
|
54
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
55
|
+
var e = new Error(message);
|
|
56
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
57
|
+
});
|
|
6
58
|
import { zod } from '../third_party/index.js';
|
|
7
59
|
import { ToolCategory } from './categories.js';
|
|
8
60
|
import { defineTool, pageIdSchema } from './ToolDefinition.js';
|
|
9
61
|
export const evaluateScript = defineTool(cliArgs => {
|
|
10
62
|
return {
|
|
11
63
|
name: 'evaluate_script',
|
|
12
|
-
description: `Evaluate a JavaScript function inside the
|
|
64
|
+
description: `Evaluate a JavaScript function inside the target page${cliArgs?.categoryExtensions ? ' or service worker' : ''}. Returns the response as JSON, so returned values have to be JSON-serializable.`,
|
|
13
65
|
annotations: {
|
|
14
66
|
category: ToolCategory.DEBUGGING,
|
|
15
67
|
readOnlyHint: false,
|
|
16
68
|
},
|
|
17
69
|
schema: {
|
|
18
|
-
...(cliArgs?.
|
|
19
|
-
|
|
70
|
+
...(cliArgs?.pageIdRouting
|
|
71
|
+
? cliArgs.categoryExtensions
|
|
72
|
+
? {
|
|
73
|
+
pageId: zod
|
|
74
|
+
.number()
|
|
75
|
+
.optional()
|
|
76
|
+
.describe('Targets a specific page by ID. Required when not evaluating in a service worker.'),
|
|
77
|
+
}
|
|
78
|
+
: pageIdSchema
|
|
79
|
+
: {}),
|
|
80
|
+
function: zod.string().describe(`A JavaScript function declaration to be executed by the tool in the target page.
|
|
20
81
|
Example without arguments: \`() => document.title\` or \`async () => await fetch("example.com")\`.
|
|
21
82
|
Example with arguments: \`(el) => el.innerText\`
|
|
22
83
|
`),
|
|
@@ -34,6 +95,10 @@ Example with arguments: \`(el) => el.innerText\`
|
|
|
34
95
|
.string()
|
|
35
96
|
.optional()
|
|
36
97
|
.describe('Handle dialogs while execution. "accept", "dismiss", or string for response of window.prompt. Defaults to accept.'),
|
|
98
|
+
waitForStableDom: zod
|
|
99
|
+
.boolean()
|
|
100
|
+
.optional()
|
|
101
|
+
.describe('Whether to wait for the DOM to settle. Pass false if the script only reads data. Defaults to true.'),
|
|
37
102
|
...(cliArgs?.categoryExtensions
|
|
38
103
|
? {
|
|
39
104
|
serviceWorkerId: zod
|
|
@@ -44,41 +109,51 @@ Example with arguments: \`(el) => el.innerText\`
|
|
|
44
109
|
: {}),
|
|
45
110
|
},
|
|
46
111
|
blockedByDialog: true,
|
|
47
|
-
verifyFilesSchema:
|
|
112
|
+
verifyFilesSchema: {
|
|
113
|
+
filePath: true,
|
|
114
|
+
},
|
|
48
115
|
handler: async (request, response, context) => {
|
|
49
|
-
const {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
116
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
117
|
+
try {
|
|
118
|
+
const { serviceWorkerId, args: uidArgs, function: fnString, pageId, dialogAction, filePath, waitForStableDom, } = request.params;
|
|
119
|
+
if (cliArgs?.categoryExtensions && serviceWorkerId) {
|
|
120
|
+
if (uidArgs && uidArgs.length > 0) {
|
|
121
|
+
throw new Error('args (element uids) cannot be used when evaluating in a service worker.');
|
|
122
|
+
}
|
|
123
|
+
if (pageId) {
|
|
124
|
+
throw new Error('specify either a pageId or a serviceWorkerId.');
|
|
125
|
+
}
|
|
126
|
+
const worker = await getWebWorker(context, serviceWorkerId);
|
|
127
|
+
const result = await context
|
|
128
|
+
.getSelectedMcpPage()
|
|
129
|
+
.waitForEventsAfterAction(async () => {
|
|
130
|
+
await performEvaluation(worker, fnString, [], response, {
|
|
131
|
+
filePath,
|
|
132
|
+
context,
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
// Service workers cannot interact with the DOM, so never wait for it.
|
|
136
|
+
{ handleDialog: dialogAction ?? 'accept', waitForStableDom: false });
|
|
137
|
+
if (result.dialogHandled) {
|
|
138
|
+
context.getSelectedMcpPage().clearDialog();
|
|
139
|
+
}
|
|
140
|
+
response.attachWaitForResult(result);
|
|
141
|
+
return;
|
|
53
142
|
}
|
|
54
|
-
if (pageId) {
|
|
143
|
+
if (cliArgs?.categoryExtensions && cliArgs?.pageIdRouting && !pageId) {
|
|
55
144
|
throw new Error('specify either a pageId or a serviceWorkerId.');
|
|
56
145
|
}
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
.getSelectedMcpPage()
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
context,
|
|
64
|
-
});
|
|
65
|
-
}, { handleDialog: dialogAction ?? 'accept' });
|
|
66
|
-
if (result.dialogHandled) {
|
|
67
|
-
context.getSelectedMcpPage().clearDialog();
|
|
68
|
-
}
|
|
69
|
-
response.attachWaitForResult(result);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
const mcpPage = cliArgs?.experimentalPageIdRouting
|
|
73
|
-
? context.getPageById(request.params.pageId)
|
|
74
|
-
: context.getSelectedMcpPage();
|
|
75
|
-
const page = mcpPage.pptrPage;
|
|
76
|
-
const args = [];
|
|
77
|
-
try {
|
|
146
|
+
const mcpPage = cliArgs?.pageIdRouting && request.params.pageId
|
|
147
|
+
? context.getPageById(request.params.pageId)
|
|
148
|
+
: context.getSelectedMcpPage();
|
|
149
|
+
const page = mcpPage.pptrPage;
|
|
150
|
+
const args = [];
|
|
151
|
+
const stack = __addDisposableResource(env_1, new DisposableStack(), false);
|
|
78
152
|
const frames = new Set();
|
|
79
153
|
for (const uid of uidArgs ?? []) {
|
|
80
154
|
const handle = await mcpPage.getElementByUid(uid);
|
|
81
155
|
frames.add(handle.frame);
|
|
156
|
+
stack.use(handle);
|
|
82
157
|
args.push(handle);
|
|
83
158
|
}
|
|
84
159
|
const evaluatable = await getPageOrFrame(page, frames);
|
|
@@ -87,18 +162,23 @@ Example with arguments: \`(el) => el.innerText\`
|
|
|
87
162
|
filePath,
|
|
88
163
|
context,
|
|
89
164
|
});
|
|
90
|
-
}, { handleDialog: dialogAction ?? 'accept' });
|
|
165
|
+
}, { handleDialog: dialogAction ?? 'accept', waitForStableDom });
|
|
91
166
|
response.attachWaitForResult(result);
|
|
92
167
|
}
|
|
168
|
+
catch (e_1) {
|
|
169
|
+
env_1.error = e_1;
|
|
170
|
+
env_1.hasError = true;
|
|
171
|
+
}
|
|
93
172
|
finally {
|
|
94
|
-
|
|
173
|
+
__disposeResources(env_1);
|
|
95
174
|
}
|
|
96
175
|
},
|
|
97
176
|
};
|
|
98
177
|
});
|
|
99
178
|
const performEvaluation = async (evaluatable, fnString, args, response, options) => {
|
|
100
|
-
const
|
|
179
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
101
180
|
try {
|
|
181
|
+
const fn = __addDisposableResource(env_2, await evaluatable.evaluateHandle(`(${fnString})`), false);
|
|
102
182
|
const result = await evaluatable.evaluate(async (fn, ...args) => {
|
|
103
183
|
// @ts-expect-error no types for function fn
|
|
104
184
|
return JSON.stringify(await fn(...args));
|
|
@@ -115,8 +195,12 @@ const performEvaluation = async (evaluatable, fnString, args, response, options)
|
|
|
115
195
|
response.appendResponseLine('```');
|
|
116
196
|
}
|
|
117
197
|
}
|
|
198
|
+
catch (e_2) {
|
|
199
|
+
env_2.error = e_2;
|
|
200
|
+
env_2.hasError = true;
|
|
201
|
+
}
|
|
118
202
|
finally {
|
|
119
|
-
|
|
203
|
+
__disposeResources(env_2);
|
|
120
204
|
}
|
|
121
205
|
};
|
|
122
206
|
const getPageOrFrame = async (page, frames) => {
|
|
@@ -16,7 +16,7 @@ export const screenshot = definePageTool({
|
|
|
16
16
|
},
|
|
17
17
|
schema: {},
|
|
18
18
|
blockedByDialog: true,
|
|
19
|
-
verifyFilesSchema:
|
|
19
|
+
verifyFilesSchema: {},
|
|
20
20
|
handler: async (request, response, context) => {
|
|
21
21
|
const page = request.page;
|
|
22
22
|
const screenshot = await page.pptrPage.screenshot({
|
|
@@ -38,7 +38,7 @@ export const navigate = definePageTool({
|
|
|
38
38
|
url: zod.string().describe('URL to navigate to'),
|
|
39
39
|
},
|
|
40
40
|
blockedByDialog: false,
|
|
41
|
-
verifyFilesSchema:
|
|
41
|
+
verifyFilesSchema: {},
|
|
42
42
|
handler: async (request, response) => {
|
|
43
43
|
const page = request.page;
|
|
44
44
|
const options = {
|
|
@@ -73,7 +73,7 @@ export const evaluate = definePageTool({
|
|
|
73
73
|
script: zod.string().describe(`JS script to run on the page`),
|
|
74
74
|
},
|
|
75
75
|
blockedByDialog: true,
|
|
76
|
-
verifyFilesSchema:
|
|
76
|
+
verifyFilesSchema: {},
|
|
77
77
|
handler: async (request, response) => {
|
|
78
78
|
const page = request.page;
|
|
79
79
|
try {
|
|
@@ -8,7 +8,7 @@ import { ToolCategory } from './categories.js';
|
|
|
8
8
|
import { definePageTool, timeoutSchema } from './ToolDefinition.js';
|
|
9
9
|
export const takeSnapshot = definePageTool({
|
|
10
10
|
name: 'take_snapshot',
|
|
11
|
-
description: `Take a text snapshot of the
|
|
11
|
+
description: `Take a text snapshot of the target page based on the a11y tree. The snapshot lists page elements along with a unique
|
|
12
12
|
identifier (uid). Always use the latest snapshot. Prefer taking a snapshot over taking a screenshot. The snapshot indicates the element selected
|
|
13
13
|
in the DevTools Elements panel (if any).`,
|
|
14
14
|
annotations: {
|
|
@@ -27,7 +27,9 @@ in the DevTools Elements panel (if any).`,
|
|
|
27
27
|
.describe('The absolute path, or a path relative to the current working directory, to save the snapshot to instead of attaching it to the response.'),
|
|
28
28
|
},
|
|
29
29
|
blockedByDialog: true,
|
|
30
|
-
verifyFilesSchema:
|
|
30
|
+
verifyFilesSchema: {
|
|
31
|
+
filePath: true,
|
|
32
|
+
},
|
|
31
33
|
handler: async (request, response) => {
|
|
32
34
|
response.includeSnapshot({
|
|
33
35
|
verbose: request.params.verbose ?? false,
|
|
@@ -50,7 +52,7 @@ export const waitFor = definePageTool({
|
|
|
50
52
|
...timeoutSchema,
|
|
51
53
|
},
|
|
52
54
|
blockedByDialog: true,
|
|
53
|
-
verifyFilesSchema:
|
|
55
|
+
verifyFilesSchema: {},
|
|
54
56
|
handler: async (request, response) => {
|
|
55
57
|
const page = request.page;
|
|
56
58
|
await page.waitForTextOnPage(request.params.text, request.params.timeout);
|
|
@@ -21,7 +21,7 @@ third-party developer tools with additional functionality.`,
|
|
|
21
21
|
},
|
|
22
22
|
schema: {},
|
|
23
23
|
blockedByDialog: false,
|
|
24
|
-
verifyFilesSchema:
|
|
24
|
+
verifyFilesSchema: {},
|
|
25
25
|
handler: async (_request, response) => {
|
|
26
26
|
response.setListThirdPartyDeveloperTools();
|
|
27
27
|
},
|
|
@@ -41,7 +41,7 @@ export const executeThirdPartyDeveloperTool = definePageTool({
|
|
|
41
41
|
.describe('The JSON-stringified parameters to pass to the tool'),
|
|
42
42
|
},
|
|
43
43
|
blockedByDialog: false,
|
|
44
|
-
verifyFilesSchema:
|
|
44
|
+
verifyFilesSchema: {},
|
|
45
45
|
handler: async (request, response) => {
|
|
46
46
|
const toolName = request.params.toolName;
|
|
47
47
|
let params = {};
|
package/build/src/tools/tools.js
CHANGED
|
@@ -12,6 +12,7 @@ import * as memoryTools from './memory.js';
|
|
|
12
12
|
import * as networkTools from './network.js';
|
|
13
13
|
import * as pagesTools from './pages.js';
|
|
14
14
|
import * as performanceTools from './performance.js';
|
|
15
|
+
import * as pwaTools from './pwa.js';
|
|
15
16
|
import * as screencastTools from './screencast.js';
|
|
16
17
|
import * as screenshotTools from './screenshot.js';
|
|
17
18
|
import * as scriptTools from './script.js';
|
|
@@ -32,6 +33,7 @@ export const createTools = (args) => {
|
|
|
32
33
|
...Object.values(networkTools),
|
|
33
34
|
...Object.values(pagesTools),
|
|
34
35
|
...Object.values(performanceTools),
|
|
36
|
+
...Object.values(pwaTools),
|
|
35
37
|
...Object.values(screencastTools),
|
|
36
38
|
...Object.values(screenshotTools),
|
|
37
39
|
...Object.values(scriptTools),
|
|
@@ -15,7 +15,7 @@ export const listWebMcpTools = definePageTool({
|
|
|
15
15
|
},
|
|
16
16
|
schema: {},
|
|
17
17
|
blockedByDialog: false,
|
|
18
|
-
verifyFilesSchema:
|
|
18
|
+
verifyFilesSchema: {},
|
|
19
19
|
handler: async (_request, response) => {
|
|
20
20
|
response.setListWebMcpTools();
|
|
21
21
|
},
|
|
@@ -35,7 +35,7 @@ export const executeWebMcpTool = definePageTool({
|
|
|
35
35
|
.describe('The JSON-stringified parameters to pass to the WebMCP tool'),
|
|
36
36
|
},
|
|
37
37
|
blockedByDialog: false,
|
|
38
|
-
verifyFilesSchema:
|
|
38
|
+
verifyFilesSchema: {},
|
|
39
39
|
handler: async (request, response) => {
|
|
40
40
|
const toolName = request.params.toolName;
|
|
41
41
|
let input = {};
|
|
@@ -0,0 +1,299 @@
|
|
|
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 { logger } from './logger.js';
|
|
59
|
+
export class WaitForHelper {
|
|
60
|
+
#abortController = new AbortController();
|
|
61
|
+
#page;
|
|
62
|
+
#stableDomTimeout;
|
|
63
|
+
#stableDomFor;
|
|
64
|
+
#expectNavigationIn;
|
|
65
|
+
#navigationTimeout;
|
|
66
|
+
#dialogHandled = false;
|
|
67
|
+
/** Track all dialogs as they pause the renderer. */
|
|
68
|
+
#dialogDetected = false;
|
|
69
|
+
#initialUrl;
|
|
70
|
+
constructor(page, cpuTimeoutMultiplier, networkTimeoutMultiplier) {
|
|
71
|
+
this.#stableDomTimeout = 3000 * cpuTimeoutMultiplier;
|
|
72
|
+
this.#stableDomFor = 100 * cpuTimeoutMultiplier;
|
|
73
|
+
this.#expectNavigationIn = 100 * cpuTimeoutMultiplier;
|
|
74
|
+
this.#navigationTimeout = 3000 * networkTimeoutMultiplier;
|
|
75
|
+
this.#page = page;
|
|
76
|
+
this.#initialUrl = page.url();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A wrapper that executes a action and waits for
|
|
80
|
+
* a potential navigation, after which it waits
|
|
81
|
+
* for the DOM to be stable before returning.
|
|
82
|
+
*/
|
|
83
|
+
async waitForStableDom() {
|
|
84
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
85
|
+
try {
|
|
86
|
+
// Bound the setup evaluation against the stable-DOM timeout. Without this
|
|
87
|
+
// cap a paused renderer (e.g. an open dialog) would make evaluateHandle
|
|
88
|
+
// hang until protocolTimeout (default 180s) while the tool mutex is held.
|
|
89
|
+
const stableDomObserver = __addDisposableResource(env_1, await Promise.race([
|
|
90
|
+
this.#page.evaluateHandle(timeout => {
|
|
91
|
+
let timeoutId;
|
|
92
|
+
function callback() {
|
|
93
|
+
clearTimeout(timeoutId);
|
|
94
|
+
timeoutId = setTimeout(() => {
|
|
95
|
+
domObserver.resolver.resolve();
|
|
96
|
+
domObserver.observer.disconnect();
|
|
97
|
+
}, timeout);
|
|
98
|
+
}
|
|
99
|
+
const domObserver = {
|
|
100
|
+
resolver: Promise.withResolvers(),
|
|
101
|
+
observer: new MutationObserver(callback),
|
|
102
|
+
};
|
|
103
|
+
// It's possible that the DOM is not gonna change so we
|
|
104
|
+
// need to start the timeout initially.
|
|
105
|
+
callback();
|
|
106
|
+
domObserver.observer.observe(document.body, {
|
|
107
|
+
childList: true,
|
|
108
|
+
subtree: true,
|
|
109
|
+
attributes: true,
|
|
110
|
+
});
|
|
111
|
+
return domObserver;
|
|
112
|
+
}, this.#stableDomFor),
|
|
113
|
+
this.timeout(this.#stableDomTimeout),
|
|
114
|
+
]).catch(() => undefined), false);
|
|
115
|
+
if (!stableDomObserver) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
this.#abortController.signal.addEventListener('abort', async () => {
|
|
119
|
+
try {
|
|
120
|
+
await stableDomObserver.evaluate(observer => {
|
|
121
|
+
observer.observer.disconnect();
|
|
122
|
+
observer.resolver.resolve();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// Ignored cleanup errors
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return Promise.race([
|
|
130
|
+
stableDomObserver.evaluate(async (observer) => {
|
|
131
|
+
return await observer.resolver.promise;
|
|
132
|
+
}),
|
|
133
|
+
this.timeout(this.#stableDomTimeout).then(() => {
|
|
134
|
+
throw new Error('Timeout');
|
|
135
|
+
}),
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
catch (e_1) {
|
|
139
|
+
env_1.error = e_1;
|
|
140
|
+
env_1.hasError = true;
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
__disposeResources(env_1);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
timeout(time) {
|
|
147
|
+
return new Promise(res => {
|
|
148
|
+
const id = setTimeout(res, time);
|
|
149
|
+
this.#abortController.signal.addEventListener('abort', () => {
|
|
150
|
+
res();
|
|
151
|
+
clearTimeout(id);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
async waitForEventsAfterAction(action, options) {
|
|
156
|
+
if (this.#abortController.signal.aborted) {
|
|
157
|
+
throw new Error("Can't re-use a WaitForHelper");
|
|
158
|
+
}
|
|
159
|
+
const dialogHandler = (dialog) => {
|
|
160
|
+
this.#dialogDetected = true;
|
|
161
|
+
if (!options?.handleDialog) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
let actionToTake;
|
|
165
|
+
if (typeof options.handleDialog === 'object') {
|
|
166
|
+
actionToTake = options.handleDialog[dialog.type()];
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
actionToTake = options.handleDialog;
|
|
170
|
+
}
|
|
171
|
+
if (actionToTake) {
|
|
172
|
+
this.#dialogHandled = true;
|
|
173
|
+
if (actionToTake === 'dismiss') {
|
|
174
|
+
void dialog.dismiss();
|
|
175
|
+
}
|
|
176
|
+
else if (actionToTake === 'accept') {
|
|
177
|
+
void dialog.accept();
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
void dialog.accept(actionToTake);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
this.#page.on('dialog', dialogHandler);
|
|
185
|
+
this.#abortController.signal.addEventListener('abort', () => {
|
|
186
|
+
this.#page.off('dialog', dialogHandler);
|
|
187
|
+
});
|
|
188
|
+
// A scoped AbortController used to clean up navigation probe listeners.
|
|
189
|
+
// When aborted (either after navigation detection finishes or if this.#abortController
|
|
190
|
+
// aborts), it removes the CDP Page.frameStartedNavigating listener and automatically
|
|
191
|
+
// detaches the abort listener from this.#abortController.signal.
|
|
192
|
+
const navigationAbortController = new AbortController();
|
|
193
|
+
const navigationStartedResolvers = Promise.withResolvers();
|
|
194
|
+
const navigationListener = (event) => {
|
|
195
|
+
if (event.frameId !== this.#page.mainFrame()._id) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (event.navigationType === 'sameDocument' ||
|
|
199
|
+
event.navigationType === 'historySameDocument') {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
navigationStartedResolvers.resolve(true);
|
|
203
|
+
};
|
|
204
|
+
this.#page._client().on('Page.frameStartedNavigating', navigationListener);
|
|
205
|
+
navigationAbortController.signal.addEventListener('abort', () => {
|
|
206
|
+
this.#page
|
|
207
|
+
._client()
|
|
208
|
+
.off('Page.frameStartedNavigating', navigationListener);
|
|
209
|
+
});
|
|
210
|
+
this.#abortController.signal.addEventListener('abort', () => {
|
|
211
|
+
navigationStartedResolvers.resolve(false);
|
|
212
|
+
navigationAbortController.abort();
|
|
213
|
+
}, { signal: navigationAbortController.signal });
|
|
214
|
+
// Puppeteer's waitForNavigation must be started before the action runs so that
|
|
215
|
+
// it captures the pre-action loader ID. If started after the action triggers navigation,
|
|
216
|
+
// it risks recording the new loader ID and hanging until timeout.
|
|
217
|
+
// If no navigation occurs, this.#abortController will cancel it in the finally block.
|
|
218
|
+
const navigationFinished = this.#page
|
|
219
|
+
.waitForNavigation({
|
|
220
|
+
timeout: options?.timeout ?? this.#navigationTimeout,
|
|
221
|
+
signal: this.#abortController.signal,
|
|
222
|
+
ignoreSameDocumentNavigation: true,
|
|
223
|
+
})
|
|
224
|
+
.then(result => {
|
|
225
|
+
navigationStartedResolvers.resolve(true);
|
|
226
|
+
return result;
|
|
227
|
+
})
|
|
228
|
+
.catch(error => {
|
|
229
|
+
if (this.#abortController.signal.aborted ||
|
|
230
|
+
(error instanceof Error && error.name === 'AbortError')) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
logger?.(error);
|
|
234
|
+
});
|
|
235
|
+
try {
|
|
236
|
+
await action();
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
// Clear up pending promises
|
|
240
|
+
this.#abortController.abort();
|
|
241
|
+
throw error;
|
|
242
|
+
}
|
|
243
|
+
const expectNavigationIn = options?.expectNavigationIn ?? this.#expectNavigationIn;
|
|
244
|
+
const navigationStarted = await Promise.race([
|
|
245
|
+
navigationStartedResolvers.promise,
|
|
246
|
+
this.timeout(expectNavigationIn).then(() => {
|
|
247
|
+
navigationStartedResolvers.resolve(false);
|
|
248
|
+
return false;
|
|
249
|
+
}),
|
|
250
|
+
]);
|
|
251
|
+
navigationAbortController.abort();
|
|
252
|
+
try {
|
|
253
|
+
// Only await navigation if one was actually initiated; otherwise, the
|
|
254
|
+
// pending waitForNavigation promise will be cancelled when this.#abortController aborts.
|
|
255
|
+
if (navigationStarted) {
|
|
256
|
+
await navigationFinished;
|
|
257
|
+
}
|
|
258
|
+
if (this.#dialogDetected) {
|
|
259
|
+
return this.#getResult();
|
|
260
|
+
}
|
|
261
|
+
// Wait for stable dom after navigation so we execute in
|
|
262
|
+
// the correct context
|
|
263
|
+
if (options?.waitForStableDom !== false) {
|
|
264
|
+
await this.waitForStableDom();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (error) {
|
|
268
|
+
logger?.(error);
|
|
269
|
+
}
|
|
270
|
+
finally {
|
|
271
|
+
this.#abortController.abort();
|
|
272
|
+
}
|
|
273
|
+
return this.#getResult();
|
|
274
|
+
}
|
|
275
|
+
#getResult() {
|
|
276
|
+
const urlAfterAction = this.#page.url();
|
|
277
|
+
return {
|
|
278
|
+
...(urlAfterAction !== this.#initialUrl
|
|
279
|
+
? { navigatedToUrl: urlAfterAction }
|
|
280
|
+
: {}),
|
|
281
|
+
dialogHandled: this.#dialogHandled,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
export function getNetworkMultiplierFromString(condition) {
|
|
286
|
+
const puppeteerCondition = condition;
|
|
287
|
+
switch (puppeteerCondition) {
|
|
288
|
+
case 'Fast 4G':
|
|
289
|
+
return 1;
|
|
290
|
+
case 'Slow 4G':
|
|
291
|
+
return 2.5;
|
|
292
|
+
case 'Fast 3G':
|
|
293
|
+
return 5;
|
|
294
|
+
case 'Slow 3G':
|
|
295
|
+
return 10;
|
|
296
|
+
}
|
|
297
|
+
return 1;
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=WaitForHelper.js.map
|