chrome-devtools-frontend 1.0.1616061 → 1.0.1621064

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 (318) hide show
  1. package/AUTHORS +1 -0
  2. package/docs/checklist/README.md +8 -7
  3. package/eslint.config.mjs +7 -0
  4. package/front_end/core/common/Object.ts +11 -2
  5. package/front_end/core/dom_extension/DOMExtension.ts +11 -8
  6. package/front_end/core/host/AidaClient.ts +8 -0
  7. package/front_end/core/host/AidaGcaTranslation.ts +1 -0
  8. package/front_end/core/host/UserMetrics.ts +0 -1
  9. package/front_end/core/platform/api/HostRuntime.ts +2 -2
  10. package/front_end/core/platform/browser/HostRuntime.ts +4 -2
  11. package/front_end/core/platform/node/HostRuntime.ts +2 -2
  12. package/front_end/core/root/ExperimentNames.ts +0 -1
  13. package/front_end/core/sdk/NetworkManager.ts +30 -4
  14. package/front_end/core/sdk/NetworkRequest.ts +2 -10
  15. package/front_end/core/sdk/Resource.ts +2 -1
  16. package/front_end/core/sdk/ServerSentEventsProtocol.ts +1 -1
  17. package/front_end/core/sdk/TraceObject.ts +7 -2
  18. package/front_end/entrypoint_template.html +1 -2
  19. package/front_end/entrypoints/greendev_floaty/FloatyEntrypoint.ts +119 -15
  20. package/front_end/entrypoints/greendev_floaty/greendev_floaty.ts +0 -2
  21. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +43 -33
  22. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts +2 -1
  23. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotWorkerDispatcher.ts +9 -6
  24. package/front_end/entrypoints/main/MainImpl.ts +0 -2
  25. package/front_end/generated/InspectorBackendCommands.ts +8 -7
  26. package/front_end/generated/SupportedCSSProperties.js +119 -100
  27. package/front_end/generated/protocol-mapping.d.ts +1 -9
  28. package/front_end/generated/protocol-proxy-api.d.ts +1 -9
  29. package/front_end/generated/protocol.ts +24 -1
  30. package/front_end/legacy/legacy-defs.d.ts +1 -1
  31. package/front_end/models/ai_assistance/AiConversation.ts +1 -0
  32. package/front_end/models/ai_assistance/AiHistoryStorage.ts +39 -0
  33. package/front_end/models/ai_assistance/agents/AiAgent.ts +2 -0
  34. package/front_end/models/ai_assistance/agents/ConversationSummaryAgent.ts +28 -16
  35. package/front_end/models/ai_assistance/agents/GreenDevAgent.ts +512 -0
  36. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +112 -145
  37. package/front_end/models/ai_assistance/agents/README.md +0 -5
  38. package/front_end/models/ai_assistance/agents/StylingAgent.ts +9 -16
  39. package/front_end/models/ai_assistance/ai_assistance.ts +2 -0
  40. package/front_end/models/ai_code_completion/AiCodeCompletion.ts +19 -1
  41. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +48 -13
  42. package/front_end/models/bindings/SymbolizedError.ts +95 -8
  43. package/front_end/models/emulation/DeviceModeModel.ts +42 -13
  44. package/front_end/models/emulation/EmulatedDevices.ts +1 -1
  45. package/front_end/models/issues_manager/IssuesManager.ts +13 -6
  46. package/front_end/models/issues_manager/IssuesManagerEvents.ts +1 -0
  47. package/front_end/models/javascript_metadata/NativeFunctions.js +2 -2
  48. package/front_end/models/live-metrics/web-vitals-injected/web-vitals-injected.ts +1 -0
  49. package/front_end/models/stack_trace/DetailedErrorStackParser.ts +49 -10
  50. package/front_end/models/stack_trace/ErrorStackParser.ts +18 -0
  51. package/front_end/models/stack_trace/StackTraceModel.ts +5 -1
  52. package/front_end/models/text_utils/ContentData.ts +71 -10
  53. package/front_end/models/trace/types/File.ts +8 -1
  54. package/front_end/models/web_mcp/WebMCPModel.ts +22 -0
  55. package/front_end/models/workspace/UISourceCode.ts +4 -4
  56. package/front_end/panels/accessibility/ARIAAttributesView.ts +4 -4
  57. package/front_end/panels/accessibility/AccessibilitySubPane.ts +3 -2
  58. package/front_end/panels/accessibility/SourceOrderView.ts +4 -4
  59. package/front_end/panels/ai_assistance/ai_assistance.ts +1 -0
  60. package/front_end/panels/ai_assistance/components/ChatInput.ts +66 -0
  61. package/front_end/panels/ai_assistance/components/ChatMessage.ts +144 -21
  62. package/front_end/panels/ai_assistance/components/ChatView.ts +43 -8
  63. package/front_end/panels/ai_assistance/components/ExportForAgentsDialog.ts +1 -0
  64. package/front_end/panels/ai_assistance/components/WalkthroughUtils.ts +74 -0
  65. package/front_end/panels/ai_assistance/components/WalkthroughView.ts +34 -5
  66. package/front_end/panels/ai_assistance/components/chatMessage.css +11 -0
  67. package/front_end/panels/ai_assistance/components/walkthroughView.css +7 -0
  68. package/front_end/panels/application/ApplicationPanelTreeElement.ts +1 -1
  69. package/front_end/panels/application/CookieItemsView.ts +8 -9
  70. package/front_end/panels/application/DOMStorageItemsView.ts +3 -3
  71. package/front_end/panels/application/DeviceBoundSessionsModel.ts +7 -0
  72. package/front_end/panels/application/DeviceBoundSessionsTreeElement.ts +21 -0
  73. package/front_end/panels/application/DeviceBoundSessionsView.ts +2 -2
  74. package/front_end/panels/application/ExtensionStorageItemsView.ts +1 -1
  75. package/front_end/panels/application/KeyValueStorageItemsView.ts +32 -14
  76. package/front_end/panels/application/ResourcesPanel.ts +5 -5
  77. package/front_end/panels/application/StorageItemsToolbar.ts +0 -19
  78. package/front_end/panels/application/WebMCPView.ts +285 -86
  79. package/front_end/panels/application/components/BounceTrackingMitigationsView.ts +4 -4
  80. package/front_end/panels/application/preloading/components/MismatchedPreloadingGrid.ts +4 -4
  81. package/front_end/panels/application/webMCPView.css +261 -182
  82. package/front_end/panels/browser_debugger/CategorizedBreakpointsSidebarPane.ts +9 -5
  83. package/front_end/panels/changes/ChangesSidebar.ts +2 -2
  84. package/front_end/panels/changes/ChangesView.ts +9 -14
  85. package/front_end/panels/console/ConsolePanel.ts +10 -3
  86. package/front_end/panels/console/ConsoleSidebar.ts +5 -5
  87. package/front_end/panels/console/ConsoleView.ts +11 -4
  88. package/front_end/panels/console/ConsoleViewMessage.ts +1 -19
  89. package/front_end/panels/coverage/CoverageView.ts +4 -5
  90. package/front_end/panels/elements/ElementsPanel.ts +9 -12
  91. package/front_end/panels/elements/ElementsSidebarPane.ts +4 -5
  92. package/front_end/panels/elements/ElementsTreeElement.ts +61 -0
  93. package/front_end/panels/elements/ElementsTreeOutline.ts +46 -0
  94. package/front_end/panels/elements/LayersWidget.ts +2 -2
  95. package/front_end/panels/elements/MetricsSidebarPane.ts +5 -4
  96. package/front_end/panels/elements/StylePropertiesSection.ts +1 -1
  97. package/front_end/panels/elements/StylePropertyTreeElement.ts +11 -6
  98. package/front_end/panels/elements/StylesSidebarPane.ts +4 -1
  99. package/front_end/panels/elements/components/ElementsBreadcrumbs.ts +19 -20
  100. package/front_end/panels/elements/components/ElementsBreadcrumbsUtils.ts +29 -29
  101. package/front_end/panels/elements/components/QueryContainer.ts +5 -6
  102. package/front_end/panels/elements/components/components.ts +0 -2
  103. package/front_end/panels/emulation/MediaQueryInspector.ts +4 -7
  104. package/front_end/panels/layer_viewer/LayerDetailsView.ts +4 -7
  105. package/front_end/panels/layer_viewer/Layers3DView.ts +2 -2
  106. package/front_end/panels/lighthouse/LighthouseStartView.ts +2 -2
  107. package/front_end/panels/mobile_throttling/NetworkThrottlingSelector.ts +47 -66
  108. package/front_end/panels/network/NetworkConfigView.ts +11 -11
  109. package/front_end/panels/network/RequestConditionsDrawer.ts +6 -4
  110. package/front_end/panels/network/RequestCookiesView.ts +2 -2
  111. package/front_end/panels/network/RequestDeviceBoundSessionsView.ts +2 -2
  112. package/front_end/panels/network/RequestHeadersView.ts +2 -2
  113. package/front_end/panels/network/components/DirectSocketConnectionView.ts +4 -5
  114. package/front_end/panels/performance_monitor/PerformanceMonitor.ts +6 -9
  115. package/front_end/panels/profiler/HeapProfileView.ts +29 -4
  116. package/front_end/panels/profiler/ProfilesPanel.ts +1 -1
  117. package/front_end/panels/protocol_monitor/JSONEditor.css +8 -1
  118. package/front_end/panels/protocol_monitor/JSONEditor.ts +7 -2
  119. package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +6 -4
  120. package/front_end/panels/recorder/components/ControlButton.ts +4 -4
  121. package/front_end/panels/recorder/components/StepView.ts +6 -6
  122. package/front_end/panels/search/SearchView.ts +4 -7
  123. package/front_end/panels/sources/DebuggerPausedMessage.ts +18 -22
  124. package/front_end/panels/sources/SourcesView.ts +1 -1
  125. package/front_end/panels/sources/TabbedEditorContainer.ts +2 -2
  126. package/front_end/panels/sources/ThreadsSidebarPane.ts +2 -4
  127. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +24 -20
  128. package/front_end/panels/timeline/StatusDialog.ts +5 -8
  129. package/front_end/panels/timeline/ThirdPartyTreeView.ts +10 -0
  130. package/front_end/panels/timeline/TimelineLoader.ts +3 -4
  131. package/front_end/panels/timeline/TimelineSelectorStatsView.ts +2 -2
  132. package/front_end/panels/timeline/components/TimelineRangeSummaryView.ts +2 -0
  133. package/front_end/panels/timeline/components/TimelineSummary.ts +9 -1
  134. package/front_end/panels/timeline/components/timelineSummary.css +4 -0
  135. package/front_end/panels/timeline/overlays/components/TimespanBreakdownOverlay.ts +2 -2
  136. package/front_end/panels/timeline/thirdPartyTreeView.css +8 -1
  137. package/front_end/panels/web_audio/WebAudioView.ts +5 -4
  138. package/front_end/panels/whats_new/ReleaseNoteText.ts +9 -9
  139. package/front_end/panels/whats_new/resources/WNDT.md +9 -6
  140. package/front_end/third_party/chromium/README.chromium +1 -1
  141. package/front_end/third_party/puppeteer/README.chromium +2 -2
  142. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/ElementHandle.d.ts +41 -2
  143. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/ElementHandle.d.ts.map +1 -1
  144. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/ElementHandle.js.map +1 -1
  145. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Extension.d.ts +13 -1
  146. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Extension.d.ts.map +1 -1
  147. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Extension.js +21 -1
  148. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/api/Extension.js.map +1 -1
  149. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/ElementHandle.d.ts.map +1 -1
  150. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/ElementHandle.js +1 -0
  151. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/bidi/ElementHandle.js.map +1 -1
  152. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts +2 -2
  153. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.d.ts.map +1 -1
  154. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js +5 -5
  155. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Browser.js.map +1 -1
  156. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserConnector.d.ts.map +1 -1
  157. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserConnector.js +2 -2
  158. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/BrowserConnector.js.map +1 -1
  159. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/ElementHandle.d.ts.map +1 -1
  160. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/ElementHandle.js +1 -0
  161. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/ElementHandle.js.map +1 -1
  162. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Extension.d.ts +1 -1
  163. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Extension.d.ts.map +1 -1
  164. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Extension.js +2 -2
  165. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/Extension.js.map +1 -1
  166. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.d.ts +1 -1
  167. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.d.ts.map +1 -1
  168. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.js +52 -1
  169. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.js.map +1 -1
  170. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebMCP.d.ts.map +1 -1
  171. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/WebMCP.js.map +1 -1
  172. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConnectOptions.d.ts +25 -0
  173. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/common/ConnectOptions.d.ts.map +1 -1
  174. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
  175. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
  176. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.js +2 -2
  177. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/BrowserLauncher.js.map +1 -1
  178. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  179. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js +0 -1
  180. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/node/ChromeLauncher.js.map +1 -1
  181. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +2 -2
  182. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +2 -2
  183. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
  184. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  185. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  186. package/front_end/third_party/puppeteer/package/lib/cjs/third_party/urlpattern-polyfill/urlpattern-polyfill.d.ts +1 -0
  187. package/front_end/third_party/puppeteer/package/lib/cjs/third_party/urlpattern-polyfill/urlpattern-polyfill.js +853 -0
  188. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.d.ts +91 -11
  189. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +1046 -33
  190. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/ElementHandle.d.ts +41 -2
  191. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/ElementHandle.d.ts.map +1 -1
  192. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/ElementHandle.js.map +1 -1
  193. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Extension.d.ts +13 -1
  194. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Extension.d.ts.map +1 -1
  195. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Extension.js +21 -1
  196. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/api/Extension.js.map +1 -1
  197. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/ElementHandle.d.ts.map +1 -1
  198. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/ElementHandle.js +1 -0
  199. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/bidi/ElementHandle.js.map +1 -1
  200. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts +2 -2
  201. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.d.ts.map +1 -1
  202. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js +5 -5
  203. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Browser.js.map +1 -1
  204. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserConnector.d.ts.map +1 -1
  205. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserConnector.js +2 -2
  206. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/BrowserConnector.js.map +1 -1
  207. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/ElementHandle.d.ts.map +1 -1
  208. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/ElementHandle.js +1 -0
  209. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/ElementHandle.js.map +1 -1
  210. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Extension.d.ts +1 -1
  211. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Extension.d.ts.map +1 -1
  212. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Extension.js +2 -2
  213. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/Extension.js.map +1 -1
  214. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.d.ts +1 -1
  215. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.d.ts.map +1 -1
  216. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.js +52 -1
  217. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.js.map +1 -1
  218. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebMCP.d.ts.map +1 -1
  219. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/WebMCP.js.map +1 -1
  220. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConnectOptions.d.ts +25 -0
  221. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/common/ConnectOptions.d.ts.map +1 -1
  222. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/injected/injected.d.ts +1 -1
  223. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.d.ts.map +1 -1
  224. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.js +2 -2
  225. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/BrowserLauncher.js.map +1 -1
  226. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.d.ts.map +1 -1
  227. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js +0 -1
  228. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/node/ChromeLauncher.js.map +1 -1
  229. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +2 -2
  230. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +2 -2
  231. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/Mutex.d.ts +2 -2
  232. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  233. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  234. package/front_end/third_party/puppeteer/package/lib/esm/third_party/urlpattern-polyfill/urlpattern-polyfill.d.ts +1 -0
  235. package/front_end/third_party/puppeteer/package/lib/esm/third_party/urlpattern-polyfill/urlpattern-polyfill.js +805 -0
  236. package/front_end/third_party/puppeteer/package/lib/types.d.ts +91 -11
  237. package/front_end/third_party/puppeteer/package/package.json +3 -2
  238. package/front_end/third_party/puppeteer/package/src/api/ElementHandle.ts +53 -11
  239. package/front_end/third_party/puppeteer/package/src/api/Extension.ts +29 -1
  240. package/front_end/third_party/puppeteer/package/src/bidi/ElementHandle.ts +1 -0
  241. package/front_end/third_party/puppeteer/package/src/cdp/Browser.ts +6 -0
  242. package/front_end/third_party/puppeteer/package/src/cdp/BrowserConnector.ts +2 -0
  243. package/front_end/third_party/puppeteer/package/src/cdp/ElementHandle.ts +1 -0
  244. package/front_end/third_party/puppeteer/package/src/cdp/Extension.ts +9 -2
  245. package/front_end/third_party/puppeteer/package/src/cdp/TargetManager.ts +59 -0
  246. package/front_end/third_party/puppeteer/package/src/cdp/WebMCP.ts +6 -1
  247. package/front_end/third_party/puppeteer/package/src/common/ConnectOptions.ts +26 -0
  248. package/front_end/third_party/puppeteer/package/src/node/BrowserLauncher.ts +2 -0
  249. package/front_end/third_party/puppeteer/package/src/node/ChromeLauncher.ts +0 -1
  250. package/front_end/third_party/puppeteer/package/src/revisions.ts +2 -2
  251. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  252. package/front_end/third_party/puppeteer/puppeteer-tsconfig.json +2 -1
  253. package/front_end/third_party/web-vitals/README.chromium +2 -2
  254. package/front_end/third_party/web-vitals/package/README.md +21 -10
  255. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onCLS.js +2 -4
  256. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onFCP.js +1 -2
  257. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onINP.d.ts +4 -0
  258. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onINP.js +44 -39
  259. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onLCP.js +25 -19
  260. package/front_end/third_party/web-vitals/package/dist/modules/attribution/onTTFB.js +1 -2
  261. package/front_end/third_party/web-vitals/package/dist/modules/lib/doubleRAF.js +1 -1
  262. package/front_end/third_party/web-vitals/package/dist/modules/lib/getActivationStart.js +1 -2
  263. package/front_end/third_party/web-vitals/package/dist/modules/lib/getLoadState.js +16 -18
  264. package/front_end/third_party/web-vitals/package/dist/modules/lib/getVisibilityWatcher.js +2 -1
  265. package/front_end/third_party/web-vitals/package/dist/modules/lib/initMetric.d.ts +1 -1
  266. package/front_end/third_party/web-vitals/package/dist/modules/lib/observe.js +1 -1
  267. package/front_end/third_party/web-vitals/package/dist/modules/lib/polyfills/interactionCountPolyfill.d.ts +1 -1
  268. package/front_end/third_party/web-vitals/package/dist/modules/lib/polyfills/interactionCountPolyfill.js +1 -3
  269. package/front_end/third_party/web-vitals/package/dist/modules/lib/whenActivated.js +1 -1
  270. package/front_end/third_party/web-vitals/package/dist/modules/lib/whenIdleOrHidden.js +11 -7
  271. package/front_end/third_party/web-vitals/package/dist/modules/onCLS.js +1 -1
  272. package/front_end/third_party/web-vitals/package/dist/modules/types/inp.d.ts +4 -0
  273. package/front_end/third_party/web-vitals/package/dist/modules/types.d.ts +1 -2
  274. package/front_end/third_party/web-vitals/package/dist/modules/types.js +0 -1
  275. package/front_end/third_party/web-vitals/package/package.json +24 -27
  276. package/front_end/third_party/web-vitals/package/src/attribution/onCLS.ts +2 -7
  277. package/front_end/third_party/web-vitals/package/src/attribution/onFCP.ts +1 -2
  278. package/front_end/third_party/web-vitals/package/src/attribution/onINP.ts +49 -43
  279. package/front_end/third_party/web-vitals/package/src/attribution/onLCP.ts +27 -24
  280. package/front_end/third_party/web-vitals/package/src/attribution/onTTFB.ts +1 -2
  281. package/front_end/third_party/web-vitals/package/src/lib/doubleRAF.ts +1 -1
  282. package/front_end/third_party/web-vitals/package/src/lib/getActivationStart.ts +1 -2
  283. package/front_end/third_party/web-vitals/package/src/lib/getLoadState.ts +21 -20
  284. package/front_end/third_party/web-vitals/package/src/lib/getVisibilityWatcher.ts +2 -3
  285. package/front_end/third_party/web-vitals/package/src/lib/observe.ts +1 -1
  286. package/front_end/third_party/web-vitals/package/src/lib/polyfills/interactionCountPolyfill.ts +2 -4
  287. package/front_end/third_party/web-vitals/package/src/lib/whenActivated.ts +1 -1
  288. package/front_end/third_party/web-vitals/package/src/lib/whenIdleOrHidden.ts +13 -7
  289. package/front_end/third_party/web-vitals/package/src/onCLS.ts +1 -1
  290. package/front_end/third_party/web-vitals/package/src/types/inp.ts +4 -0
  291. package/front_end/third_party/web-vitals/package/src/types.ts +1 -2
  292. package/front_end/third_party/web-vitals/patches/0001-Add-onEachInteraction-to-onINP-options.patch +13 -74
  293. package/front_end/third_party/web-vitals/rebuild.sh +3 -3
  294. package/front_end/third_party/web-vitals/web-vitals-tsconfig.json +0 -1
  295. package/front_end/ui/components/icon_button/iconButton.css +1 -0
  296. package/front_end/ui/components/legacy_wrapper/LegacyWrapper.ts +6 -6
  297. package/front_end/ui/components/lists/list.css +4 -0
  298. package/front_end/ui/legacy/Dialog.ts +21 -2
  299. package/front_end/ui/legacy/SoftContextMenu.ts +3 -3
  300. package/front_end/ui/legacy/SplitWidget.ts +9 -9
  301. package/front_end/ui/legacy/TabbedPane.ts +12 -12
  302. package/front_end/ui/legacy/View.ts +24 -22
  303. package/front_end/ui/legacy/ViewManager.ts +12 -12
  304. package/front_end/ui/legacy/ViewRegistration.ts +2 -2
  305. package/front_end/ui/legacy/Widget.ts +165 -119
  306. package/front_end/ui/legacy/components/source_frame/ImageView.ts +10 -5
  307. package/front_end/ui/legacy/components/utils/JSPresentationUtils.ts +9 -6
  308. package/front_end/ui/legacy/components/utils/Linkifier.ts +37 -11
  309. package/front_end/ui/legacy/components/utils/jsUtils.css +1 -0
  310. package/front_end/ui/legacy/inspectorCommon.css +0 -6
  311. package/front_end/ui/lit/render.ts +11 -9
  312. package/front_end/ui/visual_logging/KnownContextValues.ts +36 -0
  313. package/package.json +1 -1
  314. package/front_end/Images/src/dots-circle.svg +0 -10
  315. package/front_end/panels/elements/components/Helper.ts +0 -35
  316. package/front_end/third_party/web-vitals/package/dist/modules/types/polyfills.d.ts +0 -4
  317. package/front_end/third_party/web-vitals/package/dist/modules/types/polyfills.js +0 -16
  318. package/front_end/third_party/web-vitals/package/src/types/polyfills.ts +0 -24
