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

edition = "2023";

package optimization_guide.proto;

import "components/optimization_guide/proto/features/common_quality_data.proto";

import "components/optimization_guide/proto/model_quality_metadata.proto";

option optimize_for = LITE_RUNTIME;
option java_package = "org.chromium.components.optimization_guide.features.proto";

option java_outer_classname = "ContentAnnotationProto";

// DO NOT EDIT THIS FILE DIRECTLY!
//
// This file is generated in g3 and then synced to Chrome. Instead, please refer to
// http://go/chrome-mqls-onboarding (Google-internal link), and then changes will
// be synced with Chrome automatically.

message ContentAnnotationLoggingData {
  ContentAnnotationRequest request = 1 [features = { field_presence: EXPLICIT }];

  ContentAnnotationResponse response = 2 [features = { field_presence: EXPLICIT }];

  // Internal logging information from the model execution.
  ModelExecutionInfo model_execution_info = 3 [features = { field_presence: EXPLICIT }];
}

// Holds the input data e.g. web page content for the content annotation
// feature.
// Next ID: 2
message ContentAnnotationRequest {
  // The annotated page content of the high value pages e.g. checkout, cart and
  // booking pages.
  PageContext page_context = 1 [features = { field_presence: EXPLICIT }];
}

// Holds the output data for the content annotation feature.
// Next ID: 3
message ContentAnnotationResponse {
  // Deprecated. Use content_annotation field instead.
  string extracted_data = 1 [
    deprecated = true,
    features = { field_presence: EXPLICIT }
  ];

  // The structured content annotation result schema.
  ContentAnnotation content_annotation = 2 [features = { field_presence: EXPLICIT }];
}

// Structured content annotation result from the LLM.
// Max length of arrays is 100 items. Max length of strings is 1000 characters,
// unless it holds a numerical string value, e.g. tracking number, which has a
// maximum length of 100 characters.
message ContentAnnotation {
  // A brief summary of the annotation.
  string description = 1 [features = { field_presence: EXPLICIT }];

  Status status = 2 [features = { field_presence: EXPLICIT }];

  // The structured, validated extracted data for supported verticals.
  // One of structured_data or supplemental_data must be set.
  StructuredData structured_data = 3 [features = { field_presence: EXPLICIT }];

  // Free schema key-value pairs from the page containing user insights/context.
  repeated DynamicAttribute supplemental_data = 5;

  // The validation status: 'confirmed' or 'pending'.
  enum Status {
    STATUS_UNSPECIFIED = 0;

    CONFIRMED = 1;

    PENDING = 2;
  }

  reserved 4;
}

// Holds the structured fields for supported verticals.
message StructuredData {
  repeated Order orders = 1;

  repeated Shipment shipments = 2;

  repeated FlightReservation flight_reservations = 3;

  repeated HotelBooking hotel_bookings = 4;

  repeated CarRental car_rentals = 5;
}

message Order {
  string id = 1 [features = { field_presence: EXPLICIT }];

  repeated Product products = 2;

  Date order_date = 3 [features = { field_presence: EXPLICIT }];

  double grand_total = 4 [features = { field_presence: EXPLICIT }];
}

message Product {
  string name = 1 [features = { field_presence: EXPLICIT }];

  int32 quantity = 2 [features = { field_presence: EXPLICIT }];
}

message Date {
  int32 year = 1 [features = { field_presence: EXPLICIT }];

  int32 month = 2 [features = { field_presence: EXPLICIT }];

  int32 day = 3 [features = { field_presence: EXPLICIT }];
}

message Shipment {
  string associated_order_id = 1 [features = { field_presence: EXPLICIT }];

  string tracking_number = 2 [features = { field_presence: EXPLICIT }];

  string carrier_name = 3 [features = { field_presence: EXPLICIT }];

  string delivery_address = 4 [features = { field_presence: EXPLICIT }];
}

message FlightReservation {
  string confirmation_code = 1 [features = { field_presence: EXPLICIT }];

  double grand_total = 2 [features = { field_presence: EXPLICIT }];

  string flight_number = 3 [features = { field_presence: EXPLICIT }];

  string passenger_name = 4 [features = { field_presence: EXPLICIT }];

  // IATA airport code
  string departure_airport = 5 [features = { field_presence: EXPLICIT }];

  // IATA airport code
  string arrival_airport = 6 [features = { field_presence: EXPLICIT }];

  Date departure_date = 7 [features = { field_presence: EXPLICIT }];
}

message HotelBooking {
  string confirmation_code = 1 [features = { field_presence: EXPLICIT }];

  double grand_total = 2 [features = { field_presence: EXPLICIT }];

  string property_name = 3 [features = { field_presence: EXPLICIT }];

  Date check_in_date = 4 [features = { field_presence: EXPLICIT }];

  Date check_out_date = 5 [features = { field_presence: EXPLICIT }];

  string city = 6 [features = { field_presence: EXPLICIT }];

  string guest_name = 7 [features = { field_presence: EXPLICIT }];

  int32 number_of_guests = 8 [features = { field_presence: EXPLICIT }];
}

message CarRental {
  string confirmation_code = 1 [features = { field_presence: EXPLICIT }];

  double grand_total = 2 [features = { field_presence: EXPLICIT }];

  string car_model = 3 [features = { field_presence: EXPLICIT }];

  string guest_name = 4 [features = { field_presence: EXPLICIT }];

  string pickup_location_name = 5 [features = { field_presence: EXPLICIT }];

  string dropoff_location_name = 6 [features = { field_presence: EXPLICIT }];

  Date pickup_date = 7 [features = { field_presence: EXPLICIT }];

  Date dropoff_date = 8 [features = { field_presence: EXPLICIT }];

  string merchant = 9 [features = { field_presence: EXPLICIT }];
}

message DynamicAttribute {
  oneof value {
    string string_value = 2;

    double number_value = 3;
  }

  string key = 1 [features = { field_presence: EXPLICIT }];
}
