chrome-devtools-frontend 1.0.1605390 → 1.0.1606789
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.
- package/front_end/core/host/UserMetrics.ts +0 -1
- package/front_end/core/platform/api/HostRuntime.ts +9 -6
- package/front_end/core/platform/browser/HostRuntime.ts +2 -2
- package/front_end/core/platform/node/HostRuntime.ts +7 -7
- package/front_end/core/protocol_client/InspectorBackend.ts +4 -0
- package/front_end/core/root/ExperimentNames.ts +0 -1
- package/front_end/core/sdk/CrashReportContextModel.ts +28 -0
- package/front_end/core/sdk/sdk.ts +2 -2
- package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotWorkerDispatcher.ts +3 -3
- package/front_end/entrypoints/heap_snapshot_worker/heap_snapshot_worker-entrypoint.ts +5 -4
- package/front_end/entrypoints/main/MainImpl.ts +0 -101
- package/front_end/models/ai_assistance/ChangeManager.ts +6 -6
- package/front_end/models/ai_assistance/agents/AccessibilityAgent.ts +112 -5
- package/front_end/models/ai_assistance/agents/AiAgent.ts +0 -24
- package/front_end/models/ai_assistance/agents/ContextSelectionAgent.snapshot.txt +2 -2
- package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +6 -3
- package/front_end/models/ai_assistance/agents/ExecuteJavascript.ts +13 -1
- package/front_end/models/ai_assistance/agents/FileAgent.ts +15 -1
- package/front_end/models/ai_assistance/agents/NetworkAgent.ts +15 -1
- package/front_end/models/ai_assistance/agents/StylingAgent.ts +24 -15
- package/front_end/models/ai_assistance/ai_assistance.ts +0 -2
- package/front_end/models/javascript_metadata/NativeFunctions.js +1 -5
- package/front_end/models/web_mcp/WebMCPModel.ts +187 -0
- package/front_end/models/web_mcp/web_mcp.ts +9 -0
- package/front_end/panels/ai_assistance/AiAssistancePanel.ts +8 -1
- package/front_end/panels/ai_assistance/ai_assistance.ts +1 -0
- package/front_end/panels/ai_assistance/components/AccessibilityAgentMarkdownRenderer.ts +88 -0
- package/front_end/panels/ai_assistance/components/ChatMessage.ts +19 -3
- package/front_end/panels/ai_assistance/components/ChatView.ts +11 -4
- package/front_end/panels/ai_assistance/components/ExportForAgentsDialog.ts +12 -3
- package/front_end/panels/ai_assistance/components/chatMessage.css +10 -0
- package/front_end/panels/ai_assistance/components/chatView.css +0 -2
- package/front_end/panels/ai_assistance/components/exportForAgentsDialog.css +13 -0
- package/front_end/panels/application/WebMCPView.ts +126 -30
- package/front_end/panels/application/webMCPView.css +28 -2
- package/front_end/panels/elements/ElementsTreeElement.ts +1 -1
- package/front_end/panels/elements/StylePropertiesSection.ts +0 -4
- package/front_end/panels/elements/elements.ts +3 -0
- package/front_end/panels/elements/stylePropertiesTreeOutline.css +7 -0
- package/front_end/panels/lighthouse/LighthousePanel.ts +7 -1
- package/front_end/panels/lighthouse/LighthouseProtocolService.ts +25 -2
- package/front_end/panels/profiler/HeapSnapshotProxy.ts +2 -6
- package/front_end/panels/profiler/HeapSnapshotView.ts +7 -16
- package/front_end/panels/profiler/ProfileHeader.ts +1 -4
- package/front_end/panels/protocol_monitor/ProtocolMonitor.ts +27 -22
- package/front_end/panels/timeline/TimelinePanel.ts +0 -153
- package/front_end/panels/timeline/TimelineTreeView.ts +11 -1
- package/front_end/panels/timeline/TimelineUIUtils.ts +2 -1
- package/front_end/third_party/chromium/README.chromium +1 -1
- package/front_end/ui/components/markdown_view/CodeBlock.ts +47 -1
- package/front_end/ui/components/markdown_view/codeBlock.css +8 -0
- package/front_end/ui/legacy/TabbedPane.ts +123 -3
- package/front_end/ui/legacy/Widget.ts +67 -28
- package/front_end/ui/legacy/components/source_frame/JSONView.ts +1 -1
- package/front_end/ui/legacy/components/utils/jsUtils.css +2 -0
- package/front_end/ui/legacy/infobar.css +1 -0
- package/front_end/ui/visual_logging/KnownContextValues.ts +0 -1
- package/package.json +1 -1
- package/front_end/core/sdk/WebMCPModel.ts +0 -159
- package/front_end/models/ai_assistance/ConversationHandler.ts +0 -325
|
@@ -1,325 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 The Chromium Authors
|
|
2
|
-
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
-
// found in the LICENSE file.
|
|
4
|
-
|
|
5
|
-
import * as Common from '../../core/common/common.js';
|
|
6
|
-
import * as Host from '../../core/host/host.js';
|
|
7
|
-
import * as i18n from '../../core/i18n/i18n.js';
|
|
8
|
-
import * as Platform from '../../core/platform/platform.js';
|
|
9
|
-
import * as Root from '../../core/root/root.js';
|
|
10
|
-
import * as SDK from '../../core/sdk/sdk.js';
|
|
11
|
-
import * as NetworkTimeCalculator from '../network_time_calculator/network_time_calculator.js';
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
type AiAgent,
|
|
15
|
-
type ExternalRequestResponse,
|
|
16
|
-
ExternalRequestResponseType,
|
|
17
|
-
ResponseType
|
|
18
|
-
} from './agents/AiAgent.js';
|
|
19
|
-
import {NetworkAgent, RequestContext} from './agents/NetworkAgent.js';
|
|
20
|
-
import type {PerformanceTraceContext} from './agents/PerformanceAgent.js';
|
|
21
|
-
import {NodeContext, StylingAgent} from './agents/StylingAgent.js';
|
|
22
|
-
import {AiConversation, CONTEXT_TITLE} from './AiConversation.js';
|
|
23
|
-
import {
|
|
24
|
-
ConversationType,
|
|
25
|
-
} from './AiHistoryStorage.js';
|
|
26
|
-
import {getDisabledReasons} from './AiUtils.js';
|
|
27
|
-
|
|
28
|
-
interface ExternalStylingRequestParameters {
|
|
29
|
-
conversationType: ConversationType.STYLING;
|
|
30
|
-
prompt: string;
|
|
31
|
-
selector?: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface ExternalNetworkRequestParameters {
|
|
35
|
-
conversationType: ConversationType.NETWORK;
|
|
36
|
-
prompt: string;
|
|
37
|
-
requestUrl: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface ExternalPerformanceAIConversationData {
|
|
41
|
-
conversationHandler: ConversationHandler;
|
|
42
|
-
conversation: AiConversation;
|
|
43
|
-
selected: PerformanceTraceContext;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface ExternalPerformanceRequestParameters {
|
|
47
|
-
conversationType: ConversationType.PERFORMANCE;
|
|
48
|
-
prompt: string;
|
|
49
|
-
data: ExternalPerformanceAIConversationData;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/*
|
|
53
|
-
* Strings that don't need to be translated at this time.
|
|
54
|
-
*/
|
|
55
|
-
const UIStringsNotTranslate = {
|
|
56
|
-
/**
|
|
57
|
-
* @description Error message shown when AI assistance is not enabled in DevTools settings.
|
|
58
|
-
*/
|
|
59
|
-
enableInSettings: 'For AI features to be available, you need to enable AI assistance in DevTools settings.',
|
|
60
|
-
} as const;
|
|
61
|
-
|
|
62
|
-
const lockedString = i18n.i18n.lockedString;
|
|
63
|
-
|
|
64
|
-
function isAiAssistanceServerSideLoggingEnabled(): boolean {
|
|
65
|
-
return !Root.Runtime.hostConfig.aidaAvailability?.disallowLogging;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function inspectElementBySelector(selector: string): Promise<SDK.DOMModel.DOMNode|null> {
|
|
69
|
-
const whitespaceTrimmedQuery = selector.trim();
|
|
70
|
-
if (!whitespaceTrimmedQuery.length) {
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const showUAShadowDOM = Common.Settings.Settings.instance().moduleSetting('show-ua-shadow-dom').get();
|
|
75
|
-
const domModels = SDK.TargetManager.TargetManager.instance().models(SDK.DOMModel.DOMModel, {scoped: true});
|
|
76
|
-
|
|
77
|
-
const performSearchPromises =
|
|
78
|
-
domModels.map(domModel => domModel.performSearch(whitespaceTrimmedQuery, showUAShadowDOM));
|
|
79
|
-
const resultCounts = await Promise.all(performSearchPromises);
|
|
80
|
-
|
|
81
|
-
// If the selector matches multiple times, this returns the first match.
|
|
82
|
-
const index = resultCounts.findIndex(value => value > 0);
|
|
83
|
-
if (index >= 0) {
|
|
84
|
-
return await domModels[index].searchResult(0);
|
|
85
|
-
}
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async function inspectNetworkRequestByUrl(selector: string): Promise<SDK.NetworkRequest.NetworkRequest|null> {
|
|
90
|
-
const networkManagers =
|
|
91
|
-
SDK.TargetManager.TargetManager.instance().models(SDK.NetworkManager.NetworkManager, {scoped: true});
|
|
92
|
-
|
|
93
|
-
const results = networkManagers
|
|
94
|
-
.map(networkManager => {
|
|
95
|
-
let request = networkManager.requestForURL(Platform.DevToolsPath.urlString`${selector}`);
|
|
96
|
-
if (!request && selector.at(-1) === '/') {
|
|
97
|
-
request =
|
|
98
|
-
networkManager.requestForURL(Platform.DevToolsPath.urlString`${selector.slice(0, -1)}`);
|
|
99
|
-
} else if (!request && selector.at(-1) !== '/') {
|
|
100
|
-
request = networkManager.requestForURL(Platform.DevToolsPath.urlString`${selector}/`);
|
|
101
|
-
}
|
|
102
|
-
return request;
|
|
103
|
-
})
|
|
104
|
-
.filter(req => !!req);
|
|
105
|
-
const request = results.at(0);
|
|
106
|
-
|
|
107
|
-
return request ?? null;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
let conversationHandlerInstance: ConversationHandler|undefined;
|
|
111
|
-
|
|
112
|
-
export class ConversationHandler extends Common.ObjectWrapper.ObjectWrapper<EventTypes> {
|
|
113
|
-
#aiAssistanceEnabledSetting: Common.Settings.Setting<boolean>|undefined;
|
|
114
|
-
#aidaClient: Host.AidaClient.AidaClient;
|
|
115
|
-
#aidaAvailability?: Host.AidaClient.AidaAccessPreconditions;
|
|
116
|
-
|
|
117
|
-
private constructor(
|
|
118
|
-
aidaClient: Host.AidaClient.AidaClient, aidaAvailability?: Host.AidaClient.AidaAccessPreconditions) {
|
|
119
|
-
super();
|
|
120
|
-
this.#aidaClient = aidaClient;
|
|
121
|
-
this.#aidaAvailability = aidaAvailability;
|
|
122
|
-
this.#aiAssistanceEnabledSetting = this.#getAiAssistanceEnabledSetting();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
static instance(opts?: {
|
|
126
|
-
aidaClient?: Host.AidaClient.AidaClient,
|
|
127
|
-
aidaAvailability?: Host.AidaClient.AidaAccessPreconditions,
|
|
128
|
-
forceNew?: boolean,
|
|
129
|
-
}): ConversationHandler {
|
|
130
|
-
if (opts?.forceNew || conversationHandlerInstance === undefined) {
|
|
131
|
-
const aidaClient = opts?.aidaClient ?? new Host.AidaClient.AidaClient();
|
|
132
|
-
conversationHandlerInstance = new ConversationHandler(aidaClient, opts?.aidaAvailability);
|
|
133
|
-
}
|
|
134
|
-
return conversationHandlerInstance;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
static removeInstance(): void {
|
|
138
|
-
conversationHandlerInstance = undefined;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
get aidaClient(): Host.AidaClient.AidaClient {
|
|
142
|
-
return this.#aidaClient;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
#getAiAssistanceEnabledSetting(): Common.Settings.Setting<boolean>|undefined {
|
|
146
|
-
try {
|
|
147
|
-
return Common.Settings.moduleSetting('ai-assistance-enabled') as Common.Settings.Setting<boolean>;
|
|
148
|
-
} catch {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
async #getDisabledReasons(): Promise<Platform.UIString.LocalizedString[]> {
|
|
154
|
-
if (this.#aidaAvailability === undefined) {
|
|
155
|
-
this.#aidaAvailability = await Host.AidaClient.AidaClient.checkAccessPreconditions();
|
|
156
|
-
}
|
|
157
|
-
return getDisabledReasons(this.#aidaAvailability);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// eslint-disable-next-line require-yield
|
|
161
|
-
async * #generateErrorResponse(message: string): AsyncGenerator<ExternalRequestResponse, ExternalRequestResponse> {
|
|
162
|
-
return {
|
|
163
|
-
type: ExternalRequestResponseType.ERROR,
|
|
164
|
-
message,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Handles an external request using the given prompt and uses the
|
|
170
|
-
* conversation type to use the correct agent.
|
|
171
|
-
*/
|
|
172
|
-
async handleExternalRequest(
|
|
173
|
-
parameters: ExternalStylingRequestParameters|ExternalNetworkRequestParameters|
|
|
174
|
-
ExternalPerformanceRequestParameters,
|
|
175
|
-
): Promise<AsyncGenerator<ExternalRequestResponse, ExternalRequestResponse>> {
|
|
176
|
-
try {
|
|
177
|
-
this.dispatchEventToListeners(ConversationHandlerEvents.EXTERNAL_REQUEST_RECEIVED);
|
|
178
|
-
const disabledReasons = await this.#getDisabledReasons();
|
|
179
|
-
const aiAssistanceSetting = this.#aiAssistanceEnabledSetting?.getIfNotDisabled();
|
|
180
|
-
if (!aiAssistanceSetting) {
|
|
181
|
-
disabledReasons.push(lockedString(UIStringsNotTranslate.enableInSettings));
|
|
182
|
-
}
|
|
183
|
-
if (disabledReasons.length > 0) {
|
|
184
|
-
return this.#generateErrorResponse(disabledReasons.join(' '));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
this.dispatchEventToListeners(
|
|
188
|
-
ConversationHandlerEvents.EXTERNAL_CONVERSATION_STARTED, parameters.conversationType);
|
|
189
|
-
switch (parameters.conversationType) {
|
|
190
|
-
case ConversationType.STYLING: {
|
|
191
|
-
return await this.#handleExternalStylingConversation(parameters.prompt, parameters.selector);
|
|
192
|
-
}
|
|
193
|
-
case ConversationType.PERFORMANCE:
|
|
194
|
-
return await this.#handleExternalPerformanceConversation(parameters.prompt, parameters.data);
|
|
195
|
-
case ConversationType.NETWORK:
|
|
196
|
-
if (!parameters.requestUrl) {
|
|
197
|
-
return this.#generateErrorResponse('The url is required for debugging a network request.');
|
|
198
|
-
}
|
|
199
|
-
return await this.#handleExternalNetworkConversation(parameters.prompt, parameters.requestUrl);
|
|
200
|
-
}
|
|
201
|
-
} catch (error) {
|
|
202
|
-
return this.#generateErrorResponse(error.message);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
async * #createAndDoExternalConversation(opts: {
|
|
207
|
-
conversationType: ConversationType,
|
|
208
|
-
aiAgent: AiAgent<unknown>,
|
|
209
|
-
prompt: string,
|
|
210
|
-
selected: NodeContext|PerformanceTraceContext|RequestContext|null,
|
|
211
|
-
}): AsyncGenerator<ExternalRequestResponse, ExternalRequestResponse> {
|
|
212
|
-
const {conversationType, aiAgent, prompt, selected} = opts;
|
|
213
|
-
const conversation = new AiConversation({
|
|
214
|
-
type: conversationType,
|
|
215
|
-
data: [],
|
|
216
|
-
id: aiAgent.sessionId,
|
|
217
|
-
isReadOnly: true,
|
|
218
|
-
aidaClient: this.#aidaClient,
|
|
219
|
-
isExternal: true,
|
|
220
|
-
});
|
|
221
|
-
return yield* this.#doExternalConversation({conversation, prompt, selected});
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
async * #doExternalConversation(opts: {
|
|
225
|
-
conversation: AiConversation,
|
|
226
|
-
prompt: string,
|
|
227
|
-
selected: NodeContext|PerformanceTraceContext|RequestContext|null,
|
|
228
|
-
}): AsyncGenerator<ExternalRequestResponse, ExternalRequestResponse> {
|
|
229
|
-
const {conversation, prompt, selected} = opts;
|
|
230
|
-
conversation.setContext(selected);
|
|
231
|
-
const generator = conversation.run(prompt);
|
|
232
|
-
const devToolsLogs: object[] = [];
|
|
233
|
-
for await (const data of generator) {
|
|
234
|
-
if (data.type !== ResponseType.ANSWER || data.complete) {
|
|
235
|
-
devToolsLogs.push(data);
|
|
236
|
-
}
|
|
237
|
-
if (data.type === ResponseType.TITLE) {
|
|
238
|
-
yield {
|
|
239
|
-
type: ExternalRequestResponseType.NOTIFICATION,
|
|
240
|
-
message: data.title,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
if (data.type === ResponseType.CONTEXT) {
|
|
244
|
-
yield {
|
|
245
|
-
type: ExternalRequestResponseType.NOTIFICATION,
|
|
246
|
-
message: CONTEXT_TITLE,
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
if (data.type === ResponseType.SIDE_EFFECT) {
|
|
250
|
-
data.confirm(true);
|
|
251
|
-
}
|
|
252
|
-
if (data.type === ResponseType.ANSWER && data.complete) {
|
|
253
|
-
return {
|
|
254
|
-
type: ExternalRequestResponseType.ANSWER,
|
|
255
|
-
message: data.text,
|
|
256
|
-
devToolsLogs,
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
return {
|
|
261
|
-
type: ExternalRequestResponseType.ERROR,
|
|
262
|
-
message: 'Something went wrong. No answer was generated.',
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
async #handleExternalStylingConversation(prompt: string, selector = 'body'):
|
|
267
|
-
Promise<AsyncGenerator<ExternalRequestResponse, ExternalRequestResponse>> {
|
|
268
|
-
const stylingAgent = new StylingAgent({
|
|
269
|
-
aidaClient: this.#aidaClient,
|
|
270
|
-
serverSideLoggingEnabled: isAiAssistanceServerSideLoggingEnabled(),
|
|
271
|
-
});
|
|
272
|
-
const node = await inspectElementBySelector(selector);
|
|
273
|
-
if (node) {
|
|
274
|
-
await node.setAsInspectedNode();
|
|
275
|
-
}
|
|
276
|
-
const selected = node ? new NodeContext(node) : null;
|
|
277
|
-
return this.#createAndDoExternalConversation({
|
|
278
|
-
conversationType: ConversationType.STYLING,
|
|
279
|
-
aiAgent: stylingAgent,
|
|
280
|
-
prompt,
|
|
281
|
-
selected,
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
async #handleExternalPerformanceConversation(prompt: string, data: ExternalPerformanceAIConversationData):
|
|
286
|
-
Promise<AsyncGenerator<ExternalRequestResponse, ExternalRequestResponse>> {
|
|
287
|
-
return this.#doExternalConversation({
|
|
288
|
-
conversation: data.conversation,
|
|
289
|
-
prompt,
|
|
290
|
-
selected: data.selected,
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
async #handleExternalNetworkConversation(prompt: string, requestUrl: string):
|
|
295
|
-
Promise<AsyncGenerator<ExternalRequestResponse, ExternalRequestResponse>> {
|
|
296
|
-
const networkAgent = new NetworkAgent({
|
|
297
|
-
aidaClient: this.#aidaClient,
|
|
298
|
-
serverSideLoggingEnabled: isAiAssistanceServerSideLoggingEnabled(),
|
|
299
|
-
});
|
|
300
|
-
const request = await inspectNetworkRequestByUrl(requestUrl);
|
|
301
|
-
if (!request) {
|
|
302
|
-
return this.#generateErrorResponse(`Can't find request with the given selector ${requestUrl}`);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const calculator = new NetworkTimeCalculator.NetworkTransferTimeCalculator();
|
|
306
|
-
calculator.updateBoundaries(request);
|
|
307
|
-
|
|
308
|
-
return this.#createAndDoExternalConversation({
|
|
309
|
-
conversationType: ConversationType.NETWORK,
|
|
310
|
-
aiAgent: networkAgent,
|
|
311
|
-
prompt,
|
|
312
|
-
selected: new RequestContext(request, calculator),
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export const enum ConversationHandlerEvents {
|
|
318
|
-
EXTERNAL_REQUEST_RECEIVED = 'ExternalRequestReceived',
|
|
319
|
-
EXTERNAL_CONVERSATION_STARTED = 'ExternalConversationStarted',
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
export interface EventTypes {
|
|
323
|
-
[ConversationHandlerEvents.EXTERNAL_REQUEST_RECEIVED]: void;
|
|
324
|
-
[ConversationHandlerEvents.EXTERNAL_CONVERSATION_STARTED]: ConversationType;
|
|
325
|
-
}
|