github.com/livekit/protocol@v1.16.1-0.20240517185851-47e4c6bba773/protobufs/livekit_agent.proto (about)

     1  // Copyright 2023 LiveKit, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  syntax = "proto3";
    16  
    17  package livekit;
    18  option go_package = "github.com/livekit/protocol/livekit";
    19  option csharp_namespace = "LiveKit.Proto";
    20  option ruby_package = "LiveKit::Proto";
    21  
    22  import "livekit_models.proto";
    23  
    24  message WorkerInfo {
    25      string id = 1;
    26      string namespace = 2;
    27      string version = 3;
    28      string name = 4;
    29      JobType type = 5;
    30      ParticipantPermission allowed_permissions = 6;
    31  }
    32  
    33  message AgentInfo {
    34      string id = 1;
    35      string name = 2;
    36      string version = 3;
    37  }
    38  
    39  message Job {
    40      string id = 1;
    41      JobType type = 2;
    42      Room room = 3;
    43      optional ParticipantInfo participant = 4;
    44      string namespace = 5;
    45  }
    46  
    47  // from Worker to Server
    48  message WorkerMessage {
    49      oneof message {
    50          // agent workers need to register themselves with the server first
    51          RegisterWorkerRequest register = 1;
    52          // worker confirms to server that it's available for a job, or declines it
    53          AvailabilityResponse availability = 2;
    54  
    55          // worker can update its status to the server, including taking itself out of the pool
    56  	UpdateWorkerStatus update_worker = 3;
    57  	// job can send status updates to the server, useful for tracking progress
    58          UpdateJobStatus update_job = 4;
    59  
    60  	WorkerPing ping = 5;
    61  	SimulateJobRequest simulate_job = 6;
    62  	MigrateJobRequest migrate_job = 7;
    63      };
    64  }
    65  
    66  // from Server to Worker
    67  message ServerMessage {
    68      oneof message {
    69          // server confirms the registration, from this moment on, the worker is considered active
    70          RegisterWorkerResponse register = 1;
    71          // server asks worker to confirm availability for a job
    72          AvailabilityRequest availability = 2;
    73          JobAssignment assignment = 3;
    74  	WorkerPong pong = 4;
    75      }
    76  }
    77  
    78  enum JobType {
    79      JT_ROOM = 0;
    80      JT_PUBLISHER = 1;
    81  }
    82  
    83  enum WorkerStatus {
    84      WS_AVAILABLE = 0;
    85      WS_FULL = 1;
    86  }
    87  
    88  enum JobStatus {
    89      JS_UNKNOWN = 0;
    90      JS_SUCCESS = 1;
    91      JS_FAILED = 2;
    92  }
    93  
    94  message SimulateJobRequest {
    95      JobType type = 1;
    96      Room room = 2;
    97      ParticipantInfo participant = 3;
    98  }
    99  
   100  message WorkerPing {
   101      int64 timestamp = 1;
   102  }
   103  
   104  message WorkerPong {
   105      int64 last_timestamp = 1;
   106      int64 timestamp = 2;
   107  }
   108  
   109  message RegisterWorkerRequest {
   110      JobType type = 1;
   111      //string worker_id = 2;
   112      string version = 3;
   113      string name = 4;
   114      uint32 ping_interval = 5;
   115      optional string namespace = 6;
   116      ParticipantPermission allowed_permissions = 7;
   117  }
   118  
   119  message RegisterWorkerResponse {
   120      string worker_id = 1;
   121      ServerInfo server_info = 3;
   122  }
   123  
   124  message MigrateJobRequest {
   125      string job_id = 1;
   126  }
   127  
   128  message AvailabilityRequest {
   129      Job job = 1;
   130  
   131      // True when the job was previously assigned to another worker but has been 
   132      // migrated due to different reasons (e.g. worker failure, job migration)
   133      bool resuming = 2;
   134  }
   135  
   136  
   137  message AvailabilityResponse {
   138      string job_id = 1;
   139      bool available = 2;
   140      bool supports_resume = 3;
   141  
   142      string participant_name = 4;
   143      string participant_identity = 5;
   144      string participant_metadata = 6;
   145  }
   146  
   147  message UpdateJobStatus {
   148      string job_id = 1;
   149  
   150      // The worker can indicate the job end by either specifying SUCCESS or FAILED
   151      optional JobStatus status = 2;
   152  
   153      // metadata shown on the dashboard, useful for debugging
   154      string error = 3;
   155  
   156      // the metadata can be updated multiple times
   157      optional string metadata = 4;
   158      
   159      // The load that the job currently has on the worker
   160      float load = 5;
   161  }
   162  
   163  message UpdateWorkerStatus {
   164      optional WorkerStatus status = 1;
   165      optional string metadata = 2;
   166      float load = 3;
   167  }
   168  
   169  message JobAssignment {
   170      Job job = 1;
   171      optional string url = 2;
   172      string token = 3; 
   173  }
   174