chrome-devtools-frontend 1.0.1543472 → 1.0.1544076

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 (109) hide show
  1. package/AUTHORS +1 -0
  2. package/front_end/core/host/AidaClient.ts +10 -7
  3. package/front_end/core/host/DispatchHttpRequestClient.ts +18 -3
  4. package/front_end/core/root/Runtime.ts +8 -7
  5. package/front_end/core/sdk/CPUThrottlingManager.ts +0 -4
  6. package/front_end/core/sdk/CSSMatchedStyles.ts +7 -9
  7. package/front_end/core/sdk/CSSModel.ts +1 -1
  8. package/front_end/core/sdk/CSSRule.ts +18 -6
  9. package/front_end/core/sdk/ChildTargetManager.ts +2 -2
  10. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts +2 -0
  11. package/front_end/entrypoints/main/MainImpl.ts +0 -16
  12. package/front_end/foundation/Universe.ts +12 -1
  13. package/front_end/models/ai_assistance/agents/AiAgent.ts +10 -8
  14. package/front_end/models/ai_assistance/agents/PatchAgent.ts +7 -1
  15. package/front_end/models/ai_assistance/agents/PerformanceAgent.ts +0 -5
  16. package/front_end/models/ai_assistance/agents/StylingAgent.ts +4 -8
  17. package/front_end/models/ai_code_completion/AiCodeCompletion.ts +1 -1
  18. package/front_end/models/ai_code_generation/AiCodeGeneration.ts +5 -3
  19. package/front_end/models/bindings/CSSWorkspaceBinding.ts +8 -7
  20. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +9 -8
  21. package/front_end/models/bindings/ResourceMapping.ts +57 -15
  22. package/front_end/models/live-metrics/LiveMetrics.ts +12 -20
  23. package/front_end/panels/accessibility/AccessibilityNodeView.ts +6 -2
  24. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +1 -1
  25. package/front_end/panels/ai_assistance/components/ChatView.ts +2 -4
  26. package/front_end/panels/ai_assistance/components/PerformanceAgentMarkdownRenderer.ts +2 -1
  27. package/front_end/panels/animation/AnimationTimeline.ts +6 -6
  28. package/front_end/panels/application/components/ReportsGrid.ts +7 -2
  29. package/front_end/panels/application/components/SharedStorageAccessGrid.ts +5 -3
  30. package/front_end/panels/application/components/TrustTokensView.ts +7 -1
  31. package/front_end/panels/application/preloading/PreloadingView.ts +10 -4
  32. package/front_end/panels/application/preloading/components/PreloadingDisabledInfobar.ts +7 -11
  33. package/front_end/panels/application/preloading/components/UsedPreloadingView.ts +15 -3
  34. package/front_end/panels/browser_debugger/DOMBreakpointsSidebarPane.ts +12 -13
  35. package/front_end/panels/{elements → common}/DOMLinkifier.ts +6 -6
  36. package/front_end/panels/common/common.ts +1 -0
  37. package/front_end/panels/console/ConsoleViewMessage.ts +4 -4
  38. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +2 -1
  39. package/front_end/panels/elements/ElementsTreeElement.ts +3 -1
  40. package/front_end/panels/elements/StylePropertiesSection.ts +52 -15
  41. package/front_end/panels/elements/StylePropertyTreeElement.ts +8 -3
  42. package/front_end/panels/elements/StylesSidebarPane.ts +24 -14
  43. package/front_end/panels/elements/elements-meta.ts +11 -2
  44. package/front_end/panels/elements/elements.ts +0 -3
  45. package/front_end/panels/explain/components/ConsoleInsight.ts +31 -20
  46. package/front_end/panels/issues/AffectedResourcesView.ts +2 -1
  47. package/front_end/panels/lighthouse/LighthouseReportRenderer.ts +2 -1
  48. package/front_end/panels/network/NetworkLogView.ts +1 -1
  49. package/front_end/panels/recorder/RecorderController.ts +7 -1
  50. package/front_end/panels/sources/AiCodeCompletionPlugin.ts +42 -294
  51. package/front_end/panels/sources/DebuggerPausedMessage.ts +3 -3
  52. package/front_end/panels/sources/SourcesPanel.ts +5 -1
  53. package/front_end/panels/timeline/TimelineUIUtils.ts +3 -2
  54. package/front_end/panels/timeline/components/LiveMetricsView.ts +7 -4
  55. package/front_end/panels/timeline/components/insights/NodeLink.ts +3 -2
  56. package/front_end/third_party/puppeteer/README.chromium +2 -2
  57. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts +1 -0
  58. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
  59. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.js +4 -1
  60. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/HTTPRequest.js.map +1 -1
  61. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.d.ts +1 -0
  62. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.d.ts.map +1 -1
  63. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.js +8 -0
  64. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkEventManager.js.map +1 -1
  65. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
  66. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.js +22 -0
  67. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/NetworkManager.js.map +1 -1
  68. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
  69. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.d.ts +3 -3
  70. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js +3 -3
  71. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/revisions.js.map +1 -1
  72. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
  73. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  74. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  75. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +34 -6
  76. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts +1 -0
  77. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.d.ts.map +1 -1
  78. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.js +4 -1
  79. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/HTTPRequest.js.map +1 -1
  80. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.d.ts +1 -0
  81. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.d.ts.map +1 -1
  82. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.js +8 -0
  83. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkEventManager.js.map +1 -1
  84. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.d.ts.map +1 -1
  85. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.js +22 -0
  86. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/NetworkManager.js.map +1 -1
  87. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.d.ts +3 -3
  88. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js +3 -3
  89. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/revisions.js.map +1 -1
  90. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  91. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  92. package/front_end/third_party/puppeteer/package/package.json +2 -2
  93. package/front_end/third_party/puppeteer/package/src/cdp/HTTPRequest.ts +5 -1
  94. package/front_end/third_party/puppeteer/package/src/cdp/NetworkEventManager.ts +16 -1
  95. package/front_end/third_party/puppeteer/package/src/cdp/NetworkManager.ts +28 -0
  96. package/front_end/third_party/puppeteer/package/src/revisions.ts +3 -3
  97. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  98. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +8 -5
  99. package/front_end/ui/i18n/i18n.ts +16 -0
  100. package/front_end/ui/legacy/UIUtils.ts +1 -1
  101. package/front_end/ui/legacy/Widget.ts +56 -25
  102. package/front_end/ui/legacy/XLink.ts +0 -2
  103. package/front_end/ui/legacy/components/object_ui/ObjectPopoverHelper.ts +3 -1
  104. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +155 -198
  105. package/front_end/ui/legacy/inspectorCommon.css +0 -4
  106. package/mcp/mcp.ts +1 -0
  107. package/package.json +1 -1
  108. package/front_end/ui/components/expandable_list/ExpandableList.docs.ts +0 -30
  109. /package/front_end/panels/{elements → common}/domLinkifier.css +0 -0
