chrome-devtools-frontend 1.0.1674545 → 1.0.1676824

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 (258) hide show
  1. package/.agents/skills/devtools-ux-writing-refactor/SKILL.md +26 -9
  2. package/WATCHLISTS +0 -4
  3. package/front_end/core/common/ParsedURL.ts +5 -1
  4. package/front_end/core/common/SettingRegistration.ts +29 -8
  5. package/front_end/core/common/Settings.ts +0 -77
  6. package/front_end/core/root/Runtime.ts +4 -5
  7. package/front_end/core/sdk/CSSMetadata.ts +5 -9
  8. package/front_end/core/sdk/CSSPropertyParserMatchers.ts +8 -28
  9. package/front_end/core/sdk/DebuggerModel.ts +50 -30
  10. package/front_end/core/sdk/ResourceTreeModel.ts +20 -1
  11. package/front_end/core/sdk/Script.ts +9 -53
  12. package/front_end/core/sdk/TargetManager.ts +18 -0
  13. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +213 -23
  14. package/front_end/entrypoints/main/MainImpl.ts +32 -0
  15. package/front_end/foundation/Universe.ts +44 -29
  16. package/front_end/generated/InspectorBackendCommands.ts +3 -1
  17. package/front_end/generated/SupportedCSSProperties.ts +21 -4
  18. package/front_end/generated/protocol-mapping.d.ts +14 -0
  19. package/front_end/generated/protocol-proxy-api.d.ts +10 -0
  20. package/front_end/generated/protocol.ts +35 -0
  21. package/front_end/models/ai_assistance/AiAgent2.ts +11 -0
  22. package/front_end/models/ai_assistance/AiConversation.ts +22 -5
  23. package/front_end/models/ai_assistance/README.md +52 -26
  24. package/front_end/models/ai_assistance/agents/AiAgent.ts +54 -8
  25. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +1 -1
  26. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +15 -192
  27. package/front_end/models/ai_assistance/agents/StorageAgent.ts +8 -87
  28. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +2 -1
  29. package/front_end/models/ai_assistance/ai_assistance.ts +16 -0
  30. package/front_end/models/ai_assistance/contexts/PerformanceTraceContext.ts +124 -0
  31. package/front_end/models/ai_assistance/contexts/StorageContext.ts +111 -0
  32. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +69 -1
  33. package/front_end/models/ai_assistance/skills/README.md +63 -1
  34. package/front_end/models/ai_assistance/skills/Skill.ts +1 -1
  35. package/front_end/models/ai_assistance/skills/SkillRegistry.ts +4 -0
  36. package/front_end/models/ai_assistance/skills/performance.md +8 -0
  37. package/front_end/models/ai_assistance/skills/sources.md +16 -0
  38. package/front_end/models/ai_assistance/skills/storage.md +31 -0
  39. package/front_end/models/ai_assistance/tools/GetSourceContent.ts +101 -0
  40. package/front_end/models/ai_assistance/tools/GetTraceEventByKey.ts +83 -0
  41. package/front_end/models/ai_assistance/tools/GetTraceMainThreadSummary.ts +106 -0
  42. package/front_end/models/ai_assistance/tools/GetTraceNetworkSummary.ts +104 -0
  43. package/front_end/models/ai_assistance/tools/ListPageOrigins.ts +81 -0
  44. package/front_end/models/ai_assistance/tools/ListSources.ts +116 -0
  45. package/front_end/models/ai_assistance/tools/SelectTraceEventByKey.ts +90 -0
  46. package/front_end/models/ai_assistance/tools/Tool.ts +22 -1
  47. package/front_end/models/ai_assistance/tools/ToolRegistry.ts +14 -0
  48. package/front_end/models/bindings/CSSWorkspaceBinding.ts +4 -0
  49. package/front_end/models/bindings/CompilerScriptMapping.ts +4 -0
  50. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +8 -0
  51. package/front_end/models/bindings/ResourceScriptMapping.ts +3 -201
  52. package/front_end/models/bindings/SASSSourceMapping.ts +6 -0
  53. package/front_end/models/breakpoints/BreakpointManager.ts +2 -49
  54. package/front_end/models/emulation/DeviceModeModel.ts +60 -71
  55. package/front_end/models/emulation/EmulatedDevices.ts +18 -66
  56. package/front_end/models/heap_snapshot/HeapSnapshotModel.ts +27 -0
  57. package/front_end/models/heap_snapshot/HeapSnapshotProxy.ts +10 -2
  58. package/front_end/models/issues_manager/descriptions/connectionAllowlistEmbeddingRequirementNotSatisfied.md +26 -0
  59. package/front_end/models/issues_manager/descriptions/connectionAllowlistIFrameAttributeLoosensEmbeddingRequirement.md +19 -0
  60. package/front_end/models/issues_manager/descriptions/connectionAllowlistInvalidAllowConnectionAllowlistFrom.md +21 -0
  61. package/front_end/models/javascript_metadata/NativeFunctions.js +1 -1
  62. package/front_end/models/persistence/AutomaticFileSystemManager.ts +2 -2
  63. package/front_end/models/persistence/IsolatedFileSystem.ts +7 -8
  64. package/front_end/models/persistence/IsolatedFileSystemManager.ts +22 -31
  65. package/front_end/models/persistence/PlatformFileSystem.ts +1 -1
  66. package/front_end/models/persistence/persistence-meta.ts +9 -9
  67. package/front_end/models/trace/types/TraceEvents.ts +36 -0
  68. package/front_end/models/workspace/FileManager.ts +13 -6
  69. package/front_end/panels/accessibility/ARIAAttributesView.ts +3 -3
  70. package/front_end/panels/accessibility/AccessibilityNodeView.ts +36 -36
  71. package/front_end/panels/accessibility/AccessibilityStrings.ts +168 -168
  72. package/front_end/panels/accessibility/SourceOrderView.ts +7 -7
  73. package/front_end/panels/accessibility/accessibility-meta.ts +2 -2
  74. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +5 -5
  75. package/front_end/panels/ai_assistance/components/AIv2MarkdownRenderer.ts +2 -3
  76. package/front_end/panels/ai_assistance/components/ChatInput.ts +2 -2
  77. package/front_end/panels/ai_assistance/components/ChatMessage.ts +27 -2
  78. package/front_end/panels/application/IndexedDBViews.ts +65 -63
  79. package/front_end/panels/application/WebMCPView.ts +29 -12
  80. package/front_end/panels/application/components/AdsView.ts +24 -1
  81. package/front_end/panels/application/components/adsView.css +27 -21
  82. package/front_end/panels/autofill/AutofillView.ts +12 -12
  83. package/front_end/panels/autofill/autofill-meta.ts +2 -2
  84. package/front_end/panels/common/AiCodeCompletionSummaryToolbar.ts +5 -5
  85. package/front_end/panels/common/BadgeNotification.ts +8 -8
  86. package/front_end/panels/common/ExtensionServer.ts +21 -1
  87. package/front_end/panels/common/GdpSignUpDialog.ts +16 -16
  88. package/front_end/panels/common/GeminiRebrandPromoDialog.ts +5 -6
  89. package/front_end/panels/common/PersistenceUtils.ts +2 -2
  90. package/front_end/panels/common/common.ts +0 -97
  91. package/front_end/panels/console/ConsoleInsightTeaser.ts +2 -2
  92. package/front_end/panels/console/ConsolePinPane.ts +2 -2
  93. package/front_end/panels/console/ConsoleView.ts +20 -19
  94. package/front_end/panels/elements/ElementsTreeElement.ts +550 -327
  95. package/front_end/panels/elements/ElementsTreeOutline.ts +1 -1
  96. package/front_end/panels/elements/LayoutPane.ts +2 -8
  97. package/front_end/panels/event_listeners/EventListenersView.ts +8 -4
  98. package/front_end/panels/issues/AffectedTrackingSitesView.ts +25 -14
  99. package/front_end/panels/js_timeline/js_timeline-meta.ts +8 -8
  100. package/front_end/panels/layer_viewer/LayerDetailsView.ts +30 -30
  101. package/front_end/panels/layer_viewer/LayerTreeOutline.ts +6 -6
  102. package/front_end/panels/layer_viewer/LayerViewHost.ts +1 -1
  103. package/front_end/panels/layer_viewer/Layers3DView.ts +11 -11
  104. package/front_end/panels/layer_viewer/PaintProfilerView.ts +8 -8
  105. package/front_end/panels/layer_viewer/TransformController.ts +3 -3
  106. package/front_end/panels/layer_viewer/layer_viewer-meta.ts +11 -11
  107. package/front_end/panels/media/PlayerMessagesView.ts +149 -68
  108. package/front_end/panels/mobile_throttling/ThrottlingManager.ts +1 -58
  109. package/front_end/panels/mobile_throttling/mobile_throttling.ts +0 -10
  110. package/front_end/panels/network/NetworkPanel.ts +1 -1
  111. package/front_end/panels/network/RequestPayloadView.ts +1 -0
  112. package/front_end/panels/profiler/HeapSnapshotView.ts +0 -2
  113. package/front_end/panels/profiler/heapProfiler.css +0 -9
  114. package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +7 -0
  115. package/front_end/panels/recorder/RecorderPanel.ts +2 -3
  116. package/front_end/panels/screencast/ScreencastView.ts +148 -138
  117. package/front_end/panels/settings/emulation/DevicesSettingsTab.ts +1 -2
  118. package/front_end/panels/sources/AiCodeCompletionPlugin.ts +2 -2
  119. package/front_end/panels/sources/DebuggerPlugin.ts +9 -58
  120. package/front_end/panels/sources/ScopeChainSidebarPane.ts +1 -1
  121. package/front_end/panels/sources/UISourceCodeFrame.ts +3 -8
  122. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +4 -2
  123. package/front_end/panels/timeline/TimelineController.ts +36 -64
  124. package/front_end/panels/timeline/TimelinePanel.ts +11 -8
  125. package/front_end/panels/timeline/TimelineUIUtils.ts +5 -2
  126. package/front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts +2 -2
  127. package/front_end/panels/timeline/timelinePanel.css +0 -10
  128. package/front_end/panels/utils/utils.ts +7 -7
  129. package/front_end/services/tracing/PerformanceTracing.ts +5 -17
  130. package/front_end/third_party/chromium/README.chromium +1 -1
  131. package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
  132. package/front_end/third_party/codemirror.next/chunk/codemirror.js.map +1 -1
  133. package/front_end/third_party/codemirror.next/package.json +2 -2
  134. package/front_end/third_party/codemirror.next/rebuild.sh +4 -1
  135. package/front_end/ui/comments/CommentAnchorResolver.ts +558 -0
  136. package/front_end/ui/comments/CommentManager.ts +640 -0
  137. package/front_end/ui/comments/CommentsOverlayWidget.ts +121 -0
  138. package/front_end/ui/comments/comments.ts +13 -0
  139. package/front_end/ui/comments/commentsOverlay.css +49 -0
  140. package/front_end/{panels/common → ui/components/dialogs}/FreDialog.ts +6 -6
  141. package/front_end/ui/components/dialogs/TypeToAllowDialog.ts +96 -0
  142. package/front_end/ui/components/dialogs/dialogs.ts +4 -0
  143. package/front_end/ui/components/settings/SettingCheckbox.ts +3 -3
  144. package/front_end/{panels/common → ui/components/text_editor}/AiCodeCompletionDisclaimer.ts +13 -13
  145. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +7 -6
  146. package/front_end/{panels/common → ui/components/text_editor}/AiCodeCompletionTeaser.ts +43 -46
  147. package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +22 -26
  148. package/front_end/{panels/common → ui/components/text_editor}/AiCodeGenerationTeaser.ts +10 -10
  149. package/front_end/{panels/common → ui/components/text_editor}/AiCodeGenerationUpgradeDialog.ts +5 -5
  150. package/front_end/ui/components/text_editor/text_editor.ts +4 -0
  151. package/front_end/ui/legacy/Toolbar.ts +1 -1
  152. package/front_end/ui/legacy/components/data_grid/DataGridElement.ts +40 -0
  153. package/front_end/ui/legacy/components/object_ui/CustomPreviewComponent.ts +11 -3
  154. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +270 -162
  155. package/front_end/ui/legacy/components/object_ui/objectPropertiesSection.css +5 -0
  156. package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +11 -16
  157. package/front_end/ui/legacy/components/settings_ui/SettingsUI.ts +5 -12
  158. package/front_end/ui/legacy/components/source_frame/JSONView.ts +8 -1
  159. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +2 -2
  160. package/front_end/ui/legacy/components/utils/Linkifier.ts +1 -0
  161. package/front_end/ui/settings/SettingUIRegistration.ts +59 -6
  162. package/front_end/ui/visual_logging/Debugging.ts +1 -5
  163. package/front_end/ui/visual_logging/KnownContextValues.ts +2 -0
  164. package/front_end/ui/visual_logging/LoggingConfig.ts +21 -0
  165. package/front_end/ui/visual_logging/visual_logging.ts +9 -0
  166. package/mcp/mcp.ts +6 -1
  167. package/package.json +1 -1
  168. package/front_end/Images/toolbarResizerVertical.png +0 -0
  169. package/front_end/emulated_devices/MotoG4-landscape.svg +0 -155
  170. package/front_end/emulated_devices/MotoG4-portrait.svg +0 -155
  171. package/front_end/emulated_devices/Nexus5X-landscape.svg +0 -19
  172. package/front_end/emulated_devices/Nexus5X-portrait.svg +0 -19
  173. package/front_end/emulated_devices/Nexus6P-landscape.svg +0 -50
  174. package/front_end/emulated_devices/Nexus6P-portrait.svg +0 -54
  175. package/front_end/emulated_devices/google-nest-hub-horizontal.png +0 -0
  176. package/front_end/emulated_devices/google-nest-hub-max-horizontal.png +0 -0
  177. package/front_end/emulated_devices/google-nexus-5-horizontal-default-1x.png +0 -0
  178. package/front_end/emulated_devices/google-nexus-5-horizontal-default-2x.png +0 -0
  179. package/front_end/emulated_devices/google-nexus-5-horizontal-keyboard-1x.png +0 -0
  180. package/front_end/emulated_devices/google-nexus-5-horizontal-keyboard-2x.png +0 -0
  181. package/front_end/emulated_devices/google-nexus-5-horizontal-navigation-1x.png +0 -0
  182. package/front_end/emulated_devices/google-nexus-5-horizontal-navigation-2x.png +0 -0
  183. package/front_end/emulated_devices/google-nexus-5-vertical-default-1x.png +0 -0
  184. package/front_end/emulated_devices/google-nexus-5-vertical-default-2x.png +0 -0
  185. package/front_end/emulated_devices/google-nexus-5-vertical-keyboard-1x.png +0 -0
  186. package/front_end/emulated_devices/google-nexus-5-vertical-keyboard-2x.png +0 -0
  187. package/front_end/emulated_devices/google-nexus-5-vertical-navigation-1x.png +0 -0
  188. package/front_end/emulated_devices/google-nexus-5-vertical-navigation-2x.png +0 -0
  189. package/front_end/emulated_devices/google-nexus-5x-horizontal-default-1x.png +0 -0
  190. package/front_end/emulated_devices/google-nexus-5x-horizontal-default-2x.png +0 -0
  191. package/front_end/emulated_devices/google-nexus-5x-horizontal-keyboard-1x.png +0 -0
  192. package/front_end/emulated_devices/google-nexus-5x-horizontal-keyboard-2x.png +0 -0
  193. package/front_end/emulated_devices/google-nexus-5x-horizontal-navigation-1x.png +0 -0
  194. package/front_end/emulated_devices/google-nexus-5x-horizontal-navigation-2x.png +0 -0
  195. package/front_end/emulated_devices/google-nexus-5x-vertical-default-1x.png +0 -0
  196. package/front_end/emulated_devices/google-nexus-5x-vertical-default-2x.png +0 -0
  197. package/front_end/emulated_devices/google-nexus-5x-vertical-keyboard-1x.png +0 -0
  198. package/front_end/emulated_devices/google-nexus-5x-vertical-keyboard-2x.png +0 -0
  199. package/front_end/emulated_devices/google-nexus-5x-vertical-navigation-1x.png +0 -0
  200. package/front_end/emulated_devices/google-nexus-5x-vertical-navigation-2x.png +0 -0
  201. package/front_end/emulated_devices/iPad-landscape.svg +0 -73
  202. package/front_end/emulated_devices/iPad-portrait.svg +0 -76
  203. package/front_end/emulated_devices/iPhone5-landscape.svg +0 -99
  204. package/front_end/emulated_devices/iPhone5-portrait.svg +0 -83
  205. package/front_end/emulated_devices/iPhone6-landscape.svg +0 -111
  206. package/front_end/emulated_devices/iPhone6-portrait.svg +0 -116
  207. package/front_end/emulated_devices/iPhone6Plus-landscape.svg +0 -118
  208. package/front_end/emulated_devices/iPhone6Plus-portrait.svg +0 -116
  209. package/front_end/emulated_devices/optimized/MotoG4-landscape.avif +0 -0
  210. package/front_end/emulated_devices/optimized/MotoG4-portrait.avif +0 -0
  211. package/front_end/emulated_devices/optimized/Nexus5X-landscape.avif +0 -0
  212. package/front_end/emulated_devices/optimized/Nexus5X-portrait.avif +0 -0
  213. package/front_end/emulated_devices/optimized/Nexus6P-landscape.avif +0 -0
  214. package/front_end/emulated_devices/optimized/Nexus6P-portrait.avif +0 -0
  215. package/front_end/emulated_devices/optimized/README.md +0 -9
  216. package/front_end/emulated_devices/optimized/google-nest-hub-horizontal.avif +0 -0
  217. package/front_end/emulated_devices/optimized/google-nest-hub-max-horizontal.avif +0 -0
  218. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-default-1x.avif +0 -0
  219. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-default-2x.avif +0 -0
  220. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-keyboard-1x.avif +0 -0
  221. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-keyboard-2x.avif +0 -0
  222. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-navigation-1x.avif +0 -0
  223. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-navigation-2x.avif +0 -0
  224. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-default-1x.avif +0 -0
  225. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-default-2x.avif +0 -0
  226. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-keyboard-1x.avif +0 -0
  227. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-keyboard-2x.avif +0 -0
  228. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-navigation-1x.avif +0 -0
  229. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-navigation-2x.avif +0 -0
  230. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-default-1x.avif +0 -0
  231. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-default-2x.avif +0 -0
  232. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-keyboard-1x.avif +0 -0
  233. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-keyboard-2x.avif +0 -0
  234. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-navigation-1x.avif +0 -0
  235. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-navigation-2x.avif +0 -0
  236. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-default-1x.avif +0 -0
  237. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-default-2x.avif +0 -0
  238. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-keyboard-1x.avif +0 -0
  239. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-keyboard-2x.avif +0 -0
  240. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-navigation-1x.avif +0 -0
  241. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-navigation-2x.avif +0 -0
  242. package/front_end/emulated_devices/optimized/iPad-landscape.avif +0 -0
  243. package/front_end/emulated_devices/optimized/iPad-portrait.avif +0 -0
  244. package/front_end/emulated_devices/optimized/iPhone5-landscape.avif +0 -0
  245. package/front_end/emulated_devices/optimized/iPhone5-portrait.avif +0 -0
  246. package/front_end/emulated_devices/optimized/iPhone6-landscape.avif +0 -0
  247. package/front_end/emulated_devices/optimized/iPhone6-portrait.avif +0 -0
  248. package/front_end/emulated_devices/optimized/iPhone6Plus-landscape.avif +0 -0
  249. package/front_end/emulated_devices/optimized/iPhone6Plus-portrait.avif +0 -0
  250. package/front_end/emulated_devices/optimized/optimized_images.gni +0 -53
  251. package/front_end/models/ai_assistance/agents/README.md +0 -136
  252. package/front_end/panels/mobile_throttling/MobileThrottlingSelector.ts +0 -92
  253. /package/front_end/{panels/common → ui/components/dialogs}/freDialog.css +0 -0
  254. /package/front_end/{panels/common/common.css → ui/components/dialogs/typeToAllowDialog.css} +0 -0
  255. /package/front_end/{panels/common → ui/components/text_editor}/aiCodeCompletionDisclaimer.css +0 -0
  256. /package/front_end/{panels/common → ui/components/text_editor}/aiCodeCompletionTeaser.css +0 -0
  257. /package/front_end/{panels/common → ui/components/text_editor}/aiCodeGenerationTeaser.css +0 -0
  258. /package/front_end/{panels/common → ui/components/text_editor}/aiCodeGenerationUpgradeDialog.css +0 -0
