chrome-devtools-frontend 1.0.1574367 → 1.0.1575635

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 (107) hide show
  1. package/.stylelintrc.json +1 -1
  2. package/AUTHORS +1 -0
  3. package/docs/contributing/settings-experiments-features.md +5 -2
  4. package/front_end/core/common/Settings.ts +1 -1
  5. package/front_end/core/host/InspectorFrontendHostAPI.ts +7 -1
  6. package/front_end/core/host/InspectorFrontendHostStub.ts +10 -0
  7. package/front_end/core/host/UserMetrics.ts +15 -0
  8. package/front_end/core/root/Runtime.ts +119 -39
  9. package/front_end/core/sdk/CSSMatchedStyles.ts +27 -0
  10. package/front_end/entrypoints/main/MainImpl.ts +25 -7
  11. package/front_end/entrypoints/node_app/app/NodeConnectionsPanel.ts +3 -2
  12. package/front_end/generated/InspectorBackendCommands.ts +37 -0
  13. package/front_end/generated/protocol-mapping.d.ts +257 -0
  14. package/front_end/generated/protocol-proxy-api.d.ts +256 -0
  15. package/front_end/generated/protocol.ts +359 -0
  16. package/front_end/models/ai_assistance/AiConversation.ts +31 -10
  17. package/front_end/models/ai_assistance/AiHistoryStorage.ts +1 -0
  18. package/front_end/models/ai_assistance/agents/AiAgent.ts +29 -5
  19. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.snapshot.txt +73 -0
  20. package/front_end/models/ai_assistance/agents/ContextSelectionAgent.ts +141 -0
  21. package/front_end/models/ai_assistance/agents/StylingAgent.snapshot.txt +3 -3
  22. package/front_end/models/ai_assistance/agents/StylingAgent.ts +5 -4
  23. package/front_end/models/ai_assistance/ai_assistance.ts +2 -0
  24. package/front_end/models/issues_manager/CorsIssue.ts +0 -3
  25. package/front_end/models/javascript_metadata/NativeFunctions.js +5 -0
  26. package/front_end/models/live-metrics/LiveMetrics.ts +31 -51
  27. package/front_end/models/stack_trace/StackTrace.ts +41 -0
  28. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +72 -6
  29. package/front_end/panels/ai_assistance/ai_assistance-meta.ts +1 -0
  30. package/front_end/panels/ai_assistance/components/ChatInput.ts +24 -2
  31. package/front_end/panels/ai_assistance/components/ChatMessage.ts +6 -4
  32. package/front_end/panels/ai_assistance/components/ChatView.ts +5 -6
  33. package/front_end/panels/ai_assistance/components/chatView.css +10 -0
  34. package/front_end/panels/application/StorageView.ts +3 -3
  35. package/front_end/panels/application/preloading/components/preloadingDisabledInfobar.css +1 -1
  36. package/front_end/panels/common/AiCodeGenerationUpgradeDialog.ts +32 -16
  37. package/front_end/panels/common/aiCodeCompletionSummaryToolbar.css +1 -1
  38. package/front_end/panels/console/ConsoleContextSelector.ts +4 -3
  39. package/front_end/panels/console/ConsoleFormat.ts +31 -2
  40. package/front_end/panels/console/ConsoleInsightTeaser.ts +6 -1
  41. package/front_end/panels/elements/ElementsTreeElement.ts +46 -2
  42. package/front_end/panels/elements/ElementsTreeOutline.ts +1 -1
  43. package/front_end/panels/elements/StylePropertyTreeElement.ts +63 -0
  44. package/front_end/panels/elements/StylesSidebarPane.ts +17 -2
  45. package/front_end/panels/elements/stylePropertiesTreeOutline.css +4 -0
  46. package/front_end/panels/issues/AffectedMetadataAllowedSitesView.ts +3 -3
  47. package/front_end/panels/layer_viewer/Layers3DView.ts +2 -1
  48. package/front_end/panels/lighthouse/LighthouseStartView.ts +7 -6
  49. package/front_end/panels/linear_memory_inspector/LinearMemoryInspectorPane.ts +3 -2
  50. package/front_end/panels/network/RequestConditionsDrawer.ts +2 -3
  51. package/front_end/panels/network/SignedExchangeInfoView.ts +3 -4
  52. package/front_end/panels/network/components/HeaderSectionRow.css +1 -1
  53. package/front_end/panels/recorder/components/RecordingView.ts +2 -2
  54. package/front_end/panels/recorder/components/recordingView.css +5 -0
  55. package/front_end/panels/security/SecurityPanelSidebar.ts +10 -9
  56. package/front_end/panels/settings/AISettingsTab.ts +2 -1
  57. package/front_end/panels/settings/KeybindsSettingsTab.ts +3 -5
  58. package/front_end/panels/settings/SettingsScreen.ts +14 -9
  59. package/front_end/panels/settings/settings-meta.ts +1 -0
  60. package/front_end/panels/sources/CallStackSidebarPane.ts +10 -0
  61. package/front_end/panels/sources/DebuggerPlugin.ts +18 -12
  62. package/front_end/panels/sources/ScopeChainSidebarPane.ts +4 -3
  63. package/front_end/panels/sources/SourcesNavigator.ts +2 -2
  64. package/front_end/panels/sources/SourcesPanel.ts +6 -3
  65. package/front_end/panels/sources/TabbedEditorContainer.ts +2 -2
  66. package/front_end/panels/sources/sources-meta.ts +2 -1
  67. package/front_end/panels/timeline/TimelinePanel.ts +2 -1
  68. package/front_end/panels/timeline/TimelineUIUtils.ts +2 -2
  69. package/front_end/panels/timeline/components/DetailsView.ts +7 -7
  70. package/front_end/panels/timeline/components/insights/BaseInsightComponent.ts +2 -2
  71. package/front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts +4 -4
  72. package/front_end/panels/whats_new/ReleaseNoteText.ts +11 -11
  73. package/front_end/panels/whats_new/releaseNoteView.css +1 -1
  74. package/front_end/panels/whats_new/resources/WNDT.md +6 -6
  75. package/front_end/third_party/chromium/README.chromium +1 -1
  76. package/front_end/third_party/puppeteer/README.chromium +2 -2
  77. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.d.ts.map +1 -1
  78. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.js +30 -25
  79. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/cdp/TargetManager.js.map +1 -1
  80. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/injected/injected.d.ts +1 -1
  81. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/Mutex.d.ts +2 -2
  82. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.d.ts +1 -1
  83. package/front_end/third_party/puppeteer/package/lib/cjs/puppeteer/util/version.js +1 -1
  84. package/front_end/third_party/puppeteer/package/lib/es5-iife/puppeteer-core-browser.js +30 -21
  85. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.d.ts.map +1 -1
  86. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.js +31 -26
  87. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/cdp/TargetManager.js.map +1 -1
  88. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.d.ts +1 -1
  89. package/front_end/third_party/puppeteer/package/lib/esm/puppeteer/util/version.js +1 -1
  90. package/front_end/third_party/puppeteer/package/package.json +3 -3
  91. package/front_end/third_party/puppeteer/package/src/cdp/TargetManager.ts +45 -44
  92. package/front_end/third_party/puppeteer/package/src/util/version.ts +1 -1
  93. package/front_end/ui/components/buttons/Button.ts +2 -2
  94. package/front_end/ui/components/panel_feedback/PreviewToggle.ts +1 -1
  95. package/front_end/ui/components/panel_feedback/panelFeedback.css +1 -1
  96. package/front_end/ui/kit/link/Link.ts +31 -0
  97. package/front_end/ui/legacy/LinkContextMenuProvider.ts +3 -5
  98. package/front_end/ui/legacy/components/object_ui/ObjectPopoverHelper.ts +2 -2
  99. package/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts +336 -250
  100. package/front_end/ui/legacy/inspectorCommon.css +0 -1
  101. package/front_end/ui/legacy/legacy.ts +0 -4
  102. package/front_end/ui/visual_logging/KnownContextValues.ts +4 -0
  103. package/front_end/ui/visual_logging/LoggingDriver.ts +10 -6
  104. package/mcp/HostBindings.ts +6 -0
  105. package/package.json +1 -1
  106. package/front_end/ui/legacy/XElement.ts +0 -41
  107. package/front_end/ui/legacy/XLink.ts +0 -128
