chrome-devtools-frontend 1.0.1675430 → 1.0.1678416

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 (308) hide show
  1. package/AUTHORS +1 -0
  2. package/WATCHLISTS +0 -4
  3. package/front_end/core/common/EventTarget.ts +0 -5
  4. package/front_end/core/common/Settings.ts +0 -66
  5. package/front_end/core/host/InspectorFrontendHostAPI.ts +1 -0
  6. package/front_end/core/host/UserMetrics.ts +5 -0
  7. package/front_end/core/root/Runtime.ts +5 -5
  8. package/front_end/core/sdk/CSSMetadata.ts +5 -9
  9. package/front_end/core/sdk/CSSPropertyParserMatchers.ts +16 -34
  10. package/front_end/core/sdk/DebuggerModel.ts +92 -57
  11. package/front_end/core/sdk/EmulationModel.ts +2 -1
  12. package/front_end/core/sdk/NetworkManager.ts +16 -2
  13. package/front_end/core/sdk/OverlayModel.ts +19 -9
  14. package/front_end/core/sdk/OverlayPersistentHighlighter.ts +10 -4
  15. package/front_end/core/sdk/ResourceTreeModel.ts +20 -1
  16. package/front_end/core/sdk/SDKSettings.ts +117 -0
  17. package/front_end/core/sdk/Script.ts +9 -53
  18. package/front_end/core/sdk/sdk-meta.ts +0 -431
  19. package/front_end/devtools_compatibility.js +1 -0
  20. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +213 -23
  21. package/front_end/entrypoints/inspector_main/InspectorMain.ts +6 -5
  22. package/front_end/entrypoints/inspector_main/RenderingOptions.ts +14 -15
  23. package/front_end/entrypoints/inspector_main/inspector_main-meta.ts +157 -0
  24. package/front_end/entrypoints/main/MainImpl.ts +32 -0
  25. package/front_end/entrypoints/shell/shell.ts +0 -1
  26. package/front_end/foundation/Universe.ts +8 -0
  27. package/front_end/generated/InspectorBackendCommands.ts +8 -8
  28. package/front_end/generated/SupportedCSSProperties.ts +53 -4
  29. package/front_end/generated/protocol-mapping.d.ts +27 -21
  30. package/front_end/generated/protocol-proxy-api.d.ts +22 -17
  31. package/front_end/generated/protocol.ts +43 -18
  32. package/front_end/models/ai_assistance/AiAgent2.ts +47 -2
  33. package/front_end/models/ai_assistance/AiConversation.ts +22 -5
  34. package/front_end/models/ai_assistance/README.md +52 -26
  35. package/front_end/models/ai_assistance/agents/AiAgent.ts +54 -8
  36. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +1 -1
  37. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +7 -194
  38. package/front_end/models/ai_assistance/agents/StorageAgent.ts +21 -87
  39. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +2 -1
  40. package/front_end/models/ai_assistance/ai_assistance.ts +24 -0
  41. package/front_end/models/ai_assistance/contexts/PerformanceTraceContext.ts +124 -0
  42. package/front_end/models/ai_assistance/contexts/StorageContext.ts +100 -0
  43. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.ts +69 -1
  44. package/front_end/models/ai_assistance/skills/README.md +63 -1
  45. package/front_end/models/ai_assistance/skills/Skill.ts +1 -1
  46. package/front_end/models/ai_assistance/skills/SkillRegistry.ts +4 -0
  47. package/front_end/models/ai_assistance/skills/accessibility.md +7 -0
  48. package/front_end/models/ai_assistance/skills/performance.md +15 -1
  49. package/front_end/models/ai_assistance/skills/sources.md +16 -0
  50. package/front_end/models/ai_assistance/skills/storage.md +31 -0
  51. package/front_end/models/ai_assistance/tools/GetDetailedCallTree.ts +107 -0
  52. package/front_end/models/ai_assistance/tools/GetFunctionCode.ts +122 -0
  53. package/front_end/models/ai_assistance/tools/GetResourceContent.ts +127 -0
  54. package/front_end/models/ai_assistance/tools/GetSourceContent.ts +101 -0
  55. package/front_end/models/ai_assistance/tools/GetTraceEventByKey.ts +83 -0
  56. package/front_end/models/ai_assistance/tools/GetTraceMainThreadSummary.ts +106 -0
  57. package/front_end/models/ai_assistance/tools/GetTraceNetworkSummary.ts +104 -0
  58. package/front_end/models/ai_assistance/tools/ListPageOrigins.ts +95 -0
  59. package/front_end/models/ai_assistance/tools/ListSources.ts +116 -0
  60. package/front_end/models/ai_assistance/tools/RunLighthouse.ts +89 -0
  61. package/front_end/models/ai_assistance/tools/SelectTraceEventByKey.ts +90 -0
  62. package/front_end/models/ai_assistance/tools/Tool.ts +26 -1
  63. package/front_end/models/ai_assistance/tools/ToolRegistry.ts +22 -0
  64. package/front_end/models/bindings/CSSWorkspaceBinding.ts +4 -0
  65. package/front_end/models/bindings/CompilerScriptMapping.ts +4 -0
  66. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +8 -0
  67. package/front_end/models/bindings/ResourceScriptMapping.ts +3 -201
  68. package/front_end/models/bindings/SASSSourceMapping.ts +6 -0
  69. package/front_end/models/breakpoints/BreakpointManager.ts +2 -49
  70. package/front_end/models/comment_manager/CommentManager.ts +141 -0
  71. package/front_end/models/comment_manager/comment_manager.ts +9 -0
  72. package/front_end/models/heap_snapshot/HeapSnapshotModel.ts +27 -0
  73. package/front_end/models/heap_snapshot/HeapSnapshotProxy.ts +10 -2
  74. package/front_end/models/issues_manager/descriptions/connectionAllowlistEmbeddingRequirementNotSatisfied.md +26 -0
  75. package/front_end/models/issues_manager/descriptions/connectionAllowlistIFrameAttributeLoosensEmbeddingRequirement.md +19 -0
  76. package/front_end/models/issues_manager/descriptions/connectionAllowlistInvalidAllowConnectionAllowlistFrom.md +21 -0
  77. package/front_end/models/javascript_metadata/NativeFunctions.js +6 -6
  78. package/front_end/models/persistence/IsolatedFileSystem.ts +7 -8
  79. package/front_end/models/persistence/IsolatedFileSystemManager.ts +2 -2
  80. package/front_end/models/persistence/PlatformFileSystem.ts +1 -1
  81. package/front_end/models/persistence/persistence-meta.ts +9 -9
  82. package/front_end/models/trace/types/TraceEvents.ts +36 -0
  83. package/front_end/panels/accessibility/ARIAAttributesView.ts +3 -3
  84. package/front_end/panels/accessibility/AccessibilityAnnouncementRecordingView.ts +25 -0
  85. package/front_end/panels/accessibility/AccessibilityNodeView.ts +36 -36
  86. package/front_end/panels/accessibility/AccessibilitySidebarView.ts +9 -0
  87. package/front_end/panels/accessibility/AccessibilityStrings.ts +168 -168
  88. package/front_end/panels/accessibility/SourceOrderView.ts +7 -7
  89. package/front_end/panels/accessibility/accessibility-meta.ts +2 -2
  90. package/front_end/panels/accessibility/accessibility.ts +2 -0
  91. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +5 -5
  92. package/front_end/panels/ai_assistance/components/AIv2MarkdownRenderer.ts +2 -3
  93. package/front_end/panels/ai_assistance/components/ChatInput.ts +2 -2
  94. package/front_end/panels/ai_assistance/components/ChatMessage.ts +92 -12
  95. package/front_end/panels/ai_assistance/components/chatMessage.css +6 -0
  96. package/front_end/panels/application/ApplicationPanelSidebar.ts +10 -4
  97. package/front_end/panels/application/IndexedDBViews.ts +65 -63
  98. package/front_end/panels/application/StorageView.ts +116 -45
  99. package/front_end/panels/application/WebMCPView.ts +16 -7
  100. package/front_end/panels/application/application-meta.ts +11 -0
  101. package/front_end/panels/application/components/AdsView.ts +1 -1
  102. package/front_end/panels/common/AiCodeCompletionSummaryToolbar.ts +5 -5
  103. package/front_end/panels/common/BadgeNotification.ts +8 -8
  104. package/front_end/panels/common/ExtensionPanel.ts +9 -8
  105. package/front_end/panels/common/ExtensionServer.ts +21 -1
  106. package/front_end/panels/common/GdpSignUpDialog.ts +16 -16
  107. package/front_end/panels/common/GeminiRebrandPromoDialog.ts +5 -6
  108. package/front_end/panels/common/PersistenceUtils.ts +2 -2
  109. package/front_end/panels/common/common.ts +0 -97
  110. package/front_end/panels/console/ConsoleInsightTeaser.ts +2 -2
  111. package/front_end/panels/console/ConsolePanel.ts +4 -0
  112. package/front_end/panels/console/ConsolePinPane.ts +2 -2
  113. package/front_end/panels/console/ConsolePrompt.ts +12 -0
  114. package/front_end/panels/console/ConsoleView.ts +31 -20
  115. package/front_end/panels/console/ConsoleViewMessage.ts +37 -13
  116. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +2 -2
  117. package/front_end/panels/css_overview/CSSOverviewModel.ts +1 -1
  118. package/front_end/panels/elements/ElementStatePaneWidget.ts +2 -1
  119. package/front_end/panels/elements/ElementsTreeElement.ts +455 -372
  120. package/front_end/panels/elements/LayoutPane.ts +2 -8
  121. package/front_end/panels/elements/StylePropertyTreeElement.ts +16 -15
  122. package/front_end/panels/elements/elements-meta.ts +152 -10
  123. package/front_end/panels/elements/elements.ts +0 -2
  124. package/front_end/panels/emulation/DeviceModeView.ts +9 -1
  125. package/front_end/panels/event_listeners/EventListenersView.ts +8 -4
  126. package/front_end/panels/issues/AffectedTrackingSitesView.ts +25 -14
  127. package/front_end/panels/lighthouse/LighthouseController.ts +3 -2
  128. package/front_end/panels/media/PlayerMessagesView.ts +149 -68
  129. package/front_end/panels/network/BinaryResourceView.ts +134 -81
  130. package/front_end/panels/network/EventSourceMessagesView.ts +10 -10
  131. package/front_end/panels/network/FetchHeaderCommenting.ts +291 -0
  132. package/front_end/panels/network/NetworkConfigView.ts +10 -10
  133. package/front_end/panels/network/NetworkDataGridNode.ts +14 -14
  134. package/front_end/panels/network/NetworkItemView.ts +27 -28
  135. package/front_end/panels/network/NetworkLogView.ts +137 -38
  136. package/front_end/panels/network/NetworkLogViewColumns.ts +35 -35
  137. package/front_end/panels/network/NetworkManageCustomHeadersView.ts +1 -1
  138. package/front_end/panels/network/NetworkPanel.ts +2 -2
  139. package/front_end/panels/network/RequestConditionsDrawer.ts +5 -5
  140. package/front_end/panels/network/RequestCookiesView.ts +4 -4
  141. package/front_end/panels/network/RequestHeadersView.ts +5 -5
  142. package/front_end/panels/network/RequestPayloadView.ts +4 -3
  143. package/front_end/panels/network/RequestTimingView.ts +8 -8
  144. package/front_end/panels/network/ResourceChunkView.ts +1 -1
  145. package/front_end/panels/network/ResourceDirectSocketChunkView.ts +1 -1
  146. package/front_end/panels/network/ResourceWebSocketFrameView.ts +16 -16
  147. package/front_end/panels/network/binaryResourceView.css +14 -12
  148. package/front_end/panels/network/components/DirectSocketConnectionView.ts +2 -2
  149. package/front_end/panels/network/components/HeaderSectionRow.ts +1 -1
  150. package/front_end/panels/network/components/RequestTrustTokensView.ts +2 -2
  151. package/front_end/panels/network/network-meta.ts +1 -1
  152. package/front_end/panels/network/network.ts +2 -0
  153. package/front_end/panels/profiler/HeapDetachedElementsDataGrid.ts +0 -1
  154. package/front_end/panels/profiler/HeapSnapshotView.ts +0 -2
  155. package/front_end/panels/profiler/heapProfiler.css +0 -9
  156. package/front_end/panels/recorder/RecorderPanel.ts +2 -3
  157. package/front_end/panels/screencast/ScreencastView.ts +148 -138
  158. package/front_end/panels/sources/AiCodeCompletionPlugin.ts +2 -2
  159. package/front_end/panels/sources/BreakpointsView.ts +2 -2
  160. package/front_end/panels/sources/DebuggerPlugin.ts +10 -59
  161. package/front_end/panels/sources/NavigatorView.ts +2 -1
  162. package/front_end/panels/sources/ScopeChainSidebarPane.ts +1 -1
  163. package/front_end/panels/sources/SourcesPanel.ts +23 -73
  164. package/front_end/panels/sources/SourcesView.ts +248 -157
  165. package/front_end/panels/sources/TabbedEditorContainer.ts +118 -23
  166. package/front_end/panels/sources/UISourceCodeFrame.ts +5 -9
  167. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +4 -2
  168. package/front_end/panels/sources/sources-meta.ts +52 -0
  169. package/front_end/panels/timeline/TimelineController.ts +36 -64
  170. package/front_end/panels/timeline/TimelinePanel.ts +11 -8
  171. package/front_end/panels/timeline/TimelineUIUtils.ts +5 -2
  172. package/front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts +2 -2
  173. package/front_end/panels/timeline/timelinePanel.css +0 -10
  174. package/front_end/panels/utils/utils.ts +7 -7
  175. package/front_end/services/tracing/PerformanceTracing.ts +5 -17
  176. package/front_end/third_party/chromium/README.chromium +1 -1
  177. package/front_end/third_party/codemirror.next/chunk/codemirror.js +1 -1
  178. package/front_end/third_party/codemirror.next/chunk/codemirror.js.map +1 -1
  179. package/front_end/third_party/codemirror.next/package.json +2 -2
  180. package/front_end/third_party/codemirror.next/rebuild.sh +4 -1
  181. package/front_end/ui/comments/CommentAnchorResolver.ts +430 -35
  182. package/front_end/ui/comments/CommentOverlayManager.ts +635 -0
  183. package/front_end/ui/comments/CommentsOverlayWidget.ts +134 -0
  184. package/front_end/ui/comments/comments.ts +4 -0
  185. package/front_end/ui/comments/commentsOverlay.css +49 -0
  186. package/front_end/{panels/common → ui/components/dialogs}/FreDialog.ts +6 -6
  187. package/front_end/ui/components/dialogs/TypeToAllowDialog.ts +96 -0
  188. package/front_end/ui/components/dialogs/dialogs.ts +4 -0
  189. package/front_end/ui/components/settings/SettingCheckbox.ts +3 -3
  190. package/front_end/{panels/common → ui/components/text_editor}/AiCodeCompletionDisclaimer.ts +13 -13
  191. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +7 -6
  192. package/front_end/{panels/common → ui/components/text_editor}/AiCodeCompletionTeaser.ts +43 -46
  193. package/front_end/ui/components/text_editor/AiCodeGenerationProvider.ts +22 -26
  194. package/front_end/{panels/common → ui/components/text_editor}/AiCodeGenerationTeaser.ts +10 -10
  195. package/front_end/{panels/common → ui/components/text_editor}/AiCodeGenerationUpgradeDialog.ts +5 -5
  196. package/front_end/ui/components/text_editor/text_editor.ts +4 -0
  197. package/front_end/ui/legacy/Toolbar.ts +1 -1
  198. package/front_end/ui/legacy/UIUtils.ts +0 -56
  199. package/front_end/ui/legacy/View.ts +10 -4
  200. package/front_end/ui/legacy/Widget.ts +10 -1
  201. package/front_end/ui/legacy/components/color_picker/ContrastDetails.ts +2 -1
  202. package/front_end/ui/legacy/components/color_picker/ContrastOverlay.ts +5 -4
  203. package/front_end/ui/legacy/components/object_ui/CustomPreviewComponent.ts +11 -3
  204. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +507 -209
  205. package/front_end/ui/legacy/components/object_ui/objectPropertiesSection.css +5 -0
  206. package/front_end/ui/legacy/components/quick_open/CommandMenu.ts +11 -16
  207. package/front_end/ui/legacy/components/settings_ui/SettingsUI.ts +5 -12
  208. package/front_end/ui/legacy/components/source_frame/BinaryResourceViewFactory.ts +38 -20
  209. package/front_end/ui/legacy/components/source_frame/JSONView.ts +12 -2
  210. package/front_end/ui/legacy/components/source_frame/ResourceSourceFrame.ts +3 -3
  211. package/front_end/ui/legacy/components/source_frame/SourceFrame.ts +37 -6
  212. package/front_end/ui/legacy/components/source_frame/StreamingContentHexView.ts +22 -4
  213. package/front_end/ui/settings/SettingUIRegistration.ts +55 -6
  214. package/front_end/ui/visual_logging/KnownContextValues.ts +3 -0
  215. package/mcp/mcp.ts +6 -1
  216. package/package.json +6 -6
  217. package/front_end/Images/toolbarResizerVertical.png +0 -0
  218. package/front_end/emulated_devices/MotoG4-landscape.svg +0 -155
  219. package/front_end/emulated_devices/MotoG4-portrait.svg +0 -155
  220. package/front_end/emulated_devices/Nexus5X-landscape.svg +0 -19
  221. package/front_end/emulated_devices/Nexus5X-portrait.svg +0 -19
  222. package/front_end/emulated_devices/Nexus6P-landscape.svg +0 -50
  223. package/front_end/emulated_devices/Nexus6P-portrait.svg +0 -54
  224. package/front_end/emulated_devices/google-nest-hub-horizontal.png +0 -0
  225. package/front_end/emulated_devices/google-nest-hub-max-horizontal.png +0 -0
  226. package/front_end/emulated_devices/google-nexus-5-horizontal-default-1x.png +0 -0
  227. package/front_end/emulated_devices/google-nexus-5-horizontal-default-2x.png +0 -0
  228. package/front_end/emulated_devices/google-nexus-5-horizontal-keyboard-1x.png +0 -0
  229. package/front_end/emulated_devices/google-nexus-5-horizontal-keyboard-2x.png +0 -0
  230. package/front_end/emulated_devices/google-nexus-5-horizontal-navigation-1x.png +0 -0
  231. package/front_end/emulated_devices/google-nexus-5-horizontal-navigation-2x.png +0 -0
  232. package/front_end/emulated_devices/google-nexus-5-vertical-default-1x.png +0 -0
  233. package/front_end/emulated_devices/google-nexus-5-vertical-default-2x.png +0 -0
  234. package/front_end/emulated_devices/google-nexus-5-vertical-keyboard-1x.png +0 -0
  235. package/front_end/emulated_devices/google-nexus-5-vertical-keyboard-2x.png +0 -0
  236. package/front_end/emulated_devices/google-nexus-5-vertical-navigation-1x.png +0 -0
  237. package/front_end/emulated_devices/google-nexus-5-vertical-navigation-2x.png +0 -0
  238. package/front_end/emulated_devices/google-nexus-5x-horizontal-default-1x.png +0 -0
  239. package/front_end/emulated_devices/google-nexus-5x-horizontal-default-2x.png +0 -0
  240. package/front_end/emulated_devices/google-nexus-5x-horizontal-keyboard-1x.png +0 -0
  241. package/front_end/emulated_devices/google-nexus-5x-horizontal-keyboard-2x.png +0 -0
  242. package/front_end/emulated_devices/google-nexus-5x-horizontal-navigation-1x.png +0 -0
  243. package/front_end/emulated_devices/google-nexus-5x-horizontal-navigation-2x.png +0 -0
  244. package/front_end/emulated_devices/google-nexus-5x-vertical-default-1x.png +0 -0
  245. package/front_end/emulated_devices/google-nexus-5x-vertical-default-2x.png +0 -0
  246. package/front_end/emulated_devices/google-nexus-5x-vertical-keyboard-1x.png +0 -0
  247. package/front_end/emulated_devices/google-nexus-5x-vertical-keyboard-2x.png +0 -0
  248. package/front_end/emulated_devices/google-nexus-5x-vertical-navigation-1x.png +0 -0
  249. package/front_end/emulated_devices/google-nexus-5x-vertical-navigation-2x.png +0 -0
  250. package/front_end/emulated_devices/iPad-landscape.svg +0 -73
  251. package/front_end/emulated_devices/iPad-portrait.svg +0 -76
  252. package/front_end/emulated_devices/iPhone5-landscape.svg +0 -99
  253. package/front_end/emulated_devices/iPhone5-portrait.svg +0 -83
  254. package/front_end/emulated_devices/iPhone6-landscape.svg +0 -111
  255. package/front_end/emulated_devices/iPhone6-portrait.svg +0 -116
  256. package/front_end/emulated_devices/iPhone6Plus-landscape.svg +0 -118
  257. package/front_end/emulated_devices/iPhone6Plus-portrait.svg +0 -116
  258. package/front_end/emulated_devices/optimized/MotoG4-landscape.avif +0 -0
  259. package/front_end/emulated_devices/optimized/MotoG4-portrait.avif +0 -0
  260. package/front_end/emulated_devices/optimized/Nexus5X-landscape.avif +0 -0
  261. package/front_end/emulated_devices/optimized/Nexus5X-portrait.avif +0 -0
  262. package/front_end/emulated_devices/optimized/Nexus6P-landscape.avif +0 -0
  263. package/front_end/emulated_devices/optimized/Nexus6P-portrait.avif +0 -0
  264. package/front_end/emulated_devices/optimized/README.md +0 -9
  265. package/front_end/emulated_devices/optimized/google-nest-hub-horizontal.avif +0 -0
  266. package/front_end/emulated_devices/optimized/google-nest-hub-max-horizontal.avif +0 -0
  267. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-default-1x.avif +0 -0
  268. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-default-2x.avif +0 -0
  269. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-keyboard-1x.avif +0 -0
  270. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-keyboard-2x.avif +0 -0
  271. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-navigation-1x.avif +0 -0
  272. package/front_end/emulated_devices/optimized/google-nexus-5-horizontal-navigation-2x.avif +0 -0
  273. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-default-1x.avif +0 -0
  274. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-default-2x.avif +0 -0
  275. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-keyboard-1x.avif +0 -0
  276. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-keyboard-2x.avif +0 -0
  277. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-navigation-1x.avif +0 -0
  278. package/front_end/emulated_devices/optimized/google-nexus-5-vertical-navigation-2x.avif +0 -0
  279. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-default-1x.avif +0 -0
  280. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-default-2x.avif +0 -0
  281. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-keyboard-1x.avif +0 -0
  282. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-keyboard-2x.avif +0 -0
  283. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-navigation-1x.avif +0 -0
  284. package/front_end/emulated_devices/optimized/google-nexus-5x-horizontal-navigation-2x.avif +0 -0
  285. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-default-1x.avif +0 -0
  286. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-default-2x.avif +0 -0
  287. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-keyboard-1x.avif +0 -0
  288. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-keyboard-2x.avif +0 -0
  289. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-navigation-1x.avif +0 -0
  290. package/front_end/emulated_devices/optimized/google-nexus-5x-vertical-navigation-2x.avif +0 -0
  291. package/front_end/emulated_devices/optimized/iPad-landscape.avif +0 -0
  292. package/front_end/emulated_devices/optimized/iPad-portrait.avif +0 -0
  293. package/front_end/emulated_devices/optimized/iPhone5-landscape.avif +0 -0
  294. package/front_end/emulated_devices/optimized/iPhone5-portrait.avif +0 -0
  295. package/front_end/emulated_devices/optimized/iPhone6-landscape.avif +0 -0
  296. package/front_end/emulated_devices/optimized/iPhone6-portrait.avif +0 -0
  297. package/front_end/emulated_devices/optimized/iPhone6Plus-landscape.avif +0 -0
  298. package/front_end/emulated_devices/optimized/iPhone6Plus-portrait.avif +0 -0
  299. package/front_end/emulated_devices/optimized/optimized_images.gni +0 -53
  300. package/front_end/models/ai_assistance/agents/README.md +0 -136
  301. package/front_end/panels/elements/ElementsTreeOutlineRenderer.ts +0 -89
  302. package/front_end/ui/legacy/components/object_ui/object_ui-meta.ts +0 -27
  303. /package/front_end/{panels/common → ui/components/dialogs}/freDialog.css +0 -0
  304. /package/front_end/{panels/common/common.css → ui/components/dialogs/typeToAllowDialog.css} +0 -0
  305. /package/front_end/{panels/common → ui/components/text_editor}/aiCodeCompletionDisclaimer.css +0 -0
  306. /package/front_end/{panels/common → ui/components/text_editor}/aiCodeCompletionTeaser.css +0 -0
  307. /package/front_end/{panels/common → ui/components/text_editor}/aiCodeGenerationTeaser.css +0 -0
  308. /package/front_end/{panels/common → ui/components/text_editor}/aiCodeGenerationUpgradeDialog.css +0 -0
