chrome-devtools-frontend 1.0.1730971 → 1.0.1732697

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 (210) hide show
  1. package/docs/get_the_code.md +1 -73
  2. package/front_end/Tests.js +15 -0
  3. package/front_end/core/host/AidaClient.ts +47 -3
  4. package/front_end/core/host/AidaClientTypes.ts +27 -3
  5. package/front_end/core/host/AidaGcaTranslation.ts +1 -1
  6. package/front_end/core/sdk/DOMModel.ts +8 -3
  7. package/front_end/core/sdk/NetworkManager.ts +2 -1
  8. package/front_end/entrypoints/formatter_worker/ScopeParser.ts +2 -2
  9. package/front_end/generated/Deprecation.ts +0 -8
  10. package/front_end/generated/InspectorBackendCommands.ts +2 -1
  11. package/front_end/generated/SupportedCSSProperties.ts +2 -2
  12. package/front_end/generated/protocol.ts +9 -0
  13. package/front_end/models/ai-utils/debug.ts +127 -22
  14. package/front_end/models/ai_assistance/README.md +1 -1
  15. package/front_end/models/ai_assistance/agents/AiAgent.ts +10 -5
  16. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +1 -1
  17. package/front_end/models/ai_assistance/contexts/DOMNodeContext.ts +4 -3
  18. package/front_end/models/ai_assistance/contexts/LighthouseContext.snapshot.txt +9 -2
  19. package/front_end/models/ai_assistance/contexts/LighthouseContext.ts +4 -3
  20. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.snapshot.txt +97 -11
  21. package/front_end/models/ai_assistance/data_formatters/LighthouseFormatter.ts +92 -43
  22. package/front_end/models/ai_assistance/data_formatters/PerformanceInsightFormatter.snapshot.txt +1 -1
  23. package/front_end/models/ai_assistance/data_formatters/PerformanceTraceFormatter.snapshot.txt +26 -26
  24. package/front_end/models/ai_assistance/skills/styling.md +4 -2
  25. package/front_end/models/ai_assistance/tools/ExecuteJavaScript.ts +31 -36
  26. package/front_end/models/ai_code_completion/AiCodeCompletion.ts +2 -1
  27. package/front_end/models/ai_code_completion/ai_code_completion.ts +11 -2
  28. package/front_end/models/ai_code_generation/AiCodeGeneration.ts +2 -1
  29. package/front_end/models/ai_code_generation/ai_code_generation.ts +11 -2
  30. package/front_end/models/bindings/CompilerScriptMapping.ts +0 -1
  31. package/front_end/models/bindings/DebuggerLanguagePlugins.ts +0 -1
  32. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +0 -1
  33. package/front_end/models/har/HARFormat.ts +1 -0
  34. package/front_end/models/har/Importer.ts +7 -1
  35. package/front_end/models/har/Log.snapshot.txt +2 -0
  36. package/front_end/models/har/Log.ts +2 -0
  37. package/front_end/models/javascript_metadata/NativeFunctions.ts +0 -4
  38. package/front_end/models/trace/LanternComputationData.ts +4 -0
  39. package/front_end/models/trace/lantern/metrics/LargestContentfulPaint.ts +126 -1
  40. package/front_end/models/trace/lantern/types/Lantern.ts +3 -0
  41. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +33 -1
  42. package/front_end/panels/ai_assistance/ExternalHandler.ts +1 -1
  43. package/front_end/panels/ai_assistance/components/ChatInput.ts +2 -0
  44. package/front_end/panels/ai_assistance/components/PermissionPrompt.ts +4 -4
  45. package/front_end/panels/ai_assistance/components/chatInput.css +1 -1
  46. package/front_end/panels/ai_assistance/components/chatMessage.css +3 -4
  47. package/front_end/panels/ai_assistance/components/exploreWidget.css +3 -3
  48. package/front_end/panels/animation/animationTimeline.css +11 -9
  49. package/front_end/panels/application/IndexedDBViews.ts +2 -2
  50. package/front_end/panels/application/PrivateVerificationTokensView.ts +217 -9
  51. package/front_end/panels/application/ServiceWorkerCacheViews.ts +1 -1
  52. package/front_end/panels/application/ServiceWorkersView.ts +1 -1
  53. package/front_end/panels/application/StorageView.ts +1 -1
  54. package/front_end/panels/application/appManifestView.css +0 -6
  55. package/front_end/panels/application/backgroundServiceView.css +0 -21
  56. package/front_end/panels/application/components/backForwardCacheView.css +1 -9
  57. package/front_end/panels/application/components/endpointsGrid.css +1 -1
  58. package/front_end/panels/application/components/permissionsPolicySection.css +1 -1
  59. package/front_end/panels/application/components/reportsGrid.css +1 -1
  60. package/front_end/panels/application/components/serviceWorkerRouterView.css +2 -2
  61. package/front_end/panels/application/components/trustTokensView.css +1 -1
  62. package/front_end/panels/application/cookieItemsView.css +0 -1
  63. package/front_end/panels/application/frameDetailsReportView.css +0 -10
  64. package/front_end/panels/application/indexedDBViews.css +0 -10
  65. package/front_end/panels/application/privateVerificationTokensView.css +12 -0
  66. package/front_end/panels/application/resourcesPanel.css +0 -23
  67. package/front_end/panels/application/serviceWorkerUpdateCycleView.css +7 -7
  68. package/front_end/panels/application/serviceWorkersView.css +4 -3
  69. package/front_end/panels/changes/CombinedDiffView.ts +1 -1
  70. package/front_end/panels/comments/CommentsPane.ts +7 -11
  71. package/front_end/panels/common/CommentThreadWidget.ts +11 -3
  72. package/front_end/panels/common/CommentsOverlayWidget.ts +337 -117
  73. package/front_end/panels/console/consoleContextSelector.css +1 -1
  74. package/front_end/panels/console/consolePinPane.css +1 -1
  75. package/front_end/panels/console/consolePrompt.css +4 -2
  76. package/front_end/panels/console/consoleView.css +5 -3
  77. package/front_end/panels/coverage/CoverageView.ts +0 -1
  78. package/front_end/panels/coverage/coverageView.css +4 -3
  79. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +0 -1
  80. package/front_end/panels/elements/AccessibilityTreeView.ts +1 -1
  81. package/front_end/panels/elements/CSSValueTraceView.ts +2 -4
  82. package/front_end/panels/elements/ComputedStyleWidget.ts +8 -19
  83. package/front_end/panels/elements/DOMTreeContextMenu.ts +1 -1
  84. package/front_end/panels/elements/DOMTreeWidget.ts +14 -0
  85. package/front_end/panels/elements/MetricsSidebarPane.ts +1 -1
  86. package/front_end/panels/elements/PlatformFontsWidget.ts +0 -1
  87. package/front_end/panels/elements/PropertiesWidget.ts +1 -1
  88. package/front_end/panels/elements/PropertyRenderer.ts +7 -27
  89. package/front_end/panels/elements/StylePropertyTreeElement.ts +61 -72
  90. package/front_end/panels/elements/StylesSidebarPane.ts +2 -0
  91. package/front_end/panels/elements/WebCustomData.ts +1 -1
  92. package/front_end/panels/elements/components/cssHintDetailsView.css +1 -1
  93. package/front_end/panels/elements/components/cssVariableValueView.css +3 -1
  94. package/front_end/panels/elements/components/elementsBreadcrumbs.css +1 -1
  95. package/front_end/panels/elements/components/elementsTreeExpandButton.css +3 -2
  96. package/front_end/panels/elements/components/stylePropertyEditor.css +2 -2
  97. package/front_end/panels/elements/layoutPane.css +1 -1
  98. package/front_end/panels/elements/metricsSidebarPane.css +6 -6
  99. package/front_end/panels/elements/platformFontsWidget.css +1 -1
  100. package/front_end/panels/elements/propertiesWidget.css +0 -5
  101. package/front_end/panels/elements/stylesSidebarPane.css +1 -1
  102. package/front_end/panels/emulation/DeviceModeView.ts +4 -3
  103. package/front_end/panels/emulation/deviceModeView.css +9 -10
  104. package/front_end/panels/event_listeners/eventListenersView.css +5 -5
  105. package/front_end/panels/explain/components/consoleInsight.css +5 -20
  106. package/front_end/panels/issues/issuesTree.css +11 -10
  107. package/front_end/panels/layer_viewer/LayerDetailsView.ts +4 -2
  108. package/front_end/panels/layer_viewer/TransformController.ts +106 -54
  109. package/front_end/panels/layer_viewer/layerTreeOutline.css +1 -1
  110. package/front_end/panels/lighthouse/lighthousePanel.css +5 -8
  111. package/front_end/panels/lighthouse/lighthouseStartView.css +1 -2
  112. package/front_end/panels/linear_memory_inspector/components/linearMemoryHighlightChipList.css +4 -4
  113. package/front_end/panels/linear_memory_inspector/components/valueInterpreterDisplay.css +1 -1
  114. package/front_end/panels/media/EventTimelineView.ts +1 -4
  115. package/front_end/panels/media/TickingFlameChart.ts +3 -2
  116. package/front_end/panels/media/playerListView.css +14 -7
  117. package/front_end/panels/media/playerMessagesView.css +11 -7
  118. package/front_end/panels/mobile_throttling/ThrottlingSettingsTab.ts +1 -1
  119. package/front_end/panels/mobile_throttling/throttlingSettingsTab.css +5 -7
  120. package/front_end/panels/network/NetworkConfigView.ts +1 -1
  121. package/front_end/panels/network/NetworkWaterfallColumn.ts +92 -55
  122. package/front_end/panels/network/binaryResourceView.css +0 -7
  123. package/front_end/panels/network/networkConfigView.css +3 -3
  124. package/front_end/panels/network/networkLogView.css +5 -11
  125. package/front_end/panels/network/networkManageCustomHeadersView.css +1 -1
  126. package/front_end/panels/network/networkTimingTable.css +6 -6
  127. package/front_end/panels/network/requestConditionsDrawer.css +1 -24
  128. package/front_end/panels/network/requestPayloadView.css +1 -1
  129. package/front_end/panels/performance_monitor/PerformanceMonitor.ts +1 -1
  130. package/front_end/panels/performance_monitor/performanceMonitor.css +2 -2
  131. package/front_end/panels/profiler/ModuleUIStrings.ts +12 -0
  132. package/front_end/panels/protocol_monitor/JSONEditor.css +4 -3
  133. package/front_end/panels/protocol_monitor/JSONEditor.ts +1 -1
  134. package/front_end/panels/protocol_monitor/protocolMonitor.css +1 -1
  135. package/front_end/panels/recorder/createRecordingView.css +2 -2
  136. package/front_end/panels/recorder/extensionView.css +1 -1
  137. package/front_end/panels/recorder/recorderPanel.css +3 -3
  138. package/front_end/panels/recorder/recordingListView.css +1 -1
  139. package/front_end/panels/recorder/stepEditor.css +2 -2
  140. package/front_end/panels/recorder/stepView.css +0 -31
  141. package/front_end/panels/recorder/timelineSection.css +1 -1
  142. package/front_end/panels/screencast/screencastView.css +3 -2
  143. package/front_end/panels/search/searchView.css +4 -3
  144. package/front_end/panels/security/SecurityPanelSidebar.ts +0 -1
  145. package/front_end/panels/security/mainView.css +2 -2
  146. package/front_end/panels/security/originView.css +1 -5
  147. package/front_end/panels/settings/FrameworkIgnoreListSettingsTab.ts +2 -1
  148. package/front_end/panels/sources/WatchExpressionsSidebarPane.ts +1 -2
  149. package/front_end/panels/sources/breakpointsView.css +3 -4
  150. package/front_end/panels/sources/tabbedEditorContainer.css +1 -1
  151. package/front_end/panels/sources/watchExpressionsSidebarPane.css +4 -3
  152. package/front_end/panels/timeline/CompatibilityTracksAppender.ts +30 -10
  153. package/front_end/panels/timeline/TimelineSelectorStatsView.ts +1 -1
  154. package/front_end/panels/timeline/components/OriginMap.ts +1 -1
  155. package/front_end/panels/timeline/components/fieldSettingsDialog.css +1 -1
  156. package/front_end/panels/timeline/components/metricCard.css +1 -1
  157. package/front_end/panels/timeline/components/networkRequestDetails.css +0 -1
  158. package/front_end/panels/timeline/components/networkRequestTooltip.css +4 -4
  159. package/front_end/panels/timeline/components/relatedInsightChips.css +1 -1
  160. package/front_end/panels/timeline/timelineFlameChartView.css +4 -4
  161. package/front_end/panels/timeline/timelineFlamechartPopover.css +3 -3
  162. package/front_end/panels/timeline/timelineHistoryManager.css +1 -1
  163. package/front_end/panels/timeline/timelineMiniMap.css +3 -2
  164. package/front_end/panels/timeline/timelineStatusDialog.css +1 -1
  165. package/front_end/panels/web_audio/webAudio.css +0 -20
  166. package/front_end/third_party/chromium/README.chromium +1 -1
  167. package/front_end/ui/comments/CommentAnchorResolver.ts +166 -8
  168. package/front_end/ui/comments/CommentOverlayManager.ts +17 -2
  169. package/front_end/ui/components/buttons/button.css +0 -1
  170. package/front_end/ui/components/diff_view/diffView.css +2 -2
  171. package/front_end/ui/components/markdown_view/codeBlock.css +3 -3
  172. package/front_end/ui/components/markdown_view/markdownView.css +3 -3
  173. package/front_end/ui/components/menus/Menu.ts +1 -1
  174. package/front_end/ui/components/menus/menuItem.css +1 -1
  175. package/front_end/ui/components/panel_feedback/panelFeedback.css +5 -4
  176. package/front_end/ui/components/panel_introduction_steps/panelIntroductionSteps.css +1 -1
  177. package/front_end/ui/components/report_view/reportValue.css +5 -2
  178. package/front_end/ui/components/suggestion_input/suggestionInput.css +6 -6
  179. package/front_end/ui/legacy/ContextMenu.ts +3 -0
  180. package/front_end/ui/legacy/GlassPane.ts +3 -3
  181. package/front_end/ui/legacy/SoftContextMenu.ts +7 -1
  182. package/front_end/ui/legacy/components/data_grid/DataGrid.ts +2 -0
  183. package/front_end/ui/legacy/components/inline_editor/bezierEditor.css +7 -6
  184. package/front_end/ui/legacy/components/inline_editor/colorSwatch.css +1 -2
  185. package/front_end/ui/legacy/components/inline_editor/cssAngleEditor.css +3 -3
  186. package/front_end/ui/legacy/components/perf_ui/chartViewport.css +1 -1
  187. package/front_end/ui/legacy/components/perf_ui/filmStripView.css +1 -1
  188. package/front_end/ui/legacy/components/perf_ui/flameChart.css +12 -9
  189. package/front_end/ui/legacy/components/perf_ui/overviewGrid.css +11 -7
  190. package/front_end/ui/legacy/components/perf_ui/pieChart.css +3 -4
  191. package/front_end/ui/legacy/components/source_frame/imageView.css +4 -4
  192. package/front_end/ui/legacy/components/utils/imagePreview.css +1 -1
  193. package/front_end/ui/legacy/components/utils/jsUtils.css +2 -1
  194. package/front_end/ui/legacy/dropTarget.css +1 -1
  195. package/front_end/ui/legacy/filter.css +4 -3
  196. package/front_end/ui/legacy/inspectorCommon.css +16 -48
  197. package/front_end/ui/legacy/inspectorDrawerTabbedPane.css +1 -1
  198. package/front_end/ui/legacy/progressIndicator.css +1 -2
  199. package/front_end/ui/legacy/reportView.css +4 -1
  200. package/front_end/ui/legacy/searchableView.css +1 -1
  201. package/front_end/ui/legacy/suggestBox.css +2 -1
  202. package/front_end/ui/legacy/tabbedPane.css +7 -4
  203. package/front_end/ui/legacy/toolbar.css +2 -1
  204. package/front_end/ui/legacy/treeoutline.css +6 -5
  205. package/front_end/ui/legacy/viewContainers.css +3 -2
  206. package/front_end/ui/visual_logging/KnownContextValues.ts +15 -0
  207. package/inspector_overlay/highlight_anchor.ts +8 -11
  208. package/package.json +1 -1
  209. package/front_end/models/ai_code_completion/debug.ts +0 -33
  210. package/front_end/models/ai_code_generation/debug.ts +0 -33
