chrome-devtools-frontend 1.0.1602348 → 1.0.1603822

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.
Files changed (105) hide show
  1. package/.agents/skills/version-control/SKILL.md +17 -2
  2. package/AUTHORS +1 -0
  3. package/front_end/core/common/Settings.ts +1 -871
  4. package/front_end/core/common/VersionController.ts +880 -0
  5. package/front_end/core/common/common.ts +2 -0
  6. package/front_end/core/platform/HostRuntime.ts +9 -3
  7. package/front_end/core/protocol_client/InspectorBackend.ts +8 -0
  8. package/front_end/core/root/Runtime.ts +5 -0
  9. package/front_end/core/sdk/OverlayModel.ts +13 -13
  10. package/front_end/core/sdk/OverlayPersistentHighlighter.ts +13 -10
  11. package/front_end/core/sdk/RuntimeModel.ts +5 -5
  12. package/front_end/core/sdk/ServiceWorkerManager.ts +4 -2
  13. package/front_end/core/sdk/Target.ts +5 -0
  14. package/front_end/core/sdk/TargetManager.ts +5 -0
  15. package/front_end/core/sdk/WebMCPModel.ts +104 -0
  16. package/front_end/core/sdk/sdk.ts +2 -0
  17. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +13 -19
  18. package/front_end/generated/InspectorBackendCommands.ts +3 -0
  19. package/front_end/generated/protocol-mapping.d.ts +8 -0
  20. package/front_end/generated/protocol-proxy-api.d.ts +10 -0
  21. package/front_end/generated/protocol.ts +57 -0
  22. package/front_end/models/ai_assistance/AiConversation.ts +3 -3
  23. package/front_end/models/ai_assistance/agents/AccessibilityAgent.ts +50 -0
  24. package/front_end/models/ai_assistance/agents/AiAgent.ts +14 -1
  25. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +19 -4
  26. package/front_end/models/ai_assistance/agents/NetworkAgent.ts +7 -1
  27. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +30 -7
  28. package/front_end/models/ai_assistance/agents/StylingAgent.ts +0 -23
  29. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.snapshot.txt +60 -9
  30. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.ts +71 -15
  31. package/front_end/models/heap_snapshot_model/HeapSnapshotModel.ts +7 -7
  32. package/front_end/models/javascript_metadata/NativeFunctions.js +6 -2
  33. package/front_end/models/lighthouse/LighthouseReporterTypes.ts +10 -8
  34. package/front_end/models/lighthouse/RunTypes.ts +3 -1
  35. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +13 -5
  36. package/front_end/panels/ai_assistance/components/ChatMessage.ts +143 -18
  37. package/front_end/panels/ai_assistance/components/WalkthroughView.ts +30 -10
  38. package/front_end/panels/ai_assistance/components/chatMessage.css +58 -3
  39. package/front_end/panels/ai_assistance/components/walkthroughView.css +35 -5
  40. package/front_end/panels/application/AppManifestView.ts +2 -2
  41. package/front_end/panels/application/BackgroundServiceView.ts +9 -9
  42. package/front_end/panels/application/FrameDetailsView.ts +4 -13
  43. package/front_end/panels/application/IndexedDBViews.ts +1 -1
  44. package/front_end/panels/application/ServiceWorkerCacheViews.ts +3 -3
  45. package/front_end/panels/application/components/PermissionsPolicySection.ts +1 -1
  46. package/front_end/panels/application/components/permissionsPolicySection.css +54 -52
  47. package/front_end/panels/application/frameDetailsReportView.css +13 -1
  48. package/front_end/panels/common/ThrottlingUtils.ts +46 -0
  49. package/front_end/panels/common/common.ts +1 -0
  50. package/front_end/panels/elements/CSSValueTraceView.ts +9 -1
  51. package/front_end/panels/elements/ComputedStyleWidget.ts +11 -1
  52. package/front_end/panels/elements/PropertiesWidget.ts +14 -13
  53. package/front_end/panels/elements/PropertyRenderer.ts +10 -9
  54. package/front_end/panels/elements/StandaloneStylesContainer.ts +15 -5
  55. package/front_end/panels/elements/StylePropertiesSection.ts +0 -49
  56. package/front_end/panels/elements/StylePropertyTreeElement.ts +20 -0
  57. package/front_end/panels/elements/StylesContainer.ts +0 -1
  58. package/front_end/panels/elements/StylesSidebarPane.ts +65 -31
  59. package/front_end/panels/elements/stylePropertiesTreeOutline.css +5 -0
  60. package/front_end/panels/issues/AffectedSelectivePermissionsInterventionView.ts +2 -2
  61. package/front_end/panels/lighthouse/LighthouseController.ts +4 -1
  62. package/front_end/panels/media/EventDisplayTable.ts +3 -2
  63. package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +14 -0
  64. package/front_end/panels/network/EventSourceMessagesView.ts +2 -2
  65. package/front_end/panels/network/ResourceChunkView.ts +1 -1
  66. package/front_end/panels/profiler/HeapDetachedElementsView.ts +9 -4
  67. package/front_end/panels/profiler/HeapProfileView.ts +8 -4
  68. package/front_end/panels/profiler/HeapSnapshotDataGrids.ts +40 -33
  69. package/front_end/panels/profiler/HeapSnapshotGridNodes.ts +1 -1
  70. package/front_end/panels/profiler/HeapSnapshotProxy.ts +1 -1
  71. package/front_end/panels/profiler/HeapSnapshotView.ts +12 -18
  72. package/front_end/panels/profiler/LiveHeapProfileView.ts +3 -4
  73. package/front_end/panels/profiler/ProfileHeader.ts +5 -11
  74. package/front_end/panels/profiler/ProfileView.ts +1 -10
  75. package/front_end/panels/sensors/SensorsView.ts +24 -43
  76. package/front_end/panels/settings/keybindsSettingsTab.css +25 -31
  77. package/front_end/panels/timeline/EventsTimelineTreeView.ts +2 -2
  78. package/front_end/panels/timeline/ThirdPartyTreeView.ts +8 -0
  79. package/front_end/panels/timeline/TimelinePanel.ts +14 -2
  80. package/front_end/panels/timeline/TimelineTreeView.ts +19 -17
  81. package/front_end/panels/timeline/components/FieldSettingsDialog.ts +5 -9
  82. package/front_end/panels/timeline/components/LiveMetricsView.ts +1 -2
  83. package/front_end/panels/timeline/components/OriginMap.ts +176 -159
  84. package/front_end/panels/timeline/components/originMap.css +4 -51
  85. package/front_end/panels/timeline/components/timelineRangeSummaryView.css +3 -1
  86. package/front_end/panels/timeline/thirdPartyTreeView.css +6 -0
  87. package/front_end/panels/timeline/timeline-meta.ts +11 -0
  88. package/front_end/panels/timeline/utils/Helpers.ts +5 -25
  89. package/front_end/panels/webauthn/WebauthnPane.ts +52 -0
  90. package/front_end/third_party/acorn/README.chromium +1 -0
  91. package/front_end/third_party/chromium/README.chromium +1 -1
  92. package/front_end/ui/components/{list → lists}/List.ts +1 -1
  93. package/front_end/ui/components/{list → lists}/list.css +0 -1
  94. package/front_end/ui/legacy/Treeoutline.ts +7 -3
  95. package/front_end/ui/legacy/UIUtils.ts +13 -11
  96. package/front_end/ui/legacy/Widget.ts +5 -0
  97. package/front_end/ui/legacy/components/data_grid/DataGrid.ts +1 -1
  98. package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +3 -3
  99. package/front_end/ui/legacy/components/data_grid/SortableDataGrid.ts +2 -2
  100. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +39 -23
  101. package/front_end/ui/legacy/components/perf_ui/GCActionDelegate.ts +20 -4
  102. package/front_end/ui/legacy/treeoutline.css +4 -0
  103. package/front_end/ui/visual_logging/KnownContextValues.ts +2 -0
  104. package/package.json +1 -1
  105. /package/front_end/ui/components/{list → lists}/lists.ts +0 -0
