1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
  211
  212
  213
  214
  215
  216
  217
  218
  219
  220
  221
  222
  223
  224
  225
  226
  227
  228
  229
  230
  231
  232
  233
  234
  235
  236
  237
  238
  239
  240
  241
  242
  243
  244
  245
  246
  247
  248
  249
  250
  251
  252
  253
  254
  255
  256
  257
  258
  259
  260
  261
  262
  263
  264
  265
  266
  267
  268
  269
  270
  271
  272
  273
  274
  275
  276
  277
  278
  279
  280
  281
  282
  283
  284
  285
  286
  287
  288
  289
  290
  291
  292
  293
  294
  295
  296
  297
  298
  299
  300
  301
  302
  303
  304
  305
  306
  307
  308
  309
  310
  311
  312
  313
  314
  315
  316
  317
  318
  319
  320
  321
  322
  323
  324
  325
  326
  327
  328
  329
  330
  331
  332
  333
  334
  335
  336
  337
  338
  339
  340
  341
  342
  343
  344
  345
  346
  347
  348
  349
  350
  351
  352
  353
  354
  355
  356
  357
  358
  359
  360
  361
  362
  363
  364
  365
  366
  367
  368
  369
  370
  371
  372
  373
  374
  375
  376
  377
  378
  379
  380
  381
  382
  383
  384
  385
  386
  387
  388
  389
  390
  391
  392
  393
  394
  395
  396
  397
  398
  399
  400
  401
  402
  403
  404
  405
  406
  407
  408
  409
  410
  411
  412
  413
  414
  415
  416
  417
  418
  419
  420
  421
  422
  423
  424
  425
  426
  427
  428
  429
  430
  431
  432
  433
  434
  435
  436
  437
  438
  439
  440
  441
  442
  443
  444
  445
  446
  447
  448
  449
  450
  451
  452
  453
  454
  455
  456
  457
  458
  459
  460
  461
  462
  463
  464
  465
  466
  467
  468
  469
  470
  471
  472
  473
  474
  475
  476
  477
  478
  479
  480
  481
  482
  483
  484
  485
  486
  487
  488
  489
  490
  491
  492
  493
  494
  495
  496
  497
  498
  499
  500
  501
  502
  503
  504
  505
  506
  507
  508
  509
  510
  511
  512
  513
  514
  515
  516
  517
  518
  519
  520
  521
  522
  523
  524
  525
  526
  527
  528
  529
  530
  531
  532
  533
  534
  535
  536
  537
  538
  539
  540
  541
  542
  543
  544
  545
  546
  547
  548
  549
  550
  551
  552
  553
  554
  555
  556
  557
  558
  559
  560
  561
  562
  563
  564
  565
  566
  567
  568
  569
  570
  571
  572
  573
  574
  575
  576
  577
  578
  579
  580
  581
  582
  583
  584
  585
  586
  587
  588
  589
  590
  591
  592
  593
  594
  595
  596
  597
  598
  599
  600
  601
  602
  603
  604
  605
  606
  607
  608
  609
  610
  611
  612
  613
  614
  615
  616
  617
  618
  619
  620
  621
  622
  623
  624
  625
  626
  627
  628
  629
  630
  631
  632
  633
  634
  635
  636
  637
  638
  639
  640
  641
  642
  643
  644
  645
  646
  647
  648
  649
  650
  651
  652
  653
  654
  655
  656
  657
  658
  659
  660
  661
  662
  663
  664
  665
  666
  667

content / services / auction_worklet / public / mojom / bidder_worklet.mojom [blame]

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module auction_worklet.mojom;

import "content/services/auction_worklet/public/mojom/private_aggregation_request.mojom";
import "content/services/auction_worklet/public/mojom/real_time_reporting.mojom";
import "content/services/auction_worklet/public/mojom/reject_reason.mojom";
import "content/services/auction_worklet/public/mojom/trusted_signals_cache.mojom";
import "mojo/public/mojom/base/time.mojom";
import "services/network/public/mojom/url_loader_factory.mojom";
import "third_party/blink/public/mojom/devtools/devtools_agent.mojom";
import "third_party/blink/public/mojom/interest_group/ad_display_size.mojom";
import "third_party/blink/public/mojom/interest_group/interest_group_types.mojom";
import "url/mojom/origin.mojom";
import "url/mojom/url.mojom";

