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

syntax = "proto3";

option optimize_for = LITE_RUNTIME;

package lens;

import "lens_overlay_client_context.proto";
import "lens_overlay_client_logs.proto";
import "lens_overlay_platform.proto";
import "lens_overlay_routing_info.proto";
import "lens_overlay_service_deps.proto";
import "lens_overlay_surface.proto";

// The cluster info request for a Lens Overlay session.
message LensOverlayServerClusterInfoRequest {
  // Whether to return a search session id alongside the server session id.
  bool enable_search_session_id = 1;

  // The client surface.
  Surface surface = 2;

  // The client platform.
  Platform platform = 3;

  // The rendering context.
  RenderingContext rendering_context = 4;
}

message LensOverlayServerClusterInfoResponse {
  // ID for subsequent server requests.
  string server_session_id = 1;

  // ID for subsequent search requests.
  string search_session_id = 2;

  // The routing info for the server session.
  LensOverlayRoutingInfo routing_info = 3;
}

// An error encountered while handling a request.
// Next ID: 4
message LensOverlayServerError {
  enum ErrorType {
    UNKNOWN_TYPE = 0;
    MISSING_REQUEST = 1;

    // Payload chunks are missing from the server cache.
    MISSING_CHUNKS = 2;
  }

  // The error type.
  ErrorType error_type = 1;

  // The metadata for missing chunks.
  MissingChunksMetadata missing_chunks_metadata = 2;
}

// Metadata for missing chunks.
// Next ID: 3
message MissingChunksMetadata {
  // Whether the chunk metadata is missing. Used to verify if
  // the ObjectInteractionRequest was routed to the correct task.
  // If true, the read hit the correct task, and clients should reupload
  // the missing chunks reported.
  // If false, the read hit the wrong task, so clients should retry the read.
  bool has_chunk_metadata = 1;

  // The ids of the missing chunks.
  repeated int64 missing_chunk_ids = 2;
}

// Next ID: 8
message LensOverlayServerRequest {
  // Options for fetching objects.
  LensOverlayObjectsRequest objects_request = 1;

  // Options for fetching interactions.
  LensOverlayInteractionRequest interaction_request = 2;

  // Client logs for the request.
  LensOverlayClientLogs client_logs = 3;

  // A flag to indicate that the request corresponds to an upload from
  // a flow where the user has expressed clear user intent to use Lens.
  bool has_lens_intent = 6;

  // A flag to indicate whether or not to process the image for AIM.
  bool process_image_for_aim = 7;
}

// Response details for an LensOverlay request.
// Next ID: 4
message LensOverlayServerResponse {
  // The encountered error.
  LensOverlayServerError error = 1;

  // The objects response.
  LensOverlayObjectsResponse objects_response = 2;

  // The interaction response.
  LensOverlayInteractionResponse interaction_response = 3;
}