@@ -17251,6 +17251,365 @@ export namespace ServiceWorker {
17251
17251
  }
17252
17252
  }
17253
17253
 
17254
+ export namespace SmartCardEmulation {
17255
+
17256
+ /**
17257
+ * Indicates the PC/SC error code.
17258
+ *
17259
+ * This maps to:
17260
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__ErrorCodes.html
17261
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/secauthn/authentication-return-values
17262
+ */
17263
+ export const enum ResultCode {
17264
+ Success = 'success',
17265
+ RemovedCard = 'removed-card',
17266
+ ResetCard = 'reset-card',
17267
+ UnpoweredCard = 'unpowered-card',
17268
+ UnresponsiveCard = 'unresponsive-card',
17269
+ UnsupportedCard = 'unsupported-card',
17270
+ ReaderUnavailable = 'reader-unavailable',
17271
+ SharingViolation = 'sharing-violation',
17272
+ NotTransacted = 'not-transacted',
17273
+ NoSmartcard = 'no-smartcard',
17274
+ ProtoMismatch = 'proto-mismatch',
17275
+ SystemCancelled = 'system-cancelled',
17276
+ NotReady = 'not-ready',
17277
+ Cancelled = 'cancelled',
17278
+ InsufficientBuffer = 'insufficient-buffer',
17279
+ InvalidHandle = 'invalid-handle',
17280
+ InvalidParameter = 'invalid-parameter',
17281
+ InvalidValue = 'invalid-value',
17282
+ NoMemory = 'no-memory',
17283
+ Timeout = 'timeout',
17284
+ UnknownReader = 'unknown-reader',
17285
+ UnsupportedFeature = 'unsupported-feature',
17286
+ NoReadersAvailable = 'no-readers-available',
17287
+ ServiceStopped = 'service-stopped',
17288
+ NoService = 'no-service',
17289
+ CommError = 'comm-error',
17290
+ InternalError = 'internal-error',
17291
+ ServerTooBusy = 'server-too-busy',
17292
+ Unexpected = 'unexpected',
17293
+ Shutdown = 'shutdown',
17294
+ UnknownCard = 'unknown-card',
17295
+ Unknown = 'unknown',
17296
+ }
17297
+
17298
+ /**
17299
+ * Maps to the |SCARD_SHARE_*| values.
17300
+ */
17301
+ export const enum ShareMode {
17302
+ Shared = 'shared',
17303
+ Exclusive = 'exclusive',
17304
+ Direct = 'direct',
17305
+ }
17306
+
17307
+ /**
17308
+ * Indicates what the reader should do with the card.
17309
+ */
17310
+ export const enum Disposition {
17311
+ LeaveCard = 'leave-card',
17312
+ ResetCard = 'reset-card',
17313
+ UnpowerCard = 'unpower-card',
17314
+ EjectCard = 'eject-card',
17315
+ }
17316
+
17317
+ /**
17318
+ * Maps to |SCARD_*| connection state values.
17319
+ */
17320
+ export const enum ConnectionState {
17321
+ Absent = 'absent',
17322
+ Present = 'present',
17323
+ Swallowed = 'swallowed',
17324
+ Powered = 'powered',
17325
+ Negotiable = 'negotiable',
17326
+ Specific = 'specific',
17327
+ }
17328
+
17329
+ /**
17330
+ * Maps to the |SCARD_STATE_*| flags.
17331
+ */
17332
+ export interface ReaderStateFlags {
17333
+ unaware?: boolean;
17334
+ ignore?: boolean;
17335
+ changed?: boolean;
17336
+ unknown?: boolean;
17337
+ unavailable?: boolean;
17338
+ empty?: boolean;
17339
+ present?: boolean;
17340
+ exclusive?: boolean;
17341
+ inuse?: boolean;
17342
+ mute?: boolean;
17343
+ unpowered?: boolean;
17344
+ }
17345
+
17346
+ /**
17347
+ * Maps to the |SCARD_PROTOCOL_*| flags.
17348
+ */
17349
+ export interface ProtocolSet {
17350
+ t0?: boolean;
17351
+ t1?: boolean;
17352
+ raw?: boolean;
17353
+ }
17354
+
17355
+ /**
17356
+ * Maps to the |SCARD_PROTOCOL_*| values.
17357
+ */
17358
+ export const enum Protocol {
17359
+ T0 = 't0',
17360
+ T1 = 't1',
17361
+ Raw = 'raw',
17362
+ }
17363
+
17364
+ export interface ReaderStateIn {
17365
+ reader: string;
17366
+ currentState: ReaderStateFlags;
17367
+ currentInsertionCount: integer;
17368
+ }
17369
+
17370
+ export interface ReaderStateOut {
17371
+ reader: string;
17372
+ eventState: ReaderStateFlags;
17373
+ eventCount: integer;
17374
+ atr: binary;
17375
+ }
17376
+
17377
+ export interface ReportEstablishContextResultRequest {
17378
+ requestId: string;
17379
+ contextId: integer;
17380
+ }
17381
+
17382
+ export interface ReportReleaseContextResultRequest {
17383
+ requestId: string;
17384
+ }
17385
+
17386
+ export interface ReportListReadersResultRequest {
17387
+ requestId: string;
17388
+ readers: string[];
17389
+ }
17390
+
17391
+ export interface ReportGetStatusChangeResultRequest {
17392
+ requestId: string;
17393
+ readerStates: ReaderStateOut[];
17394
+ }
17395
+
17396
+ export interface ReportBeginTransactionResultRequest {
17397
+ requestId: string;
17398
+ }
17399
+
17400
+ export interface ReportPlainResultRequest {
17401
+ requestId: string;
17402
+ }
17403
+
17404
+ export interface ReportConnectResultRequest {
17405
+ requestId: string;
17406
+ handle: integer;
17407
+ activeProtocol?: Protocol;
17408
+ }
17409
+
17410
+ export interface ReportDataResultRequest {
17411
+ requestId: string;
17412
+ data: binary;
17413
+ }
17414
+
17415
+ export interface ReportStatusResultRequest {
17416
+ requestId: string;
17417
+ readerName: string;
17418
+ state: ConnectionState;
17419
+ atr: binary;
17420
+ protocol?: Protocol;
17421
+ }
17422
+
17423
+ export interface ReportErrorRequest {
17424
+ requestId: string;
17425
+ resultCode: ResultCode;
17426
+ }
17427
+
17428
+ /**
17429
+ * Fired when |SCardEstablishContext| is called.
17430
+ *
17431
+ * This maps to:
17432
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#gaa1b8970169fd4883a6dc4a8f43f19b67
17433
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardestablishcontext
17434
+ */
17435
+ export interface EstablishContextRequestedEvent {
17436
+ requestId: string;
17437
+ }
17438
+
17439
+ /**
17440
+ * Fired when |SCardReleaseContext| is called.
17441
+ *
17442
+ * This maps to:
17443
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#ga6aabcba7744c5c9419fdd6404f73a934
17444
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardreleasecontext
17445
+ */
17446
+ export interface ReleaseContextRequestedEvent {
17447
+ requestId: string;
17448
+ contextId: integer;
17449
+ }
17450
+
17451
+ /**
17452
+ * Fired when |SCardListReaders| is called.
17453
+ *
17454
+ * This maps to:
17455
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#ga93b07815789b3cf2629d439ecf20f0d9
17456
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardlistreadersa
17457
+ */
17458
+ export interface ListReadersRequestedEvent {
17459
+ requestId: string;
17460
+ contextId: integer;
17461
+ }
17462
+
17463
+ /**
17464
+ * Fired when |SCardGetStatusChange| is called. Timeout is specified in milliseconds.
17465
+ *
17466
+ * This maps to:
17467
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#ga33247d5d1257d59e55647c3bb717db24
17468
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardgetstatuschangea
17469
+ */
17470
+ export interface GetStatusChangeRequestedEvent {
17471
+ requestId: string;
17472
+ contextId: integer;
17473
+ readerStates: ReaderStateIn[];
17474
+ /**
17475
+ * in milliseconds, if absent, it means "infinite"
17476
+ */
17477
+ timeout?: integer;
17478
+ }
17479
+
17480
+ /**
17481
+ * Fired when |SCardCancel| is called.
17482
+ *
17483
+ * This maps to:
17484
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#gaacbbc0c6d6c0cbbeb4f4debf6fbeeee6
17485
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardcancel
17486
+ */
17487
+ export interface CancelRequestedEvent {
17488
+ requestId: string;
17489
+ contextId: integer;
17490
+ }
17491
+
17492
+ /**
17493
+ * Fired when |SCardConnect| is called.
17494
+ *
17495
+ * This maps to:
17496
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#ga4e515829752e0a8dbc4d630696a8d6a5
17497
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardconnecta
17498
+ */
17499
+ export interface ConnectRequestedEvent {
17500
+ requestId: string;
17501
+ contextId: integer;
17502
+ reader: string;
17503
+ shareMode: ShareMode;
17504
+ preferredProtocols: ProtocolSet;
17505
+ }
17506
+
17507
+ /**
17508
+ * Fired when |SCardDisconnect| is called.
17509
+ *
17510
+ * This maps to:
17511
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#ga4be198045c73ec0deb79e66c0ca1738a
17512
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scarddisconnect
17513
+ */
17514
+ export interface DisconnectRequestedEvent {
17515
+ requestId: string;
17516
+ handle: integer;
17517
+ disposition: Disposition;
17518
+ }
17519
+
17520
+ /**
17521
+ * Fired when |SCardTransmit| is called.
17522
+ *
17523
+ * This maps to:
17524
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#ga9a2d77242a271310269065e64633ab99
17525
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardtransmit
17526
+ */
17527
+ export interface TransmitRequestedEvent {
17528
+ requestId: string;
17529
+ handle: integer;
17530
+ data: binary;
17531
+ protocol?: Protocol;
17532
+ }
17533
+
17534
+ /**
17535
+ * Fired when |SCardControl| is called.
17536
+ *
17537
+ * This maps to:
17538
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#gac3454d4657110fd7f753b2d3d8f4e32f
17539
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardcontrol
17540
+ */
17541
+ export interface ControlRequestedEvent {
17542
+ requestId: string;
17543
+ handle: integer;
17544
+ controlCode: integer;
17545
+ data: binary;
17546
+ }
17547
+
17548
+ /**
17549
+ * Fired when |SCardGetAttrib| is called.
17550
+ *
17551
+ * This maps to:
17552
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#gaacfec51917255b7a25b94c5104961602
17553
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardgetattrib
17554
+ */
17555
+ export interface GetAttribRequestedEvent {
17556
+ requestId: string;
17557
+ handle: integer;
17558
+ attribId: integer;
17559
+ }
17560
+
17561
+ /**
17562
+ * Fired when |SCardSetAttrib| is called.
17563
+ *
17564
+ * This maps to:
17565
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#ga060f0038a4ddfd5dd2b8fadf3c3a2e4f
17566
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardsetattrib
17567
+ */
17568
+ export interface SetAttribRequestedEvent {
17569
+ requestId: string;
17570
+ handle: integer;
17571
+ attribId: integer;
17572
+ data: binary;
17573
+ }
17574
+
17575
+ /**
17576
+ * Fired when |SCardStatus| is called.
17577
+ *
17578
+ * This maps to:
17579
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#gae49c3c894ad7ac12a5b896bde70d0382
17580
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardstatusa
17581
+ */
17582
+ export interface StatusRequestedEvent {
17583
+ requestId: string;
17584
+ handle: integer;
17585
+ }
17586
+
17587
+ /**
17588
+ * Fired when |SCardBeginTransaction| is called.
17589
+ *
17590
+ * This maps to:
17591
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#gaddb835dce01a0da1d6ca02d33ee7d861
17592
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardbegintransaction
17593
+ */
17594
+ export interface BeginTransactionRequestedEvent {
17595
+ requestId: string;
17596
+ handle: integer;
17597
+ }
17598
+
17599
+ /**
17600
+ * Fired when |SCardEndTransaction| is called.
17601
+ *
17602
+ * This maps to:
17603
+ * PC/SC Lite: https://pcsclite.apdu.fr/api/group__API.html#gae8742473b404363e5c587f570d7e2f3b
17604
+ * Microsoft: https://learn.microsoft.com/en-us/windows/win32/api/winscard/nf-winscard-scardendtransaction
17605
+ */
17606
+ export interface EndTransactionRequestedEvent {
17607
+ requestId: string;
17608
+ handle: integer;
17609
+ disposition: Disposition;
17610
+ }
17611
+ }
17612
+
17254
17613
  export namespace Storage {
17255
17614
 
17256
17615
  export type SerializedStorageKey = string;
@@ -16,6 +16,7 @@ import {
16
16
  type ResponseData,
17
17
  ResponseType
18
18
  } from './agents/AiAgent.js';
19
+ import {ContextSelectionAgent} from './agents/ContextSelectionAgent.js';
19
20
  import {FileAgent} from './agents/FileAgent.js';
20
21
  import {NetworkAgent} from './agents/NetworkAgent.js';
21
22
  import {PerformanceAgent} from './agents/PerformanceAgent.js';
@@ -87,6 +88,7 @@ export class AiConversation {
87
88
  this.#isReadOnly = isReadOnly;
88
89
  this.#isExternal = isExternal;
89
90
  this.history = this.#reconstructHistory(data);
91
+ // Needs to be last
90
92
  this.#agent = this.#createAgent();
91
93
  }
92
94
 
@@ -226,16 +228,22 @@ export class AiConversation {
226
228
  serialize(): SerializedConversation {
227
229
  return {
228
230
  id: this.id,
229
- history: this.history.map(item => {
230
- if (item.type === ResponseType.USER_QUERY) {
231
- return {...item, imageInput: undefined};
232
- }
233
- // Remove the `confirm()`-function because `structuredClone()` throws on functions
234
- if (item.type === ResponseType.SIDE_EFFECT) {
235
- return {...item, confirm: undefined};
236
- }
237
- return item;
238
- }),
231
+ history: this.history
232
+ .map(item => {
233
+ if (item.type === ResponseType.CONTEXT_CHANGE) {
234
+ return null;
235
+ }
236
+
237
+ if (item.type === ResponseType.USER_QUERY) {
238
+ return {...item, imageInput: undefined};
239
+ }
240
+ // Remove the `confirm()`-function because `structuredClone()` throws on functions
241
+ if (item.type === ResponseType.SIDE_EFFECT) {
242
+ return {...item, confirm: undefined};
243
+ }
244
+ return item;
245
+ })
246
+ .filter(history => !!history),
239
247
  type: this.#type,
240
248
  isExternal: this.#isExternal,
241
249
  };
@@ -266,6 +274,10 @@ export class AiConversation {
266
274
  agent = new PerformanceAgent(options);
267
275
  break;
268
276
  }
277
+ case ConversationType.NONE: {
278
+ agent = new ContextSelectionAgent(options);
279
+ break;
280
+ }
269
281
  }
270
282
  return agent;
271
283
  }
@@ -366,6 +378,10 @@ Time: ${micros(time)}`;
366
378
  }
367
379
 
368
380
  function shouldAddToHistory(data: ResponseData): boolean {
381
+ if (data.type === ResponseType.CONTEXT_CHANGE) {
382
+ return false;
383
+ }
384
+
369
385
  // We don't want to save partial responses to the conversation history.
370
386
  // TODO(crbug.com/463325400): We should save interleaved answers to the history as well.
371
387
  if (data.type === ResponseType.ANSWER && !data.complete) {
@@ -383,6 +399,11 @@ Time: ${micros(time)}`;
383
399
  },