@@ -34,6 +34,7 @@ import * as StringOutputStream from './StringOutputStream.js';
34
34
  import * as TextDictionary from './TextDictionary.js';
35
35
  import * as Throttler from './Throttler.js';
36
36
  import * as Trie from './Trie.js';
37
+ import * as VersionController from './VersionController.js';
37
38
 
38
39
  /*
39
40
  * This is re-exported here because we moved UIString into platform from
@@ -74,4 +75,5 @@ export {
74
75
  TextDictionary,
75
76
  Throttler,
76
77
  Trie,
78
+ VersionController,
77
79
  };
@@ -14,12 +14,18 @@ export const IS_BROWSER =
14
14
  typeof window !== 'undefined' || (typeof self !== 'undefined' && typeof self.postMessage === 'function');
15
15
 
16
16
  export const HOST_RUNTIME = await (async(): Promise<Api.HostRuntime.HostRuntime> => {
17
- if (IS_NODE) {
18
- return (await import('./node/node.js')).HostRuntime.HOST_RUNTIME;
19
- }
17
+ // Check IS_BROWSER first: in some embedder environments, both IS_NODE
18
+ // and IS_BROWSER can be true because `process` is available in renderer
19
+ // contexts. The browser runtime is always correct when browser APIs
20
+ // (window/self) are available; the Node.js runtime should only be used in
21
+ // pure Node.js environments where those APIs don't exist.
20
22
  if (IS_BROWSER) {
21
23
  return (await import('./browser/browser.js')).HostRuntime.HOST_RUNTIME;
22
24
  }
23
25
 
26
+ if (IS_NODE) {
27
+ return (await import('./node/node.js')).HostRuntime.HOST_RUNTIME;
28
+ }
29
+
24
30
  throw new Error('Unknown runtime!');
25
31
  })();
@@ -491,6 +491,10 @@ export class TargetBase {
491
491
  return this.getAgent('WebAuthn');
492
492
  }
493
493
 
494
+ webMCPAgent(): ProtocolProxyApi.WebMCPApi {
495
+ return this.getAgent('WebMCP');
496
+ }
497
+
494
498
  // Dispatcher registration and de-registration, keep alphabetically sorted.
495
499
 
496
500
  /**
@@ -638,6 +642,10 @@ export class TargetBase {
638
642
  registerWebAuthnDispatcher(dispatcher: ProtocolProxyApi.WebAuthnDispatcher): void {
639
643
  this.registerDispatcher('WebAuthn', dispatcher);
640
644
  }
645
+
646
+ registerWebMCPDispatcher(dispatcher: ProtocolProxyApi.WebMCPDispatcher): void {
647
+ this.registerDispatcher('WebMCP', dispatcher);
648
+ }
641
649
  }
642
650
 
643
651
  /** These are not logged as console.error */
@@ -606,6 +606,10 @@ interface DevToolsProtocolMonitor {
606
606
  enabled: boolean;
607
607
  }
608
608
 
