// ───────────────────────────────────────── proto/lesavka.proto
syntax = "proto3";
package lesavka;

message KeyboardReport { bytes data = 1; }
message MouseReport    { bytes data = 1; }

message MonitorRequest {
  uint32 id = 1;
  uint32 max_bitrate = 2;
  uint32 requested_width = 3;
  uint32 requested_height = 4;
  uint32 requested_fps = 5;
  optional uint32 source_id = 6;
}
message VideoPacket    {
  uint32 id = 1;
  uint64 pts = 2;
  bytes data = 3;
  uint64 seq = 4;
  uint32 effective_fps = 5;
  uint64 dropped_total = 6;
  uint32 queue_depth = 7;
  uint32 server_source_gap_peak_ms = 8;
  uint32 server_send_gap_peak_ms = 9;
  uint32 server_queue_peak = 10;
  string server_encoder_label = 11;
  uint32 server_process_cpu_tenths = 12;
}
message AudioPacket    { uint32 id = 1; uint64 pts = 2; bytes data = 3; }

message ResetUsbReply  { bool ok = 1; } // true = success

message PasteRequest   {
  bytes nonce = 1;
  bytes data = 2;
  bool encrypted = 3;
}
message PasteReply     { bool ok = 1; string error = 2; }
message CapturePowerState {
  bool available = 1;
  bool enabled = 2;
  string unit = 3;
  string detail = 4;
  uint32 active_leases = 5;
  string mode = 6;
  uint32 detected_devices = 7;
}
enum CapturePowerCommand {
  CAPTURE_POWER_COMMAND_UNSPECIFIED = 0;
  CAPTURE_POWER_COMMAND_AUTO = 1;
  CAPTURE_POWER_COMMAND_FORCE_ON = 2;
  CAPTURE_POWER_COMMAND_FORCE_OFF = 3;
}
message SetCapturePowerRequest {
  bool enabled = 1;
  CapturePowerCommand command = 2;
}

message HandshakeSet  {
  bool camera = 1;
  bool microphone = 2;
  string camera_output = 3;
  string camera_codec = 4;
  uint32 camera_width = 5;
  uint32 camera_height = 6;
  uint32 camera_fps = 7;
  uint32 eye_width = 8;
  uint32 eye_height = 9;
  uint32 eye_fps = 10;
  string server_version = 11;
}

message Empty          {}

service Relay {
  rpc StreamKeyboard   (stream KeyboardReport)   returns (stream KeyboardReport);
  rpc StreamMouse      (stream MouseReport)      returns (stream MouseReport);
  rpc CaptureVideo     (MonitorRequest)          returns (stream VideoPacket);
  rpc CaptureAudio     (MonitorRequest)          returns (stream AudioPacket);
  rpc StreamMicrophone (stream AudioPacket)      returns (stream Empty);
  rpc StreamCamera     (stream VideoPacket)      returns (stream Empty);

  rpc PasteText        (PasteRequest)            returns (PasteReply);
  rpc ResetUsb         (Empty)                   returns (ResetUsbReply);
  rpc GetCapturePower  (Empty)                   returns (CapturePowerState);
  rpc SetCapturePower  (SetCapturePowerRequest)  returns (CapturePowerState);
}

service Handshake {
  rpc GetCapabilities (Empty)                    returns (HandshakeSet);
}
