@crvouga/mockingbird-service-livekit

中文文档
3.11.0发布于 2026/11/11MITTypeScriptES Module构建来源已验证近 30 天下载 1.5万

Stateful LiveKit emulator with Twirp room APIs, JWT grants, participants, data, SIP/egress controls, and signed webhooks.

原始使用文档
文档目录5 节
  1. Install
  2. Usage
  3. Controls
  4. API
  5. Deliberately not modelled

@crvouga/mockingbird-service-livekit

Local emulators. Real API contracts. Part of Mockingbird.

Stateful LiveKit emulator for livekit-server-sdk. It serves Twirp JSON room and agent-dispatch APIs, validates genuine HS256 LiveKit grants, models participant/track/data state, exposes deterministic SIP and egress controls, and emits correctly signed lifecycle webhooks.

Install

npm install -D @crvouga/mockingbird-service-livekit

ESM only. Node 22+ or Bun 1.2+.

Usage

import { RoomServiceClient } from "livekit-server-sdk"
import { createServer } from "@crvouga/mockingbird-service-livekit/server"

// Test setup: the emulator, with the API key and secret the application signs with.
const emulator = await createServer({
  keys: { fixture: "fixture-secret-that-is-at-least-32-chars" },
})

// The application's client. Only the host changes.
const rooms = new RoomServiceClient(emulator.url, "fixture", "fixture-secret-that-is-at-least-32-chars")
const room = await rooms.createRoom({ name: "consult", emptyTimeout: 60, maxParticipants: 4 })
const listed = await rooms.listRooms() // [room]

await emulator.close()

Point RoomServiceClient at emulator.url. Supported RoomService calls include CreateRoom, ListRooms, DeleteRoom, UpdateRoomMetadata, ListParticipants, GetParticipant, RemoveParticipant, UpdateParticipant, MutePublishedTrack, and SendData. Room creation is idempotent by name and participant identity is unique within a room.

AgentDispatchClient uses the same URL and genuine roomAdmin JWTs for createDispatch, listDispatch, getDispatch, and deleteDispatch. Both snake_case and camelCase request fields work. A dispatch creates a missing room, starts with no assigned jobs, and preserves its agent name and opaque metadata. Lists read shared room dispatch state, with an optional dispatch-id filter; deleting a dispatch removes its membership. Deleting or expiring a room removes its dispatches. Dispatch/job timestamps are emulator-clock Unix seconds encoded as protobuf JSON strings (the SDK exposes bigint values). Tests exercise the existing 2.19.1 SDK and the reporter's exact 2.19.0 over HTTP.

Controls

  • POST /__admin/rooms/:room/participants joins a synthetic participant.
  • DELETE /__admin/rooms/:room/participants/:identity disconnects it.
  • POST /__admin/rooms/:room/participants/:identity/tracks publishes a track.
  • GET /__admin/rooms/:room/participants/:identity/inbox inspects targeted data.
  • GET /__admin/resources and POST /__admin/resources/:id/transition inspect and advance SIP/egress state.
  • POST /__admin/dispatches/:id/jobs scripts one room job with {status?: "JS_PENDING"|"JS_RUNNING"|"JS_SUCCESS"|"JS_FAILED", workerId?, agentId?, participantIdentity?, error?}. First assignment creates a stable job id; later calls update it and stamp its start/end/update times. The default status is running.
  • Dispatches and jobs participate in namespaces, reset, snapshots, Timeline and fault recovery alongside room state.
  • Fault presets include rate limiting, network loss, and webhook duplicate/reorder/drop delivery.

Webhooks cover room, participant, track, egress, and SIP transitions. Each raw body is signed by a short-lived LiveKit access token whose sha256 claim is accepted by the official WebhookReceiver.

API

  • LiveKitAPI, LiveKitAPIOptions, LiveKitEvent: handler and event contract.
  • LiveKitRoom, LiveKitParticipant, LiveKitTrack, DataMessage, AsyncResource, AgentDispatch, AgentJob, JobStatus: durable state.
  • createRuntime, LiveKitRuntime, LiveKitRuntimeOptions: full runtime and webhook hub.
  • LIVEKIT_NAMESPACE, LIVEKIT_PRESETS: constants and fault controls.
  • document, operationIds, supportedOperationIds: generated OpenAPI metadata.
  • createServer, LiveKitServerOptions, DEFAULT_PORT, serveTarget from ./server: Node adapter and CLI integration.

Deliberately not modelled

Real agent worker registration, job execution, publisher dispatch, restart/deployment policies, WebRTC media transport, signaling sockets, transcoding, PSTN calls, production scaling, billing, and dashboards are not modelled. The deterministic server API and lifecycle contract is the initial fidelity boundary.

Official oracles: LiveKit RoomService API and AgentDispatchService API.

版本与发布记录

@crvouga/mockingbird-service-livekit 共发布 41 个版本,首次发布于 2026/09/23;过去 12 个月发布了 41 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.11.0latest2026/11/11今天
3.10.92026/11/038 天前
3.10.82026/11/038 天前
3.10.72026/11/038 天前
3.10.62026/11/038 天前
3.10.52026/11/038 天前

关于 @crvouga/mockingbird-service-livekit 的常见问题

@crvouga/mockingbird-service-livekit 是什么?

Stateful LiveKit emulator with Twirp room APIs, JWT grants, participants, data, SIP/egress controls, and signed webhooks.

如何安装 @crvouga/mockingbird-service-livekit?

在项目目录运行 npm install @crvouga/mockingbird-service-livekit,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mockingbird-livekit,可以用 npx mockingbird-livekit 直接运行。

@crvouga/mockingbird-service-livekit 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@crvouga/mockingbird-service-livekit 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@crvouga/mockingbird-service-livekit 可以商用吗?

@crvouga/mockingbird-service-livekit 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@crvouga/mockingbird-service-livekit 的下载量有多少?

根据 npm 官方下载统计,@crvouga/mockingbird-service-livekit 在 2026/10/11 – 2026/11/09 这 30 天内被下载 15,307 次,日均约 510 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@crvouga/mockingbird-service-livekit 还在维护吗?

最新版本 3.11.0 发布于 2026/11/11(今天);至今共发布 41 个版本,其中过去 12 个月发布了 41 个;首次发布于 2026/09/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。