@@ -0,0 +1,111 @@
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 * as Common from '../../../core/common/common.js';
6
+ import type * as SDK from '../../../core/sdk/sdk.js';
7
+ import {
8
+ ConversationContext,
9
+ type ConversationSuggestions,
10
+ } from '../agents/AiAgent.js';
11
+ import {areOriginsEquivalent} from '../AiOrigins.js';
12
+ import {CookieItem, DOMStorageItem, type StorageItem} from '../StorageItem.js';
13
+
14
+ export class StorageContext extends ConversationContext<StorageItem> {
15
+ #item: StorageItem;
16
+
17
+ constructor(item: StorageItem) {
18
+ super();
19
+ this.#item = item;
20
+ }
21
+
22
+ override getURL(): string {
23
+ return this.#item.primaryTargetOrigin;
24
+ }
25
+
26
+ override getItem(): StorageItem {
27
+ return this.#item;
28
+ }
29
+
30
+ override getTitle(): string {
31
+ if (this.#item instanceof CookieItem) {
32
+ if (this.#item.name) {
33
+ return `cookie: ${this.#item.name}${this.#item.origin ? ` ${this.#item.origin}` : ''}`;
34
+ }
35
+ return `cookies${this.#item.isGenericContext ? '' : `: ${this.#item.origin}`}`;
36
+ }
37
+ if (this.#item instanceof DOMStorageItem) {
38
+ if (this.#item.key) {
39
+ return `entry: ${this.#item.key}${this.#item.origin ? ` ${this.#item.origin}` : ''}`;
40
+ }
41
+ const prefix = this.#item.type === 'localStorage' ? 'local storage' : 'session storage';
42
+ return `${prefix}${this.#item.isGenericContext ? '' : `: ${this.#item.origin}`}`;
43
+ }
44
+ return `Storage: ${this.getOrigin()}`;
45
+ }
46
+
47
+ /**
48
+ * @override
49
+ */
50
+ override isLoggingEnabled(): boolean {
51
+ if (this.#item instanceof CookieItem && Boolean(this.#item.name)) {
52
+ return false;
53
+ }
54
+ if (this.#item instanceof DOMStorageItem && Boolean(this.#item.key)) {
55
+ return false;
56
+ }
57
+ return true;
58
+ }
59
+
60
+ override async getSuggestions(): Promise<ConversationSuggestions|undefined> {
61
+ if (this.#item instanceof CookieItem) {
62
+ if (this.#item.name) {
63
+ return [
64
+ {
65
+ title: 'Why is this cookie set?',
66
+ jslogContext: 'storage-cookie',
67
+ },
68
+ {
69
+ title: 'Explain the value of this cookie',
70
+ jslogContext: 'storage-cookie',
71
+ },
72
+ ];
73
+ }
74
+ return [
75
+ {
76
+ title: 'Explain the cookies set by this page',
77
+ jslogContext: 'storage-cookie',
78
+ },
79
+ ];
80
+ }
81
+ if (this.#item instanceof DOMStorageItem) {
82
+ if (this.#item.key) {
83
+ return [
84
+ {
85
+ title: 'What is the purpose of this storage entry?',
86
+ jslogContext: 'storage-domstorage',
87
+ },
88
+ {
89
+ title: 'Explain the value of this storage entry',
90
+ jslogContext: 'storage-domstorage',
91
+ },
92
+ ];
93
+ }
94
+ return [
95
+ {
96
+ title: 'Explain these storage items',
97
+ jslogContext: 'storage-domstorage',
98
+ },
99
+ ];
100
+ }
101
+ return undefined;
102
+ }
103
+ }
104
+
105
+ export function isSamePageOrigin(target: SDK.Target.Target|null, allowedOrigin: string): boolean {
106
+ if (!target) {
107
+ return false;
108
+ }
109
+ const pageOrigin = Common.ParsedURL.ParsedURL.extractOrigin(target.inspectedURL());
110
+ return pageOrigin !== '' && areOriginsEquivalent(pageOrigin, allowedOrigin);
111
+ }
@@ -11,7 +11,7 @@ import type {AICallTree} from '../performance/AICallTree.js';
11
11
  import type {AgentFocus} from '../performance/AIContext.js';
12
12
  import {AIQueries} from '../performance/AIQueries.js';
13
13
 
14
- import {NetworkRequestFormatter} from './NetworkRequestFormatter.js';
14
+ import {NetworkRequestFormatter, sanitizeHeaders} from './NetworkRequestFormatter.js';
15
15
  import {PerformanceInsightFormatter} from './PerformanceInsightFormatter.js';
16
16
  import {bytes, micros, millis} from './UnitFormatters.js';
17
17
 
@@ -1036,3 +1036,71 @@ The order of headers corresponds to an internal fixed list. If a header is not p
1036
1036
  ].join('\n\n');
1037
1037
  }
1038
1038
  }
1039
+
1040
+ /**
1041
+ * Serializes a trace event to a JSON string for AI consumption,
1042
+ * ensuring sensitive data (like headers and raw script source code)
1043
+ * is sanitized or redacted.
1044
+ */
1045
+ export function formatEventForAI(event: Trace.Types.Events.Event): string {
1046
+ if (Trace.Types.Events.isSyntheticNetworkRequest(event)) {
1047
+ return JSON.stringify({
1048
+ ...event,
1049
+ args: {
1050
+ ...event.args,
1051
+ data: {
1052
+ ...event.args.data,
1053
+ responseHeaders: event.args.data.responseHeaders ? sanitizeHeaders(event.args.data.responseHeaders) : null,
1054
+ },
1055
+ },
1056
+ });
1057
+ }
1058
+
1059
+ if (Trace.Types.Events.isResourceReceiveResponse(event)) {
1060
+ return JSON.stringify({
1061
+ ...event,
1062
+ args: {
1063
+ ...event.args,
1064
+ data: {
1065
+ ...event.args.data,
1066
+ headers: event.args.data.headers ? sanitizeHeaders(event.args.data.headers) : undefined,
1067
+ },
1068
+ },
1069
+ });
1070
+ }
1071
+
1072
+ if (Trace.Types.Events.isRundownScriptSource(event)) {
1073
+ // Redact sensitive cross-origin script source text.
1074
+ const safeData: Omit<Trace.Types.Events.RundownScriptSource['args']['data'], 'sourceText'> = {
1075
+ isolate: event.args.data.isolate,
1076
+ scriptId: event.args.data.scriptId,
1077
+ length: event.args.data.length,
1078
+ };
1079
+ return JSON.stringify({
1080
+ ...event,
1081
+ args: {
1082
+ ...event.args,
1083
+ data: safeData,
1084
+ },
1085
+ });
1086
+ }
1087
+
1088
+ if (Trace.Types.Events.isRundownScriptSourceLarge(event)) {
1089
+ // Redact sensitive cross-origin script source text.
1090
+ const safeData: Omit<Trace.Types.Events.RundownScriptSourceLarge['args']['data'], 'sourceText'> = {
1091
+ isolate: event.args.data.isolate,
1092
+ scriptId: event.args.data.scriptId,
1093
+ splitIndex: event.args.data.splitIndex,
1094
+ splitCount: event.args.data.splitCount,
1095
+ };
1096
+ return JSON.stringify({
1097
+ ...event,
1098
+ args: {
1099
+ ...event.args,
1100
+ data: safeData,
1101
+ },
1102
+ });
1103
+ }
1104
+
1105
+ return JSON.stringify(event);
1106
+ }
@@ -10,7 +10,7 @@ Example:
10
10
  ```markdown
11
11
  ---
12
12
  name: styling
13
- allowed-tools: [search_web]
13
+ allowed-tools: [executeJavaScript]
14
14
  ---
15
15
  You are a CSS expert...
16
16
  ```
@@ -38,3 +38,65 @@ To use a skill in TypeScript:
38
38
  2. Register it in `SkillRegistry.ts`.
39
39
 
40
40
  Types are provided globally in `front_end/global_typings/global_defs.d.ts` via a wildcard module declaration (`*.skill.js`). This avoids the need to generate `tsconfig.json` files for the generated skills.
41
+
42
+ ## Building a skill for AIv2
43
+
44
+ _Note: some of this is a bit rough around the edges and subject to change as we build V2 out._
45
+
46
+ If you want to add a new skill to DevTools AI v2 you should:
47
+
48
+ Firstly, consider if we need it or not. Can we test the AI to see how it can handle relevant prompts without a new skill? (We are currently working on eval architecture to make this easier in the future too).
49
+
50
+ Assuming we do want it, then we should create the new skill in `models/ai_assistance/skills/<NAME>.md`.
51
+
52
+ This skill must have YAML frontmatter that defines its name and description, and optionally any tools that it is allowed to call (more on tools below):
53
+
54
+ ```
55
+ ---
56
+ name: performance
57
+ description: Web performance analysis, trace inspection, and trace recording.
58
+ allowed-tools:
59
+ - recordPerformanceTrace
60
+ ---
61
+
62
+ <body of the skill goes here>
63
+ ```
64
+
65
+ The name and description are important. These are given to the AI in its context window so it knows that this tool exists and understands when to use it. You should think carefully about producing a very clear description and ideally evaluate this to check if the AI uses the tool in the right scenarios.
66
+
67
+ To have the skill built as JavaScript and available to the AI:
68
+
69
+ 1. Update `models/ai_assistance/skills/BUILD.gn` to add the new skill file as a source.
70
+ 2. Update `models/ai_assistance/skills/Skill.ts` to add the new skill name to the `SkillName` union type.
71
+ 3. Update `models/ai_assistance/skills/SkillRegistry.ts` to import the generated skill file and register it in the `SKILLS` object.
72
+ 4. Add the generated skill file (`front_end/models/ai_assistance/skills/<NAME>.skill.js`) to the list of release sources in `config/gni/devtools_grd_files.gni`.
73
+
74
+ If your skill does not need to call any tools, then you are done. The AI can now learn your skill and use it.
75
+
76
+ ### Using existing tools
77
+
78
+ If your new skill needs to use tools that are already implemented:
79
+
80
+ 1. **Find the tool name**: Locate the tool's registration name in the `ToolName` enum (e.g., `executeJavaScript`, `listNetworkRequests`, `getStyles`) from `models/ai_assistance/tools/Tool.ts`.
81
+ 2. **Bind the tool to the skill**: Add the tool name to the `allowed-tools` list in your skill's Markdown frontmatter:
82
+ ```yaml
83
+ ---
84
+ name: my-skill
85
+ allowed-tools:
86
+ - executeJavaScript
87
+ ---
88
+ ```
89
+
90
+ By doing this you ensure that if the AI learns you skill, those functions are learned and added to the active conversation for the AI to invoke.
91
+
92
+ Even if other skills list the tool you need, you should list it also. Tools are not learned more than once; any subsequent skills that use the same tool do not cause it to be redeclared.
93
+
94
+ ### Implementing and binding tools
95
+
96
+ If your new skill requires tools that do not exist yet, you should:
97
+
98
+ 1. Implement your new tool under `models/ai_assistance/tools/` extending the `BaseTool` class and implementing the `Tool` interface. Use the existing tools as guidance.
99
+ 2. Register the tool in the build system:
100
+ - Add the tool's source file to the `sources` list in `models/ai_assistance/BUILD.gn`.
101
+ - Import and register it inside `models/ai_assistance/tools/ToolRegistry.ts`.
102
+ 3. List the tool's name under the `allowed-tools` section of your skill's markdown frontmatter.
@@ -3,7 +3,7 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  // This will become a union type as we add more skills (e.g. 'styling' | 'network').
6
- export type SkillName = 'styling'|'network'|'accessibility'|'performance';
6
+ export type SkillName = 'styling'|'network'|'accessibility'|'performance'|'storage'|'sources';
7
7
 
8
8
  export interface Skill {
9
9
  name: SkillName;
@@ -6,6 +6,8 @@ import {skill as accessibilitySkill} from './accessibility.skill.js';
6
6
  import {skill as networkSkill} from './network.skill.js';
7
7
  import {skill as performanceSkill} from './performance.skill.js';
8
8
  import type {Skill, SkillName} from './Skill.js';
9
+ import {skill as sourcesSkill} from './sources.skill.js';
10
+ import {skill as storageSkill} from './storage.skill.js';
9
11
  import {skill as stylingSkill} from './styling.skill.js';
10
12
 
11
13
  export const SKILLS: Record<SkillName, Skill> = {
@@ -13,4 +15,6 @@ export const SKILLS: Record<SkillName, Skill> = {
13
15
  network: networkSkill,
14
16
  accessibility: accessibilitySkill,
15
17
  performance: performanceSkill,
18
+ storage: storageSkill,
19
+ sources: sourcesSkill,
16
20
  };
@@ -3,8 +3,16 @@ name: performance
3
3
  description: Web performance analysis, trace inspection, and trace recording.
4
4
  allowed-tools:
5
5
  - recordPerformanceTrace
6
+ - getTraceEventByKey
7
+ - selectTraceEventByKey
8
+ - getTraceMainThreadSummary
9
+ - getTraceNetworkSummary
6
10
  ---
7
11
  You are an expert web performance assistant integrated into Chrome DevTools.
8
12
  Your goal is to help users analyze, measure, and improve web page performance.
9
13
 
10
14
  Use `recordPerformanceTrace` to record a new performance trace when requested by the user or when live measurement is required.
15
+ - Trace events in the provided insights or summaries may have an `eventKey`. Use `getTraceEventByKey` with this key to retrieve detailed event data for verification.
16
+ - If the user asks to see, locate, or show a specific event, use `selectTraceEventByKey` to reveal and select it in the Flamechart.
17
+ - Use `getTraceMainThreadSummary` to get a bottom-up activity summary of the main thread for a specific labeled period.
18
+ - Use `getTraceNetworkSummary` to get a summary of network requests within a specific microsecond time range.
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: sources
3
+ description: Analyzing workspace sources, inspecting code files, reading script contents, and viewing files in the workspace.
4
+ allowed-tools:
5
+ - listSources
6
+ - getSourceContent
7
+ ---
8
+ You are the most advanced source code analysis and debugging assistant integrated into Chrome DevTools.
9
+ Provide a comprehensive analysis of source files, focusing on areas crucial for a software engineer. Your analysis should include:
10
+ * Briefly explain the purpose and architecture of the file or script.
11
+ * Analyze code blocks to identify potential bugs, logic issues, or areas for optimization.
12
+ * Walk through execution flow if requested, pointing to key lines or functions.
13
+
14
+ # Considerations
15
+ * Never leak sensitive user data or API keys found in source code files. Redact or generalize them in your analysis.
16
+ * Provide clean code snippets and direct line references where helpful.
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: storage
3
+ description: inspect, understand, and audit the state stored in browser storage (LocalStorage, SessionStorage) or cookies.
4
+ allowed-tools:
5
+ - listPageOrigins
6
+ ---
7
+ You are a Senior Software Engineer specializing in state audit and storage analysis within Chrome DevTools. Your mission is to help developers debug storage-related issues faster by analyzing the evidence in LocalStorage, SessionStorage, and Cookies.
8
+
9
+ You have access to the site's storage using tools.
10
+
11
+ # Goals
12
+
13
+ 1. **Explain Purpose**: Identify what specific storage entries or cookies are for.
14
+ 2. **Understand Application State**: Help users inspect, understand, and audit the state stored in browser storage or cookies, and how it relates to application behavior or issues (such as state mismatch/drift, security misconfigurations, or oversized cookies).
15
+ 3. **Top-Level Page First**: Your primary goal is to assist the user in understanding and debugging the storage of the **top-level page**. This context is the most critical for debugging and should be your default starting point for any analysis.
16
+
17
+ # Tools & Workflow
18
+
19
+ - **Top-Level Context**: Generally, questions refer to the primary page target ("my page", "this page", etc.). If the user selects a general category or a specific selection, answers should refer to that particular selection, but follow-up questions may switch to the primary page target.
20
+ - **Address Specific Selections**: The user can select individual storage items in the DevTools UI (provided in the '# Active Context' section of the prompt). If the query is about a selected item (e.g., "Why is this cookie set?"), focus your response on that specific item.
21
+ - **General Category Selection**: If a general storage category (such as Cookies, Local Storage, or Session Storage) is selected in the active context (indicated by an empty context origin), your first step MUST be to look through all active page origins by calling `listPageOrigins` to discover origins, unless the user's explicit request hints otherwise.
22
+ - **Expand Scope When Necessary**: For general questions or those implying a wider scope (e.g., "Check all storages," "Are there related cookies on subdomains?"), proactively use your tools to explore other relevant storage contexts, including iframes and different origins.
23
+ - **Discovery**: Start by calling `listPageOrigins` to discover all active, non-empty frame origins loaded by the page.
24
+ - **Active Context**: Start by inspecting the active context's origin (provided in the '# Active Context' section of the prompt).
25
+
26
+ # Considerations
27
+
28
+ - **Strictly Read-Only**: You cannot write, clear, delete, or edit storage or cookies.
29
+ - **DevTools UI Fallback**: If the user asks you to modify state, politely decline and provide exact step-by-step visual navigation directions on how they can perform the edit manually in the DevTools Application panel. Do NOT supply Console scripts.
30
+ - **Raw Evidence**: Treat storage data as raw evidence. Do not make assumptions about values without reading them first.
31
+ - **Dynamic State**: Always re-request values if you suspect they might have changed, rather than relying on past tool outputs.
@@ -0,0 +1,101 @@
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 * as Common from '../../../core/common/common.js';
6
+ import * as Host from '../../../core/host/host.js';
7
+ import * as i18n from '../../../core/i18n/i18n.js';
8
+ import * as TextUtils from '../../../core/text_utils/text_utils.js';
9
+ import {FileFormatter} from '../data_formatters/FileFormatter.js';
10
+
11
+ import {ListSourcesTool} from './ListSources.js';
12
+ import {
13
+ type BaseToolCapability,
14
+ type DataHandlerResult,
15
+ type DataTool,
16
+ type OriginLockCapability,
17
+ type ToolArgs,
18
+ ToolName,
19
+ } from './Tool.js';
20
+
21
+ const UIStringsNotTranslate = {
22
+ readingSource: 'Reading source content',
23
+ } as const;
24
+
25
+ const lockedString = i18n.i18n.lockedString;
26
+
27
+ export interface GetSourceContentArgs extends ToolArgs {
28
+ id: number;
29
+ }
30
+
31
+ /**
32
+ * A tool that retrieves the contents of a source file by its unique ID.
33
+ * Filters access by origin lock to prevent cross-origin leakage.
34
+ */
35
+ export class GetSourceContentTool implements
36
+ DataTool<GetSourceContentArgs, {content: string}, BaseToolCapability&OriginLockCapability> {
37
+ readonly name = ToolName.GET_SOURCE_CONTENT;
38
+ readonly description = 'Gets the content and metadata of a source file by its ID.';
39
+
40
+ readonly parameters: Host.AidaClient.FunctionObjectParam<keyof GetSourceContentArgs> = {
41
+ type: Host.AidaClient.ParametersTypes.OBJECT,
42
+ description: '',
43
+ properties: {
44
+ id: {
45
+ type: Host.AidaClient.ParametersTypes.INTEGER,
46
+ description: 'The unique numeric ID of the source file to retrieve.',
47
+ nullable: false,
48
+ },
49
+ },
50
+ required: ['id'],
51
+ };
52
+
53
+ displayInfoFromArgs(args: GetSourceContentArgs): {
54
+ title: string,
55
+ action: string,
56
+ } {
57
+ return {
58
+ title: lockedString(UIStringsNotTranslate.readingSource),
59
+ action: `getSourceContent(${args.id})`,
60
+ };
61
+ }
62
+
63
+ async handler(
64
+ args: GetSourceContentArgs,
65
+ context: BaseToolCapability&OriginLockCapability,
66
+ ): Promise<DataHandlerResult<{content: string}>> {
67
+ const origin = context.getEstablishedOrigin();
68
+ const file = ListSourcesTool.getUISourceCodes().find(
69
+ f => ListSourcesTool.uiSourceCodeId.get(f) === args.id,
70
+ );
71
+
72
+ if (!file) {
73
+ return {
74
+ error: 'Unable to find file.',
75
+ };
76
+ }
77
+
78
+ const fileUrl = file.url();
79
+ const fileOrigin = Common.ParsedURL.ParsedURL.extractOrigin(fileUrl);
80
+ if (origin && fileOrigin !== origin) {
81
+ return {
82
+ error: 'Cross-origin access blocked.',
83
+ };
84
+ }
85
+
86
+ const contentData = await file.requestContentData();
87
+ if (TextUtils.ContentData.ContentData.isError(contentData)) {
88
+ return {
89
+ error: `Failed to load file content: ${contentData.error}`,
90
+ };
91
+ }
92
+
93
+ const formatter = new FileFormatter(file);
94
+
95
+ return {
96
+ result: {
97
+ content: formatter.formatFile(),
98
+ },
99
+ };
100
+ }
101
+ }
@@ -0,0 +1,83 @@
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 * as Host from '../../../core/host/host.js';
6
+ import * as i18n from '../../../core/i18n/i18n.js';
7
+ import {PerformanceTraceContext} from '../contexts/PerformanceTraceContext.js';
8
+ import {formatEventForAI} from '../data_formatters/PerformanceTraceFormatter.js';
9
+
10
+ import {
11
+ type BaseToolCapability,
12
+ type DataHandlerResult,
13
+ type DataTool,
14
+ type ToolArgs,
15
+ ToolName,
16
+ } from './Tool.js';
17
+
18
+ const UIStringsNotTranslate = {
19
+ lookingAtTraceEvent: 'Looking at trace event',
20
+ } as const;
21
+
22
+ const lockedString = i18n.i18n.lockedString;
23
+
24
+ export interface GetTraceEventByKeyArgs extends ToolArgs {
25
+ eventKey: string;
26
+ }
27
+
28
+ export class GetTraceEventByKeyTool implements DataTool<GetTraceEventByKeyArgs, string, BaseToolCapability> {
29
+ readonly name = ToolName.GET_TRACE_EVENT_BY_KEY;
30
+ readonly description = 'Get details for a specific trace event by its event key.';
31
+
32
+ readonly parameters: Host.AidaClient.FunctionObjectParam<keyof GetTraceEventByKeyArgs> = {
33
+ type: Host.AidaClient.ParametersTypes.OBJECT,
34
+ description: 'Arguments for looking up a trace event.',
35
+ nullable: false,
36
+ properties: {
37
+ eventKey: {
38
+ type: Host.AidaClient.ParametersTypes.STRING,
39
+ description: 'The key of the event to look up.',
40
+ nullable: false,
41
+ },
42
+ },
43
+ required: ['eventKey'],
44
+ };
45
+
46
+ displayInfoFromArgs(params: GetTraceEventByKeyArgs): {
47
+ title: string,
48
+ action: string,
49
+ } {
50
+ return {
51
+ title: lockedString(UIStringsNotTranslate.lookingAtTraceEvent),
52
+ action: `getTraceEventByKey('${params.eventKey}')`,
53
+ };
54
+ }
55
+
56
+ async handler(
57
+ params: GetTraceEventByKeyArgs,
58
+ capabilities: BaseToolCapability,
59
+ ): Promise<DataHandlerResult<string>> {
60
+ const conversationContext = capabilities.conversationContext;
61
+ if (!conversationContext || !(conversationContext instanceof PerformanceTraceContext)) {
62
+ return {error: 'Performance trace context is not available.'};
63
+ }
64
+
65
+ const focus = conversationContext.getItem();
66
+ const event = focus.lookupEvent(params.eventKey);
67
+ if (!event) {
68
+ return {error: `Could not find event with key "${params.eventKey}".`};
69
+ }
70
+
71
+ const details = formatEventForAI(event);
72
+ return {
73
+ result: details,
74
+ widgets: [{
75
+ name: 'TIMELINE_EVENT_SUMMARY',
76
+ data: {
77
+ event,
78
+ parsedTrace: focus.parsedTrace,
79
+ },
80
+ }],
81
+ };
82
+ }
83
+ }
@@ -0,0 +1,106 @@
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 * as Host from '../../../core/host/host.js';
6
+ import * as i18n from '../../../core/i18n/i18n.js';
7
+ import {
8
+ type MainThreadSectionLabel,
9
+ PerformanceTraceContext,
10
+ } from '../contexts/PerformanceTraceContext.js';
11
+
12
+ import {
13
+ type BaseToolCapability,
14
+ type DataHandlerResult,
15
+ type DataTool,
16
+ MAX_FUNCTION_RESULT_BYTE_LENGTH,
17
+ type ToolArgs,
18
+ ToolName,
19
+ } from './Tool.js';
20
+
21
+ const UIStringsNotTranslate = {
22
+ mainThreadActivity: 'Main thread activity',
23
+ } as const;
24
+
25
+ const lockedString = i18n.i18n.lockedString;
26
+
27
+ export interface GetTraceMainThreadSummaryArgs extends ToolArgs {
28
+ label: MainThreadSectionLabel;
29
+ }
30
+
31
+ export class GetTraceMainThreadSummaryTool implements
32
+ DataTool<GetTraceMainThreadSummaryArgs, string, BaseToolCapability> {
33
+ readonly name = ToolName.GET_TRACE_MAIN_THREAD_SUMMARY;
34
+ readonly description = 'Returns a focused, detailed summary of the main thread for a predefined labeled period.';
35
+
36
+ readonly parameters: Host.AidaClient.FunctionObjectParam<keyof GetTraceMainThreadSummaryArgs> = {
37
+ type: Host.AidaClient.ParametersTypes.OBJECT,
38
+ description: 'Arguments for looking up a main thread summary.',
39
+ nullable: false,
40
+ properties: {
41
+ label: {
42
+ type: Host.AidaClient.ParametersTypes.STRING,
43
+ description:
44
+ 'The label of the period to investigate (e.g., \'LCPBreakdown\', \'CLSCulprits\', \'nav-to-lcp\').',
45
+ nullable: false,
46
+ },
47
+ },
48
+ required: ['label'],
49
+ };
50
+
51
+ displayInfoFromArgs(params: GetTraceMainThreadSummaryArgs): {
52
+ title: string,
53
+ action: string,
54
+ } {
55
+ return {
56
+ title: `${lockedString(UIStringsNotTranslate.mainThreadActivity)}: ${params.label}`,
57
+ action: `getTraceMainThreadSummary('${params.label}')`,
58
+ };
59
+ }
60
+
61
+ async handler(
62
+ params: GetTraceMainThreadSummaryArgs,
63
+ capabilities: BaseToolCapability,
64
+ ): Promise<DataHandlerResult<string>> {
65
+ const conversationContext = capabilities.conversationContext;
66
+ if (!conversationContext || !(conversationContext instanceof PerformanceTraceContext)) {
67
+ return {error: 'Performance trace context is not available.'};
68
+ }
69
+
70
+ const focus = conversationContext.getItem();
71
+ const bounds = conversationContext.getBoundsForLabel(params.label);
72
+ if (!bounds) {
73
+ return {error: `Invalid label: ${params.label}`};
74
+ }
75
+
76
+ const formatter = conversationContext.createFormatter();
77
+ const summary = await formatter.formatMainThreadTrackSummary(bounds);
78
+ if (summary.length > MAX_FUNCTION_RESULT_BYTE_LENGTH) {
79
+ return {
80
+ error:
81
+ 'getTraceMainThreadSummary response is too large. Try investigating using other functions, or a more narrow bounds',
82
+ };
83
+ }
84
+
85
+ return {
86
+ result: summary,
87
+ widgets: [
88
+ {
89
+ name: 'TIMELINE_RANGE_SUMMARY',
90
+ data: {
91
+ parsedTrace: focus.parsedTrace,
92
+ bounds,
93
+ track: 'main',
94
+ },
95
+ },
96
+ {
97
+ name: 'BOTTOM_UP_TREE',
98
+ data: {
99
+ bounds,
100
+ parsedTrace: focus.parsedTrace,
101
+ },
102
+ },
103
+ ],
104
+ };
105
+ }
106
+ }