chrome-devtools-mcp 0.17.1 → 0.17.2
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 +4 -1
- package/package.json +3 -3
- package/build/src/DevToolsConnectionAdapter.js +0 -69
- package/build/src/DevtoolsUtils.js +0 -340
- package/build/src/McpContext.js +0 -603
- package/build/src/McpResponse.js +0 -490
- package/build/src/Mutex.js +0 -37
- package/build/src/PageCollector.js +0 -309
- package/build/src/WaitForHelper.js +0 -139
- package/build/src/browser.js +0 -182
- package/build/src/cli.js +0 -295
- package/build/src/formatters/ConsoleFormatter.js +0 -240
- package/build/src/formatters/IssueFormatter.js +0 -190
- package/build/src/formatters/NetworkFormatter.js +0 -226
- package/build/src/formatters/SnapshotFormatter.js +0 -134
- package/build/src/index.js +0 -21
- package/build/src/issue-descriptions.js +0 -39
- package/build/src/logger.js +0 -36
- package/build/src/main.js +0 -196
- package/build/src/polyfill.js +0 -7
- package/build/src/telemetry/ClearcutLogger.js +0 -102
- package/build/src/telemetry/WatchdogClient.js +0 -60
- package/build/src/telemetry/flagUtils.js +0 -45
- package/build/src/telemetry/metricUtils.js +0 -14
- package/build/src/telemetry/persistence.js +0 -53
- package/build/src/telemetry/types.js +0 -33
- package/build/src/telemetry/watchdog/ClearcutSender.js +0 -201
- package/build/src/telemetry/watchdog/main.js +0 -127
- package/build/src/third_party/THIRD_PARTY_NOTICES +0 -2011
- package/build/src/third_party/bundled-packages.json +0 -8
- package/build/src/third_party/devtools-formatter-worker.js +0 -15449
- package/build/src/third_party/index.js +0 -172791
- package/build/src/third_party/issue-descriptions/CoepCoopSandboxedIframeCannotNavigateToCoopPage.md +0 -4
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameOrigin.md +0 -8
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameOriginAfterDefaultedToSameOriginByCoep.md +0 -18
- package/build/src/third_party/issue-descriptions/CoepCorpNotSameSite.md +0 -7
- package/build/src/third_party/issue-descriptions/CoepFrameResourceNeedsCoepHeader.md +0 -10
- package/build/src/third_party/issue-descriptions/CompatibilityModeQuirks.md +0 -5
- package/build/src/third_party/issue-descriptions/CookieAttributeValueExceedsMaxSize.md +0 -5
- package/build/src/third_party/issue-descriptions/LowTextContrast.md +0 -5
- 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/SameSiteNoneInsecureErrorRead.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureErrorSet.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnRead.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteNoneInsecureWarnSet.md +0 -8
- package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeRead.md +0 -9
- package/build/src/third_party/issue-descriptions/SameSiteUnspecifiedLaxAllowUnsafeSet.md +0 -9
- 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/third_party/issue-descriptions/bounceTrackingMitigations.md +0 -3
- package/build/src/third_party/issue-descriptions/clientHintMetaTagAllowListInvalidOrigin.md +0 -4
- package/build/src/third_party/issue-descriptions/clientHintMetaTagModifiedHTML.md +0 -4
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidAllowlistItemType.md +0 -12
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidHeader.md +0 -12
- package/build/src/third_party/issue-descriptions/connectionAllowlistInvalidUrlPattern.md +0 -8
- package/build/src/third_party/issue-descriptions/connectionAllowlistItemNotInnerList.md +0 -12
- package/build/src/third_party/issue-descriptions/connectionAllowlistMoreThanOneList.md +0 -7
- package/build/src/third_party/issue-descriptions/connectionAllowlistReportingEndpointNotToken.md +0 -10
- package/build/src/third_party/issue-descriptions/cookieCrossSiteRedirectDowngrade.md +0 -12
- package/build/src/third_party/issue-descriptions/cookieExcludeBlockedWithinRelatedWebsiteSet.md +0 -4
- package/build/src/third_party/issue-descriptions/cookieExcludeDomainNonAscii.md +0 -11
- package/build/src/third_party/issue-descriptions/cookieExcludePortMismatch.md +0 -8
- package/build/src/third_party/issue-descriptions/cookieExcludeSchemeMismatch.md +0 -7
- package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutRead.md +0 -6
- package/build/src/third_party/issue-descriptions/cookieExcludeThirdPartyPhaseoutSet.md +0 -6
- package/build/src/third_party/issue-descriptions/cookieWarnDomainNonAscii.md +0 -11
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantRead.md +0 -4
- package/build/src/third_party/issue-descriptions/cookieWarnMetadataGrantSet.md +0 -4
- package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutRead.md +0 -6
- package/build/src/third_party/issue-descriptions/cookieWarnThirdPartyPhaseoutSet.md +0 -6
- package/build/src/third_party/issue-descriptions/corsAllowCredentialsRequired.md +0 -6
- package/build/src/third_party/issue-descriptions/corsDisabledScheme.md +0 -7
- package/build/src/third_party/issue-descriptions/corsDisallowedByMode.md +0 -7
- package/build/src/third_party/issue-descriptions/corsHeaderDisallowedByPreflightResponse.md +0 -5
- package/build/src/third_party/issue-descriptions/corsInsecurePrivateNetwork.md +0 -10
- package/build/src/third_party/issue-descriptions/corsInvalidHeaderValues.md +0 -7
- package/build/src/third_party/issue-descriptions/corsLocalNetworkAccessPermissionDenied.md +0 -19
- package/build/src/third_party/issue-descriptions/corsMethodDisallowedByPreflightResponse.md +0 -5
- package/build/src/third_party/issue-descriptions/corsNoCorsRedirectModeNotFollow.md +0 -5
- package/build/src/third_party/issue-descriptions/corsOriginMismatch.md +0 -6
- package/build/src/third_party/issue-descriptions/corsPreflightAllowPrivateNetworkError.md +0 -10
- package/build/src/third_party/issue-descriptions/corsPreflightResponseInvalid.md +0 -5
- package/build/src/third_party/issue-descriptions/corsPrivateNetworkPermissionDenied.md +0 -10
- package/build/src/third_party/issue-descriptions/corsRedirectContainsCredentials.md +0 -5
- package/build/src/third_party/issue-descriptions/corsWildcardOriginNotAllowed.md +0 -8
- package/build/src/third_party/issue-descriptions/cspEvalViolation.md +0 -9
- package/build/src/third_party/issue-descriptions/cspInlineViolation.md +0 -10
- package/build/src/third_party/issue-descriptions/cspTrustedTypesPolicyViolation.md +0 -5
- package/build/src/third_party/issue-descriptions/cspTrustedTypesSinkViolation.md +0 -8
- package/build/src/third_party/issue-descriptions/cspURLViolation.md +0 -10
- package/build/src/third_party/issue-descriptions/deprecation.md +0 -3
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsHttpNotFound.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsInvalidResponse.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestAccountsNoResponse.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestApprovalDeclined.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestCanceled.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorFetchingSignin.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestErrorIdToken.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenHttpNotFound.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidRequest.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenInvalidResponse.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestIdTokenNoResponse.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestInvalidSigninResponse.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestHttpNotFound.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestInvalidResponse.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestManifestNoResponse.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthRequestTooManyRequests.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidAccountsResponse.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestInvalidConfigOrWellKnown.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoAccountSharingPermission.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoApiPermission.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNoReturningUserFromFetchedAccounts.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotIframe.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotPotentiallyTrustworthy.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSameOrigin.md +0 -1
- package/build/src/third_party/issue-descriptions/federatedAuthUserInfoRequestNotSignedInWithIdp.md +0 -1
- package/build/src/third_party/issue-descriptions/fetchingPartitionedBlobURL.md +0 -7
- package/build/src/third_party/issue-descriptions/genericFormAriaLabelledByToNonExistingIdError.md +0 -8
- package/build/src/third_party/issue-descriptions/genericFormAutocompleteAttributeEmptyError.md +0 -5
- package/build/src/third_party/issue-descriptions/genericFormDuplicateIdForInputError.md +0 -5
- package/build/src/third_party/issue-descriptions/genericFormEmptyIdAndNameAttributesForInputError.md +0 -5
- package/build/src/third_party/issue-descriptions/genericFormInputAssignedAutocompleteValueToIdOrNameAttributeError.md +0 -5
- package/build/src/third_party/issue-descriptions/genericFormInputHasWrongButWellIntendedAutocompleteValueError.md +0 -5
- package/build/src/third_party/issue-descriptions/genericFormInputWithNoLabelError.md +0 -5
- package/build/src/third_party/issue-descriptions/genericFormLabelForMatchesNonExistingIdError.md +0 -5
- package/build/src/third_party/issue-descriptions/genericFormLabelForNameError.md +0 -5
- package/build/src/third_party/issue-descriptions/genericFormLabelHasNeitherForNorNestedInputError.md +0 -5
- package/build/src/third_party/issue-descriptions/genericNavigationEntryMarkedSkippable.md +0 -7
- package/build/src/third_party/issue-descriptions/genericResponseWasBlockedByORB.md +0 -4
- package/build/src/third_party/issue-descriptions/heavyAd.md +0 -10
- package/build/src/third_party/issue-descriptions/mixedContent.md +0 -5
- package/build/src/third_party/issue-descriptions/navigatingPartitionedBlobURL.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabled.md +0 -7
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluder.md +0 -9
- package/build/src/third_party/issue-descriptions/permissionElementActivationDisabledWithOccluderParent.md +0 -9
- package/build/src/third_party/issue-descriptions/permissionElementCspFrameAncestorsMissing.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementFencedFrameDisallowed.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooLarge.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementFontSizeTooSmall.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementGeolocationDeprecated.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementInsetBoxShadowUnsupported.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementInvalidDisplayStyle.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementInvalidSizeValue.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementInvalidType.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementInvalidTypeActivation.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementLowContrast.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementNonOpaqueColor.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementPaddingBottomUnsupported.md +0 -6
- package/build/src/third_party/issue-descriptions/permissionElementPaddingRightUnsupported.md +0 -6
- package/build/src/third_party/issue-descriptions/permissionElementPermissionsPolicyBlocked.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementRegistrationFailed.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementRequestInProgress.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementSecurityChecksFailed.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementTypeNotSupported.md +0 -5
- package/build/src/third_party/issue-descriptions/permissionElementUntrustedEvent.md +0 -7
- package/build/src/third_party/issue-descriptions/placeholderDescriptionForInvisibleIssues.md +0 -3
- package/build/src/third_party/issue-descriptions/propertyRuleInvalidNameIssue.md +0 -3
- package/build/src/third_party/issue-descriptions/propertyRuleIssue.md +0 -7
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedOptGroupChild.md +0 -7
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityDisallowedSelectChild.md +0 -7
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentAttributesSelectDescendant.md +0 -3
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentLegendChild.md +0 -3
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityInteractiveContentOptionChild.md +0 -3
- package/build/src/third_party/issue-descriptions/selectElementAccessibilityNonPhrasingContentOptionChild.md +0 -3
- package/build/src/third_party/issue-descriptions/sharedArrayBuffer.md +0 -7
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorCrossOriginNoCorsRequest.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorDictionaryLoadFailure.md +0 -3
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorMatchingDictionaryNotUsed.md +0 -3
- package/build/src/third_party/issue-descriptions/sharedDictionaryUseErrorUnexpectedContentDictionaryHeader.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorCossOriginNoCorsRequest.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorDisallowedBySettings.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorExpiredResponse.md +0 -3
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorFeatureDisabled.md +0 -3
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInsufficientResources.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidMatchField.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidStructuredHeader.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorInvalidTTLField.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNavigationRequest.md +0 -3
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNoMatchField.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonIntegerTTLField.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonListMatchDestField.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonSecureContext.md +0 -3
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringIdField.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringInMatchDestList.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonStringMatchField.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorNonTokenTypeField.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorRequestAborted.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorShuttingDown.md +0 -1
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorTooLongIdField.md +0 -3
- package/build/src/third_party/issue-descriptions/sharedDictionaryWriteErrorUnsupportedType.md +0 -3
- package/build/src/third_party/issue-descriptions/sriInvalidSignatureHeader.md +0 -14
- package/build/src/third_party/issue-descriptions/sriInvalidSignatureInputHeader.md +0 -15
- package/build/src/third_party/issue-descriptions/sriMissingSignatureHeader.md +0 -8
- package/build/src/third_party/issue-descriptions/sriMissingSignatureInputHeader.md +0 -7
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsIncorrectLength.md +0 -11
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsNotByteSequence.md +0 -14
- package/build/src/third_party/issue-descriptions/sriSignatureHeaderValueIsParameterized.md +0 -15
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentName.md +0 -8
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidComponentType.md +0 -13
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidDerivedComponentParameter.md +0 -4
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidHeaderComponentParameter.md +0 -5
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderInvalidParameter.md +0 -11
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderKeyIdLength.md +0 -12
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingLabel.md +0 -6
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderMissingRequiredParameters.md +0 -8
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueMissingComponents.md +0 -11
- package/build/src/third_party/issue-descriptions/sriSignatureInputHeaderValueNotInnerList.md +0 -11
- package/build/src/third_party/issue-descriptions/sriValidationFailedIntegrityMismatch.md +0 -10
- package/build/src/third_party/issue-descriptions/sriValidationFailedInvalidLength.md +0 -5
- package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureExpired.md +0 -6
- package/build/src/third_party/issue-descriptions/sriValidationFailedSignatureMismatch.md +0 -11
- package/build/src/third_party/issue-descriptions/stylesheetLateImport.md +0 -4
- package/build/src/third_party/issue-descriptions/stylesheetRequestFailed.md +0 -3
- package/build/src/third_party/issue-descriptions/summaryElementAccessibilityInteractiveContentSummaryDescendant.md +0 -3
- package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestLength.md +0 -12
- package/build/src/third_party/issue-descriptions/unencodedDigestIncorrectDigestType.md +0 -17
- package/build/src/third_party/issue-descriptions/unencodedDigestMalformedDictionary.md +0 -14
- package/build/src/third_party/issue-descriptions/unencodedDigestUnknownAlgorithm.md +0 -15
- package/build/src/tools/ToolDefinition.js +0 -20
- package/build/src/tools/categories.js +0 -24
- package/build/src/tools/console.js +0 -85
- package/build/src/tools/emulation.js +0 -169
- package/build/src/tools/extensions.js +0 -79
- package/build/src/tools/input.js +0 -343
- package/build/src/tools/network.js +0 -120
- package/build/src/tools/pages.js +0 -323
- package/build/src/tools/performance.js +0 -188
- package/build/src/tools/screenshot.js +0 -84
- package/build/src/tools/script.js +0 -71
- package/build/src/tools/snapshot.js +0 -52
- package/build/src/tools/tools.js +0 -31
- package/build/src/trace-processing/parse.js +0 -84
- package/build/src/utils/ExtensionRegistry.js +0 -35
- package/build/src/utils/keyboard.js +0 -296
- package/build/src/utils/pagination.js +0 -49
- package/build/src/utils/string.js +0 -36
- package/build/src/utils/types.js +0 -6
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { zod } from '../third_party/index.js';
|
|
7
|
-
import { ToolCategory } from './categories.js';
|
|
8
|
-
import { defineTool } from './ToolDefinition.js';
|
|
9
|
-
const FILTERABLE_RESOURCE_TYPES = [
|
|
10
|
-
'document',
|
|
11
|
-
'stylesheet',
|
|
12
|
-
'image',
|
|
13
|
-
'media',
|
|
14
|
-
'font',
|
|
15
|
-
'script',
|
|
16
|
-
'texttrack',
|
|
17
|
-
'xhr',
|
|
18
|
-
'fetch',
|
|
19
|
-
'prefetch',
|
|
20
|
-
'eventsource',
|
|
21
|
-
'websocket',
|
|
22
|
-
'manifest',
|
|
23
|
-
'signedexchange',
|
|
24
|
-
'ping',
|
|
25
|
-
'cspviolationreport',
|
|
26
|
-
'preflight',
|
|
27
|
-
'fedcm',
|
|
28
|
-
'other',
|
|
29
|
-
];
|
|
30
|
-
export const listNetworkRequests = defineTool({
|
|
31
|
-
name: 'list_network_requests',
|
|
32
|
-
description: `List all requests for the currently selected page since the last navigation.`,
|
|
33
|
-
annotations: {
|
|
34
|
-
category: ToolCategory.NETWORK,
|
|
35
|
-
readOnlyHint: true,
|
|
36
|
-
},
|
|
37
|
-
schema: {
|
|
38
|
-
pageSize: zod
|
|
39
|
-
.number()
|
|
40
|
-
.int()
|
|
41
|
-
.positive()
|
|
42
|
-
.optional()
|
|
43
|
-
.describe('Maximum number of requests to return. When omitted, returns all requests.'),
|
|
44
|
-
pageIdx: zod
|
|
45
|
-
.number()
|
|
46
|
-
.int()
|
|
47
|
-
.min(0)
|
|
48
|
-
.optional()
|
|
49
|
-
.describe('Page number to return (0-based). When omitted, returns the first page.'),
|
|
50
|
-
resourceTypes: zod
|
|
51
|
-
.array(zod.enum(FILTERABLE_RESOURCE_TYPES))
|
|
52
|
-
.optional()
|
|
53
|
-
.describe('Filter requests to only return requests of the specified resource types. When omitted or empty, returns all requests.'),
|
|
54
|
-
includePreservedRequests: zod
|
|
55
|
-
.boolean()
|
|
56
|
-
.default(false)
|
|
57
|
-
.optional()
|
|
58
|
-
.describe('Set to true to return the preserved requests over the last 3 navigations.'),
|
|
59
|
-
},
|
|
60
|
-
handler: async (request, response, context) => {
|
|
61
|
-
const data = await context.getDevToolsData();
|
|
62
|
-
response.attachDevToolsData(data);
|
|
63
|
-
const reqid = data?.cdpRequestId
|
|
64
|
-
? context.resolveCdpRequestId(data.cdpRequestId)
|
|
65
|
-
: undefined;
|
|
66
|
-
response.setIncludeNetworkRequests(true, {
|
|
67
|
-
pageSize: request.params.pageSize,
|
|
68
|
-
pageIdx: request.params.pageIdx,
|
|
69
|
-
resourceTypes: request.params.resourceTypes,
|
|
70
|
-
includePreservedRequests: request.params.includePreservedRequests,
|
|
71
|
-
networkRequestIdInDevToolsUI: reqid,
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
export const getNetworkRequest = defineTool({
|
|
76
|
-
name: 'get_network_request',
|
|
77
|
-
description: `Gets a network request by an optional reqid, if omitted returns the currently selected request in the DevTools Network panel.`,
|
|
78
|
-
annotations: {
|
|
79
|
-
category: ToolCategory.NETWORK,
|
|
80
|
-
readOnlyHint: false,
|
|
81
|
-
},
|
|
82
|
-
schema: {
|
|
83
|
-
reqid: zod
|
|
84
|
-
.number()
|
|
85
|
-
.optional()
|
|
86
|
-
.describe('The reqid of the network request. If omitted returns the currently selected request in the DevTools Network panel.'),
|
|
87
|
-
requestFilePath: zod
|
|
88
|
-
.string()
|
|
89
|
-
.optional()
|
|
90
|
-
.describe('The absolute or relative path to save the request body to. If omitted, the body is returned inline.'),
|
|
91
|
-
responseFilePath: zod
|
|
92
|
-
.string()
|
|
93
|
-
.optional()
|
|
94
|
-
.describe('The absolute or relative path to save the response body to. If omitted, the body is returned inline.'),
|
|
95
|
-
},
|
|
96
|
-
handler: async (request, response, context) => {
|
|
97
|
-
if (request.params.reqid) {
|
|
98
|
-
response.attachNetworkRequest(request.params.reqid, {
|
|
99
|
-
requestFilePath: request.params.requestFilePath,
|
|
100
|
-
responseFilePath: request.params.responseFilePath,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
const data = await context.getDevToolsData();
|
|
105
|
-
response.attachDevToolsData(data);
|
|
106
|
-
const reqid = data?.cdpRequestId
|
|
107
|
-
? context.resolveCdpRequestId(data.cdpRequestId)
|
|
108
|
-
: undefined;
|
|
109
|
-
if (reqid) {
|
|
110
|
-
response.attachNetworkRequest(reqid, {
|
|
111
|
-
requestFilePath: request.params.requestFilePath,
|
|
112
|
-
responseFilePath: request.params.responseFilePath,
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
response.appendResponseLine(`Nothing is currently selected in the DevTools Network panel.`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
});
|
package/build/src/tools/pages.js
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { logger } from '../logger.js';
|
|
7
|
-
import { zod } from '../third_party/index.js';
|
|
8
|
-
import { ToolCategory } from './categories.js';
|
|
9
|
-
import { CLOSE_PAGE_ERROR, defineTool, timeoutSchema } from './ToolDefinition.js';
|
|
10
|
-
export const listPages = defineTool({
|
|
11
|
-
name: 'list_pages',
|
|
12
|
-
description: `Get a list of pages open in the browser.`,
|
|
13
|
-
annotations: {
|
|
14
|
-
category: ToolCategory.NAVIGATION,
|
|
15
|
-
readOnlyHint: true,
|
|
16
|
-
},
|
|
17
|
-
schema: {},
|
|
18
|
-
handler: async (_request, response) => {
|
|
19
|
-
response.setIncludePages(true);
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
export const selectPage = defineTool({
|
|
23
|
-
name: 'select_page',
|
|
24
|
-
description: `Select a page as a context for future tool calls.`,
|
|
25
|
-
annotations: {
|
|
26
|
-
category: ToolCategory.NAVIGATION,
|
|
27
|
-
readOnlyHint: true,
|
|
28
|
-
},
|
|
29
|
-
schema: {
|
|
30
|
-
pageId: zod
|
|
31
|
-
.number()
|
|
32
|
-
.describe(`The ID of the page to select. Call ${listPages.name} to get available pages.`),
|
|
33
|
-
bringToFront: zod
|
|
34
|
-
.boolean()
|
|
35
|
-
.optional()
|
|
36
|
-
.describe('Whether to focus the page and bring it to the top.'),
|
|
37
|
-
},
|
|
38
|
-
handler: async (request, response, context) => {
|
|
39
|
-
const page = context.getPageById(request.params.pageId);
|
|
40
|
-
context.selectPage(page);
|
|
41
|
-
response.setIncludePages(true);
|
|
42
|
-
if (request.params.bringToFront) {
|
|
43
|
-
await page.bringToFront();
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
export const closePage = defineTool({
|
|
48
|
-
name: 'close_page',
|
|
49
|
-
description: `Closes the page by its index. The last open page cannot be closed.`,
|
|
50
|
-
annotations: {
|
|
51
|
-
category: ToolCategory.NAVIGATION,
|
|
52
|
-
readOnlyHint: false,
|
|
53
|
-
},
|
|
54
|
-
schema: {
|
|
55
|
-
pageId: zod
|
|
56
|
-
.number()
|
|
57
|
-
.describe('The ID of the page to close. Call list_pages to list pages.'),
|
|
58
|
-
},
|
|
59
|
-
handler: async (request, response, context) => {
|
|
60
|
-
try {
|
|
61
|
-
await context.closePage(request.params.pageId);
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
if (err.message === CLOSE_PAGE_ERROR) {
|
|
65
|
-
response.appendResponseLine(err.message);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
throw err;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
response.setIncludePages(true);
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
export const newPage = defineTool({
|
|
75
|
-
name: 'new_page',
|
|
76
|
-
description: `Creates a new page`,
|
|
77
|
-
annotations: {
|
|
78
|
-
category: ToolCategory.NAVIGATION,
|
|
79
|
-
readOnlyHint: false,
|
|
80
|
-
},
|
|
81
|
-
schema: {
|
|
82
|
-
url: zod.string().describe('URL to load in a new page.'),
|
|
83
|
-
background: zod
|
|
84
|
-
.boolean()
|
|
85
|
-
.optional()
|
|
86
|
-
.describe('Whether to open the page in the background without bringing it to the front. Default is false (foreground).'),
|
|
87
|
-
...timeoutSchema,
|
|
88
|
-
},
|
|
89
|
-
handler: async (request, response, context) => {
|
|
90
|
-
const page = await context.newPage(request.params.background);
|
|
91
|
-
await context.waitForEventsAfterAction(async () => {
|
|
92
|
-
await page.goto(request.params.url, {
|
|
93
|
-
timeout: request.params.timeout,
|
|
94
|
-
});
|
|
95
|
-
}, { timeout: request.params.timeout });
|
|
96
|
-
response.setIncludePages(true);
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
export const navigatePage = defineTool({
|
|
100
|
-
name: 'navigate_page',
|
|
101
|
-
description: `Navigates the currently selected page to a URL.`,
|
|
102
|
-
annotations: {
|
|
103
|
-
category: ToolCategory.NAVIGATION,
|
|
104
|
-
readOnlyHint: false,
|
|
105
|
-
},
|
|
106
|
-
schema: {
|
|
107
|
-
type: zod
|
|
108
|
-
.enum(['url', 'back', 'forward', 'reload'])
|
|
109
|
-
.optional()
|
|
110
|
-
.describe('Navigate the page by URL, back or forward in history, or reload.'),
|
|
111
|
-
url: zod.string().optional().describe('Target URL (only type=url)'),
|
|
112
|
-
ignoreCache: zod
|
|
113
|
-
.boolean()
|
|
114
|
-
.optional()
|
|
115
|
-
.describe('Whether to ignore cache on reload.'),
|
|
116
|
-
handleBeforeUnload: zod
|
|
117
|
-
.enum(['accept', 'decline'])
|
|
118
|
-
.optional()
|
|
119
|
-
.describe('Whether to auto accept or beforeunload dialogs triggered by this navigation. Default is accept.'),
|
|
120
|
-
initScript: zod
|
|
121
|
-
.string()
|
|
122
|
-
.optional()
|
|
123
|
-
.describe('A JavaScript script to be executed on each new document before any other scripts for the next navigation.'),
|
|
124
|
-
...timeoutSchema,
|
|
125
|
-
},
|
|
126
|
-
handler: async (request, response, context) => {
|
|
127
|
-
const page = context.getSelectedPage();
|
|
128
|
-
const options = {
|
|
129
|
-
timeout: request.params.timeout,
|
|
130
|
-
};
|
|
131
|
-
if (!request.params.type && !request.params.url) {
|
|
132
|
-
throw new Error('Either URL or a type is required.');
|
|
133
|
-
}
|
|
134
|
-
if (!request.params.type) {
|
|
135
|
-
request.params.type = 'url';
|
|
136
|
-
}
|
|
137
|
-
const handleBeforeUnload = request.params.handleBeforeUnload ?? 'accept';
|
|
138
|
-
const dialogHandler = (dialog) => {
|
|
139
|
-
if (dialog.type() === 'beforeunload') {
|
|
140
|
-
if (handleBeforeUnload === 'accept') {
|
|
141
|
-
response.appendResponseLine(`Accepted a beforeunload dialog.`);
|
|
142
|
-
void dialog.accept();
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
response.appendResponseLine(`Declined a beforeunload dialog.`);
|
|
146
|
-
void dialog.dismiss();
|
|
147
|
-
}
|
|
148
|
-
// We are not going to report the dialog like regular dialogs.
|
|
149
|
-
context.clearDialog();
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
let initScriptId;
|
|
153
|
-
if (request.params.initScript) {
|
|
154
|
-
const { identifier } = await page.evaluateOnNewDocument(request.params.initScript);
|
|
155
|
-
initScriptId = identifier;
|
|
156
|
-
}
|
|
157
|
-
page.on('dialog', dialogHandler);
|
|
158
|
-
try {
|
|
159
|
-
await context.waitForEventsAfterAction(async () => {
|
|
160
|
-
switch (request.params.type) {
|
|
161
|
-
case 'url':
|
|
162
|
-
if (!request.params.url) {
|
|
163
|
-
throw new Error('A URL is required for navigation of type=url.');
|
|
164
|
-
}
|
|
165
|
-
try {
|
|
166
|
-
await page.goto(request.params.url, options);
|
|
167
|
-
response.appendResponseLine(`Successfully navigated to ${request.params.url}.`);
|
|
168
|
-
}
|
|
169
|
-
catch (error) {
|
|
170
|
-
response.appendResponseLine(`Unable to navigate in the selected page: ${error.message}.`);
|
|
171
|
-
}
|
|
172
|
-
break;
|
|
173
|
-
case 'back':
|
|
174
|
-
try {
|
|
175
|
-
await page.goBack(options);
|
|
176
|
-
response.appendResponseLine(`Successfully navigated back to ${page.url()}.`);
|
|
177
|
-
}
|
|
178
|
-
catch (error) {
|
|
179
|
-
response.appendResponseLine(`Unable to navigate back in the selected page: ${error.message}.`);
|
|
180
|
-
}
|
|
181
|
-
break;
|
|
182
|
-
case 'forward':
|
|
183
|
-
try {
|
|
184
|
-
await page.goForward(options);
|
|
185
|
-
response.appendResponseLine(`Successfully navigated forward to ${page.url()}.`);
|
|
186
|
-
}
|
|
187
|
-
catch (error) {
|
|
188
|
-
response.appendResponseLine(`Unable to navigate forward in the selected page: ${error.message}.`);
|
|
189
|
-
}
|
|
190
|
-
break;
|
|
191
|
-
case 'reload':
|
|
192
|
-
try {
|
|
193
|
-
await page.reload({
|
|
194
|
-
...options,
|
|
195
|
-
ignoreCache: request.params.ignoreCache,
|
|
196
|
-
});
|
|
197
|
-
response.appendResponseLine(`Successfully reloaded the page.`);
|
|
198
|
-
}
|
|
199
|
-
catch (error) {
|
|
200
|
-
response.appendResponseLine(`Unable to reload the selected page: ${error.message}.`);
|
|
201
|
-
}
|
|
202
|
-
break;
|
|
203
|
-
}
|
|
204
|
-
}, { timeout: request.params.timeout });
|
|
205
|
-
}
|
|
206
|
-
finally {
|
|
207
|
-
page.off('dialog', dialogHandler);
|
|
208
|
-
if (initScriptId) {
|
|
209
|
-
await page
|
|
210
|
-
.removeScriptToEvaluateOnNewDocument(initScriptId)
|
|
211
|
-
.catch(error => {
|
|
212
|
-
logger(`Failed to remove init script`, error);
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
response.setIncludePages(true);
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
export const resizePage = defineTool({
|
|
220
|
-
name: 'resize_page',
|
|
221
|
-
description: `Resizes the selected page's window so that the page has specified dimension`,
|
|
222
|
-
annotations: {
|
|
223
|
-
category: ToolCategory.EMULATION,
|
|
224
|
-
readOnlyHint: false,
|
|
225
|
-
},
|
|
226
|
-
schema: {
|
|
227
|
-
width: zod.number().describe('Page width'),
|
|
228
|
-
height: zod.number().describe('Page height'),
|
|
229
|
-
},
|
|
230
|
-
handler: async (request, response, context) => {
|
|
231
|
-
const page = context.getSelectedPage();
|
|
232
|
-
try {
|
|
233
|
-
const browser = page.browser();
|
|
234
|
-
const windowId = await page.windowId();
|
|
235
|
-
const bounds = await browser.getWindowBounds(windowId);
|
|
236
|
-
if (bounds.windowState === 'fullscreen') {
|
|
237
|
-
// Have to call this twice on Ubuntu when the window is in fullscreen mode.
|
|
238
|
-
await browser.setWindowBounds(windowId, { windowState: 'normal' });
|
|
239
|
-
await browser.setWindowBounds(windowId, { windowState: 'normal' });
|
|
240
|
-
}
|
|
241
|
-
else if (bounds.windowState !== 'normal') {
|
|
242
|
-
await browser.setWindowBounds(windowId, { windowState: 'normal' });
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
catch {
|
|
246
|
-
// Window APIs are not supported on all platforms
|
|
247
|
-
}
|
|
248
|
-
await page.resize({
|
|
249
|
-
contentWidth: request.params.width,
|
|
250
|
-
contentHeight: request.params.height,
|
|
251
|
-
});
|
|
252
|
-
response.setIncludePages(true);
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
export const handleDialog = defineTool({
|
|
256
|
-
name: 'handle_dialog',
|
|
257
|
-
description: `If a browser dialog was opened, use this command to handle it`,
|
|
258
|
-
annotations: {
|
|
259
|
-
category: ToolCategory.INPUT,
|
|
260
|
-
readOnlyHint: false,
|
|
261
|
-
},
|
|
262
|
-
schema: {
|
|
263
|
-
action: zod
|
|
264
|
-
.enum(['accept', 'dismiss'])
|
|
265
|
-
.describe('Whether to dismiss or accept the dialog'),
|
|
266
|
-
promptText: zod
|
|
267
|
-
.string()
|
|
268
|
-
.optional()
|
|
269
|
-
.describe('Optional prompt text to enter into the dialog.'),
|
|
270
|
-
},
|
|
271
|
-
handler: async (request, response, context) => {
|
|
272
|
-
const dialog = context.getDialog();
|
|
273
|
-
if (!dialog) {
|
|
274
|
-
throw new Error('No open dialog found');
|
|
275
|
-
}
|
|
276
|
-
switch (request.params.action) {
|
|
277
|
-
case 'accept': {
|
|
278
|
-
try {
|
|
279
|
-
await dialog.accept(request.params.promptText);
|
|
280
|
-
}
|
|
281
|
-
catch (err) {
|
|
282
|
-
// Likely already handled by the user outside of MCP.
|
|
283
|
-
logger(err);
|
|
284
|
-
}
|
|
285
|
-
response.appendResponseLine('Successfully accepted the dialog');
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
case 'dismiss': {
|
|
289
|
-
try {
|
|
290
|
-
await dialog.dismiss();
|
|
291
|
-
}
|
|
292
|
-
catch (err) {
|
|
293
|
-
// Likely already handled.
|
|
294
|
-
logger(err);
|
|
295
|
-
}
|
|
296
|
-
response.appendResponseLine('Successfully dismissed the dialog');
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
context.clearDialog();
|
|
301
|
-
response.setIncludePages(true);
|
|
302
|
-
},
|
|
303
|
-
});
|
|
304
|
-
export const getTabId = defineTool({
|
|
305
|
-
name: 'get_tab_id',
|
|
306
|
-
description: `Get the tab ID of the page`,
|
|
307
|
-
annotations: {
|
|
308
|
-
category: ToolCategory.NAVIGATION,
|
|
309
|
-
readOnlyHint: true,
|
|
310
|
-
conditions: ['experimentalInteropTools'],
|
|
311
|
-
},
|
|
312
|
-
schema: {
|
|
313
|
-
pageId: zod
|
|
314
|
-
.number()
|
|
315
|
-
.describe(`The ID of the page to get the tab ID for. Call ${listPages.name} to get available pages.`),
|
|
316
|
-
},
|
|
317
|
-
handler: async (request, response, context) => {
|
|
318
|
-
const page = context.getPageById(request.params.pageId);
|
|
319
|
-
// @ts-expect-error _tabId is internal.
|
|
320
|
-
const tabId = page._tabId;
|
|
321
|
-
response.setTabId(tabId);
|
|
322
|
-
},
|
|
323
|
-
});
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import zlib from 'node:zlib';
|
|
7
|
-
import { logger } from '../logger.js';
|
|
8
|
-
import { zod, DevTools } from '../third_party/index.js';
|
|
9
|
-
import { parseRawTraceBuffer, traceResultIsSuccess, } from '../trace-processing/parse.js';
|
|
10
|
-
import { ToolCategory } from './categories.js';
|
|
11
|
-
import { defineTool } from './ToolDefinition.js';
|
|
12
|
-
const filePathSchema = zod
|
|
13
|
-
.string()
|
|
14
|
-
.optional()
|
|
15
|
-
.describe('The absolute file path, or a file path relative to the current working directory, to save the raw trace data. For example, trace.json.gz (compressed) or trace.json (uncompressed).');
|
|
16
|
-
export const startTrace = defineTool({
|
|
17
|
-
name: 'performance_start_trace',
|
|
18
|
-
description: `Starts a performance trace recording on the selected page. This can be used to look for performance problems and insights to improve the performance of the page. It will also report Core Web Vital (CWV) scores for the page.`,
|
|
19
|
-
annotations: {
|
|
20
|
-
category: ToolCategory.PERFORMANCE,
|
|
21
|
-
readOnlyHint: false,
|
|
22
|
-
},
|
|
23
|
-
schema: {
|
|
24
|
-
reload: zod
|
|
25
|
-
.boolean()
|
|
26
|
-
.describe('Determines if, once tracing has started, the current selected page should be automatically reloaded. Navigate the page to the right URL using the navigate_page tool BEFORE starting the trace if reload or autoStop is set to true.'),
|
|
27
|
-
autoStop: zod
|
|
28
|
-
.boolean()
|
|
29
|
-
.describe('Determines if the trace recording should be automatically stopped.'),
|
|
30
|
-
filePath: filePathSchema,
|
|
31
|
-
},
|
|
32
|
-
handler: async (request, response, context) => {
|
|
33
|
-
if (context.isRunningPerformanceTrace()) {
|
|
34
|
-
response.appendResponseLine('Error: a performance trace is already running. Use performance_stop_trace to stop it. Only one trace can be running at any given time.');
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
context.setIsRunningPerformanceTrace(true);
|
|
38
|
-
const page = context.getSelectedPage();
|
|
39
|
-
const pageUrlForTracing = page.url();
|
|
40
|
-
if (request.params.reload) {
|
|
41
|
-
// Before starting the recording, navigate to about:blank to clear out any state.
|
|
42
|
-
await page.goto('about:blank', {
|
|
43
|
-
waitUntil: ['networkidle0'],
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
// Keep in sync with the categories arrays in:
|
|
47
|
-
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/devtools-frontend/src/front_end/panels/timeline/TimelineController.ts
|
|
48
|
-
// https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/gatherers/trace.js
|
|
49
|
-
const categories = [
|
|
50
|
-
'-*',
|
|
51
|
-
'blink.console',
|
|
52
|
-
'blink.user_timing',
|
|
53
|
-
'devtools.timeline',
|
|
54
|
-
'disabled-by-default-devtools.screenshot',
|
|
55
|
-
'disabled-by-default-devtools.timeline',
|
|
56
|
-
'disabled-by-default-devtools.timeline.invalidationTracking',
|
|
57
|
-
'disabled-by-default-devtools.timeline.frame',
|
|
58
|
-
'disabled-by-default-devtools.timeline.stack',
|
|
59
|
-
'disabled-by-default-v8.cpu_profiler',
|
|
60
|
-
'disabled-by-default-v8.cpu_profiler.hires',
|
|
61
|
-
'latencyInfo',
|
|
62
|
-
'loading',
|
|
63
|
-
'disabled-by-default-lighthouse',
|
|
64
|
-
'v8.execute',
|
|
65
|
-
'v8',
|
|
66
|
-
];
|
|
67
|
-
await page.tracing.start({
|
|
68
|
-
categories,
|
|
69
|
-
});
|
|
70
|
-
if (request.params.reload) {
|
|
71
|
-
await page.goto(pageUrlForTracing, {
|
|
72
|
-
waitUntil: ['load'],
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if (request.params.autoStop) {
|
|
76
|
-
await new Promise(resolve => setTimeout(resolve, 5_000));
|
|
77
|
-
await stopTracingAndAppendOutput(page, response, context, request.params.filePath);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
response.appendResponseLine(`The performance trace is being recorded. Use performance_stop_trace to stop it.`);
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
export const stopTrace = defineTool({
|
|
85
|
-
name: 'performance_stop_trace',
|
|
86
|
-
description: 'Stops the active performance trace recording on the selected page.',
|
|
87
|
-
annotations: {
|
|
88
|
-
category: ToolCategory.PERFORMANCE,
|
|
89
|
-
readOnlyHint: false,
|
|
90
|
-
},
|
|
91
|
-
schema: {
|
|
92
|
-
filePath: filePathSchema,
|
|
93
|
-
},
|
|
94
|
-
handler: async (request, response, context) => {
|
|
95
|
-
if (!context.isRunningPerformanceTrace()) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const page = context.getSelectedPage();
|
|
99
|
-
await stopTracingAndAppendOutput(page, response, context, request.params.filePath);
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
export const analyzeInsight = defineTool({
|
|
103
|
-
name: 'performance_analyze_insight',
|
|
104
|
-
description: 'Provides more detailed information on a specific Performance Insight of an insight set that was highlighted in the results of a trace recording.',
|
|
105
|
-
annotations: {
|
|
106
|
-
category: ToolCategory.PERFORMANCE,
|
|
107
|
-
readOnlyHint: true,
|
|
108
|
-
},
|
|
109
|
-
schema: {
|
|
110
|
-
insightSetId: zod
|
|
111
|
-
.string()
|
|
112
|
-
.describe('The id for the specific insight set. Only use the ids given in the "Available insight sets" list.'),
|
|
113
|
-
insightName: zod
|
|
114
|
-
.string()
|
|
115
|
-
.describe('The name of the Insight you want more information on. For example: "DocumentLatency" or "LCPBreakdown"'),
|
|
116
|
-
},
|
|
117
|
-
handler: async (request, response, context) => {
|
|
118
|
-
const lastRecording = context.recordedTraces().at(-1);
|
|
119
|
-
if (!lastRecording) {
|
|
120
|
-
response.appendResponseLine('No recorded traces found. Record a performance trace so you have Insights to analyze.');
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
response.attachTraceInsight(lastRecording, request.params.insightSetId, request.params.insightName);
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
async function stopTracingAndAppendOutput(page, response, context, filePath) {
|
|
127
|
-
try {
|
|
128
|
-
const traceEventsBuffer = await page.tracing.stop();
|
|
129
|
-
if (filePath && traceEventsBuffer) {
|
|
130
|
-
let dataToWrite = traceEventsBuffer;
|
|
131
|
-
if (filePath.endsWith('.gz')) {
|
|
132
|
-
dataToWrite = await new Promise((resolve, reject) => {
|
|
133
|
-
zlib.gzip(traceEventsBuffer, (error, result) => {
|
|
134
|
-
if (error) {
|
|
135
|
-
reject(error);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
resolve(result);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
const file = await context.saveFile(dataToWrite, filePath);
|
|
144
|
-
response.appendResponseLine(`The raw trace data was saved to ${file.filename}.`);
|
|
145
|
-
}
|
|
146
|
-
const result = await parseRawTraceBuffer(traceEventsBuffer);
|
|
147
|
-
response.appendResponseLine('The performance trace has been stopped.');
|
|
148
|
-
if (traceResultIsSuccess(result)) {
|
|
149
|
-
if (context.isCruxEnabled()) {
|
|
150
|
-
await populateCruxData(result);
|
|
151
|
-
}
|
|
152
|
-
context.storeTraceRecording(result);
|
|
153
|
-
response.attachTraceSummary(result);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
throw new Error(`There was an unexpected error parsing the trace: ${result.error}`);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
finally {
|
|
160
|
-
context.setIsRunningPerformanceTrace(false);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
/** We tell CrUXManager to fetch data so it's available when DevTools.PerformanceTraceFormatter is invoked */
|
|
164
|
-
async function populateCruxData(result) {
|
|
165
|
-
logger('populateCruxData called');
|
|
166
|
-
const cruxManager = DevTools.CrUXManager.instance();
|
|
167
|
-
// go/jtfbx. Yes, we're aware this API key is public. ;)
|
|
168
|
-
cruxManager.setEndpointForTesting('https://chromeuxreport.googleapis.com/v1/records:queryRecord?key=AIzaSyBn5gimNjhiEyA_euicSKko6IlD3HdgUfk');
|
|
169
|
-
const cruxSetting = DevTools.Common.Settings.Settings.instance().createSetting('field-data', {
|
|
170
|
-
enabled: true,
|
|
171
|
-
});
|
|
172
|
-
cruxSetting.set({ enabled: true });
|
|
173
|
-
// Gather URLs to fetch CrUX data for
|
|
174
|
-
const urls = [...(result.parsedTrace.insights?.values() ?? [])].map(c => c.url.toString());
|
|
175
|
-
urls.push(result.parsedTrace.data.Meta.mainFrameURL);
|
|
176
|
-
const urlSet = new Set(urls);
|
|
177
|
-
if (urlSet.size === 0) {
|
|
178
|
-
logger('No URLs found for CrUX data');
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
logger(`Fetching CrUX data for ${urlSet.size} URLs: ${Array.from(urlSet).join(', ')}`);
|
|
182
|
-
const cruxData = await Promise.all(Array.from(urlSet).map(async (url) => {
|
|
183
|
-
const data = await cruxManager.getFieldDataForPage(url);
|
|
184
|
-
logger(`CrUX data for ${url}: ${data ? 'found' : 'not found'}`);
|
|
185
|
-
return data;
|
|
186
|
-
}));
|
|
187
|
-
result.parsedTrace.metadata.cruxFieldData = cruxData;
|
|
188
|
-
}
|