// Degree to which k-anonymity is enforced.
enum KAnonymityBidMode {
  kNone,   // k-anonymity is ignored.
  kSimulate,  // No enforcement, but result of enforcement is simulated
  kEnforce  // Enforced.
};

// An opaque identifier that identifies an ad configuration used for
// k-anonymity.
struct KAnonKey {
  string data;
};

// Subset of blink.mojom.InterestGroup that is used by GenerateBid() and can
// vary between InterestGroups that can use the same BidderWorklet (so it's
// "not shared" between InterestGroups that share the same BidderWorklet).
// See AuctionWorkletService::LoadBidderWorklet for parameters that must be the
// same between InterestGroups.
//
// See blink.mojom.InterestGroup for documentation on individual fields.
//
// This doesn't include `priority` or `priority_signals_overrides` as they can
// be modified by worklets, so could potentially have cross-origin information.
struct BidderWorkletNonSharedParams {
  string name;

  blink.mojom.InterestGroup.TrustedBiddingSignalsSlotSizeMode
      trusted_bidding_signals_slot_size_mode;

  bool enable_bidding_signals_prioritization;
  map<string, double>? priority_vector;

  blink.mojom.InterestGroup.ExecutionMode execution_mode;

  url.mojom.Url? update_url;
  array<string>? trusted_bidding_signals_keys;
  int32 max_trusted_bidding_signals_url_length;
  string? user_bidding_signals;
  array<blink.mojom.InterestGroupAd>? ads;
  array<blink.mojom.InterestGroupAd>? ad_components;

  // A key is present iff it is sufficiently k-anonymous to
  // be used as an ad or an ad component.
  array<KAnonKey> kanon_keys;
};

// The results of running a FLEDGE generateBid() script.
struct BidderWorkletBid {
  // In order to update k-anonymity information, the auction keeps track of
  // leaders both with and without enforcement. This field denotes which of
  // these this bid is suitable for.
  BidRole bid_role;

  // JSON string to be passed to the scoring function.
  string ad;

  // Offered bid value. Always greater than 0.
  double bid;

  // Currency for the bid.
  blink.mojom.AdCurrency? bid_currency;

  // 'adCost' returned by generateBid, if any.
  double? ad_cost;

  // Render URL of the bid, plus sizing information.
  blink.mojom.AdDescriptor ad_descriptor;

  // The selected reporting id from the interest group's ad's
  // `selectableBuyerAndSellerReportingIds` array.
  string? selected_buyer_and_seller_reporting_id;

  // Ad components associated with bid, if any. These allow a single ad to be
  // composed of multiple smaller ads. The `ad_descriptor` contains the main
  // URL, and is responsible for laying out these ads URLs in its subframes.
  //
  // May only contain URLs matching the `render_url`s of the `ad_components`
  // of the InterestGroup that made this bid. May have at most 20 URLs. Must
  // be null if the InterestGroup making this bid has a null `ad_components`
  // field.
  array<blink.mojom.AdDescriptor>? ad_component_descriptors;

  // `modelingSignals` returned by generateBid, if any.
  uint16? modeling_signals;

  // How long it took to run the generateBid() script.
  mojo_base.mojom.TimeDelta bid_duration;
};

// Which auctions the bid is appropriate for, based on whether the auction
// enforces k-anonymity or not.
enum BidRole {
  // Bid valid only for auctions that do not enforce k-anonymity.
  kUnenforcedKAnon,

  // Bid valid only for auctions that enforce k-anonymity.
  kEnforcedKAnon,

  // Bid valid regardless of whether the auction does k-anon enforcement.
  kBothKAnonModes
};

// An optional double value. GenerateBid() returns them as values its
// `update_priority_signals_overrides` map. Since Mojo doesn't support optional
// primitive types, this struct is needed to handle passing them. Don't need to
// have a `has_value` field, since this struct itself can be made optional.
struct PrioritySignalsDouble {
  double value;
};

// Which field identifying the ad is passed to reportWin()
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum ReportingIdField {
  kNone = 0,
  kInterestGroupName = 1,
  kBuyerReportingId = 2,
  kBuyerAndSellerReportingId = 3,
  kSelectedBuyerAndSellerReportingId = 4,
};