package/AUTHORS CHANGED
@@ -18,6 +18,7 @@ Alex Ho <wjhe1016@gmail.com>
18
18
  Alexander Stammbach <alexander@stammbach.io>
19
19
  Alexey Rodionov <fluorescent.hallucinogen@gmail.com>
20
20
  Ameen Basha <ameenbasha111@gmail.com>
21
+ Ankit Kumar Sahu <sahuankit.murhu@gmail.com>
21
22
  Ankit Mishra <ankit.mishra131990@gmail.com>
22
23
  Anna Agoha <annaagoha@gmail.com>
23
24
  Anthony Xie <anthonyxie64@gmail.com>
@@ -707,13 +707,16 @@ export class AidaClient {
707
707
  return {generatedSamples, metadata};
708
708
  }
709
709
 
710
- async generateCode(request: GenerateCodeRequest): Promise<GenerateCodeResponse|null> {
711
- const response = await DispatchHttpRequestClient.makeHttpRequest<GenerateCodeResponse>({
712
- service: SERVICE_NAME,
713
- path: '/v1/aida:generateCode',
714
- method: 'POST',
715
- body: JSON.stringify(request),
716
- });
710
+ async generateCode(request: GenerateCodeRequest, options?: {signal?: AbortSignal}):
711
+ Promise<GenerateCodeResponse|null> {
712
+ const response = await DispatchHttpRequestClient.makeHttpRequest<GenerateCodeResponse>(
713
+ {
714
+ service: SERVICE_NAME,
715
+ path: '/v1/aida:generateCode',
716
+ method: 'POST',
717
+ body: JSON.stringify(request),
718
+ },
719
+ options);
717
720
 
718
721
  return response;
719
722
  }
@@ -8,6 +8,7 @@ import type {DispatchHttpRequestRequest, DispatchHttpRequestResult} from './Insp
8
8
  export enum ErrorType {
9
9
  HTTP_RESPONSE_UNAVAILABLE = 'HTTP_RESPONSE_UNAVAILABLE',
10
10
  NOT_FOUND = 'NOT_FOUND',
11
+ ABORT = 'ABORT',
11
12
  }
12
13
 
13
14
  export class DispatchHttpRequestError extends Error {
@@ -16,9 +17,23 @@ export class DispatchHttpRequestError extends Error {
16
17
  }
17
18
  }
18
19
 
19
- export async function makeHttpRequest<R>(request: DispatchHttpRequestRequest): Promise<R> {
20
- const response = await new Promise<DispatchHttpRequestResult>(resolve => {
21
- InspectorFrontendHostInstance.dispatchHttpRequest(request, resolve);
20
+ export async function makeHttpRequest<R>(
21
+ request: DispatchHttpRequestRequest, options?: {signal?: AbortSignal}): Promise<R> {
22
+ const signal = options?.signal;
23
+ if (signal?.aborted) {
24
+ throw new DispatchHttpRequestError(ErrorType.ABORT);
25
+ }
26
+
27
+ const response = await new Promise<DispatchHttpRequestResult>((resolve, reject) => {
28
+ const onAbort = (): void => {
29
+ reject(new DispatchHttpRequestError(ErrorType.ABORT));
30
+ };
31
+
32
+ signal?.addEventListener('abort', onAbort, {once: true});
33
+ InspectorFrontendHostInstance.dispatchHttpRequest(request, result => {
34
+ signal?.removeEventListener('abort', onAbort);
35
+ resolve(result);
36
+ });
22
37
  });
23
38
 
24
39
  debugLog({request, response});
@@ -70,21 +70,22 @@ export class Runtime {
70
70
  runtimeInstance = undefined;
71
71
  }
72
72
 
73
- static queryParamsObject: URLSearchParams;
73
+ static #queryParamsObject: URLSearchParams;
74
74
 
75
- static getSearchParams(): URLSearchParams {
76
- if (!Runtime.queryParamsObject) {
77
- Runtime.queryParamsObject = new URLSearchParams(location.search);
75
+ static #getSearchParams(): URLSearchParams|null {
76
+ // TODO(crbug.com/451502260): Find a more explicit way to support running in Node.js
77
+ if (!Runtime.#queryParamsObject && 'location' in globalThis) {
78
+ Runtime.#queryParamsObject = new URLSearchParams(location.search);
78
79
  }
79
- return Runtime.queryParamsObject;
80
+ return Runtime.#queryParamsObject;
80
81
  }
81
82
 
82
83
  static queryParam(name: string): string|null {
83
- return Runtime.getSearchParams().get(name);
84
+ return Runtime.#getSearchParams()?.get(name) ?? null;
84
85
  }
85
86
 
86
87
  static setQueryParamForTesting(name: string, value: string): void {
87
- Runtime.getSearchParams().set(name, value);
88
+ Runtime.#getSearchParams()?.set(name, value);
88
89
  }
89
90
 
90
91
  static isNode(): boolean {
@@ -184,10 +184,6 @@ export interface EventTypes {
184
184
  [Events.HARDWARE_CONCURRENCY_CHANGED]: number;
185
185
  }
186
186
 
187
- export function throttlingManager(): CPUThrottlingManager {
188
- return CPUThrottlingManager.instance();
189
- }
190
-
191
187
  export enum CPUThrottlingRates {
192
188
  NO_THROTTLING = 1,
193
189
  MID_TIER_MOBILE = 4,
@@ -41,7 +41,7 @@ import {
41
41
  VariableMatcher
42
42
  } from './CSSPropertyParserMatchers.js';
43
43
  import {
44
- CSSFontPaletteValuesRule,
44
+ CSSAtRule,
45
45
  CSSFunctionRule,
46
46
  CSSKeyframeRule,
47
47
  CSSKeyframesRule,
@@ -210,7 +210,7 @@ export interface CSSMatchedStylesPayload {
210
210
  positionTryRules: Protocol.CSS.CSSPositionTryRule[];
211
211
  propertyRules: Protocol.CSS.CSSPropertyRule[];
212
212
  cssPropertyRegistrations: Protocol.CSS.CSSPropertyRegistration[];
213
- fontPaletteValuesRule: Protocol.CSS.CSSFontPaletteValuesRule|undefined;
213
+ atRules: Protocol.CSS.CSSAtRule[];
214
214
  animationStylesPayload: Protocol.CSS.CSSAnimationStyle[];
215
215
  transitionsStylePayload: Protocol.CSS.CSSStyle|null;
216
216
  inheritedAnimatedPayload: Protocol.CSS.InheritedAnimatedStyleEntry[];
@@ -305,8 +305,8 @@ export class CSSMatchedStyles {
305
305
  #pseudoDOMCascades?: Map<Protocol.DOM.PseudoType, DOMInheritanceCascade>;
306
306
  #customHighlightPseudoDOMCascades?: Map<string, DOMInheritanceCascade>;
307
307
  #functionRules: CSSFunctionRule[];
308
+ #atRules: CSSAtRule[];
308
309
  #functionRuleMap = new Map<string, CSSFunctionRule>();
309
- readonly #fontPaletteValuesRule: CSSFontPaletteValuesRule|undefined;
310
310
  #environmentVariables: Record<string, string> = {};
311
311
 
312
312
  static async create(payload: CSSMatchedStylesPayload): Promise<CSSMatchedStyles> {
@@ -323,9 +323,9 @@ export class CSSMatchedStyles {
323
323
  positionTryRules,
324
324
  propertyRules,
325
325
  cssPropertyRegistrations,
326
- fontPaletteValuesRule,
327
326
  activePositionFallbackIndex,
328
327
  functionRules,
328
+ atRules,
329
329
  }: CSSMatchedStylesPayload) {
330
330
  this.#cssModel = cssModel;
331
331
  this.#node = node;
@@ -338,11 +338,9 @@ export class CSSMatchedStyles {
338
338
  }
339
339
  this.#positionTryRules = positionTryRules.map(rule => new CSSPositionTryRule(cssModel, rule));
340
340
  this.#parentLayoutNodeId = parentLayoutNodeId;
341
- this.#fontPaletteValuesRule =
342
- fontPaletteValuesRule ? new CSSFontPaletteValuesRule(cssModel, fontPaletteValuesRule) : undefined;
343
-
344
341
  this.#activePositionFallbackIndex = activePositionFallbackIndex;
345
342
  this.#functionRules = functionRules.map(rule => new CSSFunctionRule(cssModel, rule));
343
+ this.#atRules = atRules.map(rule => new CSSAtRule(cssModel, rule));
346
344
  }
347
345
 
348
346
  private async init({
@@ -799,8 +797,8 @@ export class CSSMatchedStyles {
799
797
  return this.#functionRules;
800
798
  }
801
799
 
802
- fontPaletteValuesRule(): CSSFontPaletteValuesRule|undefined {
803
- return this.#fontPaletteValuesRule;
800
+ atRules(): CSSAtRule[] {
801
+ return this.#atRules;
804
802
  }
805
803
 
806
804
  keyframes(): CSSKeyframesRule[] {
@@ -358,7 +358,7 @@ export class CSSModel extends SDKModel<EventTypes> {
358
358
  propertyRules: matchedStylesResponse.cssPropertyRules ?? [],
359
359
  functionRules: matchedStylesResponse.cssFunctionRules ?? [],
360
360
  cssPropertyRegistrations: matchedStylesResponse.cssPropertyRegistrations ?? [],
361
- fontPaletteValuesRule: matchedStylesResponse.cssFontPaletteValuesRule,
361
+ atRules: matchedStylesResponse.cssAtRules ?? [],
362
362
  activePositionFallbackIndex: matchedStylesResponse.activePositionFallbackIndex ?? -1,
363
363
  animationStylesPayload: animatedStylesResponse?.animationStyles || [],
364
364
  inheritedAnimatedPayload: animatedStylesResponse?.inherited || [],
@@ -268,20 +268,32 @@ export class CSSPropertyRule extends CSSRule {
268
268
  }
269
269
  }
270
270
 
271
- export class CSSFontPaletteValuesRule extends CSSRule {
272
- readonly #paletteName: CSSValue;
273
- constructor(cssModel: CSSModel, payload: Protocol.CSS.CSSFontPaletteValuesRule) {
271
+ export class CSSAtRule extends CSSRule {
272
+ readonly #name: CSSValue|null;
273
+ readonly #type: string;
274
+ readonly #subsection: string|null;
275
+ constructor(cssModel: CSSModel, payload: Protocol.CSS.CSSAtRule) {
274
276
  super(cssModel, {
275
277
  origin: payload.origin,
276
278
  style: payload.style,
277
279
  header: styleSheetHeaderForRule(cssModel, payload),
278
280
  originTreeScopeNodeId: undefined
279
281
  });
280
- this.#paletteName = new CSSValue(payload.fontPaletteName);
282
+ this.#name = payload.name ? new CSSValue(payload.name) : null;
283
+ this.#type = payload.type;
284
+ this.#subsection = payload.subsection ?? null;
281
285
  }
282
286
 
283
- name(): CSSValue {
284
- return this.#paletteName;
287
+ name(): CSSValue|null {
288
+ return this.#name;
289
+ }
290
+
291
+ type(): string {
292
+ return this.#type;
293
+ }
294
+
295
+ subsection(): string|null {
296
+ return this.#subsection;
285
297
  }
286
298
  }
287
299
 
@@ -13,7 +13,7 @@ import {SDKModel} from './SDKModel.js';
13
13
  import {SecurityOriginManager} from './SecurityOriginManager.js';
14
14
  import {StorageKeyManager} from './StorageKeyManager.js';
15
15
  import {Capability, type Target, Type} from './Target.js';
16
- import {Events as TargetManagerEvents, TargetManager} from './TargetManager.js';
16
+ import {Events as TargetManagerEvents, type TargetManager} from './TargetManager.js';
17
17
 
18
18
  const UIStrings = {
19
19
  /**
@@ -126,7 +126,7 @@ export class ChildTargetManager extends SDKModel<EventTypes> implements Protocol
126
126
  }
127
127
 
128
128
  private fireAvailableTargetsChanged(): void {
129
- TargetManager.instance().dispatchEventToListeners(
129
+ this.#targetManager.dispatchEventToListeners(
130
130
  TargetManagerEvents.AVAILABLE_TARGETS_CHANGED, [...this.#targetInfos.values()]);
131
131
  }
132
132
 
@@ -46,6 +46,8 @@ export class HeapSnapshotLoader {
46
46
  }
47
47
 
48
48
  async buildSnapshot(secondWorker: MessagePort): Promise<JSHeapSnapshot> {
49
+ await this.parsingComplete;
50
+
49
51
  this.#snapshot = this.#snapshot || {};
50
52
 
51
53
  this.#progress.updateStatus('Processing snapshot…');
@@ -448,23 +448,7 @@ export class MainImpl {
448
448
  Workspace.FileManager.FileManager.instance({forceNew: true});
449
449
 
450
450
  Bindings.NetworkProject.NetworkProjectManager.instance();
451
- const resourceMapping = new Bindings.ResourceMapping.ResourceMapping(
452
- targetManager,
453
- Workspace.Workspace.WorkspaceImpl.instance(),
454
- );
455
451
  new Bindings.PresentationConsoleMessageHelper.PresentationConsoleMessageManager();
456
- Bindings.CSSWorkspaceBinding.CSSWorkspaceBinding.instance({
457
- forceNew: true,
458
- resourceMapping,
459
- targetManager,
460
- });
461
- Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance({
462
- forceNew: true,
463
- resourceMapping,
464
- targetManager,
465
- ignoreListManager: Workspace.IgnoreListManager.IgnoreListManager.instance(),
466
- workspace: Workspace.Workspace.WorkspaceImpl.instance(),
467
- });
468
452
  targetManager.setScopeTarget(targetManager.primaryPageTarget());
469
453
  UI.Context.Context.instance().addFlavorChangeListener(SDK.Target.Target, ({data}) => {
470
454
  const outermostTarget = data?.outermostTarget();
@@ -5,6 +5,7 @@
5
5
  import * as Common from '../core/common/common.js';
6
6
  import * as Root from '../core/root/root.js';
7
7
  import * as SDK from '../core/sdk/sdk.js';
8
+ import * as Bindings from '../models/bindings/bindings.js';
8
9
  import * as Workspace from '../models/workspace/workspace.js';
9
10
 
10
11
  export interface CreationOptions {
@@ -25,9 +26,19 @@ export class Universe {
25
26
 
26
27
  const targetManager = new SDK.TargetManager.TargetManager();
27
28
  this.context.set(SDK.TargetManager.TargetManager, targetManager);
28
- this.context.set(Workspace.Workspace.WorkspaceImpl, new Workspace.Workspace.WorkspaceImpl());
29
+
30
+ const workspace = new Workspace.Workspace.WorkspaceImpl();
31
+ this.context.set(Workspace.Workspace.WorkspaceImpl, workspace);
29
32
 
30
33
  const ignoreListManager = new Workspace.IgnoreListManager.IgnoreListManager(settings, targetManager);
31
34
  this.context.set(Workspace.IgnoreListManager.IgnoreListManager, ignoreListManager);
35
+
36
+ const resourceMapping = new Bindings.ResourceMapping.ResourceMapping(targetManager, workspace);
37
+ const cssWorkspaceBinding = new Bindings.CSSWorkspaceBinding.CSSWorkspaceBinding(resourceMapping, targetManager);
38
+ this.context.set(Bindings.CSSWorkspaceBinding.CSSWorkspaceBinding, cssWorkspaceBinding);
39
+
40
+ const debuggerWorkspaceBinding = new Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding(
41
+ resourceMapping, targetManager, ignoreListManager, workspace);
42
+ this.context.set(Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding, debuggerWorkspaceBinding);
32
43
  }
33
44
  }
@@ -204,6 +204,15 @@ export type FunctionCallHandlerResult<Result> = {
204
204
  requiresApproval: true,
205
205
  }|{error: string};
206
206
 
207
+ export interface FunctionHandlerOptions {
208
+ /**
209
+ * Shows that the user approved
210
+ * the execution if it was required
211
+ */
212
+ approved?: boolean;
213
+ signal?: AbortSignal;
214
+ }
215
+
207
216
  export interface FunctionDeclaration<Args extends Record<string, unknown>, ReturnType> {
208
217
  /**
209
218
  * Description of function, this is send to the LLM
@@ -228,14 +237,7 @@ export interface FunctionDeclaration<Args extends Record<string, unknown>, Retur
228
237
  /**
229
238
  * Function implementation that the LLM will try to execute,
230
239
  */
231
- handler: (args: Args, options?: {
232
- /**
233
- * Shows that the user approved
234
- * the execution if it was required
235
- */
236
- approved?: boolean,
237
- signal?: AbortSignal,
238
- }) => Promise<FunctionCallHandlerResult<ReturnType>>;
240
+ handler: (args: Args, options?: FunctionHandlerOptions) => Promise<FunctionCallHandlerResult<ReturnType>>;
239
241
  }
240
242
 
241
243
  interface AidaFetchResult {
@@ -151,7 +151,13 @@ export class PatchAgent extends AiAgent<Workspace.Workspace.Project> {
151
151
  return {
152
152
  result: {
153
153
  matches: await this.#project.searchFiles(
154
- args.query, args.caseSensitive, args.isRegex, {signal: options?.signal}),
154
+ args.query,
155
+ args.caseSensitive,
156
+ args.isRegex,
157
+ {
158
+ signal: options?.signal,
159
+ },
160
+ ),
155
161
  }
156
162
  };
157
163
  },
@@ -10,7 +10,6 @@ import * as Root from '../../../core/root/root.js';
10
10
  import * as SDK from '../../../core/sdk/sdk.js';
11
11
  import * as Tracing from '../../../services/tracing/tracing.js';
12
12
  import * as Trace from '../../trace/trace.js';
13
- import {ConversationType} from '../AiHistoryStorage.js';
14
13
  import {
15
14
  PerformanceInsightFormatter,
16
15
  } from '../data_formatters/PerformanceInsightFormatter.js';
@@ -323,10 +322,6 @@ export class PerformanceAgent extends AiAgent<AgentFocus> {
323
322
  };
324
323
  }
325
324
 
326
- getConversationType(): ConversationType {
327
- return ConversationType.PERFORMANCE;
328
- }
329
-
330
325
  async *
331
326
  handleContextDetails(context: ConversationContext<AgentFocus>|null): AsyncGenerator<ContextResponse, void, void> {
332
327
  if (!context) {
@@ -21,9 +21,10 @@ import {
21
21
  ConversationContext,
22
22
  type ConversationSuggestions,
23
23
  type FunctionCallHandlerResult,
24
+ type FunctionHandlerOptions,
24
25
  MultimodalInputType,
25
26
  type RequestOptions,
26
- ResponseType,
27
+ ResponseType
27
28
  } from './AiAgent.js';
28
29
 
29
30
  /*
@@ -268,11 +269,7 @@ export class StylingAgent extends AiAgent<SDK.DOMModel.DOMNode> {
268
269
  #createExtensionScope: CreateExtensionScopeFunction;
269
270
 
270
271
  constructor(opts: AgentOptions) {
271
- super({
272
- aidaClient: opts.aidaClient,
273
- serverSideLoggingEnabled: opts.serverSideLoggingEnabled,
274
- confirmSideEffectForTest: opts.confirmSideEffectForTest,
275
- });
272
+ super(opts);
276
273
 
277
274
  this.#changes = opts.changeManager || new ChangeManager();
278
275
  this.#execJs = opts.execJs ?? executeJsCode;
@@ -633,8 +630,7 @@ const data = {
633
630
  };
634
631
  }
635
632
 
636
- async executeAction(action: string, options?: {signal?: AbortSignal, approved?: boolean}):
637
- Promise<FunctionCallHandlerResult<unknown>> {
633
+ async executeAction(action: string, options?: FunctionHandlerOptions): Promise<FunctionCallHandlerResult<unknown>> {
638
634
  debugLog(`Action to execute: ${action}`);
639
635
 
640
636
  if (options?.approved === false) {
@@ -46,7 +46,7 @@ export interface Callbacks {
46
46
  }
47
47
 
48
48
  /* clang-format off */
49
- const consoleAdditionalContextFileContent = `/**
49
+ export const consoleAdditionalContextFileContent = `/**
50
50
  * This file describes the execution environment of the Chrome DevTools Console.
51
51
  * The code is JavaScript, but with special global functions and variables.
52
52
  * Top-level await is available.
@@ -73,6 +73,7 @@ export class AiCodeGeneration {
73
73
  inference_language: inferenceLanguage,
74
74
  temperature: validTemperature(this.#options.temperature),
75
75
  model_id: this.#options.modelId || undefined,
76
+ expect_code_output: true,
76
77
  },
77
78
  metadata: {
78
79
  disable_user_content_logging: !(this.#serverSideLoggingEnabled ?? false),
@@ -139,10 +140,11 @@ export class AiCodeGeneration {
139
140
  Host.userMetrics.actionTaken(Host.UserMetrics.Action.AiCodeGenerationSuggestionAccepted);
140
141
  }
141
142
 
142
- async generateCode(prompt: string, preamble: string, inferenceLanguage?: Host.AidaClient.AidaInferenceLanguage):
143
- Promise<Host.AidaClient.GenerateCodeResponse|null> {
143
+ async generateCode(
144
+ prompt: string, preamble: string, inferenceLanguage?: Host.AidaClient.AidaInferenceLanguage,
145
+ options?: {signal?: AbortSignal}): Promise<Host.AidaClient.GenerateCodeResponse|null> {
144
146
  const request = this.#buildRequest(prompt, preamble, inferenceLanguage);
145
- const response = await this.#aidaClient.generateCode(request);
147
+ const response = await this.#aidaClient.generateCode(request, options);
146
148
 
147
149
  debugLog({request, response});
148
150
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  import * as Common from '../../core/common/common.js';
6
6
  import * as Platform from '../../core/platform/platform.js';
7
+ import * as Root from '../../core/root/root.js';
7
8
  import * as SDK from '../../core/sdk/sdk.js';
8
9
  import type * as Workspace from '../workspace/workspace.js';
9
10
 
@@ -16,15 +17,14 @@ import type {ResourceMapping} from './ResourceMapping.js';
16
17
  import {SASSSourceMapping} from './SASSSourceMapping.js';
17
18
  import {StylesSourceMapping} from './StylesSourceMapping.js';
18
19
 
19
- let cssWorkspaceBindingInstance: CSSWorkspaceBinding|undefined;
20
-
21
20
  export class CSSWorkspaceBinding implements SDK.TargetManager.SDKModelObserver<SDK.CSSModel.CSSModel> {
22
21
  readonly #resourceMapping: ResourceMapping;
23
22
  readonly #modelToInfo: Map<SDK.CSSModel.CSSModel, ModelInfo>;
24
23
  readonly #liveLocationPromises: Set<Promise<unknown>>;
25
24
 
26
- private constructor(resourceMapping: ResourceMapping, targetManager: SDK.TargetManager.TargetManager) {
25
+ constructor(resourceMapping: ResourceMapping, targetManager: SDK.TargetManager.TargetManager) {
27
26
  this.#resourceMapping = resourceMapping;
27
+ this.#resourceMapping.cssWorkspaceBinding = this;
28
28
  this.#modelToInfo = new Map();
29
29
  targetManager.observeModels(SDK.CSSModel.CSSModel, this);
30
30
 
@@ -37,20 +37,21 @@ export class CSSWorkspaceBinding implements SDK.TargetManager.SDKModelObserver<S
37
37
  targetManager: SDK.TargetManager.TargetManager|null,
38
38
  } = {forceNew: null, resourceMapping: null, targetManager: null}): CSSWorkspaceBinding {
39
39
  const {forceNew, resourceMapping, targetManager} = opts;
40
- if (!cssWorkspaceBindingInstance || forceNew) {
40
+ if (forceNew) {
41
41
  if (!resourceMapping || !targetManager) {
42
42
  throw new Error(`Unable to create CSSWorkspaceBinding: resourceMapping and targetManager must be provided: ${
43
43
  new Error().stack}`);
44
44
  }
45
45
 
46
- cssWorkspaceBindingInstance = new CSSWorkspaceBinding(resourceMapping, targetManager);
46
+ Root.DevToolsContext.globalInstance().set(
47
+ CSSWorkspaceBinding, new CSSWorkspaceBinding(resourceMapping, targetManager));
47
48
  }
48
49
 
49
- return cssWorkspaceBindingInstance;
50
+ return Root.DevToolsContext.globalInstance().get(CSSWorkspaceBinding);
50
51
  }
51
52
 
52
53
  static removeInstance(): void {
53
- cssWorkspaceBindingInstance = undefined;
54
+ Root.DevToolsContext.globalInstance().delete(CSSWorkspaceBinding);
54
55
  }
55
56
 
56
57
  get modelToInfo(): Map<SDK.CSSModel.CSSModel, ModelInfo> {
@@ -4,6 +4,7 @@
4
4
 
5
5
  import * as Common from '../../core/common/common.js';
6
6
  import * as Platform from '../../core/platform/platform.js';
7
+ import * as Root from '../../core/root/root.js';
7
8
  import * as SDK from '../../core/sdk/sdk.js';
8
9
  import * as Protocol from '../../generated/protocol.js';
9
10
  import type * as StackTrace from '../stack_trace/stack_trace.js';
@@ -20,8 +21,6 @@ import {NetworkProject} from './NetworkProject.js';
20
21
  import type {ResourceMapping} from './ResourceMapping.js';
21
22
  import {type ResourceScriptFile, ResourceScriptMapping} from './ResourceScriptMapping.js';
22
23
 
23
- let debuggerWorkspaceBindingInstance: DebuggerWorkspaceBinding|undefined;
24
-
25
24
  export class DebuggerWorkspaceBinding implements SDK.TargetManager.SDKModelObserver<SDK.DebuggerModel.DebuggerModel> {
26
25
  readonly resourceMapping: ResourceMapping;
27
26
  readonly #debuggerModelToData: Map<SDK.DebuggerModel.DebuggerModel, ModelData>;
@@ -30,10 +29,11 @@ export class DebuggerWorkspaceBinding implements SDK.TargetManager.SDKModelObser
30
29
  readonly ignoreListManager: Workspace.IgnoreListManager.IgnoreListManager;
31
30
  readonly workspace: Workspace.Workspace.WorkspaceImpl;
32
31
 
33
- private constructor(
32
+ constructor(
34
33
  resourceMapping: ResourceMapping, targetManager: SDK.TargetManager.TargetManager,
35
34
  ignoreListManager: Workspace.IgnoreListManager.IgnoreListManager, workspace: Workspace.Workspace.WorkspaceImpl) {
36
35
  this.resourceMapping = resourceMapping;
36
+ this.resourceMapping.debuggerWorkspaceBinding = this;
37
37
  this.ignoreListManager = ignoreListManager;
38
38
  this.workspace = workspace;
39
39
 
@@ -68,22 +68,23 @@ export class DebuggerWorkspaceBinding implements SDK.TargetManager.SDKModelObser
68
68
  } = {forceNew: null, resourceMapping: null, targetManager: null, ignoreListManager: null, workspace: null}):
69
69
  DebuggerWorkspaceBinding {
70
70
  const {forceNew, resourceMapping, targetManager, ignoreListManager, workspace} = opts;
71
- if (!debuggerWorkspaceBindingInstance || forceNew) {
71
+ if (forceNew) {
72
72
  if (!resourceMapping || !targetManager || !ignoreListManager || !workspace) {
73
73
  throw new Error(
74
74
  `Unable to create DebuggerWorkspaceBinding: resourceMapping, targetManager and IgnoreLIstManager must be provided: ${
75
75
  new Error().stack}`);
76
76
  }
77
77
 
78
- debuggerWorkspaceBindingInstance =
79
- new DebuggerWorkspaceBinding(resourceMapping, targetManager, ignoreListManager, workspace);
78
+ Root.DevToolsContext.globalInstance().set(
79
+ DebuggerWorkspaceBinding,
80
+ new DebuggerWorkspaceBinding(resourceMapping, targetManager, ignoreListManager, workspace));
80
81
  }
81
82
 
82
- return debuggerWorkspaceBindingInstance;
83
+ return Root.DevToolsContext.globalInstance().get(DebuggerWorkspaceBinding);
83
84
  }
84
85
 
85
86
  static removeInstance(): void {
86
- debuggerWorkspaceBindingInstance = undefined;
87
+ Root.DevToolsContext.globalInstance().delete(DebuggerWorkspaceBinding);
87
88
  }
88
89
 
89
90
  private async computeAutoStepRanges(mode: SDK.DebuggerModel.StepMode, callFrame: SDK.DebuggerModel.CallFrame):