@@ -0,0 +1,100 @@
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 {
6
+ ConversationContext,
7
+ type ConversationSuggestions,
8
+ } from '../agents/AiAgent.js';
9
+ import {CookieItem, DOMStorageItem, type StorageItem} from '../StorageItem.js';
10
+
11
+ export class StorageContext extends ConversationContext<StorageItem> {
12
+ #item: StorageItem;
13
+
14
+ constructor(item: StorageItem) {
15
+ super();
16
+ this.#item = item;
17
+ }
18
+
19
+ override getURL(): string {
20
+ return this.#item.primaryTargetOrigin;
21
+ }
22
+
23
+ override getItem(): StorageItem {
24
+ return this.#item;
25
+ }
26
+
27
+ override getTitle(): string {
28
+ if (this.#item instanceof CookieItem) {
29
+ if (this.#item.name) {
30
+ return `cookie: ${this.#item.name}${this.#item.origin ? ` ${this.#item.origin}` : ''}`;
31
+ }
32
+ return `cookies${this.#item.isGenericContext ? '' : `: ${this.#item.origin}`}`;
33
+ }
34
+ if (this.#item instanceof DOMStorageItem) {
35
+ if (this.#item.key) {
36
+ return `entry: ${this.#item.key}${this.#item.origin ? ` ${this.#item.origin}` : ''}`;
37
+ }
38
+ const prefix = this.#item.type === 'localStorage' ? 'local storage' : 'session storage';
39
+ return `${prefix}${this.#item.isGenericContext ? '' : `: ${this.#item.origin}`}`;
40
+ }
41
+ return `Storage: ${this.getOrigin()}`;
42
+ }
43
+
44
+ /**
45
+ * @override
46
+ */
47
+ override isLoggingEnabled(): boolean {
48
+ if (this.#item instanceof CookieItem && Boolean(this.#item.name)) {
49
+ return false;
50
+ }
51
+ if (this.#item instanceof DOMStorageItem && Boolean(this.#item.key)) {
52
+ return false;
53
+ }
54
+ return true;
55
+ }
56
+
57
+ override async getSuggestions(): Promise<ConversationSuggestions|undefined> {
58
+ if (this.#item instanceof CookieItem) {
59
+ if (this.#item.name) {
60
+ return [
61
+ {
62
+ title: 'Why is this cookie set?',
63
+ jslogContext: 'storage-cookie',
64
+ },
65
+ {
66
+ title: 'Explain the value of this cookie',
67
+ jslogContext: 'storage-cookie',
68
+ },
69
+ ];
70
+ }
71
+ return [
72
+ {
73
+ title: 'Explain the cookies set by this page',
74
+ jslogContext: 'storage-cookie',
75
+ },
76
+ ];
77
+ }
78
+ if (this.#item instanceof DOMStorageItem) {
79
+ if (this.#item.key) {
80
+ return [
81
+ {
82
+ title: 'What is the purpose of this storage entry?',
83
+ jslogContext: 'storage-domstorage',
84
+ },
85
+ {
86
+ title: 'Explain the value of this storage entry',
87
+ jslogContext: 'storage-domstorage',
88
+ },
89
+ ];
90
+ }
91
+ return [
92
+ {
93
+ title: 'Explain these storage items',
94
+ jslogContext: 'storage-domstorage',
95
+ },
96
+ ];
97
+ }
98
+ return undefined;
99
+ }
100
+ }
@@ -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
  };
@@ -6,6 +6,8 @@ allowed-tools:
6
6
  - resolveDevtoolsNodePath
7
7
  - getStyles
8
8
  - getElementAccessibilityDetails
9
+ - runLighthouse
10
+ - executeJavaScript
9
11
  ---
10
12
  You are an expert accessibility debugging assistant.
11
13
  Use getLighthouseAudits to query details from the active report.
@@ -13,3 +15,8 @@ Use getLighthouseAudits to query details from the active report.
13
15
  * ALWAYS use resolveDevtoolsNodePath to resolve failing element paths to backend node IDs.
14
16
  * Once resolved, use getStyles on the backend node ID to inspect layout and styling properties.
15
17
  * Use getElementAccessibilityDetails to query detailed accessibility properties (ARIA properties, role, name, focus state) for a resolved element backend node ID.
18
+ * If the user explicitly specifies a Lighthouse mode (e.g. "snapshot", "timespan", or "navigation"), ALWAYS honor the requested mode.
19
+ * When running an initial audit (and no specific mode was requested), use runLighthouse with mode "navigation" for comprehensive page load coverage.
20
+ * When re-auditing after in-page DOM/CSS modifications or fixes, use mode "snapshot" to evaluate live page state without reloading (noting that fewer audits run in snapshot mode).
21
+ * Use mode "timespan" for measuring user interaction periods.
22
+ * Use executeJavaScript to run layout/interaction scripts to verify fixes or dynamic accessibility behaviors.
@@ -3,8 +3,22 @@ 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
10
+ - getDetailedCallTree
11
+ - getFunctionCode
12
+ - getResourceContent
6
13
  ---
7
14
  You are an expert web performance assistant integrated into Chrome DevTools.
8
15
  Your goal is to help users analyze, measure, and improve web page performance.
9
16
 
10
- Use `recordPerformanceTrace` to record a new performance trace when requested by the user or when live measurement is required.
17
+ - Use `recordPerformanceTrace` to record a new performance trace when requested by the user or when live measurement is required.
18
+ - Trace events in the provided insights or summaries may have an `eventKey`. Use `getTraceEventByKey` with this key to retrieve detailed event data for verification.
19
+ - If the user asks to see, locate, or show a specific event, use `selectTraceEventByKey` to reveal and select it in the Flamechart.
20
+ - Use `getTraceMainThreadSummary` with a section label to get a bottom-up activity summary of the main thread for a specific labeled period.
21
+ - Use `getTraceNetworkSummary` to get a summary of network requests within a specific microsecond time range.
22
+ - Use `getDetailedCallTree` with an `eventKey` to retrieve the detailed call tree for a specific main thread trace event.
23
+ - Use `getFunctionCode` with a script URL, line, and column to view annotated runtime performance of a function.
24
+ - Use `getResourceContent` with a resource URL to inspect text resource or script contents for further root-cause analysis.
@@ -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,107 @@
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 * as Trace from '../../trace/trace.js';
8
+ import {PerformanceTraceContext} from '../contexts/PerformanceTraceContext.js';
9
+ import {AICallTree} from '../performance/AICallTree.js';
10
+
11
+ import {
12
+ type BaseToolCapability,
13
+ type DataHandlerResult,
14
+ type DataTool,
15
+ type ToolArgs,
16
+ ToolName,
17
+ } from './Tool.js';
18
+
19
+ const UIStringsNotTranslate = {
20
+ lookingAtCallTree: 'Looking at call tree',
21
+ } as const;
22
+
23
+ const lockedString = i18n.i18n.lockedString;
24
+
25
+ export interface GetDetailedCallTreeArgs extends ToolArgs {
26
+ eventKey: string;
27
+ }
28
+
29
+ export class GetDetailedCallTreeTool implements DataTool<GetDetailedCallTreeArgs, string, BaseToolCapability> {
30
+ readonly name = ToolName.GET_DETAILED_CALL_TREE;
31
+ readonly description = 'Returns a detailed call tree for the given main thread event.';
32
+
33
+ readonly parameters: Host.AidaClient.FunctionObjectParam<keyof GetDetailedCallTreeArgs> = {
34
+ type: Host.AidaClient.ParametersTypes.OBJECT,
35
+ description: 'Arguments for looking up a call tree.',
36
+ nullable: false,
37
+ properties: {
38
+ eventKey: {
39
+ type: Host.AidaClient.ParametersTypes.STRING,
40
+ description: 'The key for the event.',
41
+ nullable: false,
42
+ },
43
+ },
44
+ required: ['eventKey'],
45
+ };
46
+
47
+ displayInfoFromArgs(params: GetDetailedCallTreeArgs): {
48
+ title: string,
49
+ action: string,
50
+ } {
51
+ return {
52
+ title: lockedString(UIStringsNotTranslate.lookingAtCallTree),
53
+ action: `getDetailedCallTree('${params.eventKey}')`,
54
+ };
55
+ }
56
+
57
+ async handler(
58
+ params: GetDetailedCallTreeArgs,
59
+ capabilities: BaseToolCapability,
60
+ ): Promise<DataHandlerResult<string>> {
61
+ const conversationContext = capabilities.conversationContext;
62
+ if (!conversationContext || !(conversationContext instanceof PerformanceTraceContext)) {
63
+ return {error: 'Performance trace context is not available.'};
64
+ }
65
+
66
+ if (!params.eventKey) {
67
+ return {error: 'Missing arg: eventKey'};
68
+ }
69
+
70
+ const focus = conversationContext.getItem();
71
+ const event = focus.lookupEvent(params.eventKey);
72
+ if (!event) {
73
+ return {error: 'Invalid eventKey'};
74
+ }
75
+
76
+ const tree = AICallTree.fromEvent(event, focus.parsedTrace);
77
+ if (!tree) {
78
+ return {error: 'No call tree found'};
79
+ }
80
+
81
+ const formatter = conversationContext.createFormatter();
82
+ const callTree = await formatter.formatCallTree(tree);
83
+
84
+ const bounds = Trace.Helpers.Timing.traceWindowFromEvent(event);
85
+
86
+ return {
87
+ result: callTree,
88
+ widgets: [
89
+ {
90
+ name: 'BOTTOM_UP_TREE',
91
+ data: {
92
+ bounds,
93
+ parsedTrace: focus.parsedTrace,
94
+ },
95
+ },
96
+ {
97
+ name: 'TIMELINE_RANGE_SUMMARY',
98
+ data: {
99
+ bounds,
100
+ parsedTrace: focus.parsedTrace,
101
+ track: 'main',
102
+ },
103
+ },
104
+ ],
105
+ };
106
+ }
107
+ }
@@ -0,0 +1,122 @@
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 type * as Platform from '../../../core/platform/platform.js';
8
+ import {canResourceContentsBeReadForTrace} from '../AiOrigins.js';
9
+ import {PerformanceTraceContext} from '../contexts/PerformanceTraceContext.js';
10
+
11
+ import {
12
+ type BaseToolCapability,
13
+ type DataHandlerResult,
14
+ type DataTool,
15
+ type ToolArgs,
16
+ ToolName,
17
+ } from './Tool.js';
18
+
19
+ const UIStringsNotTranslate = {
20
+ lookingUpFunctionCode: 'Looking up function code',
21
+ } as const;
22
+
23
+ const lockedString = i18n.i18n.lockedString;
24
+
25
+ export interface GetFunctionCodeArgs extends ToolArgs {
26
+ scriptUrl: string;
27
+ line: number;
28
+ column: number;
29
+ }
30
+
31
+ export class GetFunctionCodeTool implements DataTool<GetFunctionCodeArgs, string, BaseToolCapability> {
32
+ readonly name = ToolName.GET_FUNCTION_CODE;
33
+ readonly description =
34
+ 'Returns the code for a function defined at the given location. The result is annotated with the runtime performance of each line of code.';
35
+
36
+ readonly parameters: Host.AidaClient.FunctionObjectParam<keyof GetFunctionCodeArgs> = {
37
+ type: Host.AidaClient.ParametersTypes.OBJECT,
38
+ description: 'Arguments for looking up function code.',
39
+ nullable: false,
40
+ properties: {
41
+ scriptUrl: {
42
+ type: Host.AidaClient.ParametersTypes.STRING,
43
+ description: 'The url of the function.',
44
+ nullable: false,
45
+ },
46
+ line: {
47
+ type: Host.AidaClient.ParametersTypes.INTEGER,
48
+ description: 'The line number where the function is defined.',
49
+ nullable: false,
50
+ },
51
+ column: {
52
+ type: Host.AidaClient.ParametersTypes.INTEGER,
53
+ description: 'The column number where the function is defined.',
54
+ nullable: false,
55
+ },
56
+ },
57
+ required: ['scriptUrl', 'line', 'column'],
58
+ };
59
+
60
+ displayInfoFromArgs(params: GetFunctionCodeArgs): {
61
+ title: string,
62
+ action: string,
63
+ } {
64
+ return {
65
+ title: lockedString(UIStringsNotTranslate.lookingUpFunctionCode),
66
+ action: `getFunctionCode('${params.scriptUrl}', ${params.line}, ${params.column})`,
67
+ };
68
+ }
69
+
70
+ async handler(
71
+ params: GetFunctionCodeArgs,
72
+ capabilities: BaseToolCapability,
73
+ ): Promise<DataHandlerResult<string>> {
74
+ const conversationContext = capabilities.conversationContext;
75
+ if (!conversationContext || !(conversationContext instanceof PerformanceTraceContext)) {
76
+ return {error: 'Performance trace context is not available.'};
77
+ }
78
+
79
+ if (conversationContext.getOrigin().startsWith('imported-trace://')) {
80
+ return {error: 'Cannot use this tool on an imported file.'};
81
+ }
82
+
83
+ if (!params.scriptUrl) {
84
+ return {error: 'Missing arg: scriptUrl'};
85
+ }
86
+
87
+ const allowedOrigin = conversationContext.getOrigin();
88
+ if (!canResourceContentsBeReadForTrace(params.scriptUrl, allowedOrigin)) {
89
+ return {error: 'Script not found'};
90
+ }
91
+
92
+ if (params.line === undefined) {
93
+ return {error: 'Missing arg: line'};
94
+ }
95
+
96
+ if (params.column === undefined) {
97
+ return {error: 'Missing arg: column'};
98
+ }
99
+
100
+ const formatter = conversationContext.createFormatter();
101
+ const url = params.scriptUrl as Platform.DevToolsPath.UrlString;
102
+ const code = await formatter.resolveFunctionCodeAtLocation(url, params.line, params.column);
103
+ if (!code) {
104
+ return {error: 'Could not find code'};
105
+ }
106
+
107
+ const result = formatter.formatFunctionCode(code);
108
+
109
+ return {
110
+ result,
111
+ widgets: [{
112
+ name: 'SOURCE_CODE',
113
+ data: {
114
+ url,
115
+ line: params.line,
116
+ column: params.column,
117
+ code: code.code,
118
+ },
119
+ }],
120
+ };
121
+ }
122
+ }