// Represents the time between BidderWorklet::BeginGenerateBid and each of the
// dependencies to GenerateBid, which can help to identify the slowest
// dependency, both in absolute terms and relative to other dependencies.
// Each of the latencies recorded here may be null if that dependency didn't
// apply for this call to GenerateBid.
struct GenerateBidDependencyLatencies {
  // Load of Script and/or WASM
  mojo_base.mojom.TimeDelta? code_ready_latency;

  // Fulfillment of config promises
  mojo_base.mojom.TimeDelta? config_promises_latency;

  // Download of DirectFromSellerSignals
  mojo_base.mojom.TimeDelta? direct_from_seller_signals_latency;

  // Download of TrustedBiddingSignals
  mojo_base.mojom.TimeDelta? trusted_bidding_signals_latency;

  // Times of each step of the GenerateBid flow, used to compute start and end
  // times for latency phase UKMs.
  mojo_base.mojom.TimeTicks deps_wait_start_time;
  mojo_base.mojom.TimeTicks generate_bid_start_time;
  mojo_base.mojom.TimeTicks generate_bid_finish_time;
};

// How long particular tasks took. Unlike GenerateBidDependencyLatencies this
// doesn't denote how long things blocked for --- e.g. the fetch times are
// how long the download took, even for later calls to generateBid() that
// may not actually wait for the download since it's already in memory.
struct BidderTimingMetrics {
  mojo_base.mojom.TimeDelta? js_fetch_latency;
  mojo_base.mojom.TimeDelta? wasm_fetch_latency;

  // Time to run generateBid (including any k-anon re-run) or reportWin,
  // respectively. For generateBid, this will also include any top-level
  // execution which happened (which it might not have depending on the
  // execution mode).
  mojo_base.mojom.TimeDelta script_latency;

  bool script_timed_out;
};

// Single use client for each GenerateBid() call. Allows deferring generating
// bids until after a bidder's interest groups have all received priority
// vectors, which allows for cancelling generate bid calls from lower priority
// bidders based on data fetched from the trusted bidding signals URL.
//
// Needs a full callback interface because Mojo callbacks aren't otherwise
// cancellable, and one GenerateBid call invokes two callbacks.
interface GenerateBidClient {
  // Invoked once the trusted bidding signals have been successfully fetched,
  // or have failed to be fetched. Will be called even when the trusted bidding
  // signals url is null, to allow simpler mixing of GenerateBid() calls with
  // and without them. This allows the caller in the browser process to abort
  // bid generation in the case that the interest group's new priority
  // calculated using `priority_vector` results in filtering out the bid.
  // It's called in the case of no priority vector because even when there's
  // no change in priority, filtering out due to priority depends on the
  // priorities of other interest groups owned by the same bidder, so the
  // browser process needs to know if there's no priority vector before it
  // can apply priority-based filtering.
  //
  // OnGenerateBidComplete() will only be invoked after the
  // OnBiddingSignalsReceived() callback has been invoked, except on fatal
  // errors, like failing to fetch the Javascript needed to run a worklet. If
  // a fatal error occurs before OnBiddingSignalsReceived() has been invoked,
  // the pipe will be closed without invoking it.
  //
  // Arguments:
  //  `priority_vector` The priorityVector for the interest group received as
  //   part of the trusted bidding signals, or an empty list, if no signals
  //   were received, or the signals had not priorityVector for the interest
  //   group that is generating a bid.
  //
  //  `trusted_signals_fetch_latency` The amount of time taken fetching trusted
  //  bidding signals. If no trusted signals were fetched, returns a 0 duration.
  //
  //  `update_if_older_than` If present, indicates that the interest group
  //  should potentially be updated even if its last update was less than 24
  //  hours ago, if the last update was less recent than `update_if_older_than`.
  OnBiddingSignalsReceived(
      map<string, double> priority_vector,
      mojo_base.mojom.TimeDelta trusted_signals_fetch_latency,
      mojo_base.mojom.TimeDelta? update_if_older_than) => ();

