opera-devtools-mcp 0.2.4 → 0.4.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 +108 -8
- package/build/src/McpContext.js +365 -365
- package/build/src/McpPage.js +475 -48
- package/build/src/McpResponse.js +462 -288
- package/build/src/SlimMcpResponse.js +1 -1
- package/build/src/TextSnapshot.js +101 -22
- package/build/src/ToolHandler.js +142 -20
- package/build/src/bin/check-latest-version.js +27 -1
- package/build/src/bin/chrome-devtools-cli-options.js +614 -10
- package/build/src/bin/chrome-devtools-mcp-cli-options.js +119 -32
- package/build/src/bin/chrome-devtools-mcp-main.js +50 -7
- package/build/src/bin/chrome-devtools-mcp.js +7 -4
- package/build/src/bin/chrome-devtools.js +57 -14
- package/build/src/bin/opera-devtools-cli-options.js +3 -829
- package/build/src/bin/opera-devtools-mcp-cli-options.js +3 -348
- package/build/src/bin/opera-devtools-mcp-main.js +3 -37
- package/build/src/bin/opera-devtools-mcp.js +4 -19
- package/build/src/bin/opera-devtools.js +4 -185
- package/build/src/browser.js +45 -5
- package/build/src/{PageCollector.js → collectors/PageCollector.js} +64 -133
- package/build/src/collectors/ServiceWorkerCollector.js +171 -0
- package/build/src/daemon/client.js +75 -17
- package/build/src/daemon/daemon.js +92 -30
- package/build/src/daemon/utils.js +24 -8
- package/build/src/{DevtoolsUtils.js → devtools/DevtoolsUtils.js} +94 -88
- package/build/src/devtools/McpHostBindingAdapter.js +165 -0
- package/build/src/{issue-descriptions.js → devtools/issueDescriptions.js} +8 -6
- package/build/src/formatters/ConsoleFormatter.js +44 -11
- package/build/src/formatters/HeapSnapshotFormatter.js +140 -9
- package/build/src/formatters/IssueFormatter.js +7 -7
- package/build/src/formatters/NetworkFormatter.js +10 -8
- package/build/src/index.js +101 -232
- package/build/src/opera/branding.js +34 -0
- package/build/src/opera/browserFlags.js +85 -0
- package/build/src/opera/browserLaunch.js +52 -0
- package/build/src/opera/policy.js +50 -0
- package/build/src/opera/serviceWorkerRetry.js +37 -0
- package/build/src/opera/toolHandlerHooks.js +39 -0
- package/build/src/{tools → opera/tools}/opera.js +116 -21
- package/build/src/processors/HeapSnapshotManager.js +258 -0
- package/build/src/{trace-processing/parse.js → processors/PerformanceTrace.js} +9 -9
- package/build/src/telemetry/ClearcutLogger.js +12 -119
- package/build/src/telemetry/WatchdogClient.js +5 -5
- package/build/src/telemetry/errors.js +1 -1
- package/build/src/telemetry/flagUtils.js +6 -6
- package/build/src/telemetry/{toolMetricsUtils.js → metricsRegistry.js} +4 -11
- package/build/src/telemetry/persistence.js +3 -3
- package/build/src/telemetry/transformation.js +193 -0
- package/build/src/telemetry/watchdog/ClearcutSender.js +11 -11
- package/build/src/telemetry/watchdog/main.js +6 -6
- package/build/src/third_party/THIRD_PARTY_NOTICES +232 -1061
- package/build/src/third_party/bundled-packages.json +7 -8
- package/build/src/third_party/devtools-formatter-worker.js +63 -22
- package/build/src/third_party/devtools-heap-snapshot-worker.js +809 -182
- package/build/src/third_party/index.js +69558 -74691
- 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 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsHttpNotFound.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidContentType.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsInvalidResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestAccountsNoResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsFetchFailed.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestDnsInvalidRecord.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownHttpNotFound.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidContentType.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownInvalidResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestEmailVerificationWellKnownNoResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestInvalidEmail.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksHttpNotFound.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestJwksInvalidResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestKeyBindingSigningFailed.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestRpOriginIsOpaque.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenHttpNotFound.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidContentType.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenInvalidSdJwt.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenMalformedSdJwt.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenNoResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidAudience.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidIssuedAt.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidNonce.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidSdHash.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbInvalidTyp.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingAud.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingCnf.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingIat.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingNonce.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbMissingSdHash.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationKbSignatureFailed.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmail.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidEmailVerified.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidHolderKey.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuedAt.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtInvalidIssuer.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtJwksMissingKeys.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingCnf.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingEmail.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIat.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtMissingIss.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtSignatureFailed.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestTokenVerificationSdJwtUnsupportedHeaderAlg.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestUserLoggedOut.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownAccountsEndpointCrossOrigin.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownHttpNotFound.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidContentType.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownInvalidResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownIssuanceEndpointCrossOrigin.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownListEmpty.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingAccountsEndpoint.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownMissingIssuanceEndpoint.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownNoResponse.md +1 -0
- package/build/src/third_party/issue-descriptions/emailVerificationRequestWellKnownUnsupportedSigningAlgorithm.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/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/genericBackUINavigationWouldSkipAd.md +4 -0
- 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/ToolDefinition.js +2 -2
- package/build/src/tools/categories.js +3 -0
- package/build/src/tools/console.js +13 -0
- package/build/src/tools/emulation.js +30 -3
- package/build/src/tools/extensions.js +8 -1
- package/build/src/tools/input.js +246 -128
- package/build/src/tools/lighthouse.js +14 -7
- package/build/src/tools/memory.js +289 -25
- package/build/src/tools/network.js +10 -7
- package/build/src/tools/pages.js +33 -92
- package/build/src/tools/performance.js +67 -52
- package/build/src/tools/pwa.js +128 -0
- package/build/src/tools/screencast.js +35 -12
- package/build/src/tools/screenshot.js +234 -75
- package/build/src/tools/script.js +130 -45
- package/build/src/tools/slim/tools.js +3 -0
- package/build/src/tools/snapshot.js +7 -4
- package/build/src/tools/thirdPartyDeveloper.js +19 -9
- package/build/src/tools/tools.js +3 -1
- package/build/src/tools/webmcp.js +3 -1
- package/build/src/utils/WaitForHelper.js +299 -0
- package/build/src/utils/check-for-updates.js +8 -2
- package/build/src/utils/files.js +42 -3
- package/build/src/utils/logger.js +51 -0
- package/build/src/utils/polyfill.js +11 -0
- package/build/src/utils/url.js +43 -0
- package/build/src/version.js +1 -4
- package/package.json +43 -33
- package/build/src/DevToolsConnectionAdapter.js +0 -70
- package/build/src/HeapSnapshotManager.js +0 -110
- package/build/src/Mutex.js +0 -38
- package/build/src/WaitForHelper.js +0 -195
- package/build/src/bin/cliDefinitions.js +0 -616
- package/build/src/logger.js +0 -37
- package/build/src/polyfill.js +0 -8
- package/build/src/telemetry/metricUtils.js +0 -15
- 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/string.js +0 -37
- package/build/src/utils/types.js +0 -7
|
@@ -3,85 +3,244 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
category: ToolCategory.DEBUGGING,
|
|
14
|
-
// Not read-only due to filePath param.
|
|
15
|
-
readOnlyHint: false,
|
|
16
|
-
},
|
|
17
|
-
schema: {
|
|
18
|
-
format: zod
|
|
19
|
-
.enum(['png', 'jpeg', 'webp'])
|
|
20
|
-
.default('png')
|
|
21
|
-
.describe('Type of format to save the screenshot as. Default is "png"'),
|
|
22
|
-
quality: zod
|
|
23
|
-
.number()
|
|
24
|
-
.min(0)
|
|
25
|
-
.max(100)
|
|
26
|
-
.optional()
|
|
27
|
-
.describe('Compression quality for JPEG and WebP formats (0-100). Higher values mean better quality but larger file sizes. Ignored for PNG format.'),
|
|
28
|
-
uid: zod
|
|
29
|
-
.string()
|
|
30
|
-
.optional()
|
|
31
|
-
.describe('The uid of an element on the page from the page content snapshot. If omitted, takes a page screenshot.'),
|
|
32
|
-
fullPage: zod
|
|
33
|
-
.boolean()
|
|
34
|
-
.optional()
|
|
35
|
-
.describe('If set to true takes a screenshot of the full page instead of the currently visible viewport. Incompatible with uid.'),
|
|
36
|
-
filePath: zod
|
|
37
|
-
.string()
|
|
38
|
-
.optional()
|
|
39
|
-
.describe('The absolute path, or a path relative to the current working directory, to save the screenshot to instead of attaching it to the response.'),
|
|
40
|
-
},
|
|
41
|
-
blockedByDialog: true,
|
|
42
|
-
handler: async (request, response, context) => {
|
|
43
|
-
context.validatePath(request.params.filePath);
|
|
44
|
-
if (request.params.uid && request.params.fullPage) {
|
|
45
|
-
throw new Error('Providing both "uid" and "fullPage" is not allowed.');
|
|
46
|
-
}
|
|
47
|
-
let pageOrHandle;
|
|
48
|
-
if (request.params.uid) {
|
|
49
|
-
pageOrHandle = await request.page.getElementByUid(request.params.uid);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
pageOrHandle = request.page.pptrPage;
|
|
53
|
-
}
|
|
54
|
-
const format = request.params.format;
|
|
55
|
-
const quality = format === 'png' ? undefined : request.params.quality;
|
|
56
|
-
const screenshot = await pageOrHandle.screenshot({
|
|
57
|
-
type: format,
|
|
58
|
-
fullPage: request.params.fullPage,
|
|
59
|
-
quality,
|
|
60
|
-
optimizeForSpeed: true, // Bonus: optimize encoding for speed
|
|
61
|
-
});
|
|
62
|
-
if (request.params.uid) {
|
|
63
|
-
response.appendResponseLine(`Took a screenshot of node with uid "${request.params.uid}".`);
|
|
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];
|
|
64
13
|
}
|
|
65
|
-
|
|
66
|
-
|
|
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;
|
|
67
18
|
}
|
|
68
|
-
|
|
69
|
-
|
|
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;
|
|
70
33
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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;
|
|
74
51
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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 { zod } from '../third_party/index.js';
|
|
59
|
+
import { ToolCategory } from './categories.js';
|
|
60
|
+
import { definePageTool } from './ToolDefinition.js';
|
|
61
|
+
async function getSourceBox(page, element, fullPage) {
|
|
62
|
+
if (element) {
|
|
63
|
+
const box = await element.boundingBox();
|
|
64
|
+
return box ?? undefined;
|
|
65
|
+
}
|
|
66
|
+
if (fullPage) {
|
|
67
|
+
const dims = await page.evaluate(() => ({
|
|
68
|
+
width: Math.max(document.documentElement.scrollWidth, document.body?.scrollWidth ?? 0),
|
|
69
|
+
height: Math.max(document.documentElement.scrollHeight, document.body?.scrollHeight ?? 0),
|
|
70
|
+
}));
|
|
71
|
+
if (dims.width <= 0 || dims.height <= 0) {
|
|
72
|
+
return undefined;
|
|
84
73
|
}
|
|
85
|
-
|
|
74
|
+
return { x: 0, y: 0, width: dims.width, height: dims.height };
|
|
75
|
+
}
|
|
76
|
+
const viewport = page.viewport();
|
|
77
|
+
if (viewport) {
|
|
78
|
+
return { x: 0, y: 0, width: viewport.width, height: viewport.height };
|
|
79
|
+
}
|
|
80
|
+
// The browser is launched and connected with `defaultViewport: null`, so
|
|
81
|
+
// `page.viewport()` stays null until something emulates one. Fall back to the
|
|
82
|
+
// window's own dimensions, which is the area a viewport screenshot captures.
|
|
83
|
+
const dims = await page.evaluate(() => ({
|
|
84
|
+
width: window.innerWidth,
|
|
85
|
+
height: window.innerHeight,
|
|
86
|
+
}));
|
|
87
|
+
if (dims.width <= 0 || dims.height <= 0) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
return { x: 0, y: 0, width: dims.width, height: dims.height };
|
|
91
|
+
}
|
|
92
|
+
function computeDownscaleClip(box, maxWidth, maxHeight) {
|
|
93
|
+
const widthScale = maxWidth !== undefined ? Math.min(1, maxWidth / box.width) : 1;
|
|
94
|
+
const heightScale = maxHeight !== undefined ? Math.min(1, maxHeight / box.height) : 1;
|
|
95
|
+
const scale = Math.min(widthScale, heightScale);
|
|
96
|
+
if (scale >= 1) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
// Skip degenerate sub-pixel results.
|
|
100
|
+
if (Math.round(box.width * scale) < 1 || Math.round(box.height * scale) < 1) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
x: box.x,
|
|
105
|
+
y: box.y,
|
|
106
|
+
width: box.width,
|
|
107
|
+
height: box.height,
|
|
108
|
+
scale,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export const screenshot = definePageTool(args => {
|
|
112
|
+
const { screenshotFormat, screenshotQuality, screenshotMaxWidth, screenshotMaxHeight, } = args ?? {};
|
|
113
|
+
const defaultFormat = screenshotFormat ?? 'png';
|
|
114
|
+
return {
|
|
115
|
+
name: 'take_screenshot',
|
|
116
|
+
description: `Take a screenshot of the page or element.`,
|
|
117
|
+
annotations: {
|
|
118
|
+
category: ToolCategory.DEBUGGING,
|
|
119
|
+
// Not read-only due to filePath param.
|
|
120
|
+
readOnlyHint: false,
|
|
121
|
+
},
|
|
122
|
+
schema: {
|
|
123
|
+
format: zod
|
|
124
|
+
.enum(['png', 'jpeg', 'webp'])
|
|
125
|
+
.default(defaultFormat)
|
|
126
|
+
.describe(`Type of format to save the screenshot as. Default is "${defaultFormat}"`),
|
|
127
|
+
quality: zod
|
|
128
|
+
.number()
|
|
129
|
+
.min(0)
|
|
130
|
+
.max(100)
|
|
131
|
+
.optional()
|
|
132
|
+
.describe('Compression quality for JPEG and WebP formats (0-100). Higher values mean better quality but larger file sizes. Ignored for PNG format.'),
|
|
133
|
+
uid: zod
|
|
134
|
+
.string()
|
|
135
|
+
.optional()
|
|
136
|
+
.describe('The uid of an element on the page from the page content snapshot. If omitted, takes a page screenshot.'),
|
|
137
|
+
fullPage: zod
|
|
138
|
+
.boolean()
|
|
139
|
+
.optional()
|
|
140
|
+
.describe('If set to true takes a screenshot of the full page instead of the currently visible viewport. Incompatible with uid.'),
|
|
141
|
+
filePath: zod
|
|
142
|
+
.string()
|
|
143
|
+
.optional()
|
|
144
|
+
.describe('The absolute path, or a path relative to the current working directory, to save the screenshot to instead of attaching it to the response.'),
|
|
145
|
+
},
|
|
146
|
+
blockedByDialog: true,
|
|
147
|
+
verifyFilesSchema: {
|
|
148
|
+
filePath: true,
|
|
149
|
+
},
|
|
150
|
+
handler: async (request, response, context) => {
|
|
151
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
152
|
+
try {
|
|
153
|
+
if (request.params.uid && request.params.fullPage) {
|
|
154
|
+
throw new Error('Providing both "uid" and "fullPage" is not allowed.');
|
|
155
|
+
}
|
|
156
|
+
const page = request.page.pptrPage;
|
|
157
|
+
const element = __addDisposableResource(env_1, request.params.uid
|
|
158
|
+
? await request.page.getElementByUid(request.params.uid)
|
|
159
|
+
: undefined, false);
|
|
160
|
+
const format = request.params.format;
|
|
161
|
+
const quality = format === 'png'
|
|
162
|
+
? undefined
|
|
163
|
+
: (request.params.quality ?? screenshotQuality);
|
|
164
|
+
const fullPage = request.params.fullPage ?? false;
|
|
165
|
+
// `getElementByUid` mints a fresh ElementHandle per call, so dispose it
|
|
166
|
+
// once the capture is done to avoid leaking a remote object for the life
|
|
167
|
+
// of the page's execution context.
|
|
168
|
+
let screenshot;
|
|
169
|
+
// Compute a downscale clip when --screenshot-max-width or
|
|
170
|
+
// --screenshot-max-height is set and the source exceeds either bound.
|
|
171
|
+
// The smaller scale factor wins so both bounds are respected while
|
|
172
|
+
// preserving aspect ratio.
|
|
173
|
+
let clip;
|
|
174
|
+
if (screenshotMaxWidth !== undefined ||
|
|
175
|
+
screenshotMaxHeight !== undefined) {
|
|
176
|
+
const box = await getSourceBox(page, element, fullPage);
|
|
177
|
+
if (box) {
|
|
178
|
+
clip = computeDownscaleClip(box, screenshotMaxWidth, screenshotMaxHeight);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (clip) {
|
|
182
|
+
// page.screenshot with clip lets the CDP scale param downscale the
|
|
183
|
+
// capture for viewport, full-page and element shots alike. We rely on
|
|
184
|
+
// Puppeteer's default of captureBeyondViewport=true when a clip is
|
|
185
|
+
// present so element/full-page captures below the fold still work.
|
|
186
|
+
screenshot = await page.screenshot({
|
|
187
|
+
type: format,
|
|
188
|
+
quality,
|
|
189
|
+
optimizeForSpeed: true,
|
|
190
|
+
clip,
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
else if (element) {
|
|
194
|
+
screenshot = await element.screenshot({
|
|
195
|
+
type: format,
|
|
196
|
+
quality,
|
|
197
|
+
optimizeForSpeed: true,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
screenshot = await page.screenshot({
|
|
202
|
+
type: format,
|
|
203
|
+
fullPage,
|
|
204
|
+
quality,
|
|
205
|
+
optimizeForSpeed: true,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if (request.params.uid) {
|
|
209
|
+
response.appendResponseLine(`Took a screenshot of node with uid "${request.params.uid}".`);
|
|
210
|
+
}
|
|
211
|
+
else if (fullPage) {
|
|
212
|
+
response.appendResponseLine('Took a screenshot of the full current page.');
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
response.appendResponseLine("Took a screenshot of the current page's viewport.");
|
|
216
|
+
}
|
|
217
|
+
// Narrow `format` at the point of use: in the factory form of
|
|
218
|
+
// definePageTool TS widens the Schema generic, which loses the literal
|
|
219
|
+
// union from zod.enum on request.params.format.
|
|
220
|
+
const extension = format === 'jpeg' ? '.jpeg' : format === 'webp' ? '.webp' : '.png';
|
|
221
|
+
if (request.params.filePath) {
|
|
222
|
+
const result = await context.saveFile(screenshot, request.params.filePath, extension);
|
|
223
|
+
response.appendResponseLine(`Saved screenshot to ${result.filename}.`);
|
|
224
|
+
}
|
|
225
|
+
else if (screenshot.length >= 2_000_000) {
|
|
226
|
+
const { filepath } = await context.saveTemporaryFile(screenshot, `screenshot${extension}`);
|
|
227
|
+
response.appendResponseLine(`Saved screenshot to ${filepath}.`);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
response.attachImage({
|
|
231
|
+
mimeType: `image/${format}`,
|
|
232
|
+
data: Buffer.from(screenshot).toString('base64'),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch (e_1) {
|
|
237
|
+
env_1.error = e_1;
|
|
238
|
+
env_1.hasError = true;
|
|
239
|
+
}
|
|
240
|
+
finally {
|
|
241
|
+
__disposeResources(env_1);
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
};
|
|
86
245
|
});
|
|
87
246
|
//# sourceMappingURL=screenshot.js.map
|
|
@@ -3,29 +3,74 @@
|
|
|
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
|
-
import { appendWaitForResult } from '../WaitForHelper.js';
|
|
8
59
|
import { ToolCategory } from './categories.js';
|
|
9
60
|
import { defineTool, pageIdSchema } from './ToolDefinition.js';
|
|
10
61
|
export const evaluateScript = defineTool(cliArgs => {
|
|
11
62
|
return {
|
|
12
63
|
name: 'evaluate_script',
|
|
13
|
-
description: `Evaluate a JavaScript function inside the currently selected page${cliArgs?.categoryExtensions ? ' or service worker' : ''}. Returns the response as JSON,
|
|
14
|
-
so returned values have to be JSON-serializable.`,
|
|
64
|
+
description: `Evaluate a JavaScript function inside the currently selected page${cliArgs?.categoryExtensions ? ' or service worker' : ''}. Returns the response as JSON, so returned values have to be JSON-serializable.`,
|
|
15
65
|
annotations: {
|
|
16
66
|
category: ToolCategory.DEBUGGING,
|
|
17
67
|
readOnlyHint: false,
|
|
18
68
|
},
|
|
19
69
|
schema: {
|
|
70
|
+
...(cliArgs?.experimentalPageIdRouting ? pageIdSchema : {}),
|
|
20
71
|
function: zod.string().describe(`A JavaScript function declaration to be executed by the tool in the currently selected page.
|
|
21
|
-
Example without arguments: \`() =>
|
|
22
|
-
|
|
23
|
-
}\` or \`async () => {
|
|
24
|
-
return await fetch("example.com")
|
|
25
|
-
}\`.
|
|
26
|
-
Example with arguments: \`(el) => {
|
|
27
|
-
return el.innerText;
|
|
28
|
-
}\`
|
|
72
|
+
Example without arguments: \`() => document.title\` or \`async () => await fetch("example.com")\`.
|
|
73
|
+
Example with arguments: \`(el) => el.innerText\`
|
|
29
74
|
`),
|
|
30
75
|
args: zod
|
|
31
76
|
.array(zod
|
|
@@ -33,11 +78,18 @@ Example with arguments: \`(el) => {
|
|
|
33
78
|
.describe('The uid of an element on the page from the page content snapshot'))
|
|
34
79
|
.optional()
|
|
35
80
|
.describe(`An optional list of arguments to pass to the function.`),
|
|
81
|
+
filePath: zod
|
|
82
|
+
.string()
|
|
83
|
+
.optional()
|
|
84
|
+
.describe('The absolute or relative path to a file to save the script output to. If omitted, the output is returned inline.'),
|
|
36
85
|
dialogAction: zod
|
|
37
86
|
.string()
|
|
38
87
|
.optional()
|
|
39
88
|
.describe('Handle dialogs while execution. "accept", "dismiss", or string for response of window.prompt. Defaults to accept.'),
|
|
40
|
-
|
|
89
|
+
waitForStableDom: zod
|
|
90
|
+
.boolean()
|
|
91
|
+
.optional()
|
|
92
|
+
.describe('Whether to wait for the DOM to settle. Pass false if the script only reads data. Defaults to true.'),
|
|
41
93
|
...(cliArgs?.categoryExtensions
|
|
42
94
|
? {
|
|
43
95
|
serviceWorkerId: zod
|
|
@@ -48,62 +100,95 @@ Example with arguments: \`(el) => {
|
|
|
48
100
|
: {}),
|
|
49
101
|
},
|
|
50
102
|
blockedByDialog: true,
|
|
103
|
+
verifyFilesSchema: {
|
|
104
|
+
filePath: true,
|
|
105
|
+
},
|
|
51
106
|
handler: async (request, response, context) => {
|
|
52
|
-
const {
|
|
53
|
-
if (cliArgs?.categoryExtensions && serviceWorkerId) {
|
|
54
|
-
if (uidArgs && uidArgs.length > 0) {
|
|
55
|
-
throw new Error('args (element uids) cannot be used when evaluating in a service worker.');
|
|
56
|
-
}
|
|
57
|
-
if (pageId) {
|
|
58
|
-
throw new Error('specify either a pageId or a serviceWorkerId.');
|
|
59
|
-
}
|
|
60
|
-
const worker = await getWebWorker(context, serviceWorkerId);
|
|
61
|
-
const result = await context
|
|
62
|
-
.getSelectedMcpPage()
|
|
63
|
-
.waitForEventsAfterAction(async () => {
|
|
64
|
-
await performEvaluation(worker, fnString, [], response);
|
|
65
|
-
}, { handleDialog: dialogAction ?? 'accept' });
|
|
66
|
-
appendWaitForResult(response, result);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
const mcpPage = cliArgs?.experimentalPageIdRouting
|
|
70
|
-
? context.getPageById(request.params.pageId)
|
|
71
|
-
: context.getSelectedMcpPage();
|
|
72
|
-
const page = mcpPage.pptrPage;
|
|
73
|
-
const args = [];
|
|
107
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
74
108
|
try {
|
|
109
|
+
const { serviceWorkerId, args: uidArgs, function: fnString, pageId, dialogAction, filePath, waitForStableDom, } = request.params;
|
|
110
|
+
if (cliArgs?.categoryExtensions && serviceWorkerId) {
|
|
111
|
+
if (uidArgs && uidArgs.length > 0) {
|
|
112
|
+
throw new Error('args (element uids) cannot be used when evaluating in a service worker.');
|
|
113
|
+
}
|
|
114
|
+
if (pageId) {
|
|
115
|
+
throw new Error('specify either a pageId or a serviceWorkerId.');
|
|
116
|
+
}
|
|
117
|
+
const worker = await getWebWorker(context, serviceWorkerId);
|
|
118
|
+
const result = await context
|
|
119
|
+
.getSelectedMcpPage()
|
|
120
|
+
.waitForEventsAfterAction(async () => {
|
|
121
|
+
await performEvaluation(worker, fnString, [], response, {
|
|
122
|
+
filePath,
|
|
123
|
+
context,
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
// Service workers cannot interact with the DOM, so never wait for it.
|
|
127
|
+
{ handleDialog: dialogAction ?? 'accept', waitForStableDom: false });
|
|
128
|
+
if (result.dialogHandled) {
|
|
129
|
+
context.getSelectedMcpPage().clearDialog();
|
|
130
|
+
}
|
|
131
|
+
response.attachWaitForResult(result);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const mcpPage = cliArgs?.experimentalPageIdRouting
|
|
135
|
+
? context.getPageById(request.params.pageId)
|
|
136
|
+
: context.getSelectedMcpPage();
|
|
137
|
+
const page = mcpPage.pptrPage;
|
|
138
|
+
const args = [];
|
|
139
|
+
const stack = __addDisposableResource(env_1, new DisposableStack(), false);
|
|
75
140
|
const frames = new Set();
|
|
76
141
|
for (const uid of uidArgs ?? []) {
|
|
77
142
|
const handle = await mcpPage.getElementByUid(uid);
|
|
78
143
|
frames.add(handle.frame);
|
|
144
|
+
stack.use(handle);
|
|
79
145
|
args.push(handle);
|
|
80
146
|
}
|
|
81
147
|
const evaluatable = await getPageOrFrame(page, frames);
|
|
82
148
|
const result = await mcpPage.waitForEventsAfterAction(async () => {
|
|
83
|
-
await performEvaluation(evaluatable, fnString, args, response
|
|
84
|
-
|
|
85
|
-
|
|
149
|
+
await performEvaluation(evaluatable, fnString, args, response, {
|
|
150
|
+
filePath,
|
|
151
|
+
context,
|
|
152
|
+
});
|
|
153
|
+
}, { handleDialog: dialogAction ?? 'accept', waitForStableDom });
|
|
154
|
+
response.attachWaitForResult(result);
|
|
155
|
+
}
|
|
156
|
+
catch (e_1) {
|
|
157
|
+
env_1.error = e_1;
|
|
158
|
+
env_1.hasError = true;
|
|
86
159
|
}
|
|
87
160
|
finally {
|
|
88
|
-
|
|
161
|
+
__disposeResources(env_1);
|
|
89
162
|
}
|
|
90
163
|
},
|
|
91
164
|
};
|
|
92
165
|
});
|
|
93
|
-
const performEvaluation = async (evaluatable, fnString, args, response) => {
|
|
94
|
-
const
|
|
166
|
+
const performEvaluation = async (evaluatable, fnString, args, response, options) => {
|
|
167
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
95
168
|
try {
|
|
169
|
+
const fn = __addDisposableResource(env_2, await evaluatable.evaluateHandle(`(${fnString})`), false);
|
|
96
170
|
const result = await evaluatable.evaluate(async (fn, ...args) => {
|
|
97
171
|
// @ts-expect-error no types for function fn
|
|
98
172
|
return JSON.stringify(await fn(...args));
|
|
99
173
|
}, fn, ...args);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
174
|
+
if (options?.filePath) {
|
|
175
|
+
const data = new TextEncoder().encode(result ?? 'undefined');
|
|
176
|
+
const { filename } = await options.context.saveFile(data, options.filePath, '.json');
|
|
177
|
+
response.appendResponseLine(`Script ran on page. Output saved to ${filename}.`);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
response.appendResponseLine('Script ran on page and returned:');
|
|
181
|
+
response.appendResponseLine('```json');
|
|
182
|
+
response.appendResponseLine(`${result}`);
|
|
183
|
+
response.appendResponseLine('```');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (e_2) {
|
|
187
|
+
env_2.error = e_2;
|
|
188
|
+
env_2.hasError = true;
|
|
104
189
|
}
|
|
105
190
|
finally {
|
|
106
|
-
|
|
191
|
+
__disposeResources(env_2);
|
|
107
192
|
}
|
|
108
193
|
};
|
|
109
194
|
const getPageOrFrame = async (page, frames) => {
|
|
@@ -16,6 +16,7 @@ export const screenshot = definePageTool({
|
|
|
16
16
|
},
|
|
17
17
|
schema: {},
|
|
18
18
|
blockedByDialog: true,
|
|
19
|
+
verifyFilesSchema: {},
|
|
19
20
|
handler: async (request, response, context) => {
|
|
20
21
|
const page = request.page;
|
|
21
22
|
const screenshot = await page.pptrPage.screenshot({
|
|
@@ -37,6 +38,7 @@ export const navigate = definePageTool({
|
|
|
37
38
|
url: zod.string().describe('URL to navigate to'),
|
|
38
39
|
},
|
|
39
40
|
blockedByDialog: false,
|
|
41
|
+
verifyFilesSchema: {},
|
|
40
42
|
handler: async (request, response) => {
|
|
41
43
|
const page = request.page;
|
|
42
44
|
const options = {
|
|
@@ -71,6 +73,7 @@ export const evaluate = definePageTool({
|
|
|
71
73
|
script: zod.string().describe(`JS script to run on the page`),
|
|
72
74
|
},
|
|
73
75
|
blockedByDialog: true,
|
|
76
|
+
verifyFilesSchema: {},
|
|
74
77
|
handler: async (request, response) => {
|
|
75
78
|
const page = request.page;
|
|
76
79
|
try {
|
|
@@ -27,8 +27,10 @@ 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
|
-
|
|
31
|
-
|
|
30
|
+
verifyFilesSchema: {
|
|
31
|
+
filePath: true,
|
|
32
|
+
},
|
|
33
|
+
handler: async (request, response) => {
|
|
32
34
|
response.includeSnapshot({
|
|
33
35
|
verbose: request.params.verbose ?? false,
|
|
34
36
|
filePath: request.params.filePath,
|
|
@@ -50,9 +52,10 @@ export const waitFor = definePageTool({
|
|
|
50
52
|
...timeoutSchema,
|
|
51
53
|
},
|
|
52
54
|
blockedByDialog: true,
|
|
53
|
-
|
|
55
|
+
verifyFilesSchema: {},
|
|
56
|
+
handler: async (request, response) => {
|
|
54
57
|
const page = request.page;
|
|
55
|
-
await
|
|
58
|
+
await page.waitForTextOnPage(request.params.text, request.params.timeout);
|
|
56
59
|
response.appendResponseLine(`Element matching one of ${JSON.stringify(request.params.text)} found.`);
|
|
57
60
|
response.includeSnapshot();
|
|
58
61
|
},
|
|
@@ -9,19 +9,20 @@ import { definePageTool } from './ToolDefinition.js';
|
|
|
9
9
|
export const listThirdPartyDeveloperTools = definePageTool({
|
|
10
10
|
name: 'list_3p_developer_tools',
|
|
11
11
|
description: `Lists all third-party developer tools the page exposes for providing runtime information.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
Third-party developer tools can be called via the 'execute_3p_developer_tool()' MCP tool.
|
|
13
|
+
Alternatively, third-party developer tools can be executed by calling 'evaluate_script' and adding the
|
|
14
|
+
following command to the script:
|
|
15
|
+
\`window.__dtmcp.executeTool(toolName, params)\`
|
|
16
|
+
This might be helpful when the third-party developer tools return non-serializable values or when composing
|
|
17
|
+
third-party developer tools with additional functionality.`,
|
|
18
18
|
annotations: {
|
|
19
19
|
category: ToolCategory.THIRD_PARTY,
|
|
20
20
|
readOnlyHint: true,
|
|
21
21
|
},
|
|
22
22
|
schema: {},
|
|
23
23
|
blockedByDialog: false,
|
|
24
|
-
|
|
24
|
+
verifyFilesSchema: {},
|
|
25
|
+
handler: async (_request, response) => {
|
|
25
26
|
response.setListThirdPartyDeveloperTools();
|
|
26
27
|
},
|
|
27
28
|
});
|
|
@@ -40,6 +41,7 @@ export const executeThirdPartyDeveloperTool = definePageTool({
|
|
|
40
41
|
.describe('The JSON-stringified parameters to pass to the tool'),
|
|
41
42
|
},
|
|
42
43
|
blockedByDialog: false,
|
|
44
|
+
verifyFilesSchema: {},
|
|
43
45
|
handler: async (request, response) => {
|
|
44
46
|
const toolName = request.params.toolName;
|
|
45
47
|
let params = {};
|
|
@@ -58,8 +60,16 @@ export const executeThirdPartyDeveloperTool = definePageTool({
|
|
|
58
60
|
throw new Error(`Failed to parse params as JSON: ${errorMessage}`);
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
+
const toolGroups = request.page.getThirdPartyDeveloperTools();
|
|
64
|
+
let tool;
|
|
65
|
+
if (toolGroups) {
|
|
66
|
+
for (const group of toolGroups) {
|
|
67
|
+
tool = group.tools?.find(t => t.name === toolName);
|
|
68
|
+
if (tool) {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
63
73
|
if (!tool) {
|
|
64
74
|
throw new Error(`Tool ${toolName} not found`);
|
|
65
75
|
}
|