@@ -8,7 +8,7 @@ In order to make changes to DevTools frontend, build, run, test, and submit chan
8
8
 
9
9
  As a standalone project, Chrome DevTools frontend can be checked out and built independently from Chromium. The main advantage is not having to check out and build Chromium.
10
10
 
11
- However, to run layout tests, you need to use the [chromium checkout](#Chromium-checkout) or [integrated checkout](#Integrated-checkout).
11
+ However, to run layout tests, you need to use the [Chromium checkout](#Chromium-checkout).
12
12
 
13
13
  ### Checking out source
14
14
 
@@ -452,75 +452,3 @@ ended up on. If you switch back and forth across the revision that moved
452
452
  `node_modules/` out of git, `gclient sync` repairs the directory on its own
453
453
  (`ensure_node_modules` hook); in the worst case it asks you to run it once
454
454
  more.
455
-
456
- ## Integrated checkout
457
-
458
- **This solution is experimental, please report any trouble that you run into!**
459
-
460
- The integrated workflow offers the best of both worlds, and allows for working
461
- on both Chromium and DevTools frontend side-by-side.
462
-
463
- A full [Chromium checkout](#Chromium-checkout) is a pre-requisite for the
464
- following steps.
465
-
466
- ### Untrack the existing devtools-frontend submodule
467
-
468
- First, you need to untrack the existing devtools-frontend submodule in the chromium checkout. This ensures that devtools
469
- isn't dragged along whenever you update your chromium dependencies.
470
-
471
- In `chromium/src`, run `gclient sync` to make sure you have installed all required submodules.
472
-
473
- ```bash
474
- gclient sync
475
- ```
476
-
477
- Then, disable `gclient sync` for DevTools frontend inside of Chromium by editing `.gclient` config. From
478
- `chromium/src/`, run
479
-
480
- ```bash
481
- vim "$(gclient root)/.gclient"
482
- ```
483
-
484
- In the `custom_deps` section, insert this line:
485
-
486
- ```python
487
- "src/third_party/devtools-frontend/src": None,
488
- ```
489
-
490
- For the integrated checkout, create a single gclient project that automatically `gclient sync`s all dependencies for both
491
- repositories. After checking out chromium, modify the `.gclient` file for `chromium/src` to add the DevTools project:
492
-
493
- ```python
494
- solutions = [
495
- {
496
- # Chromium src project
497
- "name": "src",
498
- "url": "https://chromium.googlesource.com/chromium/src.git",
499
- "custom_deps": {
500
- "src/third_party/devtools-frontend/src": None,
501
- },
502
- },
503
- {
504
- # devtools-frontend project
505
- "name": "devtools-frontend",
506
- "managed": False,
507
- "url": "https://chromium.googlesource.com/devtools/devtools-frontend.git",
508
- }
509
- ]
510
- ```
511
-
512
- Do not run `gclient sync` now, first create the symlink. In the same directory as the .gclient file, run:
513
-
514
- ```bash
515
- ln -s src/third_party/devtools-frontend/src devtools-frontend
516
- ```
517
-
518
- If you did run `gclient sync` first, remove the devtools-frontend directory and start over.
519
-
520
- Run `gclient sync` after creating the link to fetch the dependencies for the standalone checkout.
521
-
522
- ### Known issues
523
-
524
- - GN/Siso wrappers in `depot_tools` don't assume the side-by-side solutions, and
525
- always use the binaries in Chromium. Please make sure updating Chromium when
526
- you get a build error.
@@ -610,6 +610,21 @@
610
610
  this.takeControl();
611
611
  };
612
612
 
613
+ TestSuite.prototype.showExtensionSidebarPane = function(title) {
614
+ const viewManager = UI.ViewManager.ViewManager.instance();
615
+ for (const view of viewManager.views.values()) {
616
+ if (view.viewId().startsWith('extension-sidebar-') && view.title() === title) {
617
+ return viewManager.revealView(view);
618
+ }
619
+ }
620
+ return Promise.reject(new Error(`Extension sidebar pane '${title}' not found`));
621
+ };
622
+
623
+ TestSuite.prototype.switchToExtensionSidebarPane = function(title) {
624
+ this.showExtensionSidebarPane(title).then(this.releaseControl.bind(this));
625
+ this.takeControl();
626
+ };
627
+
613
628
  // Regression test for crbug.com/370035.
614
629
  TestSuite.prototype.testDeviceMetricsOverrides = function() {
615
630
  function dumpPageMetrics() {
@@ -543,8 +543,25 @@ export interface EventTypes {
543
543
  [Events.AIDA_AVAILABILITY_CHANGED]: AidaAccessPreconditions;
544
544
  }
545
545
 
546
+ /**
547
+ * Checks whether any of the provided error strings indicate a quota or rate-limit failure.
548
+ *
549
+ * AIDA and GCA surface quota errors across different fields (status codes, human-readable
550
+ * messages, and serialized `google.rpc.ErrorInfo` details), so we check three substrings:
551
+ * - `'quota'`: direct AIDA error messages or details (for example,
552
+ * `"Quota exceeded for quota metric 'AiCodeCompleteService'"` or `"USER_QUOTA_EXCEEDED"`).
553
+ * - `'resource_exhausted'`: the standard `google.rpc.Code` status string (for example,
554
+ * `status: "RESOURCE_EXHAUSTED"` or `"RESOURCE_EXHAUSTED: quota exceeded"`).
555
+ * - `'rate_limit_exceeded'`: the `reason` field inside `google.rpc.ErrorInfo` details when
556
+ * the message itself does not mention `'quota'` (for example, GCA returning
557
+ * `message: "You have exhausted your capacity on this model."` with
558
+ * `details: [{"reason": "RATE_LIMIT_EXCEEDED", "domain": "cloudcode-pa.googleapis.com"}]`).
559
+ */
546
560
  export function isQuotaError(...inputs: Array<string|undefined>): boolean {
547
- return inputs.some(input => input?.toLowerCase().includes('quota'));
561
+ return inputs.some(input => {
562
+ const lower = input?.toLowerCase();
563
+ return lower?.includes('quota') || lower?.includes('resource_exhausted') || lower?.includes('rate_limit_exceeded');
564
+ });
548
565
  }
549
566
 
550
567
  export function isPayloadTooLargeError(...inputs: Array<string|undefined>): boolean {
@@ -552,8 +569,17 @@ export function isPayloadTooLargeError(...inputs: Array<string|undefined>): bool
552
569
  }
553
570
 
554
571
  /**
555
- * Maps AIDA-specific errors, DispatchHttpRequestErrors, strings, and generic
556
- * Errors to dedicated AidaClientError subclasses.
572
+ * Type guard that narrows an `unknown` error value in `mapError` to a plain key-value
573
+ * object so structured `google.rpc.Status` fields (`code`, `status`, `message`, `details`)
574
+ * can be safely inspected.
575
+ */
576
+ function isRecord(value: unknown): value is Record<string, unknown> {
577
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
578
+ }
579
+
580
+ /**
581
+ * Maps AIDA-specific errors, DispatchHttpRequestErrors, strings, structured
582
+ * error objects, and generic Errors to dedicated AidaClientError subclasses.
557
583
  */
558
584
  export function mapError(err: unknown, detail?: string): AidaClientError {
559
585
  if (err instanceof AidaClientError) {
@@ -602,5 +628,23 @@ export function mapError(err: unknown, detail?: string): AidaClientError {
602
628
  if (err instanceof Error) {
603
629
  return new AidaUnknownError(err.message, {cause: err});
604
630
  }
631
+
632
+ if (isRecord(err)) {
633
+ const code = typeof err.code === 'number' ? err.code : undefined;
634
+ const status = typeof err.status === 'string' ? err.status : undefined;
635
+ const message = typeof err.message === 'string' ? err.message : undefined;
636
+ const details = err.details !== undefined ? JSON.stringify(err.details) : undefined;
637
+ if (code === 429 || isQuotaError(status, message, details)) {
638
+ return new AidaQuotaError(message ?? 'Server responded: quota exceeded', {cause: err});
639
+ }
640
+ if (code === 403 || status === 'PERMISSION_DENIED') {
641
+ return new AidaPermissionDeniedError(message ?? 'Server responded: permission denied', {cause: err});
642
+ }
643
+ if (isPayloadTooLargeError(message, details)) {
644
+ return new AidaPayloadTooLargeError(message ?? 'Server responded: payload size exceeds the limit', {cause: err});
645
+ }
646
+ return new AidaUnknownError(message ?? JSON.stringify(err), {cause: err});
647
+ }
648
+
605
649
  return new AidaUnknownError(String(err));
606
650
  }
@@ -65,7 +65,7 @@ export interface FunctionPrimitiveParams extends BaseFunctionParam {
65
65
 
66
66
  export interface FunctionArrayParam extends BaseFunctionParam {
67
67
  type: ParametersTypes.ARRAY;
68
- items: FunctionPrimitiveParams;
68
+ items: FunctionPrimitiveParams|FunctionObjectParam;
69
69
  }
70
70
 
71
71
  export interface FunctionObjectParam<T extends string|number|symbol = string> extends BaseFunctionParam {
@@ -465,11 +465,35 @@ export interface AidaChunkResponse {
465
465
  functionCallChunk?: {
466
466
  functionCall: AidaFunctionCall,
467
467
  };
468
- error?: string;
468
+ /**
469
+ * Error information returned in the chunk.
470
+ * Supports direct AIDA stream chunk error strings (for example,
471
+ * "RESOURCE_EXHAUSTED: quota exceeded") and structured google.rpc.Status
472
+ * error objects translated from GCA stream chunks (for example,
473
+ * {"code": 429, "message": "You have exhausted your capacity on this model.", "status": "RESOURCE_EXHAUSTED", "details": [...]}).
474
+ */
475
+ error?: string|Record<string, unknown>;
476
+ }
477
+
478
+ // Reads `devToolsAiDebug` directly because `core/host` cannot depend on `models/ai-utils`.
479
+ function isGcaDebugMode(): boolean {
480
+ try {
481
+ const raw = Platform.HostRuntime.HOST_RUNTIME.getLocalStorage()?.getItem('devToolsAiDebug');
482
+ if (!raw) {
483
+ return false;
484
+ }
485
+ const parsed: unknown = JSON.parse(raw);
486
+ if (typeof parsed !== 'object' || parsed === null) {
487
+ return false;
488
+ }
489
+ return Boolean((parsed as Record<string, unknown>).gca);
490
+ } catch {
491
+ return false;
492
+ }
469
493
  }
470
494
 
471
495
  export function debugLog(...log: unknown[]): void {
472
- if (!Boolean(Platform.HostRuntime.HOST_RUNTIME.getLocalStorage()?.getItem('debugAiServicesEnabled'))) {
496
+ if (!isGcaDebugMode()) {
473
497
  return;
474
498
  }
475
499
 
@@ -475,7 +475,7 @@ function convertAidaParamToGcaSchema<T extends string|number|symbol = string>(pa
475
475
  export function gcaChunkResponseToAidaChunkResponse(response: GCA.GenerateContentResponse): AIDA.AidaChunkResponse[] {
476
476
  try {
477
477
  if (response.error) {
478
- throw new Error(JSON.stringify(response.error));
478
+ return [{error: response.error}];
479
479
  }
480
480
  const candidate = response.candidates?.[0];
481
481
  const parts = candidate?.content?.parts || [];
@@ -1308,10 +1308,15 @@ export class DOMNode extends Common.ObjectWrapper.ObjectWrapper<DOMNodeEventType
1308
1308
  }
1309
1309
 
1310
1310
  async saveNodeToTempVariable(): Promise<void> {
1311
- const remoteObjectForConsole = await this.resolveToObject();
1311
+ const runtimeModel = this.#domModel.runtimeModel();
1312
+ const frameId = this.frameId() ?? this.ownerDocument?.frameId();
1313
+ const executionContext =
1314
+ (frameId ? runtimeModel.executionContexts().find(context => context.frameId === frameId && context.isDefault) :
1315
+ null) ??
1316
+ runtimeModel.defaultExecutionContext();
1317
+ const remoteObjectForConsole = await this.resolveToObject(undefined, executionContext?.id);
1312
1318
  const consoleModel = this.#domModel.target().model(ConsoleModel);
1313
- await consoleModel?.saveToTempVariable(remoteObjectForConsole?.runtimeModel().defaultExecutionContext() ?? null,
1314
- remoteObjectForConsole);
1319
+ await consoleModel?.saveToTempVariable(executionContext, remoteObjectForConsole);
1315
1320
  }
1316
1321
 
1317
1322
  async scrollIntoView(): Promise<void> {
@@ -927,7 +927,8 @@ export class NetworkDispatcher implements ProtocolProxyApi.NetworkDispatcher {
927
927
  }
928
928
 
929
929
  requestForLoaderId(loaderId: Protocol.Network.LoaderId): NetworkRequest|null {
930
- return this.#requestsByLoaderId.get(loaderId) || null;
930
+ return this.#requestsByLoaderId.get(loaderId) ||
931
+ this.#multitargetNetworkManager.inflightMainResourceRequests.get(loaderId) || null;
931
932
  }
932
933
 
933
934
  resourceChangedPriority({requestId, newPriority}: Protocol.Network.ResourceChangedPriorityEvent): void {
@@ -275,7 +275,7 @@ export class ScopeVariableAnalysis {
275
275
  mappingLocationsForFunctionDeclaration(node, this.#sourceText));
276
276
  this.#addVariable('this', node.start, DefinitionKind.FIXED);
277
277
  this.#addVariable('arguments', node.start, DefinitionKind.FIXED);
278
- node.params.forEach(this.#processNodeAsDefinition.bind(this, DefinitionKind.LET, false));
278
+ node.params.forEach(this.#processNodeAsDefinition.bind(this, DefinitionKind.VAR, false));
279
279
  // Process the body of the block statement directly to avoid creating new scope.
280
280
  node.body.body.forEach(this.#processNode.bind(this));
281
281
  this.#popScope(true);
@@ -288,7 +288,7 @@ export class ScopeVariableAnalysis {
288
288
  this.#methodName = undefined;
289
289
  this.#addVariable('this', node.start, DefinitionKind.FIXED);
290
290
  this.#addVariable('arguments', node.start, DefinitionKind.FIXED);
291
- node.params.forEach(this.#processNodeAsDefinition.bind(this, DefinitionKind.LET, false));
291
+ node.params.forEach(this.#processNodeAsDefinition.bind(this, DefinitionKind.VAR, false));
292
292
  // Process the body of the block statement directly to avoid creating new scope.
293
293
  node.body.body.forEach(this.#processNode.bind(this));
294
294
  this.#popScope(true);
@@ -74,10 +74,6 @@ export const UIStrings = {
74
74
  * @description Warning displayed to developers that they are using the Fenced Frame API which has been deprecated and is scheduled to be removed.
75
75
  */
76
76
  FencedFrame: "Fenced Frame API is deprecated and scheduled for removal.",
77
- /**
78
- * @description A deprecation warning shown in the DevTools Issues tab. It's shown when one of the Protected Audience APIs like `navigator.joinAdInterestGroup`, `navigator.getInterestGroupAdAuctionData` or `navigator.runAdAuction` are called.
79
- */
80
- Fledge: "The Protected Audience API is deprecated and will be removed in a future release.",
81
77
  /**
82
78
  * @description Warning displayed to developers when the Geolocation API is used from an insecure origin (one that isn't localhost or doesn't use HTTPS) to notify them that this use is no longer supported.
83
79
  */
@@ -102,10 +98,6 @@ export const UIStrings = {
102
98
  * @description This warning occurs when an insecure context (e.g., HTTP) requests a private resource (not on open internet). This is done to mitigate the potential for CSRF and other attacks.
103
99
  */
104
100
  InsecurePrivateNetworkSubresourceRequest: "The website requested a subresource from a network that it could only access because of its users' privileged network position. These requests expose non-public devices and servers to the internet, increasing the risk of a cross-site request forgery (CSRF) attack, and/or information leakage. To mitigate these risks, Chrome deprecates requests to non-public subresources when initiated from non-secure contexts, and will start blocking them.",
105
- /**
106
- * @description This is a deprecated warning to developers that a field in a structure has been renamed.
107
- */
108
- InterestGroupDailyUpdateUrl: "The `dailyUpdateUrl` field of `InterestGroups` passed to `joinAdInterestGroup()` has been renamed to `updateUrl`, to more accurately reflect its behavior.",
109
101
  /**
110
102
  * @description Warning displayed to developers that instead of calling the `Intl.v8BreakIterator` constructor, which is not a standard JavaScript API, use ECMA402 standard API Intl.Segmenter shipped in end of 2020 instead.
111
103
  */
@@ -1160,7 +1160,8 @@ inspectorBackend.registerEnum("Page.SetTouchEmulationEnabledRequestConfiguration
1160
1160
  inspectorBackend.registerCommand("Page.setTouchEmulationEnabled", [{"name": "enabled", "type": "boolean", "optional": false, "description": "Whether the touch event emulation should be enabled.", "typeRef": null}, {"name": "configuration", "type": "string", "optional": true, "description": "Touch/gesture events configuration. Default: current platform.", "typeRef": "Page.SetTouchEmulationEnabledRequestConfiguration"}], [], "Toggles mouse event-based touch event emulation.");
1161
1161
  inspectorBackend.registerEnum("Page.StartScreencastRequestFormat", {Jpeg: "jpeg", Png: "png"});
1162
1162
  inspectorBackend.registerCommand("Page.startScreencast", [{"name": "format", "type": "string", "optional": true, "description": "Image compression format.", "typeRef": "Page.StartScreencastRequestFormat"}, {"name": "quality", "type": "number", "optional": true, "description": "Compression quality from range [0..100].", "typeRef": null}, {"name": "maxWidth", "type": "number", "optional": true, "description": "Maximum screenshot width.", "typeRef": null}, {"name": "maxHeight", "type": "number", "optional": true, "description": "Maximum screenshot height.", "typeRef": null}, {"name": "everyNthFrame", "type": "number", "optional": true, "description": "Send every n-th frame. Must be a positive integer.", "typeRef": null}, {"name": "maxFramesInFlight", "type": "number", "optional": true, "description": "Maximum number of frames sent until screencastFrameAck is required. Defaults to 3. Must be a positive integer.", "typeRef": null}, {"name": "sendLastFrame", "type": "boolean", "optional": true, "description": "By default, after screencastFrameAck arrives, the next produced frame is sent. Passing this flag enables storing the last produced frame in memory, which is immediately sent upon screencastFrameAck. This way, overall performance is traded for a better latency.", "typeRef": null}], [], "Starts sending each frame using the `screencastFrame` event.");
1163
- inspectorBackend.registerCommand("Page.startScreenRecording", [{"name": "audio", "type": "boolean", "optional": true, "description": "", "typeRef": null}, {"name": "maxWidth", "type": "number", "optional": true, "description": "Maximum frame width in pixels.", "typeRef": null}, {"name": "maxHeight", "type": "number", "optional": true, "description": "Maximum frame height in pixels.", "typeRef": null}, {"name": "frameRate", "type": "number", "optional": true, "description": "Maximum frame rate in frames per second.", "typeRef": null}], ["stream"], "Starts screencast video recording.");
1163
+ inspectorBackend.registerEnum("Page.StartScreenRecordingRequestCaptureArea", {Target: "target", BrowserWindow: "browserWindow"});
1164
+ inspectorBackend.registerCommand("Page.startScreenRecording", [{"name": "audio", "type": "boolean", "optional": true, "description": "", "typeRef": null}, {"name": "maxWidth", "type": "number", "optional": true, "description": "Maximum frame width in pixels.", "typeRef": null}, {"name": "maxHeight", "type": "number", "optional": true, "description": "Maximum frame height in pixels.", "typeRef": null}, {"name": "frameRate", "type": "number", "optional": true, "description": "Maximum frame rate in frames per second.", "typeRef": null}, {"name": "captureArea", "type": "string", "optional": true, "description": "The area to record. Defaults to `target`.", "typeRef": "Page.StartScreenRecordingRequestCaptureArea"}], ["stream"], "Starts screencast video recording.");
1164
1165
  inspectorBackend.registerCommand("Page.stopScreenRecording", [], ["stream"], "Stops screencast video recording.");
1165
1166
  inspectorBackend.registerCommand("Page.stopLoading", [], [], "Force the page stop all navigations and pending resource fetches.");
1166
1167
  inspectorBackend.registerCommand("Page.crash", [], [], "Crashes renderer on the IO thread, generates minidumps.");
@@ -4214,9 +4214,9 @@ export const generatedProperties: CSSProperty[] = [
4214
4214
  "thin"
4215
4215
  ],
4216
4216
  "longhands": [
4217
- "outline-color",
4217
+ "outline-width",
4218
4218
  "outline-style",
4219
- "outline-width"
4219
+ "outline-color"
4220
4220
  ],
4221
4221
  "name": "outline"
4222
4222
  },
@@ -16586,6 +16586,11 @@ export namespace Page {
16586
16586
  sendLastFrame?: boolean;
16587
16587
  }
16588
16588
 
16589
+ export const enum StartScreenRecordingRequestCaptureArea {
16590
+ Target = 'target',
16591
+ BrowserWindow = 'browserWindow',
16592
+ }
16593
+
16589
16594
  export interface StartScreenRecordingRequest {
16590
16595
  audio?: boolean;
16591
16596
  /**
@@ -16600,6 +16605,10 @@ export namespace Page {
16600
16605
  * Maximum frame rate in frames per second.
16601
16606
  */
16602
16607
  frameRate?: integer;
16608
+ /**
16609
+ * The area to record. Defaults to `target`.
16610
+ */
16611
+ captureArea?: StartScreenRecordingRequestCaptureArea;
16603
16612
  }
16604
16613
 
16605
16614
  export interface StartScreenRecordingResponse extends ProtocolResponseWithError {
@@ -3,23 +3,86 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  /**
6
- * @file Local debugging utilities.
6
+ * @file Local debugging utilities for DevTools AI subsystems.
7
7
  */
8
8
 
9
- export function isDebugMode(): boolean {
9
+ import * as Platform from '../../core/platform/platform.js';
10
+
11
+ export const DEVTOOLS_AI_DEBUG_STORAGE_KEY = 'devToolsAiDebug';
12
+
13
+ /**
14
+ * Configuration options for enabling DevTools AI debug logging in the console.
15
+ * Passed to `window.setDevToolsAIDebug(config)` and persisted in `localStorage`.
16
+ */
17
+ export interface DevToolsAIDebugConfig {
18
+ /**
19
+ * Enables console debug logging and structured log persistence for DevTools AI
20
+ * Assistance (`AiAgent`, `AiAgent2`, `AiUtils`, and `panels/ai_assistance/`).
21
+ */
22
+ assistance?: boolean;
23
+ /**
24
+ * Enables console debug logging for the AIDA and GCA host client and
25
+ * request/response translation layer (`AidaClient`, `GcaClient`, and
26
+ * `AidaGcaTranslation`).
27
+ */
28
+ gca?: boolean;
29
+ /**
30
+ * Enables console debug logging for AI Code Completion and AI Code Generation
31
+ * (`AiCodeCompletion` and `AiCodeGeneration`), replacing the separate
32
+ * `debug.ts` helpers in `models/ai_code_completion/` and
33
+ * `models/ai_code_generation/`.
34
+ */
35
+ codeGenComplete?: boolean;
36
+ }
37
+
38
+ /**
39
+ * Reads the persisted DevTools AI debug configuration from `localStorage`.
40
+ */
41
+ export function getDevToolsAIDebugConfig(): Required<DevToolsAIDebugConfig> {
10
42
  try {
11
- return Boolean(localStorage.getItem('debugAiAssistancePanelEnabled'));
43
+ const raw = Platform.HostRuntime.HOST_RUNTIME.getLocalStorage()?.getItem(DEVTOOLS_AI_DEBUG_STORAGE_KEY);
44
+ if (!raw) {
45
+ return {assistance: false, gca: false, codeGenComplete: false};
46
+ }
47
+ const parsed: unknown = JSON.parse(raw);
48
+ if (typeof parsed !== 'object' || parsed === null) {
49
+ return {assistance: false, gca: false, codeGenComplete: false};
50
+ }
51
+ const record = parsed as Record<string, unknown>;
52
+ return {
53
+ assistance: Boolean(record.assistance),
54
+ gca: Boolean(record.gca),
55
+ codeGenComplete: Boolean(record.codeGenComplete),
56
+ };
12
57
  } catch {
13
- return false;
58
+ return {assistance: false, gca: false, codeGenComplete: false};
14
59
  }
15
60
  }
16
61
 
17
- export function isStructuredLogEnabled(): boolean {
62
+ /**
63
+ * Merges `config` into the persisted `devToolsAiDebug` object in `localStorage`
64
+ * and logs the resulting state to the console.
65
+ */
66
+ export function setDevToolsAIDebug(config: DevToolsAIDebugConfig = {}): Required<DevToolsAIDebugConfig> {
67
+ const current = getDevToolsAIDebugConfig();
68
+ const nextConfig: Required<DevToolsAIDebugConfig> = {
69
+ assistance: config.assistance ?? current.assistance,
70
+ gca: config.gca ?? current.gca,
71
+ codeGenComplete: config.codeGenComplete ?? current.codeGenComplete,
72
+ };
73
+ const storage = Platform.HostRuntime.HOST_RUNTIME.getLocalStorage();
18
74
  try {
19
- return Boolean(localStorage.getItem('aiAssistanceStructuredLogEnabled'));
75
+ storage?.setItem(DEVTOOLS_AI_DEBUG_STORAGE_KEY, JSON.stringify(nextConfig));
20
76
  } catch {
21
- return false;
77
+ // Ignore storage write errors in restricted contexts.
22
78
  }
79
+ // eslint-disable-next-line no-console
80
+ console.log('DevTools AI debug config:', nextConfig);
81
+ return nextConfig;
82
+ }
83
+
84
+ export function isDebugMode(): boolean {
85
+ return getDevToolsAIDebugConfig().assistance;
23
86
  }
24
87
 
25
88
  export function debugLog(...log: unknown[]): void {
@@ -31,23 +94,65 @@ export function debugLog(...log: unknown[]): void {
31
94
  console.log(...log);
32
95
  }
33
96
 
34
- function setDebugAiAssistanceEnabled(enabled: boolean): void {
35
- if (enabled) {
36
- localStorage.setItem('debugAiAssistancePanelEnabled', 'true');
37
- } else {
38
- localStorage.removeItem('debugAiAssistancePanelEnabled');
39
- }
40
- setAiAssistanceStructuredLogEnabled(enabled);
97
+ export function isCodeGenCompleteDebugMode(): boolean {
98
+ return getDevToolsAIDebugConfig().codeGenComplete;
41
99
  }
42
- // @ts-expect-error
43
- globalThis.setDebugAiAssistanceEnabled = setDebugAiAssistanceEnabled;
44
100
 
45
- function setAiAssistanceStructuredLogEnabled(enabled: boolean): void {
46
- if (enabled) {
47
- localStorage.setItem('aiAssistanceStructuredLogEnabled', 'true');
48
- } else {
49
- localStorage.removeItem('aiAssistanceStructuredLogEnabled');
101
+ export function debugCodeGenCompleteLog(...log: unknown[]): void {
102
+ if (!isCodeGenCompleteDebugMode()) {
103
+ return;
50
104
  }
105
+
106
+ // eslint-disable-next-line no-console
107
+ console.log(...log);
51
108
  }
52
- // @ts-expect-error
109
+
110
+ /**
111
+ * @deprecated Use `setDevToolsAIDebug({assistance: enabled, gca: enabled})` instead.
112
+ */
113
+ export function setDebugAiAssistanceEnabled(enabled: boolean): void {
114
+ console.warn('setDebugAiAssistanceEnabled is deprecated and will be removed soon. ' +
115
+ `Use setDevToolsAIDebug({assistance: ${Boolean(enabled)}, gca: ${Boolean(enabled)}}) instead.`);
116
+ setDevToolsAIDebug({assistance: Boolean(enabled), gca: Boolean(enabled)});
117
+ }
118
+
119
+ /**
120
+ * @deprecated Use `setDevToolsAIDebug({assistance: enabled})` instead.
121
+ */
122
+ export function setAiAssistanceStructuredLogEnabled(enabled: boolean): void {
123
+ console.warn('setAiAssistanceStructuredLogEnabled is deprecated and will be removed soon. ' +
124
+ `Use setDevToolsAIDebug({assistance: ${Boolean(enabled)}}) instead.`);
125
+ setDevToolsAIDebug({assistance: Boolean(enabled)});
126
+ }
127
+
128
+ /**
129
+ * @deprecated Use `setDevToolsAIDebug({codeGenComplete: enabled})` instead.
130
+ */
131
+ export function setDebugAiCodeCompletionEnabled(enabled: boolean): void {
132
+ console.warn('setDebugAiCodeCompletionEnabled is deprecated and will be removed soon. ' +
133
+ `Use setDevToolsAIDebug({codeGenComplete: ${Boolean(enabled)}}) instead.`);
134
+ setDevToolsAIDebug({codeGenComplete: Boolean(enabled)});
135
+ }
136
+
137
+ /**
138
+ * @deprecated Use `setDevToolsAIDebug({codeGenComplete: enabled})` instead.
139
+ */
140
+ export function setDebugAiCodeGenerationEnabled(enabled: boolean): void {
141
+ console.warn('setDebugAiCodeGenerationEnabled is deprecated and will be removed soon. ' +
142
+ `Use setDevToolsAIDebug({codeGenComplete: ${Boolean(enabled)}}) instead.`);
143
+ setDevToolsAIDebug({codeGenComplete: Boolean(enabled)});
144
+ }
145
+
146
+ declare global {
147
+ var setDevToolsAIDebug: (config?: DevToolsAIDebugConfig) => Required<DevToolsAIDebugConfig>;
148
+ var setDebugAiAssistanceEnabled: (enabled: boolean) => void;
149
+ var setAiAssistanceStructuredLogEnabled: (enabled: boolean) => void;
150
+ var setDebugAiCodeCompletionEnabled: (enabled: boolean) => void;
151
+ var setDebugAiCodeGenerationEnabled: (enabled: boolean) => void;
152
+ }
153
+
154
+ globalThis.setDevToolsAIDebug = setDevToolsAIDebug;
155
+ globalThis.setDebugAiAssistanceEnabled = setDebugAiAssistanceEnabled;
53
156
  globalThis.setAiAssistanceStructuredLogEnabled = setAiAssistanceStructuredLogEnabled;
157
+ globalThis.setDebugAiCodeCompletionEnabled = setDebugAiCodeCompletionEnabled;
158
+ globalThis.setDebugAiCodeGenerationEnabled = setDebugAiCodeGenerationEnabled;
@@ -139,7 +139,7 @@ To aid debugging, you can enable the AI Assistance logging. This setting is stor
139
139
  1. Load up your local DevTools in Canary
140
140
  2. Load the AI Assistance Panel
141
141
  3. Open DevTools on DevTools.
142
- 4. In the console, run `setDebugAiAssistanceEnabled(true)`.
142
+ 4. In the console, run `setDevToolsAIDebug({assistance: true})`.
143
143
 
144
144
  Now, when interacting with the AI and sending requests, you will see output logged to the console. You can use the `debugLog` helper to add your own logging as you are building out your feature.
145
145
 
@@ -3,7 +3,7 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  import * as Host from '../../../core/host/host.js';
6
- import type * as Platform from '../../../core/platform/platform.js';
6
+ import * as Platform from '../../../core/platform/platform.js';
7
7
  import * as Root from '../../../core/root/root.js';
8
8
  import * as SDK from '../../../core/sdk/sdk.js';
9
9
  import type * as TextUtils from '../../../core/text_utils/text_utils.js';
@@ -22,7 +22,7 @@ import {
22
22
  type ToolName,
23
23
  } from '../tools/Tool.js';
24
24
 
25
- const {debugLog, isStructuredLogEnabled} = AiUtils.Debug;
25
+ const {debugLog, isDebugMode} = AiUtils.Debug;
26
26
 
27
27
  type UrlString = Platform.DevToolsPath.UrlString;
28
28
  const MAX_SUGGESTION_LENGTH = 200;
@@ -239,6 +239,7 @@ export interface SideEffectResponse extends ToolCallEvent {
239
239
  confirm: (decision: PermissionDecision) => void;
240
240
  permissionPrompt?: PermissionPrompt;
241
241
  permissionTitle?: string;
242
+ toolName?: string;
242
243
  }
243
244
 
244
245
  /**
@@ -1155,7 +1156,7 @@ export abstract class AiAgent<T> {
1155
1156
  request = this.buildRequest(outcome.functionResponses, Host.AidaClient.Role.ROLE_UNSPECIFIED);
1156
1157
  }
1157
1158
 
1158
- if (isStructuredLogEnabled()) {
1159
+ if (isDebugMode()) {
1159
1160
  dispatchAiAssistanceDoneEvent();
1160
1161
  }
1161
1162
  return;
@@ -1178,6 +1179,8 @@ export abstract class AiAgent<T> {
1178
1179
  rpcId: Host.AidaClient.RpcGlobalId|undefined,
1179
1180
  ): AsyncGenerator<ResponseData, void, void> {
1180
1181
  if (!textResponse) {
1182
+ debugLog('[AiAgent] Model returned an empty text response without tool calls:',
1183
+ {step: stepIndex + 1, rpcId, functionCalls});
1181
1184
  yield this.#createErrorResponse(ErrorType.UNKNOWN);
1182
1185
  return;
1183
1186
  }
@@ -1457,6 +1460,7 @@ export abstract class AiAgent<T> {
1457
1460
  javascriptCode,
1458
1461
  permissionPrompt: call.permissionPrompt,
1459
1462
  permissionTitle: call.permissionTitle,
1463
+ toolName: name,
1460
1464
  };
1461
1465
 
1462
1466
  let decision = PermissionDecision.REJECT;
@@ -1560,13 +1564,14 @@ export abstract class AiAgent<T> {
1560
1564
  };
1561
1565
  }
1562
1566
 
1563
- if (isStructuredLogEnabled() && aidaResponse) {
1567
+ if (isDebugMode() && aidaResponse) {
1564
1568
  this.#structuredLog.push({
1565
1569
  request: structuredClone(request),
1566
1570
  aidaResponse,
1567
1571
  });
1568
1572
  try {
1569
- localStorage.setItem('aiAssistanceStructuredLog', JSON.stringify(this.#structuredLog));
1573
+ Platform.HostRuntime.HOST_RUNTIME.getLocalStorage()?.setItem('aiAssistanceStructuredLog',
1574
+ JSON.stringify(this.#structuredLog));
1570
1575
  } catch (err) {
1571
1576
  console.warn('Failed to write to local storage "aiAssistanceStructuredLog":', err);
1572
1577
  }
@@ -78,7 +78,7 @@ Content:
78
78
  "properties": {
79
79
  "code": {
80
80
  "type": 1,
81
- "description": "JavaScript code snippet to run on the inspected page. Make sure the code is formatted for readability.\n\n# Instructions\n\n* To return data, define a top-level `data` variable and populate it with data you want to get. Only JSON-serializable objects can be assigned to `data`.\n* $0 refers to the currently selected DOM node (or document body if none selected).\n* **CRITICAL** Do not call `console` methods (e.g., `console.log`, `console.warn`, `console.error`) by default when returning data via `data`.\n* **CRITICAL** Never assume a selector for the elements unless you verified your knowledge.\n* **CRITICAL** Variables from previous function calls are not available in subsequent calls.\n* **CRITICAL** Keep code concise (max 40 lines, 120 characters per line, and 2,500 characters). Split complex logic into multiple steps.\n* **CRITICAL** Network requests (e.g., fetch, XMLHttpRequest) are disabled and cannot be made.\n\nFor example, to query DOM elements:\n\n```\nconst data = {\n title: document.title,\n elementText: $0?.textContent?.trim(),\n childCount: $0?.children.length,\n};\n```\n"
81
+ "description": "JavaScript code snippet to run on the inspected page. Make sure the code is formatted for readability.\n\n# Instructions\n\n* To return data, define a top-level `data` variable and populate it with data you want to get. Only JSON-serializable objects can be assigned to `data`.\n* $0 refers to the currently selected DOM node (or document body if none selected).\n* **CRITICAL** Do not call `console` methods (e.g., `console.log`, `console.warn`, `console.error`) by default when returning data via `data`.\n* **CRITICAL** Never assume a selector for the elements unless you verified your knowledge.\n* **CRITICAL** Variables from previous function calls are not available in subsequent calls.\n* **CRITICAL** Keep code concise (max 40 lines, max 120 characters per line, and max 2,500 total characters). To stay well under 120 characters per line:\n - Put each statement, object property, array item, and `&&`/`||` condition on its own line.\n - Extract long CSS selectors or strings into a variable (or `.join(', ')` array) before calling `querySelectorAll`.\n - Store intermediate DOM lookups (`getComputedStyle`, `getAttribute`) in short local variables instead of chaining them on one line.\n - Split complex logic into multiple steps.\n* **CRITICAL** Network requests (e.g., fetch, XMLHttpRequest) are disabled and cannot be made.\n\nFor example, to query DOM elements:\n\n```\nconst data = {\n title: document.title,\n elementText: $0?.textContent?.trim(),\n childCount: $0?.children.length,\n};\n```\n"
82
82
  },
83
83
  "explanation": {
84
84
  "type": 1,
@@ -127,16 +127,17 @@ ${await this.describe()}`;
127
127
  const textChildNodes = childNodes.filter(childNode => childNode.nodeType() === SDK.DOMModel.NodeType.TEXT_NODE);
128
128
  const elementChildNodes =
129
129
  childNodes.filter(childNode => childNode.nodeType() === SDK.DOMModel.NodeType.ELEMENT_NODE);
130
+ const formattedChildren =
131
+ elementChildNodes.map(node => `\`${node.simpleSelector()}\` (uid=${node.backendNodeId()})`).join(', ');
130
132
  switch (elementChildNodes.length) {
131
133
  case 0:
132
134
  output += '\n* It doesn\'t have any child element nodes';
133
135
  break;
134
136
  case 1:
135
- output += `\n* It only has 1 child element node: \`${elementChildNodes[0].simpleSelector()}\``;
137
+ output += `\n* It only has 1 child element node: ${formattedChildren}`;
136
138
  break;
137
139
  default:
138
- output += `\n* It has ${elementChildNodes.length} child element nodes: ${
139
- elementChildNodes.map(node => `\`${node.simpleSelector()}\` (uid=${node.backendNodeId()})`).join(', ')}`;
140
+ output += `\n* It has ${elementChildNodes.length} child element nodes: ${formattedChildren}`;
140
141
  }
141
142
 
142
143
  switch (textChildNodes.length) {