  // Invoked once GenerateBid completes, either having successfully generated
  // bids, or having failed to generate one for any reason.
  //
  // Arguments:
  //
  // `bids` List of bids generated. This is either:
  //  - At most `multi_bid_limit` items with `bid_role` of either
  //    kBothKAnonModes or kUnenforcedKAnon (if no k-anon re-run was done)
  //  - At most `multi_bid_limit` kUnenforcedKAnon bids and at most one
  //    kEnforcedKAnon bid (if k-anon re-run was done).
  //  (If no k-anon enforcement is happening, all bids are expected to be
  //   kUnenforcedKAnon).
  //
  // The following arguments all correspond to the execution that will end up
  // shown to the user if it wins per `kanon_mode` passed to GenerateBid.
  // (This distinction exists only if generateBid() was run twice to deal with
  //  k-anonymity).
  //
  // `bidding_signals_data_version` The value of the Data-Version header served
  //  with the trusted bidding signals, if the header was present.
  //
  // `debug_loss_report_url` The URL to request if the auction runs to
  //  completion and this bid does not win. All bidders are allowed to send loss
  //  report, including those who does not bid. This field has the debug prefix
  //  because it's part of an interim reporting API that will be replaced with
  //  standardized reporting APIs once available. It must be a valid HTTPS URL.
  //
  // `debug_win_report_url` The URL to request if the auction runs to completion
  //  and this bid wins. This field has the debug prefix because it's part of an
  //  interim reporting API that will be replaced with standardized reporting
  //  APIs once available. It must be a valid HTTPS URL.
  //
  // `set_priority` The value of the updated priority for this interest group.
  //  This priority should be applied to the interest group after the auction.
  //  The priority is not changed if null.
  //
  // `update_priority_signals_overrides` A map of new values to be written to
  //  the interest group's priorityOverrides map. Null values mean to delete the
  //  corresponding value, if present. Values with keys not in the map are
  //  preserved.
  //  TODO(crbug.com/40489779): Update to use `double?` type if/when
  //  that's supported as a value in a Mojo map.
  //
  // `pa_requests` The various requests made to the Private Aggregation API.
  //
  // `real_time_contributions` Real time reporting contributions.
  //
  // `generate_bid_timing_metrics` The amount of time some of the operations
  // performed took.
  //
  // `generate_bid_dependency_latencies` The amount of time GenerateBid had to
  // wait for each of its dependencies to be fulfilled before it could be run.
  //
  // `reject_reason` If there is a valid bid that can participate in the auction
  // this is kNotAvailable. Otherwise, it's the reason this bid was not
  // permitted to participate (only kWrongGenerateBidCurrency at this time),
  // or kNotAvailable.
  //
  // `errors` The various error messages to be used for debugging. These are too
  //  sensitive for the renderer to see. There may be errors even when a bid
  //  is offered, and there may be no errors when there's no bid. Includes
  //  errors from failing to load the worklet script.
  OnGenerateBidComplete(
      array<BidderWorkletBid> bids,
      uint32? bidding_signals_data_version,
      url.mojom.Url? debug_loss_report_url,
      url.mojom.Url? debug_win_report_url,
      double? set_priority,
      map<string, PrioritySignalsDouble?> update_priority_signals_overrides,
      array<PrivateAggregationRequest> pa_requests,
      array<PrivateAggregationRequest> non_kanon_pa_requests,
      array<RealTimeReportingContribution> real_time_contributions,
      BidderTimingMetrics generate_bid_timing_metrics,
      GenerateBidDependencyLatencies generate_bid_dependency_latencies,
      RejectReason reject_reason,
      array<string> errors);
};