609
+ interface DevToolsWebMCPSupport {
610
+ enabled: boolean;
611
+ }
612
+
609
613
  /**
610
614
  * The host configuration that we expect from the DevTools back-end.
611
615
  *
@@ -657,6 +661,7 @@ export type HostConfig = Platform.TypeScriptUtilities.RecursivePartial<{
657
661
  devToolsConsoleInsightsTeasers: ConsoleInsightsTeasers,
658
662
  devToolsGeminiRebranding: HostConfigGeminiRebranding,
659
663
  devToolsProtocolMonitor: DevToolsProtocolMonitor,
664
+ devToolsWebMCPSupport: DevToolsWebMCPSupport,
660
665
  }>;
661
666
 
662
667
  /**
@@ -97,10 +97,10 @@ export class OverlayModel extends SDKModel<EventTypes> implements ProtocolProxyA
97
97
  target.registerOverlayDispatcher(this);
98
98
  this.overlayAgent = target.overlayAgent();
99
99
 
100
+ const settings = this.target().targetManager().settings;
100
101
  this.#debuggerModel = target.model(DebuggerModel);
101
102
  if (this.#debuggerModel) {
102
- Common.Settings.Settings.instance()
103
- .moduleSetting('disable-paused-state-overlay')
103
+ settings.moduleSetting('disable-paused-state-overlay')
104
104
  .addChangeListener(this.updatePausedInDebuggerMessage, this);
105
105
  this.#debuggerModel.addEventListener(
106
106
  DebuggerModelEvents.DebuggerPaused, this.updatePausedInDebuggerMessage, this);
@@ -114,21 +114,19 @@ export class OverlayModel extends SDKModel<EventTypes> implements ProtocolProxyA
114
114
  this.#defaultHighlighter = new DefaultHighlighter(this);
115
115
  this.#highlighter = this.#defaultHighlighter;
116
116
 
117
- this.#showPaintRectsSetting = Common.Settings.Settings.instance().moduleSetting<boolean>('show-paint-rects');
118
- this.#showLayoutShiftRegionsSetting =
119
- Common.Settings.Settings.instance().moduleSetting<boolean>('show-layout-shift-regions');
120
- this.#showAdHighlightsSetting = Common.Settings.Settings.instance().moduleSetting<boolean>('show-ad-highlights');
121
- this.#showDebugBordersSetting = Common.Settings.Settings.instance().moduleSetting<boolean>('show-debug-borders');
122
- this.#showFPSCounterSetting = Common.Settings.Settings.instance().moduleSetting<boolean>('show-fps-counter');
123
- this.#showScrollBottleneckRectsSetting =
124
- Common.Settings.Settings.instance().moduleSetting<boolean>('show-scroll-bottleneck-rects');
117
+ this.#showPaintRectsSetting = settings.moduleSetting<boolean>('show-paint-rects');
118
+ this.#showLayoutShiftRegionsSetting = settings.moduleSetting<boolean>('show-layout-shift-regions');
119
+ this.#showAdHighlightsSetting = settings.moduleSetting<boolean>('show-ad-highlights');
120
+ this.#showDebugBordersSetting = settings.moduleSetting<boolean>('show-debug-borders');
121
+ this.#showFPSCounterSetting = settings.moduleSetting<boolean>('show-fps-counter');
122
+ this.#showScrollBottleneckRectsSetting = settings.moduleSetting<boolean>('show-scroll-bottleneck-rects');
125
123
 
126
124
  if (!target.suspended()) {
127
125
  void this.overlayAgent.invoke_enable();
128
126
  void this.wireAgentToSettings();
129
127
  }
130
128
 
131
- this.#persistentHighlighter = new OverlayPersistentHighlighter(this, {
129
+ this.#persistentHighlighter = new OverlayPersistentHighlighter(this, settings, {
132
130
  onGridOverlayStateChanged: ({nodeId, enabled}) => {
133
131
  this.#domModel.nodeForId(nodeId)?.dispatchEventToListeners(DOMNodeEvents.GRID_OVERLAY_STATE_CHANGED, {enabled});
134
132
  this.dispatchEventToListeners(Events.PERSISTENT_GRID_OVERLAY_STATE_CHANGED, {nodeId, enabled});
@@ -291,8 +289,9 @@ export class OverlayModel extends SDKModel<EventTypes> implements ProtocolProxyA
291
289
  if (this.target().suspended()) {
292
290
  return;
293
291
  }
292
+ const settings = this.target().targetManager().settings;
294
293
  const message = this.#debuggerModel && this.#debuggerModel.isPaused() &&
295
- !Common.Settings.Settings.instance().moduleSetting('disable-paused-state-overlay').get() ?
294
+ !settings.moduleSetting('disable-paused-state-overlay').get() ?
296
295
  i18nString(UIStrings.pausedInDebugger) :
297
296
  undefined;
298
297
  void this.overlayAgent.invoke_setPausedInDebuggerMessage({message});
@@ -524,7 +523,8 @@ export class OverlayModel extends SDKModel<EventTypes> implements ProtocolProxyA
524
523
 
525
524
  private buildHighlightConfig(mode: string|undefined = 'all', showDetailedToolip: boolean|undefined = false):
526
525
  Protocol.Overlay.HighlightConfig {
527
- const showRulers = Common.Settings.Settings.instance().moduleSetting('show-metrics-rulers').get();
526
+ const settings = this.target().targetManager().settings;
527
+ const showRulers = settings.moduleSetting('show-metrics-rulers').get();
528
528
  const highlightConfig: Protocol.Overlay.HighlightConfig = {
529
529
  showInfo: mode === 'all' || mode === 'container-outline',
530
530
  showRulers,
@@ -33,9 +33,7 @@ export interface PersistentHighlighterCallbacks {
33
33
  export class OverlayPersistentHighlighter {
34
34
  readonly #model: OverlayModel;
35
35
  readonly #colors = new Map<Protocol.DOM.NodeId, Common.Color.Color>();
36
- readonly #persistentHighlightSetting =
37
- Common.Settings.Settings.instance().createLocalSetting<PersistentHighlightSettingItem[]>(
38
- 'persistent-highlight-setting', []);
36
+ readonly #persistentHighlightSetting: Common.Settings.Setting<PersistentHighlightSettingItem[]>;
39
37
  #gridHighlights = new Map<Protocol.DOM.NodeId, Protocol.Overlay.GridHighlightConfig>();
40
38
  #scrollSnapHighlights = new Map<Protocol.DOM.NodeId, Protocol.Overlay.ScrollSnapContainerHighlightConfig>();
41
39
  #flexHighlights = new Map<Protocol.DOM.NodeId, Protocol.Overlay.FlexContainerHighlightConfig>();
@@ -47,18 +45,23 @@ export class OverlayPersistentHighlighter {
47
45
  /**
48
46
  * @see `front_end/core/sdk/sdk-meta.ts`
49
47
  */
