LiveKit Protocol
repository·main·Indexed 40 days ago
https://github.com/livekit/protocolProtocol definitions and generated protobuf stubs for LiveKit, featuring the participant RPC (RoomRPC) registry for structured communication between participants and the LiveKit server. Includes definitions for agent-related communication, room data structures, real-time communication protocols, and Egress/Ingress services.
What's inside LiveKit
- This repository contains the generated protobuf stubs for the LiveKit protocol. It provides the core data structures and communication definitions used for participant RPCs (RoomRPC) and other real-time communication protocols within the LiveKit ecosystem.
Understand LiveKit participant RPCs registry (roomrpc)
mainTheroomrpcregistry contains protobuf definitions for well-known LiveKit participant Remote Procedure Calls (RPCs). These definitions specify the request and response messages used when participants interact with the LiveKit server or other participants via RPC.Follow the naming convention for roomrpc proto files
mainTo ensure consistency and avoid collisions, all proto files in the
roomrpcregistry must follow a specific naming convention:roomrpc_<type>_v<vers>.proto.Note that the version is a single sequential number, not a semantic version (semver).
Example:
roomrpc_sip_v1.protoImplement versioned RPC services and messages
mainWhen defining versioned RPCs, follow these rules to maintain compatibility and avoid Go package name collisions:
- Directory Structure: Place each participant type or API in its own directory under
roomrpcnamed<type>rpc. - Service Naming: Append
V<vers>as a suffix to the service definition. - Message Naming: Append
V<vers>as a suffix to all request and response message types. - Method Naming: Do not include the version in the RPC method name itself, as the version is already captured in the service name.
Example Implementation:
service MyServiceV1 { rpc DoSomething(DoSomethingV1Request) returns (DoSomethingV1Response); } message DoSomethingV1Request {} message DoSomethingV1Response {}- Directory Structure: Place each participant type or API in its own directory under
Import LiveKit Protocol modules
mainThe
@livekit/protocolpackage provides generated Protobuf stubs for various LiveKit services. You can import specific service namespaces or utility types likeprotoInt64andTimestampfrom the main entry point.Commonly used namespaces include:
AgentSession,AgentInference,AgentText,AgentDev: For agent-related communication.livekit_agent_dispatch_pb: Agent dispatching logic.livekit_room_pb: Room-related data structures.livekit_rtc_pb: Real-time communication protocols.livekit_egress_pb/livekit_ingress_pb: Egress and Ingress services.livekit_token_source_pb: Token generation structures.
import { protoInt64, Timestamp, AgentSession, AgentInference, // ... other imports } from '@livekit/protocol';