// This interface is used to provide the arguments to generateBid() that may
// come in via promise once available. This is a separate step so that the work
// of figuring them out can overlap other work the bidder worklet does (e.g.
// fetching trusted signals).
interface GenerateBidFinalizer {
  // Provides potentially late-coming arguments to go along with those
  // provided to BeginGenerateBid with connected `bid_finalizer`.
  //
  // `auction_signals_json` The JSON representation of the auction signals for
  //  the auction, specified by the publisher page and provided to bidder
  //  worklets competing in an auction.
  //
  // `per_buyer_signals_json` The JSON representation of the auction signals
  //  for the specific owner of this interest group, specified by the
  //  publisher page and provided to all interest groups with the same owner
  //  as the one specified `interest_group`.
  //
  // `expected_buyer_currency` Currency restriction specified for this buyer.
  //
  // `per_buyer_timeout` Restrict the runtime of particular buyer's bidding
  //  scripts. Any timeout higher than 500 ms will be clamped to 500 ms before
  //  passing in as `per_buyer_timeout`. Null if not provided by the publisher
  //  page. Null will be passed to the worklet in that case.
  //
  // See BeginGenerateBid for description of
  //  `direct_from_seller_per_buyer_signals`,
  //  `direct_from_seller_auction_signals`
  //
  //  `direct_from_seller_per_buyer_signals_header_ad_slot` A JSON string of the
  //   DirectFromSellerSignals for this specific buyer. Must not be passed if
  //   `direct_from_seller_per_buyer_signals` or
  //   `direct_from_seller_auction_signals` is passed.
  //
  //  `direct_from_seller_auction_signals_header_ad_slot` A JSON string of the
  //   DirectFromSellerSignals for the seller and all buyers. Must not be passed
  //   if `direct_from_seller_auction_signals` or
  //   `direct_from_seller_per_buyer_signals` is passed.
  FinishGenerateBid(
      string? auction_signals_json,
      string? per_buyer_signals_json,
      mojo_base.mojom.TimeDelta? per_buyer_timeout,
      blink.mojom.AdCurrency? expected_buyer_currency,
      url.mojom.Url? direct_from_seller_per_buyer_signals,
      string? direct_from_seller_per_buyer_signals_header_ad_slot,
      url.mojom.Url? direct_from_seller_auction_signals,
      string? direct_from_seller_auction_signals_header_ad_slot);
};