50
- readonly #showGridLineLabelsSetting =
51
- Common.Settings.Settings.instance().moduleSetting<string>('show-grid-line-labels');
52
- readonly #extendGridLinesSetting = Common.Settings.Settings.instance().moduleSetting<boolean>('extend-grid-lines');
53
- readonly #showGridAreasSetting = Common.Settings.Settings.instance().moduleSetting<boolean>('show-grid-areas');
54
- readonly #showGridTrackSizesSetting =
55
- Common.Settings.Settings.instance().moduleSetting<boolean>('show-grid-track-sizes');
48
+ readonly #showGridLineLabelsSetting: Common.Settings.Setting<string>;
49
+ readonly #extendGridLinesSetting: Common.Settings.Setting<boolean>;
50
+ readonly #showGridAreasSetting: Common.Settings.Setting<boolean>;
51
+ readonly #showGridTrackSizesSetting: Common.Settings.Setting<boolean>;
56
52
 
57
53
  readonly #callbacks: PersistentHighlighterCallbacks;
58
- constructor(model: OverlayModel, callbacks: PersistentHighlighterCallbacks) {
54
+ constructor(model: OverlayModel, settings: Common.Settings.Settings, callbacks: PersistentHighlighterCallbacks) {
59
55
  this.#model = model;
60
56
  this.#callbacks = callbacks;
61
57
 
58
+ this.#persistentHighlightSetting =
59
+ settings.createLocalSetting<PersistentHighlightSettingItem[]>('persistent-highlight-setting', []);
60
+ this.#showGridLineLabelsSetting = settings.moduleSetting<string>('show-grid-line-labels');
61
+ this.#extendGridLinesSetting = settings.moduleSetting<boolean>('extend-grid-lines');
62
+ this.#showGridAreasSetting = settings.moduleSetting<boolean>('show-grid-areas');
63
+ this.#showGridTrackSizesSetting = settings.moduleSetting<boolean>('show-grid-track-sizes');
64
+
62
65
  this.#showGridLineLabelsSetting.addChangeListener(this.onSettingChange, this);
63
66
  this.#extendGridLinesSetting.addChangeListener(this.onSettingChange, this);
64
67
  this.#showGridAreasSetting.addChangeListener(this.onSettingChange, this);
@@ -32,13 +32,12 @@ export class RuntimeModel extends SDKModel<EventTypes> {
32
32
  this.target().registerRuntimeDispatcher(new RuntimeDispatcher(this));
33
33
  void this.agent.invoke_enable();
34
34
 
35
- if (Common.Settings.Settings.instance().moduleSetting('custom-formatters').get()) {
35
+ const settings = this.target().targetManager().context.get(Common.Settings.Settings);
36
+ if (settings.moduleSetting('custom-formatters').get()) {
36
37
  void this.agent.invoke_setCustomObjectFormatterEnabled({enabled: true});
37
38
  }
38
39
 
39
- Common.Settings.Settings.instance()
40
- .moduleSetting('custom-formatters')
41
- .addChangeListener(this.customFormattersStateChanged.bind(this));
40
+ settings.moduleSetting('custom-formatters').addChangeListener(this.customFormattersStateChanged.bind(this));
42
41
  }
43
42
 
44
43
  static isSideEffectFailure(response: Protocol.Runtime.EvaluateResponse|EvaluationResult): boolean {
@@ -301,7 +300,8 @@ export class RuntimeModel extends SDKModel<EventTypes> {
301
300
  return;
302
301
  }
303
302
 
304
- const indent = Common.Settings.Settings.instance().moduleSetting('text-editor-indent').get();
303
+ const indent =
304
+ this.target().targetManager().context.get(Common.Settings.Settings).moduleSetting('text-editor-indent').get();
305
305
  void object
306
306
  .callFunctionJSON(toStringForClipboard, [{
307
307
  value: {
@@ -77,8 +77,10 @@ export class ServiceWorkerManager extends SDKModel<EventTypes> {
77
77
  target.registerServiceWorkerDispatcher(new ServiceWorkerDispatcher(this));
78
78
  this.#agent = target.serviceWorkerAgent();
79
79
  void this.enable();
80
- this.#forceUpdateSetting =
81
- Common.Settings.Settings.instance().createSetting('service-worker-update-on-reload', false);
80
+ this.#forceUpdateSetting = this.target()
81
+ .targetManager()
82
+ .context.get(Common.Settings.Settings)
83
+ .createSetting('service-worker-update-on-reload', false);
82
84
  if (this.#forceUpdateSetting.get()) {
83
85
  this.forceUpdateSettingChanged();
84
86
  }
@@ -6,6 +6,7 @@ import type * as Protocol from '../../generated/protocol.js';
6
6
  import * as Common from '../common/common.js';
7
7
  import * as Platform from '../platform/platform.js';
8
8
  import * as ProtocolClient from '../protocol_client/protocol_client.js';
9
+ import * as Root from '../root/root.js';
9
10
 
10
11
  import {SDKModel, type SDKModelConstructor} from './SDKModel.js';
11
12
  import type {TargetManager} from './TargetManager.js';
@@ -50,6 +51,9 @@ export class Target extends ProtocolClient.InspectorBackend.TargetBase {
50
51
  Capability.LOG | Capability.NETWORK | Capability.TARGET | Capability.TRACING | Capability.EMULATION |
51
52
  Capability.INPUT | Capability.INSPECTOR | Capability.AUDITS | Capability.WEB_AUTHN | Capability.IO |
52
53
  Capability.MEDIA | Capability.EVENT_BREAKPOINTS | Capability.DOM_STORAGE;
54
+ if (Root.Runtime.hostConfig.devToolsWebMCPSupport?.enabled) {
55
+ this.#capabilitiesMask |= Capability.WEB_MCP;
56
+ }
53
57
  if (parentTarget?.type() !== Type.FRAME) {
54
58
  // This matches backend exposing certain capabilities only for the main frame.
55
59
  this.#capabilitiesMask |=
@@ -320,5 +324,6 @@ export const enum Capability {
320
324
  MEDIA = 1 << 18,
321
325
  EVENT_BREAKPOINTS = 1 << 19,
322
326
  DOM_STORAGE = 1 << 20,
327
+ WEB_MCP = 1 << 21,
323
328
  NONE = 0,
324
329
  }
@@ -26,6 +26,11 @@ export class TargetManager extends Common.ObjectWrapper.ObjectWrapper<EventTypes
26
26
  readonly context: Root.DevToolsContext.DevToolsContext;
27
27
  #targets: Set<Target>;
28
28
  readonly #observers: Set<Observer>;
29
+
30
+ get settings(): Common.Settings.Settings {
31
+ return this.context.get(Common.Settings.Settings);
32
+ }
33
+
29
34
  /* eslint-disable @typescript-eslint/no-explicit-any */
30
35
  #modelListeners: Platform.MapUtilities.Multimap<string|symbol|number, {
31
36
  modelClass: SDKModelConstructor,
@@ -0,0 +1,104 @@
1
+ // Copyright 2026 The Chromium Authors
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
6
+ import type * as Protocol from '../../generated/protocol.js';
7
+ import type * as Common from '../common/common.js';
8
+
9
+ import {Events as RuntimeModelEvents, type ExecutionContext, RuntimeModel} from './RuntimeModel.js';
10
+ import {SDKModel} from './SDKModel.js';
11
+ import {Capability, type Target} from './Target.js';
12
+
13
+ export const enum Events {
14
+ TOOLS_ADDED = 'ToolsAdded',
15
+ TOOLS_REMOVED = 'ToolsRemoved',
16
+ }
17
+
18
+ export interface EventTypes {
19
+ [Events.TOOLS_ADDED]: ReadonlyArray<Readonly<Protocol.WebMCP.Tool>>;
20
+ [Events.TOOLS_REMOVED]: ReadonlyArray<Readonly<Protocol.WebMCP.Tool>>;
21
+ }
22
+
23
+ export class WebMCPModel extends SDKModel<EventTypes> {
24
+ readonly #tools = new Map<Protocol.Page.FrameId, Map<string, Protocol.WebMCP.Tool>>();
25
+ readonly agent: ProtocolProxyApi.WebMCPApi;
26
+ #enabled = false;
27
+
28
+ constructor(target: Target) {
29
+ super(target);
30
+ this.agent = target.webMCPAgent();
31
+ target.registerWebMCPDispatcher(new WebMCPDispatcher(this));
32
+
33
+ const runtimeModel = target.model(RuntimeModel);
34
+ if (runtimeModel) {
35
+ runtimeModel.addEventListener(
36
+ RuntimeModelEvents.ExecutionContextDestroyed, this.#executionContextDestroyed, this);
37
+ }
38
+
39
+ void this.enable();
40
+ }
41
+
42
+ get tools(): IteratorObject<Protocol.WebMCP.Tool> {
43
+ return this.#tools.values().flatMap(toolMap => toolMap.values());
44
+ }
45
+
46
+ async enable(): Promise<void> {
47
+ if (this.#enabled) {
48
+ return;
49
+ }
50
+ await this.agent.invoke_enable();
51
+ this.#enabled = true;
52
+ }
53
+
54
+ #executionContextDestroyed(event: Common.EventTarget.EventTargetEvent<ExecutionContext>): void {
55
+ const executionContext = event.data;
56
+ if (executionContext.isDefault && executionContext.frameId) {
57
+ const frameTools = this.#tools.get(executionContext.frameId);
58
+ if (frameTools) {
59
+ const toolsToRemove = [...frameTools.values()];
60
+ this.#tools.delete(executionContext.frameId);
61
+ this.dispatchEventToListeners(Events.TOOLS_REMOVED, toolsToRemove);
62
+ }
63
+ }
64
+ }
65
+
66
+ onToolsRemoved(tools: Protocol.WebMCP.Tool[]): void {
67
+ const deletedTools = tools.filter(tool => this.#tools.get(tool.frameId)?.delete(tool.name));
68
+ this.dispatchEventToListeners(Events.TOOLS_REMOVED, deletedTools);
69
+ }
70
+
71
+ onToolsAdded(tools: Protocol.WebMCP.Tool[]): void {
72
+ for (const tool of tools) {
73
+ const frameTools = this.#tools.get(tool.frameId) ?? new Map();
74
+ if (!this.#tools.has(tool.frameId)) {
75
+ this.#tools.set(tool.frameId, frameTools);
76
+ }
77
+ frameTools.set(tool.name, tool);
78
+ }
79
+ this.dispatchEventToListeners(Events.TOOLS_ADDED, tools);
80
+ }
81
+ }
82
+
83
+ class WebMCPDispatcher implements ProtocolProxyApi.WebMCPDispatcher {
84
+ readonly #model: WebMCPModel;
85
+ constructor(model: WebMCPModel) {
86
+ this.#model = model;
87
+ }
88
+
89
+ toolsAdded(params: Protocol.WebMCP.ToolsAddedEvent): void {
90
+ this.#model.onToolsAdded(params.tools);
91
+ }
92
+
93
+ toolsRemoved(params: Protocol.WebMCP.ToolsRemovedEvent): void {
94
+ this.#model.onToolsRemoved(params.tools);
95
+ }
96
+
97
+ toolInvoked(): void {
98
+ }
99
+
100
+ toolResponded(): void {
101
+ }
102
+ }
103
+
104
+ SDKModel.register(WebMCPModel, {capabilities: Capability.WEB_MCP, autostart: true});
@@ -90,6 +90,7 @@ import * as Target from './Target.js';
90
90
  import * as TargetManager from './TargetManager.js';
91
91
  import * as TraceObject from './TraceObject.js';
92
92
  import * as WebAuthnModel from './WebAuthnModel.js';
93
+ import * as WebMCPModel from './WebMCPModel.js';
93
94
 
94
95
  export {
95
96
  AccessibilityModel,
@@ -173,4 +174,5 @@ export {
173
174
  TargetManager,
174
175
  TraceObject,
175
176
  WebAuthnModel,
177
+ WebMCPModel,
176
178
  };
@@ -875,7 +875,7 @@ export abstract class HeapSnapshot {
875
875
  interfaceDefinitions: string,
876
876
  aggregates: Record<string, HeapSnapshotModel.HeapSnapshotModel.AggregateForDiff>,
877
877
  };
878
- #aggregates: Record<string, Record<string, AggregatedInfo>> = {};
878
+ #aggregates: Record<string, Record<string, HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo>> = {};
879
879
  #aggregatesSortedFlags: Record<string, boolean> = {};
880
880
  profile: Profile;
881
881
  nodeTypeOffset!: number;
@@ -1288,7 +1288,7 @@ export abstract class HeapSnapshot {
1288
1288
  }
1289
1289
 
1290
1290
  aggregatesWithFilter(nodeFilter: HeapSnapshotModel.HeapSnapshotModel.NodeFilter):
1291
- Record<string, HeapSnapshotModel.HeapSnapshotModel.Aggregate> {
1291
+ Record<string, HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo> {
1292
1292
  const filter = this.createFilter(nodeFilter);
1293
1293
  // @ts-expect-error key is added in createFilter
1294
1294
  const key = filter ? filter.key : 'allObjects';
@@ -1473,8 +1473,8 @@ export abstract class HeapSnapshot {
1473
1473
  }
1474
1474
 
1475
1475
  getAggregatesByClassKey(sortedIndexes: boolean, key?: string, filter?: ((arg0: HeapSnapshotNode) => boolean)):
1476
- Record<string, HeapSnapshotModel.HeapSnapshotModel.Aggregate> {
1477
- let aggregates: Record<string, HeapSnapshotModel.HeapSnapshotModel.Aggregate>;
1476
+ Record<string, HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo> {
1477
+ let aggregates: Record<string, HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo>;
1478
1478
  if (key && this.#aggregates[key]) {
1479
1479
  aggregates = this.#aggregates[key];
1480
1480
  } else {
@@ -1504,7 +1504,7 @@ export abstract class HeapSnapshot {
1504
1504
  }
1505
1505
  }
1506
1506
 
1507
- return aggregates as Record<string, HeapSnapshotModel.HeapSnapshotModel.Aggregate>;
1507
+ return aggregates;
1508
1508
  }
1509
1509
 
1510
1510
  allocationTracesTops(): HeapSnapshotModel.HeapSnapshotModel.SerializedAllocationNode[] {
@@ -1653,8 +1653,9 @@ export abstract class HeapSnapshot {
1653
1653
  }
1654
1654
  }
1655
1655
 
1656
- private buildAggregates(filter?: ((arg0: HeapSnapshotNode) => boolean)): Map<string|number, AggregatedInfo> {
1657
- const aggregates = new Map<string|number, AggregatedInfo>();
1656
+ private buildAggregates(filter?: ((arg0: HeapSnapshotNode) => boolean)):
1657
+ Map<string|number, HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo> {
1658
+ const aggregates = new Map<string|number, HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo>();
1658
1659
 
1659
1660
  const nodes = this.nodes;
1660
1661
  const nodesLength = nodes.length;
@@ -1703,7 +1704,8 @@ export abstract class HeapSnapshot {
1703
1704
  }
1704
1705
 
1705
1706
  private calculateClassesRetainedSize(
1706
- aggregates: Map<string|number, AggregatedInfo>, filter?: ((arg0: HeapSnapshotNode) => boolean)): void {
1707
+ aggregates: Map<string|number, HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo>,
1708
+ filter?: ((arg0: HeapSnapshotNode) => boolean)): void {
1707
1709
  const rootNodeIndex = this.rootNodeIndexInternal;
1708
1710
  const node = this.createNode(rootNodeIndex);
1709
1711
  const list = [rootNodeIndex];
@@ -1725,7 +1727,7 @@ export abstract class HeapSnapshot {
1725
1727
  const dominatedIndexTo = firstDominatedNodeIndex[nodeOrdinal + 1];
1726
1728
 
1727
1729
  if (!seen && (!filter || filter(node)) && node.selfSize()) {
1728
- (aggregates.get(classKey) as AggregatedInfo).maxRet += node.retainedSize();
1730
+ (aggregates.get(classKey) as HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo).maxRet += node.retainedSize();
1729
1731
  if (dominatedIndexFrom !== dominatedIndexTo) {
1730
1732
  seenClassKeys.set(classKey, true);
1731
1733
  sizes.push(list.length);
@@ -1745,7 +1747,7 @@ export abstract class HeapSnapshot {
1745
1747
  }
1746
1748
  }
1747
1749
 
1748
- private sortAggregateIndexes(aggregates: Record<string, AggregatedInfo>): void {
1750
+ private sortAggregateIndexes(aggregates: Record<string, HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo>): void {
1749
1751
  const nodeA = this.createNode();
1750
1752
  const nodeB = this.createNode();
1751
1753
 
@@ -2700,7 +2702,7 @@ export abstract class HeapSnapshot {
2700
2702
 
2701
2703
  private calculateDiffForClass(
2702
2704
  baseAggregate: HeapSnapshotModel.HeapSnapshotModel.AggregateForDiff,
2703
- aggregate?: HeapSnapshotModel.HeapSnapshotModel.Aggregate): HeapSnapshotModel.HeapSnapshotModel.Diff|null {
2705
+ aggregate?: HeapSnapshotModel.HeapSnapshotModel.AggregatedInfo): HeapSnapshotModel.HeapSnapshotModel.Diff|null {
2704
2706
  const baseIds = baseAggregate.ids;
2705
2707
  const baseIndexes = baseAggregate.indexes;
2706
2708
  const baseSelfSizes = baseAggregate.selfSizes;
@@ -4024,11 +4026,3 @@ export class JSHeapSnapshotRetainerEdge extends HeapSnapshotRetainerEdge {
4024
4026
  return this.edge().isWeak();
4025
4027
  }
4026
4028
  }
4027
- export interface AggregatedInfo {
4028
- count: number;
4029
- distance: number;
4030
- self: number;
4031
- maxRet: number;
4032
- name: string;
4033
- idxs: number[];
4034
- }
@@ -1517,8 +1517,11 @@ inspectorBackend.registerType("WebAuthn.VirtualAuthenticatorOptions", [{"name":
1517
1517
  inspectorBackend.registerType("WebAuthn.Credential", [{"name": "credentialId", "type": "string", "optional": false, "description": "", "typeRef": null}, {"name": "isResidentCredential", "type": "boolean", "optional": false, "description": "", "typeRef": null}, {"name": "rpId", "type": "string", "optional": true, "description": "Relying Party ID the credential is scoped to. Must be set when adding a credential.", "typeRef": null}, {"name": "privateKey", "type": "string", "optional": false, "description": "The ECDSA P-256 private key in PKCS#8 format.", "typeRef": null}, {"name": "userHandle", "type": "string", "optional": true, "description": "An opaque byte sequence with a maximum size of 64 bytes mapping the credential to a specific user.", "typeRef": null}, {"name": "signCount", "type": "number", "optional": false, "description": "Signature counter. This is incremented by one for each successful assertion. See https://w3c.github.io/webauthn/#signature-counter", "typeRef": null}, {"name": "largeBlob", "type": "string", "optional": true, "description": "The large blob associated with the credential. See https://w3c.github.io/webauthn/#sctn-large-blob-extension", "typeRef": null}, {"name": "backupEligibility", "type": "boolean", "optional": true, "description": "Assertions returned by this credential will have the backup eligibility (BE) flag set to this value. Defaults to the authenticator's defaultBackupEligibility value.", "typeRef": null}, {"name": "backupState", "type": "boolean", "optional": true, "description": "Assertions returned by this credential will have the backup state (BS) flag set to this value. Defaults to the authenticator's defaultBackupState value.", "typeRef": null}, {"name": "userName", "type": "string", "optional": true, "description": "The credential's user.name property. Equivalent to empty if not set. https://w3c.github.io/webauthn/#dom-publickeycredentialentity-name", "typeRef": null}, {"name": "userDisplayName", "type": "string", "optional": true, "description": "The credential's user.displayName property. Equivalent to empty if not set. https://w3c.github.io/webauthn/#dom-publickeycredentialuserentity-displayname", "typeRef": null}]);
1518
1518
 
1519
1519
  // WebMCP.
1520
+ inspectorBackend.registerEnum("WebMCP.InvocationStatus", {Success: "Success", Canceled: "Canceled", Error: "Error"});
1520
1521
  inspectorBackend.registerEvent("WebMCP.toolsAdded", ["tools"]);
1521
1522
  inspectorBackend.registerEvent("WebMCP.toolsRemoved", ["tools"]);
1523
+ inspectorBackend.registerEvent("WebMCP.toolInvoked", ["toolName", "frameId", "invocationId", "input"]);
1524
+ inspectorBackend.registerEvent("WebMCP.toolResponded", ["invocationId", "status", "output", "errorText", "exception"]);
1522
1525
  inspectorBackend.registerCommand("WebMCP.enable", [], [], "Enables the WebMCP domain, allowing events to be sent. Enabling the domain will trigger a toolsAdded event for all currently registered tools.");
1523
1526
  inspectorBackend.registerType("WebMCP.Annotation", [{"name": "readOnly", "type": "boolean", "optional": true, "description": "A hint indicating that the tool does not modify any state.", "typeRef": null}, {"name": "autosubmit", "type": "boolean", "optional": true, "description": "If the declarative tool was declared with the autosubmit attribute.", "typeRef": null}]);
1524
1527
  inspectorBackend.registerType("WebMCP.Tool", [{"name": "name", "type": "string", "optional": false, "description": "Tool name.", "typeRef": null}, {"name": "description", "type": "string", "optional": false, "description": "Tool description.", "typeRef": null}, {"name": "inputSchema", "type": "object", "optional": true, "description": "Schema for the tool's input parameters.", "typeRef": null}, {"name": "annotations", "type": "object", "optional": true, "description": "Optional annotations for the tool.", "typeRef": "WebMCP.Annotation"}, {"name": "frameId", "type": "string", "optional": false, "description": "Frame identifier associated with the tool registration.", "typeRef": "Page.FrameId"}, {"name": "backendNodeId", "type": "number", "optional": true, "description": "Optional node ID for declarative tools.", "typeRef": "DOM.BackendNodeId"}, {"name": "stackTrace", "type": "object", "optional": true, "description": "The stack trace at the time of the registration.", "typeRef": "Runtime.StackTrace"}]);
@@ -938,6 +938,14 @@ export namespace ProtocolMapping {
938
938
  * Event fired when tools are removed.
939
939
  */
940
940
  'WebMCP.toolsRemoved': [Protocol.WebMCP.ToolsRemovedEvent];
941
+ /**
942
+ * Event fired when a tool invocation starts.
943
+ */
944
+ 'WebMCP.toolInvoked': [Protocol.WebMCP.ToolInvokedEvent];
945
+ /**
946
+ * Event fired when a tool invocation completes or fails.
947
+ */
948
+ 'WebMCP.toolResponded': [Protocol.WebMCP.ToolRespondedEvent];
941
949
  /**
942
950
  * Fired when breakpoint is resolved to an actual script and location.
943
951
  * Deprecated in favor of `resolvedBreakpoints` in the `scriptParsed` event.
@@ -4872,6 +4872,16 @@ declare namespace ProtocolProxyApi {
4872
4872
  */
4873
4873
  toolsRemoved(params: Protocol.WebMCP.ToolsRemovedEvent): void;
4874
4874
 
4875
+ /**
4876
+ * Event fired when a tool invocation starts.
4877
+ */
4878
+ toolInvoked(params: Protocol.WebMCP.ToolInvokedEvent): void;
4879
+
4880
+ /**
4881
+ * Event fired when a tool invocation completes or fails.
4882
+ */
4883
+ toolResponded(params: Protocol.WebMCP.ToolRespondedEvent): void;
4884
+
4875
4885
  }
4876
4886
 
4877
4887
  export interface DebuggerApi {
@@ -20602,6 +20602,15 @@ export namespace WebMCP {
20602
20602
  autosubmit?: boolean;
20603
20603
  }
20604
20604
 
20605
+ /**
20606
+ * Represents the status of a tool invocation.
20607
+ */
20608
+ export const enum InvocationStatus {
20609
+ Success = 'Success',
20610
+ Canceled = 'Canceled',
20611
+ Error = 'Error',
20612
+ }
20613
+
20605
20614
  /**
20606
20615
  * Definition of a tool that can be invoked.
20607
20616
  */
@@ -20655,6 +20664,54 @@ export namespace WebMCP {
20655
20664
  */
20656
20665
  tools: Tool[];
20657
20666
  }
20667
+
20668
+ /**
20669
+ * Event fired when a tool invocation starts.
20670
+ */
20671
+ export interface ToolInvokedEvent {
20672
+ /**
20673
+ * Name of the tool to invoke.
20674
+ */
20675
+ toolName: string;
20676
+ /**
20677
+ * Frame id
20678
+ */
20679
+ frameId: Page.FrameId;
20680
+ /**
20681
+ * Invocation identifier.
20682
+ */
20683
+ invocationId: string;
20684
+ /**
20685
+ * The input parameters used for the invocation.
20686
+ */
20687
+ input: string;
20688
+ }
20689
+
20690
+ /**
20691
+ * Event fired when a tool invocation completes or fails.
20692
+ */
20693
+ export interface ToolRespondedEvent {
20694
+ /**
20695
+ * Invocation identifier.
20696
+ */
20697
+ invocationId: string;
20698
+ /**
20699
+ * Status of the invocation.
20700
+ */
20701
+ status: InvocationStatus;
20702
+ /**
20703
+ * Output or error delivered as delivered to the agent. Missing if `status` is anything other than Success.
20704
+ */
20705
+ output?: any;
20706
+ /**
20707
+ * Error text for protocol users.
20708
+ */
20709
+ errorText?: string;
20710
+ /**
20711
+ * The exception object, if the javascript tool threw an error>
20712
+ */
20713
+ exception?: Runtime.RemoteObject;
20714
+ }
20658
20715
  }
20659
20716
 
20660
20717
  /**
@@ -54,7 +54,7 @@ export interface AiConversationOptions {
54
54
  performanceRecordAndReload?: () => Promise<Trace.TraceModel.ParsedTrace>;
55
55
  onInspectElement?: () => Promise<SDK.DOMModel.DOMNode|null>;
56
56
  networkTimeCalculator?: NetworkTimeCalculator.NetworkTransferTimeCalculator;
57
- lighthouseRecording?: () => Promise<LHModel.ReporterTypes.ReportJSON|null>;
57
+ lighthouseRecording?: (overrides?: LHModel.RunTypes.RunOverrides) => Promise<LHModel.ReporterTypes.ReportJSON|null>;
58
58
  }
59
59
 
60
60
  export class AiConversation {
@@ -91,7 +91,7 @@ export class AiConversation {
91
91
  #contexts: Array<ConversationContext<unknown>> = [];
92
92
 
93
93
  #performanceRecordAndReload?: () => Promise<Trace.TraceModel.ParsedTrace>;
94
- #lighthouseRecording?: () => Promise<LHModel.ReporterTypes.ReportJSON|null>;
94
+ #lighthouseRecording?: (overrides?: LHModel.RunTypes.RunOverrides) => Promise<LHModel.ReporterTypes.ReportJSON|null>;
95
95
  #onInspectElement?: () => Promise<SDK.DOMModel.DOMNode|null>;
96
96
  #networkTimeCalculator?: NetworkTimeCalculator.NetworkTransferTimeCalculator;
97
97
 
@@ -334,9 +334,9 @@ export class AiConversation {
334
334
  sessionId: this.id,
335
335
  changeManager: this.#changeManager,
336
336
  performanceRecordAndReload: this.#performanceRecordAndReload,
337
- lighthouseRecording: this.#lighthouseRecording,
338
337
  onInspectElement: this.#onInspectElement,
339
338
  networkTimeCalculator: this.#networkTimeCalculator,
339
+ lighthouseRecording: this.#lighthouseRecording,
340
340
  allowedOrigin: this.allowedOrigin,
341
341
  history,
342
342
  };