Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
Voice Runtime: LiveKit audio subscription and normalized ASR observations
Boundary
- This directory is the worker package used by the node-services voice supervisor; it has no standalone deployment image.
- It subscribes to LiveKit microphone tracks, runs the configured streaming ASR adapter, and reports normalized observations through the generated TeamHub Voice Runtime client.
- ASR serves
hardware_controlandchat_dictationand publishes no audio or data tracks. The dedicated--liveworker serveschat_liveand publishes its reply audio and structured events. - The supervisor starts isolated LiveKit workers:
start(linger-voice-runtime) transcribes;start --recorder(linger-voice-recorder) records Capture media. While the Room metadata names an epoch, the recorder encodes the publisher track into AAC HLS segments with ffmpeg and uploads them and its state to TeamHub. It holds no object-store credentials. - It owns no product database, Room permission, Capture classification, command execution, Artifact, Document, or Message state.
- Do not import source from another
apps/*directory. Cross-process calls use generated contracts.
Structure
src/config.ts: validated environment configuration without logging secrets, includingLIVEKIT_URL/LIVEKIT_API_KEY/LIVEKIT_API_SECRETwith defaults for the LiveKit service of the rootdocker-compose.ymlon its published port (TeamHub uses the same defaults), health port, session limit, Soniox model and language hints.src/livekit-worker.ts: Room/track lifecycle and bounded audio consumption.src/asr.ts: small provider interface and shared event helpers;src/soniox.tsis the only streaming adapter; the ASR worker requiresSONIOX_API_KEY. The Live worker requires onlyXAI_API_KEYand shows the live model's own input transcript; it never uses Soniox. Recording always diarizes speakers; dictation does not. TeamHub reads the same key for archive recovery.src/dictation-asr.ts:chat_dictationturn segmentation over one Soniox connection; turns end on Soniox utterance endpoints or on a manual commit's non-closing finalization.src/main.ts: process lifecycle, health/readiness endpoints, and graceful shutdown.src/recorder-agent.ts: the recorder worker's job entry; follows the publisher track and Room metadata.src/capture-recorder.ts: Capture recording. Follows the Room metadata directive, reads the track at 48 kHz independently of ASR, pads silence to wall-clock time, uploads contiguous segments then the playlist, and reports active, available, or failed (includingrecorder_handoveron shutdown).- Tests stay beside the owning module as
*.test.ts.
Commands
pnpm --filter @linger/voice-runtime typecheckpnpm --filter @linger/voice-runtime testpnpm --filter @linger/voice-runtime build
Invariants
- Never log audio bytes, transcript text, LiveKit tokens, TeamHub tokens, or provider credentials.
- Partial observations are transient; TeamHub decides which final observations become product truth.
- A duplicated provider event reuses the same stable
event_id. - Every track consumer attempt claims its transcript media epoch from TeamHub (
claimVoiceMediaEpoch) and never counts epochs in memory: a job restarted mid-session (deploy, crash, key change) must not reuse an epoch whose coverage stream an earlier job started. - Backpressure is bounded. Failure must stop or reconnect the affected track instead of accumulating unbounded PCM.
- Shutdown waits for accepted final/progress callbacks up to a fixed deadline and then exits non-zero if state is uncertain.
- During reply playback, the Live worker's local gate sends the microphone as silence unless Silero hears speech within
otherSpeakerDbof the level it learned on this track; quieter speech neither reaches the provider nor pauses a reply. Outside playback, Silero alone gates the microphone so a stale learned level cannot mute the user's next turn. - Never move recording back into the ASR job process; ASR load or failure must never stall the Capture recorder. A recorder never extends an epoch it did not start; TeamHub rejects the conflicting segment and the recorder reports failure.