livekit

livekit is a cursor rule for Cursor from SaynaAI/sayna. It costs 0 tokens per session (657 once invoked), scanned A, original, Apache-2.0.

A set of project rules for using the LiveKit Rust software development kit to receive real-time audio. It describes placing the connection code in a separate src/livekit folder and passing a LiveKit access token through the opening WebSocket message.

In plain words
What is it for?
Connecting to a LiveKit room, subscribing to audio tracks, receiving audio chunks, and sending them to a WebSocket audio callback in a Rust application.
Why use it?
It gives the project one expected place and flow for connecting to LiveKit and handling incoming audio. This reduces uncertainty about how LiveKit audio should reach the existing WebSocket callback.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/saynaai/sayna/livekit
Clone the repo
git clone --depth 1 https://github.com/SaynaAI/sayna

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for livekit

README.md
[![agentmods](https://agentmods.dev/badge/rules/saynaai/sayna/livekit.svg)](https://agentmods.dev/rules/saynaai/sayna/livekit)
Your own site
<a href="https://agentmods.dev/rules/saynaai/sayna/livekit"><img src="https://agentmods.dev/badge/rules/saynaai/sayna/livekit.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 657 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00657
Opus 5 $0.00000 $0.00329
Sonnet 5 $0.00000 $0.00131
Haiku 4.5 $0.00000 $0.00066

Measured 4d ago against content hash 0f3bf710ac29, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

livekit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/livekit.mdc · 81 lines

How it starts

The opening of the file, as written. The whole thing — 81 lines — stays where its author put it; the contents beside it link to each section on GitHub.

We are using LiveKit Rust SDK livekit-rust for our real-time communication needs. The idea is that we should have a separate folder named livekit in the src folder. That folder should contain the main logic for connecting to the livekit server and receiving the audio chunks from subscribed tracks.

Basically, user should be able to send the Websocket API message containing the livekit token to connect to the livekit server as a part of the websocket initial message. Then after we subscribe to the audio track, for the incoming audio chunks, we should send the received audio chunks to the Websocket audio callback. Similarly, how we process the audio chunks right now using websocket incoming audio chunks with a callback.

Basic LiveKit Example

This code below connects to the livekit server and subscribes to the audio tracks.

use livekit::prelude::*;

#[tokio::main]
async fn main() -> Result<()> {
    let (room, mut room_events) = Room::connect(&url, &token).await?;

    while let Some(event) = room_events.recv().await {
        match event {
            RoomEvent::TrackSubscribed { track, publication, participant } => {
                // ...
            }
            _ => {}
        }
    }

    Ok(())
}

This code below gets the audio chunks from the subscribed track.

...
use futures::StreamExt; // this trait is required for iterating on audio & video frames
use livekit::prelude::*;

match event {
    RoomEvent::TrackSubscribed { track, publication, participant } => {
        match track {
            RemoteTrack::Audio(audio_track) => {
                let rtc_track = audio_track.rtc_track();
                let mut audio_stream = NativeAudioStream::new(rtc_track);
                tokio::spawn(async move {
                    // Receive the audio frames in a new task
                    while let Some(audio_frame) = audio_stream.next().await {
                        log::info!("received audio frame - {audio_frame:#?}");
                    }
                });
            },
        }
    },
    _ => {}
}

Read the full file on GitHub · 81 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 81 lines · 0 tokens per session scan A 0f3bf710ac29

Subscribe to this mod's changes

livekit is a cursor rule published in the GitHub repository SaynaAI/sayna (311 stars, last pushed 3mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 657 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.