// Manages the auction workflow for one loaded FLEDGE bidder worklet.
// See https://github.com/WICG/turtledove/blob/main/FLEDGE.md
//
// Auctions involve running Javascript from multiple origins, so they
// cannot be run within a single process. This API allows the browser
// process to load Javascript FLEDGE worklets in other processes and
// manage their lifetimes.
//
// The BidderWorklet is functionally stateless, so methods are idempotent
// and can be called multiple times, in any order, for multiple auctions
// using the same worklet. There is no need to wait for one callback to be
// invoked before calling another method. There is no guarantee methods will
// complete in the order they are invoked.
interface BidderWorklet {
  // Loads the same-origin realtime bidding signals URL (if necessary), and
  // after the rest of the arguments for it have been provided via
  // a FinishGenerateBid() call on `bid_finalizer`, invokes the worklet's
  // generateBid() method, returning the generated bid and associated data.
  // Waits for the worklet script to be loaded first, if needed.
  // FinishGenerateBid() *must* always be called, even if no parameters are
  // provided as promises.
  //
  // Arguments:
  // `bidder_worklet_non_shared_params` values that can vary in the
  //  InterestGroup definitions of the InterestGroups that can share this
  //  BidderWorklet.
  //
  // `key_value_signals_cache_key`: When using version two of the trusted
  //  signals key value protocol, this contains information needed to retrieve
  //  the fetched signals for the call from the browser process through the
  //  TrustedSignalsCache API. When the browser-side cache is disabled and
  //  fetching is done by the worklet service directly, this should be null.
  //  SetTrustedSignalsCache() must have already been called on the parent
  //  AuctionWorkletService before creating the BidderWorklet in order to
  //  pass in a non-null value.
  //
  // `kanon_mode` determines whether to use k-anonymity to potentially re-run
  //  the bidding function with only ads that are k-anonymous and produce an
  //  alternative bid. See GenerateBidClient.OnGenerateBidComplete for more
  //  details.
  //
  // `interest_group_join_origin` is the origin from which the interest group
  //  was joined; can affect context reuse in certain execution modes.
  //
  // `direct_from_seller_per_buyer_signals` The subresource URL of the
  //  DirectFromSellerSignals for the specific owner of this interest group, as
  //  produced by concatenating the `directFromSellerSignals` URL prefix field
  //  passed from runAdAuction() with "?perBuyerSignals=[buyer]" for the
  //  URL-encoded buyer origin for this buyer. Since this is fetched from a
  //  subresource bundle, it may only be fetched using the URLLoaderFactory
  //  passed in when creating the worklet.
  //
  // `direct_from_seller_auction_signals` The subresource URL of the
  //  DirectFromSellerSignals for the seller and all buyers, as produced by
  //  concatenating the `directFromSellerSignals` URL prefix field passed from
  //  runAdAuction() with "?auctionSignals". Since this is fetched from a
  //  subresource bundle, it may only be fetched using the URLLoaderFactory
  //  passed in when creating the worklet.
  //
  // Both `direct_from_seller_auction_signals` and
  // `direct_from_seller_per_buyer_signals` can alternatively be passed as
  // parameters to FinishGenerateBid() if they are not available at time of
  // BeginGenerateBid(); but each parameter can be passed in as non-nullopt at
  // most once.
  //
  // `browser_signal_seller_origin` The origin of the seller script running
  //  the auction. Typically a valid, non-opaque HTTPS origin.
  //
  // `browser_signal_top_level_seller_origin` The top-level seller origin,
  //  if this worklet is running as part of a component (nested) Auction.
  //  Null, otherwise.
  //
  //  `browser_signal_recency` The duration of time from when this device
  //  joined this interest group until now, rounded to the nearest 100ms.
  //
  // `bidding_browser_signals` See BiddingBrowserSignals.
  //
  // `auction_start_time` The time the auction started, used to ensure the
  //  last win times provided to all worklets are relative to the same time.
  //
  //  `requested_ad_size` The size of the ad slot requested in the initial
  //  auction configuration. Will be passed into the buyer-side JS. Optional
  //  because requested size is optional in the originating auction
  //  configuration, and therefore not required to generate bids.
  //
  // `multi_bid_limit` Limit on how many bids can be returned at once from
  //  generateBid().  This is always at least 1.  It has no effect if the
  //  support for returning more than one bid at once is disabled.
  //  OnGenerateBidComplete() may get `multi_bid_limit + 1` bids in case
  //  generateBid() got re-run after returning exactly one bid that's
  //  non-k-anon.
  //
  // `trace_id` ID of a nestable asynchronous trace event of category `fledge`
  //  to use with tracing calls.
  //
  // `generate_bid_client` Client that receives callbacks as GenerateBid()
  //  progresses. Associated to retain priority ordering of calls.
  //
  // `bid_finalizer` should be used to provide the arguments to generateBid()
  //  that may be delivered later (via JS promises).
  BeginGenerateBid(
      BidderWorkletNonSharedParams bidder_worklet_non_shared_params,
      TrustedSignalsCacheKey? key_value_signals_cache_key,
      KAnonymityBidMode kanon_mode,
      url.mojom.Origin interest_group_join_origin,
      url.mojom.Url? direct_from_seller_per_buyer_signals,
      url.mojom.Url? direct_from_seller_auction_signals,
      url.mojom.Origin browser_signal_seller_origin,
      url.mojom.Origin? browser_signal_top_level_seller_origin,
      mojo_base.mojom.TimeDelta browser_signal_recency,
      blink.mojom.BiddingBrowserSignals bidding_browser_signals,
      mojo_base.mojom.Time auction_start_time,
      blink.mojom.AdSize? requested_ad_size,
      uint16 multi_bid_limit,
      uint64 trace_id,
      pending_associated_remote<GenerateBidClient> generate_bid_client,
      pending_associated_receiver<GenerateBidFinalizer> bid_finalizer);

  // Sends pending bidding signals URL requests, if any. Unlike with
  // SellerWorklets, this must be called for BidderWorklets that need to send
  // requests for realtime bidding signals URL. The difference is because each
  // auction makes all GenerateBid() calls to a single BidderWorklet at once
  // one after another, so they know at what point they have made their last
  // GenerateBid() invocation, and only one signals request will need to be
  // made.
  SendPendingSignalsRequests();