384
400
  options.multimodalInput,
385
401
  )) {
402
+ if (data.type === ResponseType.CONTEXT_CHANGE) {
403
+ this.#type = ConversationType.NETWORK;
404
+ this.#agent = this.#createAgent();
405
+ }
406
+
386
407
  if (shouldAddToHistory(data)) {
387
408
  void this.addHistoryItem(data);
388
409
  }
@@ -8,6 +8,7 @@ import * as Common from '../../core/common/common.js';
8
8
  import {ResponseType, type SerializedResponseData} from './agents/AiAgent.js';
9
9
 
10
10
  export const enum ConversationType {
11
+ NONE = 'none',
11
12
  STYLING = 'freestyler',
12
13
  FILE = 'drjones-file',
13
14
  NETWORK = 'drjones-network-request',
@@ -17,6 +17,7 @@ export const enum ResponseType {
17
17
  ERROR = 'error',
18
18
  QUERYING = 'querying',
19
19
  USER_QUERY = 'user-query',
20
+ CONTEXT_CHANGE = 'context-change'
20
21
  }
21
22
 
22
23
  export const enum ErrorType {
@@ -84,6 +85,11 @@ export interface SideEffectResponse {
84
85
  code?: string;
85
86
  confirm: (confirm: boolean) => void;
86
87
  }
88
+ export interface ContextChangeResponse {
89
+ type: ResponseType.CONTEXT_CHANGE;
90
+ context: unknown;
91
+ }
92
+
87
93
  interface SerializedSideEffectResponse extends Omit<SideEffectResponse, 'confirm'> {}
88
94
 
89
95
  export interface ActionResponse {
@@ -105,13 +111,13 @@ export interface UserQuery {
105
111
  }
106
112
 
107
113
  export type ResponseData = AnswerResponse|SuggestionsResponse|ErrorResponse|ActionResponse|SideEffectResponse|
108
- ThoughtResponse|TitleResponse|QueryingResponse|ContextResponse|UserQuery;
114
+ ThoughtResponse|TitleResponse|QueryingResponse|ContextResponse|UserQuery|ContextChangeResponse;
109
115
 
110
116
  export type SerializedResponseData = AnswerResponse|SuggestionsResponse|ErrorResponse|ActionResponse|
111
117
  SerializedSideEffectResponse|ThoughtResponse|TitleResponse|QueryingResponse|ContextResponse|UserQuery;
112
118
 
113
119
  export type FunctionCallResponseData =
114
- TitleResponse|ThoughtResponse|ActionResponse|SideEffectResponse|SuggestionsResponse;
120
+ TitleResponse|ThoughtResponse|ActionResponse|SideEffectResponse|SuggestionsResponse|ContextChangeResponse;
115
121
 
116
122
  export interface BuildRequestOptions {
117
123
  text: string;
@@ -200,10 +206,14 @@ export abstract class ConversationContext<T> {
200
206
  }
201
207
 
202
208
  export type FunctionCallHandlerResult<Result> = {
209
+ requiresApproval: true,
210
+ }|{
203
211
  result: Result,
204
212
  }|{
205
- requiresApproval: true,
206
- }|{error: string};
213
+ context: unknown,
214
+ }|{
215
+ error: string,
216
+ };
207
217
 
208
218
  export interface FunctionHandlerOptions {
209
219
  /**
@@ -594,6 +604,15 @@ export abstract class AiAgent<T> {
594
604
  yield this.#createErrorResponse(ErrorType.ABORT);
595
605
  break;
596
606
  }
607
+
608
+ if ('context' in result) {
609
+ yield {
610
+ type: ResponseType.CONTEXT_CHANGE,
611
+ context: result.context,
612
+ };
613
+
614
+ return;
615
+ }
597
616
  query = {
598
617
  functionResponse: {
599
618
  name: functionCall.name,
@@ -615,6 +634,7 @@ export abstract class AiAgent<T> {
615
634
  if (isStructuredLogEnabled()) {
616
635
  window.dispatchEvent(new CustomEvent('aiassistancedone'));
617
636
  }
637
+ return;
618
638
  }
619
639
 
620
640
  async *
@@ -622,7 +642,7 @@ export abstract class AiAgent<T> {
622
642
  name: string,
623
643
  args: Record<string, unknown>,
624
644
  options?: FunctionHandlerOptions&{explanation?: string},
625
- ): AsyncGenerator<FunctionCallResponseData, {result: unknown}> {
645
+ ): AsyncGenerator<FunctionCallResponseData, {result: unknown}|{context: unknown}> {
626
646
  const call = this.#functionDeclarations.get(name);
627
647
  if (!call) {
628
648
  throw new Error(`Function ${name} is not found.`);
@@ -733,6 +753,10 @@ export abstract class AiAgent<T> {
733
753
  };
734
754
  }
735
755
 
756
+ if ('context' in result) {
757
+ return result as {context: unknown};
758
+ }
759
+
736
760
  return result as {result: unknown};
737
761
  }
738
762
 
@@ -0,0 +1,73 @@
1
+ Title: FileAgent buildRequest structure matches the snapshot
2
+ Content:
3
+ {
4
+ "client": "CHROME_DEVTOOLS",
5
+ "current_message": {
6
+ "parts": [
7
+ {
8
+ "text": "test input"
9
+ }
10
+ ],
11
+ "role": 1
12
+ },
13
+ "historical_contexts": [
14
+ {
15
+ "parts": [
16
+ {
17
+ "text": "question"
18
+ }
19
+ ],
20
+ "role": 1
21
+ },
22
+ {
23
+ "parts": [
24
+ {
25
+ "text": "answer"
26
+ }
27
+ ],
28
+ "role": 2
29
+ }
30
+ ],
31
+ "function_declarations": [
32
+ {
33
+ "name": "listNetworkRequests",
34
+ "description": "Gives a list of network requests",
35
+ "parameters": {
36
+ "type": 6,
37
+ "description": "",
38
+ "nullable": true,
39
+ "required": [],
40
+ "properties": {}
41
+ }
42
+ },
43
+ {
44
+ "name": "selectNetworkRequest",
45
+ "description": "From the list of selected request select one to debug",
46
+ "parameters": {
47
+ "type": 6,
48
+ "description": "",
49
+ "nullable": true,
50
+ "required": [
51
+ "url"
52
+ ],
53
+ "properties": {
54
+ "url": {
55
+ "type": 1,
56
+ "description": "The url of the requests",
57
+ "nullable": false
58
+ }
59
+ }
60
+ }
61
+ }
62
+ ],
63
+ "options": {},
64
+ "metadata": {
65
+ "disable_user_content_logging": false,
66
+ "string_session_id": "sessionId",
67
+ "user_tier": 3,
68
+ "client_version": "unit_test"
69
+ },
70
+ "functionality_type": 5,
71
+ "client_feature": 9
72
+ }
73
+ === end content