@@ -19,21 +19,23 @@ You are a Conversation Summarizer. Your task is to take a transcript of a conver
19
19
  - **No UIDs/Internal IDs:** Never refer to elements by internal IDs (e.g., \`uid=123\`).
20
20
  - **Standard Selectors:** Identify elements using HTML tags, classes, or IDs (e.g., \`button.submit-form\`).
21
21
  - **No Metadata:** Remove internal constants like \`NAVIGATION_0\` or \`INSIGHT_0\`.
22
- - **No Process Narration:** Do not describe internal "thinking" or API calls. Skip phrases like "The agent investigated..." or "The user then asked...". Jump straight to the findings and their technical context.
22
+ - **No Process Narration:** Do not describe internal "thinking" or API calls. Skip phrases like "The agent investigated..." or "The user then asked...". Jump straight to the final findings and their technical context. **DO NOT** use chronological or narrative language (e.g., "Initially...", "Next...", "Then...", "After that...", "An attempt to...").
23
23
  - **No Internal Function Calls:** Never mention internal DevTools function names or API calls (e.g., \`setElementStyles\`, \`executeScript\`). Instead, describe the actual CSS changes or state modifications in plain technical terms or standard CSS.
24
24
  - **Suggest, Don't Prescribe:** When summarizing code changes made during the session (e.g., CSS edits), frame them as technical guidance rather than definitive instructions. Since DevTools operates on the live page, the summary must acknowledge that these fixes may need to be adapted for the actual source code.
25
25
 
26
26
  ### Objectives
27
27
  1. **Identify Intent:** Define the core technical goal of the session.
28
- 2. **Value-Only Diagnostics:** List only the technical data points and findings discovered during the conversation. Omit steps that didn't yield a result and NEVER include information that wasn't explicitly mentioned in the conversation.
29
- 3. **Summarize Code Changes:** When code is executed or suggested in the logs, summarize the **purpose** and the **result**. Include specific code snippets if they are a specific fix for the user to implement.
30
- 4. **Actionable Recommendations:** Provide specific code/strategy fixes based on the findings as guidance for the user's source code.
28
+ 2. **Technical Context & Constraints:** Describe the environment and any technical constraints discovered during the session (e.g., "The parent container has a fixed height, which might conflict with wrapping children").
29
+ 3. **Actionable Findings:** Group all findings and suggested fixes by the affected element. For each element:
30
+ - **Diagnostics:** List technical data points discovered (e.g., current style values, layout properties).
31
+ - **Suggested Fixes:** Provide specific code snippets or strategies identified.
32
+ - **Side-Effects:** Explicitly call out potential side-effects or risks of the proposed changes discovered during the session.
31
33
 
32
34
  ### Formatting Rules
33
35
  - **Header:** Use ## [Brief Topic Title]
34
36
  - **Context:** Describe the target element/page and the core issue or technical goal being analyzed.
35
- - **Diagnostics:** A bulleted list of technical findings.
36
37
  - **Tabular Data:** Use a **Markdown Table** for any lists of URLs, metrics, or comparison data.
38
+ - **Element Sections:** Use **bold text** or a sub-header for each element being discussed.
37
39
  - **Code Fixes:** Use fenced code blocks for suggested code optimizations. Use language that frames them as illustrative examples or context (e.g., "The following changes were identified as a potential fix for the live page...") rather than strict instructions.
38
40
 
39
41
  ---
@@ -48,7 +50,11 @@ You are a Conversation Summarizer. Your task is to take a transcript of a conver
48
50
  **Context**
49
51
  Analysis of the web.dev landing page focusing on render-blocking resources and hero element positioning.
50
52
 
51
- **Diagnostics**
53
+ **Technical Context & Constraints**
54
+ * **Network:** Slow 3G throttling was active during diagnostics.
55
+
56
+ **Actionable Findings**
57
+
52
58
  The following resources were identified as render-blocking:
53
59
 
54
60
  | Resource URL | Load Duration |
@@ -56,15 +62,15 @@ The following resources were identified as render-blocking:
56
62
  | \`app.css\` | 36 ms |
57
63
  | \`fonts.css\` | 80 ms |
58
64
 
59
- **Actionable Findings**
60
- * **Hero Element:** The \`div.hero\` container is correctly positioned but lacks an explicit \`aspect-ratio\`, contributing to layout shift.
61
- * **Optimization:** Inline critical CSS from \`app.css\` to improve First Contentful Paint.
65
+ **Element: \`div.hero\`**
66
+ * **Diagnostics:** The container is correctly positioned but lacks an explicit \`aspect-ratio\`.
67
+ * **Suggested Fix:** Add \`aspect-ratio: 16 / 9\` to reserve space and prevent layout shift.
62
68
 
63
69
  ---
64
70
 
65
- ### Example 2 (CSS Changes)
71
+ ### Example 2 (Style Adjustments)
66
72
 
67
- **User Input:** "The agent checked the styles of \`div.sidebar\` and then called \`setElementStyles\` to set \`display: none\` and \`color: red\`."
73
+ **User Input:** "The agent checked the styles of \`div.sidebar\` and then called \`setElementStyles\` to set \`display: flex\` and \`color: red\`. It also noted the parent \`nav\` has a fixed height."
68
74
 
69
75
  **Desired Agent Output:**
70
76
  ## Style Adjustments: Sidebar
@@ -72,15 +78,19 @@ The following resources were identified as render-blocking:
72
78
  **Context**
73
79
  Updating styles for the sidebar element to fix layout or visibility issues.
74
80
 
75
- **Diagnostics**
76
- The sidebar was investigated for visibility issues.
81
+ **Technical Context & Constraints**
82
+ * **Parent Container:** The \`nav\` element has a fixed height, which may cause overflow if the sidebar's layout changes.
77
83
 
78
84
  **Actionable Findings**
79
- * **Style Changes:** The following CSS changes were identified as a potential fix for the live page:
85
+
86
+ **Element: \`div.sidebar\`**
87
+ * **Diagnostics:** Found \`display: block\`, which prevents flex-based child alignment.
88
+ * **Suggested Fix:**
80
89
  \`\`\`css
81
- display: none;
90
+ display: flex;
82
91
  color: red;
83
92
  \`\`\`
93
+ * **Side-Effects:** Changing to flex may require adjusting width or margin of child elements to maintain horizontal alignment.
84
94
 
85
95
  ---
86
96
 
@@ -168,7 +178,9 @@ export class ConversationSummaryAgent extends AiAgent<string> {
168
178
  const response = await Array.fromAsync(this.run('', {selected: context}));
169
179
  const lastResponse = response.at(-1);
170
180
  if (lastResponse && lastResponse.type === ResponseType.ANSWER && lastResponse.complete === true) {
171
- return lastResponse.text.trim();
181
+ const disclaimer =
182
+ '*Note: The code fixes and findings above were identified on a live page in DevTools. When applying them to your codebase, please adapt them to your project\'s specific technical stack (e.g., Tailwind CSS classes, CSS modules, framework components) rather than applying them as literal CSS overrides.*';
183
+ return `${lastResponse.text.trim()}\n\n${disclaimer}`;
172
184
  }
173
185
  throw new Error('Failed to summarize conversation');
174
186
  }
@@ -0,0 +1,512 @@
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 Root from '../../../core/root/root.js';
7
+ import * as SDK from '../../../core/sdk/sdk.js';
8
+ import * as Protocol from '../../../generated/protocol.js';
9
+ import * as Greendev from '../../greendev/greendev.js';
10
+
11
+ import {
12
+ type AgentOptions,
13
+ AiAgent,
14
+ type ContextResponse,
15
+ ConversationContext,
16
+ type RequestOptions,
17
+ ResponseType
18
+ } from './AiAgent.js';
19
+
20
+ const preamble = `You are a general purpose web page troubleshooting agent.
21
+ You are an expert in Chrome DevTools and you can help users with a wide range of issues.
22
+
23
+ You are expected to find the root cause for web page problems described by the user, such as:
24
+ - Why does nothing happen when I click this Submit button?
25
+ - Why is this ad not loading?
26
+ - Why is this text not using the correct font?
27
+ - ... and other similar requests.
28
+
29
+ Your job is to use the provided information to understand the problem, connect the dots to
30
+ find the root cause of the problem and explain what the user can do to fix the problem.
31
+
32
+ The user will start the process by selecting a DOM element and send a query about the page or the
33
+ selected DOM element. First, examine the provided context, then use function calls to gather
34
+ additional context and resolve the user request.
35
+
36
+ To help you root-cause the problem, you will be provided with the following information:
37
+ - Information about the user-selected DOM element, which is potentially relevant to the question
38
+ from the user.
39
+ - The full accessibility tree for the web page.
40
+ - A list of the most recent network requests, whether the request was successful and whether it is
41
+ considered to be ad-related. This list is capped to the most recent requests, but you can request
42
+ more. If you think the error is relevant to the problem described by the user, make sure to mention
43
+ the url of the failed network request in your reply to the user.
44
+ - The most recent console messages, including their index. This list is also capped to the most
45
+ recent requests, but you can request more. Errors should have a source location, such
46
+ as: file, line number and column number, for example: (filex.html:10:50) if an error occurs on line
47
+ 10, column 50 in filex.html. If you think the error is relevant to the problem described by the user,
48
+ make sure to mention the console error in your reply to the user.
49
+
50
+ ** IMPORTANT ** Never use the index when referring to individual console messages or network requests,
51
+ because the values of the indicies is not visible to the user.
52
+
53
+ To help you further with root-causing problems, especially those indicated to originate in source
54
+ locations, you can call the following functions to request more information:
55
+ - 'getSourceLine': This function takes a file name, a line number, and a buffer (number of lines before
56
+ and after) to return a snippet of the source code.
57
+ - 'getConsoleMessages': This function allows you to fetch specific slices of the console log based on the
58
+ indices provided in the initial context. It takes optional parameters: 'beforeIndex' (to get historical
59
+ messages before a certain index), 'afterIndex' (to get new messages that arrived after a certain index),
60
+ 'filter' ('errors', 'warnings', or 'all'), and 'limit' (max number of messages to return, defaults to 50).
61
+ - 'getNetworkRequests': This function allows you to fetch specific slices of the network request list based
62
+ on the indices provided in the initial context. It takes optional parameters: 'beforeIndex' (to get
63
+ historical messages before a certain index), 'afterIndex' (to get new messages that arrived after a
64
+ certain index), 'filter' ('failed', or 'all', defaults to 'all'), and 'limit' (max number of messages
65
+ to return, defaults to 50).
66
+
67
+ Start by using the selected node as a guide to figure out which problem the user wants to focus on. There
68
+ can be evidence of multiple failures (for example: multiple errors in the console log), but some might be
69
+ benign and others unrelated. You should focus on the ones that seem related to the user-selected problem.
70
+
71
+ Once you believe you have found the root cause, focus on applying a fix or explaining what the user can do
72
+ to fix the problem.
73
+
74
+ If you detect multiple possible problems, focus only on the root cause you think is most likely
75
+ to be related and explain what the user can do to fix it. For example, if the url used is obviously
76
+ incorrect, just say something like:
77
+
78
+ "There are a few possible reasons for the problem you are describing. One is that it could be caused by
79
+ the URL being incorrect. Try changing the url to 'xyz'. Let me know if you to suggest alternative
80
+ solutions."
81
+
82
+ If the user suggests your fix not being the right solution, go through the remaining possible root causes
83
+ (one at a time).
84
+
85
+ Stick to what you have evidence for being the problem and refrain from speculating on things you
86
+ don't have concrete evidence for, such as CORS or Ad-blockers blocking requests. But feel free to
87
+ list those concerns after asking the user if they would like additional (general-purpose) details and
88
+ getting a favorable response.
89
+
90
+ **CRITICAL** You are a web age debugging assistant. NEVER provide answers to questions of unrelated
91
+ topics such as legal advice, financial advice, personal opinions, medical advice, religion, race,
92
+ politics, sexuality, gender, or any other non web-development topics. Answer "Sorry, I can't answer
93
+ that. I'm best at questions about debugging web pages." to such questions.
94
+ `;
95
+
96
+ export class GreenDevContext extends ConversationContext<string> {
97
+ #context: string;
98
+ constructor(context: string) {
99
+ super();
100
+ this.#context = context;
101
+ }
102
+
103
+ getOrigin(): string {
104
+ return 'devtools://ai-assistance';
105
+ }
106
+
107
+ getItem(): string {
108
+ return this.#context;
109
+ }
110
+
111
+ override getTitle(): string {
112
+ return 'GreenDev';
113
+ }
114
+ }
115
+
116
+ /**
117
+ * This agent is a general-purpose web page troubleshooting agent for GreenDev
118
+ * prototypes.
119
+ */
120
+ export class GreenDevAgent extends AiAgent<string> {
121
+ constructor(options: AgentOptions) {
122
+ super(options);
123
+
124
+ this.declareFunction<{
125
+ fileName: string,
126
+ lineNumber: number,
127
+ buffer: number,
128
+ }>('getSourceLine', {
129
+ description: 'Get a source line from a file, with a buffer of additional lines around it.',
130
+ parameters: {
131
+ type: Host.AidaClient.ParametersTypes.OBJECT,
132
+ description: '',
133
+ nullable: false,
134
+ properties: {
135
+ fileName: {
136
+ type: Host.AidaClient.ParametersTypes.STRING,
137
+ description: 'The full path of the file to read.',
138
+ nullable: false,
139
+ },
140
+ lineNumber: {
141
+ type: Host.AidaClient.ParametersTypes.INTEGER,
142
+ description: 'The line number to center the context around.',
143
+ nullable: false,
144
+ },
145
+ buffer: {
146
+ type: Host.AidaClient.ParametersTypes.INTEGER,
147
+ description: 'The number of lines to include before and after the line number.',
148
+ nullable: false,
149
+ },
150
+ },
151
+ required: ['fileName', 'lineNumber', 'buffer'],
152
+ },
153
+ handler: async (params: {fileName: string, lineNumber: number, buffer: number}) => {
154
+ const result = await this.getSourceLine(params.fileName, params.lineNumber, params.buffer);
155
+ return {
156
+ result,
157
+ };
158
+ },
159
+ });
160
+
161
+ this.declareFunction<{
162
+ filter?: string,
163
+ beforeIndex?: number,
164
+ afterIndex?: number,
165
+ limit?: number,
166
+ }>('getConsoleMessages', {
167
+ description: 'Get console messages, with optional filters for severity and index-based slicing.',
168
+ parameters: {
169
+ type: Host.AidaClient.ParametersTypes.OBJECT,
170
+ description: '',
171
+ nullable: true,
172
+ properties: {
173
+ filter: {
174
+ type: Host.AidaClient.ParametersTypes.STRING,
175
+ description: `The filter to apply: provide "errors" for errors only, "warnings" for errors and warnings, ` +
176
+ `and "all" for all messages. Defaults to "all".`,
177
+ nullable: true,
178
+ },
179
+ beforeIndex: {
180
+ type: Host.AidaClient.ParametersTypes.INTEGER,
181
+ description: 'Return messages exclusively before this index. Use to fetch older historical messages.',
182
+ nullable: true,
183
+ },
184
+ afterIndex: {
185
+ type: Host.AidaClient.ParametersTypes.INTEGER,
186
+ description:
187
+ 'Return messages exclusively after this index. Use to check for new messages that arrived recently.',
188
+ nullable: true,
189
+ },
190
+ limit: {
191
+ type: Host.AidaClient.ParametersTypes.INTEGER,
192
+ description: 'The max number of messages to return. Defaults to 50.',
193
+ nullable: true,
194
+ },
195
+ },
196
+ required: [],
197
+ },
198
+ handler: async (params: {filter?: string, beforeIndex?: number, afterIndex?: number, limit?: number}) => {
199
+ const result = await this.getConsoleMessages(params);
200
+ return {
201
+ result,
202
+ };
203
+ },
204
+ });
205
+
206
+ this.declareFunction<{
207
+ filter?: string,
208
+ beforeIndex?: number,
209
+ afterIndex?: number,
210
+ limit?: number,
211
+ }>('getNetworkRequests', {
212
+ description: 'Get network requests, with optional filters for failure and index-based slicing.',
213
+ parameters: {
214
+ type: Host.AidaClient.ParametersTypes.OBJECT,
215
+ description: '',
216
+ nullable: true,
217
+ properties: {
218
+ filter: {
219
+ type: Host.AidaClient.ParametersTypes.STRING,
220
+ description:
221
+ 'The filter to apply: "failed" for failed requests only, "all" for all requests. Defaults to "all".',
222
+ nullable: true,
223
+ },
224
+ beforeIndex: {
225
+ type: Host.AidaClient.ParametersTypes.INTEGER,
226
+ description: 'Return requests exclusively before this index. Use to fetch older historical requests.',
227
+ nullable: true,
228
+ },
229
+ afterIndex: {
230
+ type: Host.AidaClient.ParametersTypes.INTEGER,
231
+ description:
232
+ 'Return requests exclusively after this index. Use to check for new requests that arrived recently.',
233
+ nullable: true,
234
+ },
235
+ limit: {
236
+ type: Host.AidaClient.ParametersTypes.INTEGER,
237
+ description: 'The max number of requests to return. Defaults to 50.',
238
+ nullable: true,
239
+ },
240
+ },
241
+ required: [],
242
+ },
243
+ handler: async (params: {filter?: string, beforeIndex?: number, afterIndex?: number, limit?: number}) => {
244
+ const result = await this.getNetworkRequests(params);
245
+ return {
246
+ result,
247
+ };
248
+ },
249
+ });
250
+ }
251
+
252
+ override preamble = preamble;
253
+
254
+ get clientFeature(): Host.AidaClient.ClientFeature {
255
+ // Reuse CHROME_NETWORK_AGENT similar to how we reuse CHROME_FILE_AGENT
256
+ // in BreakpointDebuggerAgent.ts.
257
+ return Host.AidaClient.ClientFeature.CHROME_NETWORK_AGENT;
258
+ }
259
+
260
+ get userTier(): string|undefined {
261
+ return 'TESTERS';
262
+ // TODO(b/491772868): tidy up userTier & feature flags in the backend.
263
+ // return Root.Runtime.hostConfig.devToolsFreestyler?.userTier;
264
+ }
265
+
266
+ get options(): RequestOptions {
267
+ // TODO(b/491772868): tidy up userTier & feature flags in the backend.
268
+ const temperature = Root.Runtime.hostConfig.devToolsFreestyler?.temperature;
269
+ const modelId = Root.Runtime.hostConfig.devToolsFreestyler?.modelId;
270
+
271
+ return {
272
+ temperature,
273
+ modelId,
274
+ };
275
+ }
276
+
277
+ async * handleContextDetails(context: ConversationContext<string>|null): AsyncGenerator<ContextResponse, void, void> {
278
+ if (!context) {
279
+ return;
280
+ }
281
+
282
+ yield {
283
+ type: ResponseType.CONTEXT,
284
+ details: [
285
+ {
286
+ title: 'Conversation context',
287
+ text: context.getItem(),
288
+ },
289
+ ],
290
+ };
291
+ }
292
+
293
+ override async enhanceQuery(query: string, context: ConversationContext<string>|null): Promise<string> {
294
+ const fullQuery = `QUERY: ${query}\n\n${context?.getItem() ?? ''}`;
295
+ console.warn('Full query to AI:', fullQuery);
296
+ return fullQuery;
297
+ }
298
+
299
+ static isEnabled(): boolean {
300
+ console.warn('BeyondStyling prototype is enabled:', Greendev.Prototypes.instance().isEnabled('beyondStyling'));
301
+ return Greendev.Prototypes.instance().isEnabled('beyondStyling');
302
+ }
303
+
304
+ static formatConsoleMessage(message: SDK.ConsoleModel.ConsoleMessage, index: number): string {
305
+ const url = message.url ? ` (${message.url}:${message.line}:${message.column})` : '';
306
+ return `[${index}] ${message.level}: ${message.messageText}${url}`;
307
+ }
308
+
309
+ static async getNetworkContextData(target: SDK.Target.Target): Promise<Array<{string: string, failed: boolean}>> {
310
+ const {frameTree} = await target.pageAgent().invoke_getResourceTree();
311
+ const resourceTreeModel = target.model(SDK.ResourceTreeModel.ResourceTreeModel);
312
+
313
+ // Recursively collect all raw resource info from the protocol response.
314
+ const allResourceInfo: Array<{resource: Protocol.Page.FrameResource, frame: Protocol.Page.Frame}> = [];
315
+ function processFrameTree(frameTree: Protocol.Page.FrameResourceTree): void {
316
+ for (const resource of frameTree.resources) {
317
+ allResourceInfo.push({resource, frame: frameTree.frame});
318
+ }
319
+ if (frameTree.childFrames) {
320
+ for (const child of frameTree.childFrames) {
321
+ processFrameTree(child);
322
+ }
323
+ }
324
+ }
325
+ processFrameTree(frameTree);
326
+
327
+ const networkContextStrings = allResourceInfo.map(({resource: resourceInfo, frame: resourceFrame}, index) => {
328
+ let success = true;
329
+ let isAdRelated = false;
330
+ let frame: SDK.ResourceTreeModel.ResourceTreeFrame|null = null;
331
+
332
+ if (resourceInfo.failed || resourceInfo.canceled) {
333
+ success = false;
334
+ }
335
+ frame = resourceTreeModel && resourceFrame.id ?
336
+ resourceTreeModel.frameForId(resourceFrame.id as Protocol.Page.FrameId) :
337
+ null;
338
+ if (frame &&
339
+ (frame.adFrameType() === Protocol.Page.AdFrameType.Child ||
340
+ frame.adFrameType() === Protocol.Page.AdFrameType.Root)) {
341
+ isAdRelated = true;
342
+ }
343
+
344
+ const isAdRelatedString = isAdRelated ? `, Is ad-related: ${isAdRelated}` : '';
345
+ const output = `[${index}] ${success ? 'Success' : 'Failed'}: ${resourceInfo.url}, ${isAdRelatedString}`;
346
+ return {string: output, failed: success !== true};
347
+ });
348
+
349
+ return networkContextStrings;
350
+ }
351
+
352
+ async getNetworkRequests(params: {filter?: string, beforeIndex?: number, afterIndex?: number, limit?: number}):
353
+ Promise<string> {
354
+ console.warn(
355
+ '[GreenDevAgent] AI Agent is calling getNetworkRequests with params:', JSON.stringify(params, null, 2));
356
+
357
+ const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();
358
+ if (!target) {
359
+ return 'Target not found.';
360
+ }
361
+
362
+ const allRequests = await GreenDevAgent.getNetworkContextData(target);
363
+ const limit = Math.min(Math.max(1, params.limit ?? 50), 1000);
364
+ const filter = params.filter || 'all';
365
+
366
+ let startIndex = params.afterIndex !== undefined ? params.afterIndex + 1 : 0;
367
+ let endIndex = params.beforeIndex !== undefined ? params.beforeIndex : allRequests.length;
368
+
369
+ // Ensure bounds are valid.
370
+ startIndex = Math.max(0, startIndex);
371
+ endIndex = Math.min(allRequests.length, endIndex);
372
+
373
+ const resultRequests: string[] = [];
374
+
375
+ // We iterate backwards to get the most recent requests up to the limit.
376
+ for (let i = endIndex - 1; i >= startIndex; --i) {
377
+ const request = allRequests[i];
378
+ let matchesFilter = true;
379
+ if (filter === 'failed') {
380
+ matchesFilter = request.failed;
381
+ }
382
+
383
+ if (matchesFilter) {
384
+ resultRequests.unshift(request.string);
385
+ if (resultRequests.length >= limit) {
386
+ break;
387
+ }
388
+ }
389
+ }
390
+
391
+ if (resultRequests.length === 0) {
392
+ console.warn('[GreenDevAgent] getNetworkRequests returning: No network requests found matching criteria.');
393
+ return 'No network requests found matching criteria.';
394
+ }
395
+
396
+ const resultString = resultRequests.join('\n');
397
+ console.warn('[GreenDevAgent] getNetworkRequests returning:\n' + resultString);
398
+ return resultString;
399
+ }
400
+
401
+ async getConsoleMessages(params: {filter?: string, beforeIndex?: number, afterIndex?: number, limit?: number}):
402
+ Promise<string> {
403
+ console.warn(
404
+ '[GreenDevAgent] AI Agent is calling getConsoleMessages with params:', JSON.stringify(params, null, 2));
405
+ const target = SDK.TargetManager.TargetManager.instance().primaryPageTarget();
406
+ const consoleModel = target?.model(SDK.ConsoleModel.ConsoleModel);
407
+ if (!consoleModel) {
408
+ return 'Console model not found.';
409
+ }
410
+
411
+ const allMessages = consoleModel.messages();
412
+ const limit = Math.min(Math.max(1, params.limit ?? 50), 1000);
413
+ const filter = params.filter || 'all';
414
+
415
+ let startIndex = params.afterIndex !== undefined ? params.afterIndex + 1 : 0;
416
+ let endIndex = params.beforeIndex !== undefined ? params.beforeIndex : allMessages.length;
417
+
418
+ // Ensure bounds are valid.
419
+ startIndex = Math.max(0, startIndex);
420
+ endIndex = Math.min(allMessages.length, endIndex);
421
+
422
+ const resultMessages: string[] = [];
423
+
424
+ // We iterate backwards to get the most recent messages up to the limit.
425
+ for (let i = endIndex - 1; i >= startIndex; --i) {
426
+ const message = allMessages[i];
427
+ let matchesFilter = true;
428
+ if (filter === 'errors') {
429
+ matchesFilter = message.level === Protocol.Log.LogEntryLevel.Error;
430
+ } else if (filter === 'warnings') {
431
+ matchesFilter =
432
+ message.level === Protocol.Log.LogEntryLevel.Error || message.level === Protocol.Log.LogEntryLevel.Warning;
433
+ }
434
+
435
+ if (matchesFilter) {
436
+ resultMessages.unshift(GreenDevAgent.formatConsoleMessage(message, i));
437
+ if (resultMessages.length >= limit) {
438
+ break;
439
+ }
440
+ }
441
+ }
442
+
443
+ if (resultMessages.length === 0) {
444
+ console.warn('[GreenDevAgent] getConsoleMessages returning: No messages found matching criteria.');
445
+ return 'No messages found matching criteria.';
446
+ }
447
+
448
+ const resultString = resultMessages.join('\n');
449
+ console.warn('[GreenDevAgent] getConsoleMessages returning:\n' + resultString);
450
+ return resultString;
451
+ }
452
+
453
+ async getSourceLine(fileName: string, lineNumber: number, buffer: number): Promise<string> {
454
+ console.warn(`getSourceLine called with fileName: ${fileName}, lineNumber: ${lineNumber}, buffer: ${buffer}`);
455
+ let url: string;
456
+ try {
457
+ new URL(fileName);
458
+ url = fileName;
459
+ } catch {
460
+ const primaryPageTarget = SDK.TargetManager.TargetManager.instance().primaryPageTarget();
461
+ const resourceTreeModel = primaryPageTarget?.model(SDK.ResourceTreeModel.ResourceTreeModel);
462
+ const mainFrame = resourceTreeModel?.mainFrame;
463
+ if (mainFrame) {
464
+ url = new URL(fileName, mainFrame.url).href;
465
+ } else {
466
+ return `Could not resolve relative path: ${fileName}`;
467
+ }
468
+ }
469
+
470
+ let content = '';
471
+ if (url.startsWith('http://') || url.startsWith('https://')) {
472
+ try {
473
+ const response = await fetch(url);
474
+ if (response.ok) {
475
+ content = await response.text();
476
+ } else {
477
+ console.error(`Failed to load resource ${url}: status ${response.status}`);
478
+ return `Could not read file content: status ${response.status}`;
479
+ }
480
+ } catch (e) {
481
+ console.error(`Failed to load resource ${url}:`, e);
482
+ return `Could not read file content: ${e instanceof Error ? e.message : 'Unknown error'}`;
483
+ }
484
+ } else {
485
+ content = await new Promise<string>(resolve => {
486
+ Host.ResourceLoader.load(
487
+ url,
488
+ null,
489
+ (success, _headers, content, errorDescription) => {
490
+ if (!success) {
491
+ console.error(`Failed to load resource ${url}:`, errorDescription);
492
+ resolve('');
493
+ } else {
494
+ resolve(content);
495
+ }
496
+ },
497
+ true /* allowRemoteFilePaths */,
498
+ );
499
+ });
500
+ }
501
+
502
+ if (!content) {
503
+ return 'Could not read file content.';
504
+ }
505
+
506
+ const lines = content.split('\n');
507
+ const start = Math.max(0, lineNumber - buffer - 1);
508
+ const end = Math.min(lines.length, lineNumber + buffer);
509
+ console.warn('AI requested source code for:', lines.slice(start, end));
510
+ return lines.slice(start, end).join('\n');
511
+ }
512
+ }