  // Calls the worklet's reportWin() method. Waits for the worklet script to
  // be loaded first, if needed.
  //
  // Arguments:
  //  `is_for_additional_bid` If true, this will call reportAdditionalBidWin()
  //  rather than reportWin().
  //
  // `interest_group_name_reporting_id` Optional string value that when
  //  contains value, represents the ad campaign identification signal that
  //  has been provided to ReportWin().
  //
  // `buyer_reporting_id` Optional string value that when
  //  contains value, represents the ad campaign identification signal that
  //  has been provided to ReportWin().
  //
  // `buyer_and_seller_reporting_id` Optional string value that when
  //  contains value, represents the ad campaign identification signal that
  //  has been provided to ReportWin().
  //
  // `selected_buyer_and_seller_reporting_id` Optional string
  // value that when contains value, represents the selected ad campaign
  // identification signal that has been provided to ReportWin().
  //
  // `auction_signals_json` The JSON representation of the auction signals for
  //  the auction, if specified by the publisher page and provided to bidder
  //  worklets competing in an auction. Null if not provided by the publisher
  //  page. Null will be passed to the worklet in that case.
  //
  // `per_buyer_signals_json` The JSON representation of the auction signals
  //  for the specific owner of this interest group, specified by the
  //  publisher page and provided to all interest groups with the same owner
  //  as the one specified `interest_group`. Null if not provided by the
  //  publisher page. Null will be passed to the worklet in that case.
  //
  // `direct_from_seller_per_buyer_signals` The subresource URL of the
  //  DirectFromSellerSignals for the specific owner of this interest group, as
  //  produced by concatenating the `directFromSellerSignals` URL prefix field
  //  passed from runAdAuction() with "?perBuyerSignals=[buyer]" for the
  //  URL-encoded buyer origin for this buyer. Since this is fetched from a
  //  subresource bundle, it may only be fetched using the URLLoaderFactory
  //  passed in when creating the worklet.
  //
  // `direct_from_seller_per_buyer_signals_header_ad_slot` A JSON string of the
  //  DirectFromSellerSignals for this specific buyer. Must not be passed if
  //  `direct_from_seller_per_buyer_signals` or
  //  `direct_from_seller_auction_signals` is passed.
  //
  // `direct_from_seller_auction_signals` The subresource URL of the
  //  DirectFromSellerSignals for the seller and all buyers, as produced by
  //  concatenating the `directFromSellerSignals` URL prefix field passed from
  //  runAdAuction() with "?auctionSignals". Since this is fetched from a
  //  subresource bundle, it may only be fetched using the URLLoaderFactory
  //  passed in when creating the worklet.
  //
  // `direct_from_seller_auction_signals_header_ad_slot` A JSON string of the
  //   DirectFromSellerSignals for the seller and all buyers. Must not be passed
  //   if `direct_from_seller_auction_signals` or
  //   `direct_from_seller_per_buyer_signals` is passed.
  //
  // `seller_signals_json` is a JSON representation of the object returned by
  //  the seller worklet's ReportResult method.
  //
  // `kanon_mode` indicates whether k-anonymity was used to potentially re-run
  //  the bidding function with only ads that are k-anonymous and produce an
  //  alternative bid.
  //
  // `bid_is_kanon` is a boolean flag to show if the winner bid is k-anonymous.
  //
  // `browser_signal_render_url` is the `render_url` returned by the
  //  BidderWorklet's generateBid() method, invoked as part of BidderWorklet
  //  creation.
  //
  // `browser_signal_bid` The stochastically rounded numeric value of the
  //  winning bid. This is always in the bidder's own currency.
  //
  // `browser_signal_bid_currency` Currency for the winning bid.
  //  The client should redact the currency if it's not guaranteed by the
  //  auction configuration to avoid leaking information.
  //
  // `browser_signal_highest_scoring_other_bid` The stochastically rounded
  //  numeric value of the bid that got the second highest score, or 0 if it's
  //  not available, either because there is no such thing or because
  //  sellerCurrency is enabled, and the relevant bid was in a different
  //  currency without scoreAd providing a conversion for it.
  //
  // `browser_signal_highest_scoring_other_bid_currency` The currency associated
  //  with `browser_signal_highest_scoring_other_bid`. If a concrete value is
  //  provided, it's always the sellerCurrency for the auction.
  //
  // `browser_signal_made_highest_scoring_other_bid` True only if owner of
  //  the interest group that ReportWin() is being invoked on behalf of made
  //  all the second-highest scoring bids in the auction.
  //
  // `browser_signal_ad_cost` The stochastically rounded numeric value of the
  //  adCost associated with the winning bid, if specified by `generateBid()`.
  //
  // `browser_signal_modeling_signals` The masked and noised numeric value of
  //  the modelingSignals associated with the winning bid, if specified by
  //  `generateBid()`.
  //
  // `browser_signal_join_count` The masked and noised number of times this
  //  device has joined this interest group in the last 30 days while the
  //  interest group has been continuously stored.
  //
  // `browser_signal_recency` The masked and noised duration of time
  //  (in minutes) from when this device joined this interest group until now.
  //
  // `browser_signal_seller_origin` The origin of the seller script running
  //  the auction. Typically a valid, non-opaque HTTPS origin.
  //
  // `browser_signals_top_level_seller_origin` The top-level seller origin,
  //  if this worklet is running as part of a component (nested) Auction.
  //  Null, otherwise.
  //
  // `browser_signal_reporting_timeout`. The value restricts the runtime of
  //  reportWin() script. Any timeout higher than 5s will be clamped to 5s
  //  before passed in.
  //
  // `bidding_signals_data_version` The value of the Data-Version header served
  //  with the trusted bidding signals.
  //
  // `trace_id` ID of a nestable asynchronous trace event of category `fledge`
  //  to use with tracing calls.
  //
  // Returns:
  // `report_url` is the URL to request to report the result of the auction
  //  to the bidder. It will be null if no reports are requested, or the
  //  report script fails to run.
  //
  // `ad_beacon_map` The map of ad reporting events to URLs for fenced frame
  //  reporting.
  //
  // `ad_macro_map` The map of ad macro names to macro values for macro support
  //  in third party ad tracking.
  //
  // `pa_requests` The various requests made to the Private Aggregation API.
  //
  // `reporting_latency` How long it took to run the JavaScript for
  // `reportWin()` (including the top-level).
  //
  // `errors` is an array of any errors that occurred while attempting
  //  to run the worklet's reportWin() method. These are too sensitive for
  //  the renderer to see. There may be errors even when a `report_url` is
  //  provided, and there may be no errors when there's no `report_url`.
  //  Includes errors from failing to load the worklet script.
  ReportWin(
      bool is_for_additional_bid,
      string? interest_group_name_reporting_id,
      string? buyer_reporting_id,
      string? buyer_and_seller_reporting_id,
      string? selected_buyer_and_seller_reporting_id,
      string? auction_signals_json,
      string? per_buyer_signals_json,
      url.mojom.Url? direct_from_seller_per_buyer_signals,
      string? direct_from_seller_per_buyer_signals_header_ad_slot,
      url.mojom.Url? direct_from_seller_auction_signals,
      string? direct_from_seller_auction_signals_header_ad_slot,
      string seller_signals_json,
      KAnonymityBidMode kanon_mode,
      bool bid_is_kanon,
      url.mojom.Url browser_signal_render_url,
      double browser_signal_bid,
      blink.mojom.AdCurrency? browser_signal_bid_currency,
      double browser_signal_highest_scoring_other_bid,
      blink.mojom.AdCurrency? browser_signal_highest_scoring_other_bid_currency,
      bool browser_signal_made_highest_scoring_other_bid,
      double? browser_signal_ad_cost,
      uint16? browser_signal_modeling_signals,
      uint8 browser_signal_join_count,
      uint8 browser_signal_recency,
      url.mojom.Origin browser_signal_seller_origin,
      url.mojom.Origin? browser_signal_top_level_seller_origin,
      mojo_base.mojom.TimeDelta? browser_signal_reporting_timeout,
      uint32? bidding_signals_data_version,
      uint64 trace_id) => (
          url.mojom.Url? report_url,
          map<string, url.mojom.Url> ad_beacon_map,
          map<string, string> ad_macro_map,
          array<PrivateAggregationRequest> pa_requests,
          BidderTimingMetrics timing_metrics,
          array<string> errors);

  // Establishes a debugger connection to the worklet thread.
  //
  // Arguments:
  // `thread_index` The index of the thread in the thread pool.
  ConnectDevToolsAgent(
      pending_associated_receiver<blink.mojom.DevToolsAgent> agent,
      uint32 thread_index);
};