@relaymessenger/livekit 0.1.0-staging.0 → 0.1.0-staging.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -39,10 +39,21 @@ async function answerCall(callId: string, session: AgentSession) {
39
39
  ```
40
40
 
41
41
  `RelayLiveKitCall.connect()` does not resolve until the WebRTC media peer has
42
- reached `connected`. `RelayAudioInput` converts the remote participant's PCM16
43
- audio to LiveKit frames. `RelayAudioOutput` publishes LiveKit TTS frames to
44
- Relay, pacing larger frames into 10 ms WebRTC source slices. `clearBuffer()`
45
- drops queued outbound audio that has not yet reached WebRTC.
42
+ reached `connected`. `RelayAudioInput` hands the AgentSession the remote
43
+ participant's audio as 24 kHz mono PCM16 frames, the format of LiveKit's own
44
+ room input; the Opus decoder produces that format directly.
45
+
46
+ `RelayAudioOutput` has the shape of LiveKit's own `ParticipantAudioOutput`:
47
+ `captureFrame()` hands the frame to the transport and returns at once, so the
48
+ AgentSession may push a whole reply faster than real time; the engine's 20 ms
49
+ pump paces the wire. `flush()` closes the segment and reports
50
+ `playbackFinished` only after the transport has drained. `clearBuffer()` drops
51
+ audio that has not reached the wire and reports the segment as interrupted at
52
+ the position that actually played.
53
+
54
+ On the transport, `writeAudio()` resolves once its 10 ms slices are queued,
55
+ `queuedAudioMs()` is what has not left yet, and `waitForPlayout()` resolves when
56
+ the queue is empty and the pump is idle (early on `clearAudio()`).
46
57
 
47
58
  Use `setMuted(true)` to publish participant mute state, `end()` to end the Relay
48
59
  Call, and `close()` for local cleanup. If the signaling connection is replaced,
@@ -63,6 +74,9 @@ const transport = new RelayCallTransport({ room });
63
74
  transport.on("audio", ({ samples, sampleRate, channelCount }) => {
64
75
  // Interleaved signed PCM16 from the remote Relay participant.
65
76
  });
77
+ // Inbound audio is 48 kHz stereo unless you pass
78
+ // `inboundAudio: { sampleRate: 8000 | 12000 | 16000 | 24000 | 48000, channelCount: 1 | 2 }`;
79
+ // the `"wrtc"` engine accepts only the default.
66
80
 
67
81
  await transport.connect();
68
82
  await transport.writeAudio({
@@ -70,8 +84,84 @@ await transport.writeAudio({
70
84
  sampleRate: 48_000,
71
85
  channelCount: 1,
72
86
  });
87
+ await transport.waitForPlayout();
73
88
  ```
74
89
 
90
+ ## ICE servers, TURN, and diagnostics
91
+
92
+ By default the peer gathers host candidates only and Cloudflare's SFU supplies
93
+ its own candidates in the answer. Inside a container or behind a firewall that
94
+ blocks outbound UDP, pass TURN servers in the standard `RTCIceServer` shape and,
95
+ if every path must go through TURN, `iceTransportPolicy: "relay"`. Both options
96
+ are accepted by `RelayLiveKitCall.connect()` and `RelayCallTransport`.
97
+
98
+ ```ts
99
+ const call = await RelayLiveKitCall.connect({
100
+ relay,
101
+ callId,
102
+ iceServers: [
103
+ {
104
+ urls: [
105
+ "turn:turn.cloudflare.com:3478?transport=udp",
106
+ "turn:turn.cloudflare.com:3478?transport=tcp",
107
+ "turns:turn.cloudflare.com:5349?transport=tcp",
108
+ ],
109
+ username: process.env.TURN_USERNAME!,
110
+ credential: process.env.TURN_CREDENTIAL!,
111
+ },
112
+ ],
113
+ iceTransportPolicy: "all",
114
+ });
115
+ ```
116
+
117
+ `iceServers` may also be a function; it is called before every peer
118
+ connection, so it can mint fresh TURN credentials for each restart.
119
+
120
+ `connect()` resolves when media first reaches `connected`. It has no overall
121
+ deadline: when an SFU session is not `connected` within
122
+ `sessionConnectTimeoutMs` (5 seconds by default) of its answer, becomes
123
+ `failed`, or stays `disconnected` for 7 seconds, the transport closes that
124
+ peer, waits 250 ms (x1.1 per further attempt, at most 10 s), and publishes
125
+ from a new peer on a new session, for as long as the Call is ringing or in
126
+ progress. Outgoing audio keeps flowing into the new peer. `connect()` rejects
127
+ only when the Call ends, the room or transport closes, the room reports an
128
+ error, or the `signal` passed to it aborts. Each replacement emits
129
+ `restarted` with the reason and the replaced session's summary, for example
130
+ `local: host 2, srflx 0, relay 0; remote: udp 1473; states: new→complete 0.2s, connecting 0.3s, no connected; …`,
131
+ and `diagnostics().restarts` counts them. `mediaConnectTimeoutMs` and
132
+ `connectionTimeoutMs` are deprecated names for `sessionConnectTimeoutMs`.
133
+
134
+ `call.waitForPeerAudio(timeoutMs)` resolves once the person's audio has
135
+ arrived and the room shows them connected (the transport's `peerAudio` event);
136
+ start the agent's session after it so the first words are heard.
137
+
138
+ The same facts are available at any time from `call.diagnostics()` or
139
+ `transport.diagnostics()`: local candidate counts by type, the remote
140
+ candidates' transport and port (never their address), the ICE gathering, ICE
141
+ connection and peer connection state changes with their offsets from
142
+ `connect()`, packet counts in both directions (`inbound`: RTP received, Opus
143
+ decode failures, PCM frames delivered, first and last packet offsets, packets
144
+ in the last 5 s; `outbound`: PCM frames accepted, Opus packets, RTP written
145
+ with the caller's audio, RTP written with silence, first and last packet
146
+ offsets, packets in the last 5 s, paced queue size, pacer state), the room frames seen (`roomState` count, pull `offer` count,
147
+ `ended` reason, `error` messages), and the one-line `summary`, for example
148
+ `…; in: 1234 rtp, 0 bad, 1234 frames, first 0.9s last 41.2s, 250/5s; out: 2600 frames, 1300 opus, 1300 rtp, silence 700, first 1.1s last 41.0s, 250/5s, queue 0, pacer alive; room: 3 roomState, 1 offer`.
149
+ Packet counts come from the `werift` engine; `wrtc` reports zero packets and
150
+ `pacer n/a`.
151
+
152
+ Like a live microphone, the `werift` engine's published track sends one Opus
153
+ packet every 20 ms from the moment media connects until the transport closes:
154
+ the caller's audio when some is queued, Opus silence otherwise. Cloudflare's
155
+ SFU will not let the person's side pull a track that has carried no RTP, so a
156
+ silent agent track would never be heard. Silence never counts toward
157
+ `queuedAudioMs()` or `waitForPlayout()`. The `wrtc` engine sends only the
158
+ audio written to it; write silence yourself if you use it.
159
+
160
+ `onWarning` is called once per call, with the summary, when outbound audio is
161
+ queued but no RTP packet has been written for 2 s while media is connected.
162
+ Nothing is restarted; the callback exists so the failing direction is named in
163
+ the agent's logs.
164
+
75
165
  `RelayCallTransport` consumes the SDK's `CallRoom`; it does not duplicate the
76
166
  room protocol. The default engine is `werift` (pure TypeScript WebRTC) with
77
167
  `@evan/opus` (prebuilt Opus, WASM fallback), so no native WebRTC binding is
@@ -1,17 +1,19 @@
1
1
  import { RTCPeerConnection } from "werift";
2
- import type { RelayAudioSourceLike, RelayWebRTCFactory } from "./transport.js";
2
+ import type { RelayAudioSourceLike, RelayPeerConnectionConfig, RelayWebRTCFactory } from "./transport.js";
3
3
  /** Opus on the wire is always 48 kHz; Relay sends stereo so callers may pass either channel count. */
4
4
  export declare const WERIFT_SAMPLE_RATE = 48000;
5
5
  export declare const WERIFT_CHANNEL_COUNT = 2;
6
6
  /** One RTP packet carries 20 ms: 960 frames at 48 kHz, timestamp advances by 960. */
7
7
  export declare const WERIFT_PACKET_MS = 20;
8
8
  export type WeriftAudioSourceData = Parameters<RelayAudioSourceLike["onData"]>[0];
9
+ /** Packets counted for `diagnostics()`; the recent window is the last 5 s. */
10
+ export declare const STATS_WINDOW_MS = 5000;
9
11
  /** Convert any PCM16 frame to interleaved 48 kHz stereo by linear interpolation. */
10
12
  export declare const toWireFormat: (data: {
11
13
  samples: Int16Array;
12
14
  sampleRate: number;
13
15
  channelCount: number;
14
16
  }) => Int16Array;
15
- export declare const createWeriftPeerConnection: () => RTCPeerConnection;
17
+ export declare const createWeriftPeerConnection: (config?: RelayPeerConnectionConfig) => RTCPeerConnection;
16
18
  export declare const createWeriftWebRTCFactory: () => RelayWebRTCFactory;
17
19
  //# sourceMappingURL=engine-werift.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-werift.d.ts","sourceRoot":"","sources":["../src/engine-werift.ts"],"names":[],"mappings":"AA0BA,OAAO,EAGL,iBAAiB,EAIlB,MAAM,QAAQ,CAAC;AAChB,OAAO,KAAK,EAEV,oBAAoB,EAGpB,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AAExB,sGAAsG;AACtG,eAAO,MAAM,kBAAkB,QAAS,CAAC;AACzC,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,q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24 @@
8
8
  * `onconnectionstatechange`, `localDescription`, `close()`, and the
9
9
  * `"icegatheringstatechange"` / `"connectionstatechange"` events emitted
10
10
  * through `EventTarget.addEventListener` (peerConnection.js:317, :330).
11
+ * `RTCConfiguration.iceServers: RTCIceServer[]` ({ urls, username?,
12
+ * credential? }) and `iceTransportPolicy: "all" | "relay"` (peerConnection.d.ts
13
+ * :264-273); utils.js:110-179 parses `stun|stuns|turn|turns:` URLs with
14
+ * `?transport=`, and `secureTransportManager.js:121` maps `"relay"` to
15
+ * `forceTurn`. The W3C setters `onicecandidate`, `onicegatheringstatechange`
16
+ * and `oniceconnectionstatechange` (peerConnection.d.ts:67-82, fired at
17
+ * peerConnection.js:314-341) feed the transport's ICE diagnostics.
11
18
  * - media/track.d.ts: `MediaStreamTrack({ kind })`, `writeRtp(RtpPacket)`,
12
19
  * `onReceiveRtp: Event<[RtpPacket, Extensions?]>` with `subscribe()`.
13
20
  * - media/rtpSender.js:544-549: the sender rewrites ssrc and payloadType and
14
21
  * offsets sequenceNumber/timestamp, so the local track starts both at 0.
15
22
  * - ../../rtp/src/codec/opus.d.ts: `OpusRtpPayload.deSerialize(buffer)`.
16
23
  * - node_modules/@evan/opus/lib.d.ts: `Encoder.encode(pcm16)` returns one Opus
17
- * packet; `Decoder.decode(packet)` returns interleaved PCM16 bytes.
24
+ * packet; `Decoder.decode(packet)` returns interleaved PCM16 bytes;
25
+ * `new Decoder({ channels?: 1 | 2, sample_rate?: 8000 | 12000 | 16000 |
26
+ * 24000 | 48000 })` decodes any Opus stream to that count and rate (libopus
27
+ * `opus_decoder_create(Fs, channels)`), which is how the sink honours
28
+ * `RelayInboundAudioFormat`.
18
29
  * Participant shapes copied from the headless phone that joined Relay's room
19
30
  * through Cloudflare's SFU on 2026-09-21 (_runtime/bin/headless-phone-webrtc.mjs
20
31
  * lines 93-160): `bundlePolicy: "max-bundle", iceServers: []` (Cloudflare
@@ -34,6 +45,34 @@ const PACKET_FRAMES = (WERIFT_SAMPLE_RATE * WERIFT_PACKET_MS) / 1000;
34
45
  const PACKET_SAMPLES = PACKET_FRAMES * WERIFT_CHANNEL_COUNT;
35
46
  /** Dynamic payload type; werift's sender replaces it with the negotiated one. */
36
47
  const LOCAL_PAYLOAD_TYPE = 111;
48
+ /** Packets counted for `diagnostics()`; the recent window is the last 5 s. */
49
+ export const STATS_WINDOW_MS = 5_000;
50
+ /** Monotone packet counter with first/last epoch timestamps and a 5 s window. */
51
+ class PacketClock {
52
+ count = 0;
53
+ firstAt;
54
+ lastAt;
55
+ #recent = [];
56
+ mark(now = Date.now()) {
57
+ this.count += 1;
58
+ this.firstAt ??= now;
59
+ this.lastAt = now;
60
+ this.#recent.push(now);
61
+ this.#prune(now);
62
+ }
63
+ recent(now = Date.now()) {
64
+ this.#prune(now);
65
+ return this.#recent.length;
66
+ }
67
+ #prune(now) {
68
+ const floor = now - STATS_WINDOW_MS;
69
+ let drop = 0;
70
+ while (drop < this.#recent.length && this.#recent[drop] < floor)
71
+ drop += 1;
72
+ if (drop)
73
+ this.#recent.splice(0, drop);
74
+ }
75
+ }
37
76
  /** Convert any PCM16 frame to interleaved 48 kHz stereo by linear interpolation. */
38
77
  export const toWireFormat = (data) => {
39
78
  const { samples, sampleRate, channelCount } = data;
@@ -62,8 +101,21 @@ export const toWireFormat = (data) => {
62
101
  };
63
102
  /**
64
103
  * PCM16 in, paced 20 ms Opus RTP out. Frames are accumulated into whole
65
- * packets; a timer drains one packet every 20 ms so the wire sees a steady
66
- * cadence regardless of how the adapter chunks its writes.
104
+ * packets; a timer writes one packet every 20 ms so the wire sees a steady
105
+ * cadence regardless of how the adapter chunks its writes. Adapters may push
106
+ * far ahead of real time: `queuedMs()` is what has not left yet and
107
+ * `waitForDrain()` resolves once the queued application audio has been
108
+ * written (LiveKit's `AudioSource.queuedDuration` / `waitForPlayout` shape).
109
+ *
110
+ * From `start()` (the transport calls it when the peer first connects) until
111
+ * the track stops, the pump never pauses: a tick with no application audio
112
+ * queued writes an Opus silence frame instead, as a live microphone track
113
+ * does. Cloudflare's SFU refuses to pull a published track that has carried
114
+ * no RTP: `tracks/new` for the remote track returned `empty_track_error` "No
115
+ * track data from remote peer" after about 8.2 s on staging 2026-09-22, and
116
+ * the same pull returned in about 470 ms with silence flowing. Silence and
117
+ * application packets share one sequence and timestamp line, so queued audio
118
+ * replaces silence on the next tick with no gap and no jump.
67
119
  */
68
120
  class WeriftAudioSource {
69
121
  #encoder = new Encoder({
@@ -71,26 +123,69 @@ class WeriftAudioSource {
71
123
  sample_rate: WERIFT_SAMPLE_RATE,
72
124
  application: "voip",
73
125
  });
126
+ /** 20 ms of digital silence, encoded once by the same encoder and reused. */
127
+ #silence = Buffer.from(this.#encoder.encode(new Int16Array(PACKET_SAMPLES)));
74
128
  #track = new MediaStreamTrack({ kind: "audio", id: "microphone", streamId: "relay-call" });
75
129
  #packets = [];
130
+ /** Every RTP packet written, silence included. */
131
+ #rtp = new PacketClock();
132
+ #opusPackets = 0;
133
+ #applicationRtpPackets = 0;
134
+ #silencePackets = 0;
76
135
  #pending = new Int16Array(0);
77
136
  #sequenceNumber = 1;
78
137
  #timestamp = 0;
79
138
  #first = true;
80
139
  #pump;
140
+ #started = false;
81
141
  #stopped = false;
142
+ #drainWaiters = new Set();
143
+ stats() {
144
+ return {
145
+ opusPackets: this.#opusPackets,
146
+ rtpPackets: this.#applicationRtpPackets,
147
+ silencePackets: this.#silencePackets,
148
+ firstRtpAt: this.#rtp.firstAt,
149
+ lastRtpAt: this.#rtp.lastAt,
150
+ recentRtpPackets: this.#rtp.recent(),
151
+ queued: this.#packets.length,
152
+ pacerAlive: this.#pump !== undefined,
153
+ };
154
+ }
82
155
  createTrack() {
83
156
  const track = this.#track;
84
157
  const stop = track.stop;
85
158
  track.stop = () => {
86
159
  this.#stopped = true;
87
- this.#packets.length = 0;
88
- this.#pending = new Int16Array(0);
160
+ this.clear();
89
161
  this.#stopPump();
90
162
  stop();
91
163
  };
92
164
  return track;
93
165
  }
166
+ start() {
167
+ if (this.#started || this.#stopped)
168
+ return;
169
+ this.#started = true;
170
+ this.#startPump();
171
+ }
172
+ queuedMs() {
173
+ return this.#packets.length * WERIFT_PACKET_MS
174
+ + (this.#pending.length / WERIFT_CHANNEL_COUNT / WERIFT_SAMPLE_RATE) * 1_000;
175
+ }
176
+ waitForDrain() {
177
+ this.#flushPending();
178
+ if (this.#drained())
179
+ return Promise.resolve();
180
+ return new Promise((resolve) => this.#drainWaiters.add(resolve));
181
+ }
182
+ clear() {
183
+ this.#packets.length = 0;
184
+ this.#pending = new Int16Array(0);
185
+ if (!this.#started)
186
+ this.#stopPump();
187
+ this.#notifyDrained();
188
+ }
94
189
  onData(data) {
95
190
  if (this.#stopped)
96
191
  return;
@@ -102,21 +197,56 @@ class WeriftAudioSource {
102
197
  while (merged.length - offset >= PACKET_SAMPLES) {
103
198
  const frame = merged.subarray(offset, offset + PACKET_SAMPLES);
104
199
  this.#packets.push(Buffer.from(this.#encoder.encode(frame)));
200
+ this.#opusPackets += 1;
105
201
  offset += PACKET_SAMPLES;
106
202
  }
107
203
  this.#pending = merged.slice(offset);
108
204
  this.#startPump();
109
205
  }
206
+ /** Pad a sub-packet remainder with silence so the tail of a segment reaches the wire. */
207
+ #flushPending() {
208
+ if (this.#stopped || this.#pending.length === 0)
209
+ return;
210
+ const padded = new Int16Array(PACKET_SAMPLES);
211
+ padded.set(this.#pending);
212
+ this.#pending = new Int16Array(0);
213
+ this.#packets.push(Buffer.from(this.#encoder.encode(padded)));
214
+ this.#opusPackets += 1;
215
+ this.#startPump();
216
+ }
217
+ /** Application audio only: the silence the started pump keeps writing never counts. */
218
+ #drained() {
219
+ return this.#packets.length === 0
220
+ && this.#pending.length === 0
221
+ && (this.#started || this.#pump === undefined);
222
+ }
223
+ #notifyDrained() {
224
+ if (!this.#drained())
225
+ return;
226
+ for (const resolve of [...this.#drainWaiters]) {
227
+ this.#drainWaiters.delete(resolve);
228
+ resolve();
229
+ }
230
+ }
231
+ /**
232
+ * The first packet of a run leaves at once; every later one waits for the
233
+ * 20 ms tick, so a burst pushed faster than real time reaches the wire at
234
+ * packet cadence. Before `start()` the interval stops once the queue is
235
+ * empty; after it, the interval runs until the track stops.
236
+ */
110
237
  #startPump() {
111
- if (this.#pump || this.#packets.length === 0)
238
+ if (this.#pump || this.#stopped)
112
239
  return;
113
- this.#sendNext();
114
- if (this.#packets.length === 0)
240
+ if (!this.#started && this.#packets.length === 0)
115
241
  return;
242
+ this.#sendNext();
116
243
  this.#pump = setInterval(() => {
117
244
  this.#sendNext();
118
- if (this.#packets.length === 0)
119
- this.#stopPump();
245
+ if (this.#packets.length === 0) {
246
+ if (!this.#started)
247
+ this.#stopPump();
248
+ this.#notifyDrained();
249
+ }
120
250
  }, WERIFT_PACKET_MS);
121
251
  this.#pump.unref?.();
122
252
  }
@@ -127,8 +257,10 @@ class WeriftAudioSource {
127
257
  this.#pump = undefined;
128
258
  }
129
259
  #sendNext() {
130
- const payload = this.#packets.shift();
131
- if (!payload || this.#stopped)
260
+ if (this.#stopped)
261
+ return;
262
+ const application = this.#packets.shift();
263
+ if (!application && !this.#started)
132
264
  return;
133
265
  const header = new RtpHeader({
134
266
  payloadType: LOCAL_PAYLOAD_TYPE,
@@ -140,16 +272,35 @@ class WeriftAudioSource {
140
272
  this.#first = false;
141
273
  this.#sequenceNumber = (this.#sequenceNumber + 1) & 0xffff;
142
274
  this.#timestamp = (this.#timestamp + PACKET_FRAMES) >>> 0;
143
- this.#track.writeRtp(new RtpPacket(header, payload));
275
+ this.#track.writeRtp(new RtpPacket(header, application ?? this.#silence));
276
+ if (application)
277
+ this.#applicationRtpPackets += 1;
278
+ else
279
+ this.#silencePackets += 1;
280
+ this.#rtp.mark();
144
281
  }
145
282
  }
146
- /** Opus RTP in, PCM16 (48 kHz stereo) out, one `ondata` per packet. */
283
+ /** Opus RTP in, PCM16 in the requested format (default 48 kHz stereo) out, one `ondata` per packet. */
147
284
  class WeriftAudioSink {
148
285
  ondata = null;
149
- #decoder = new Decoder({ channels: WERIFT_CHANNEL_COUNT, sample_rate: WERIFT_SAMPLE_RATE });
286
+ #decoder;
287
+ #rtp = new PacketClock();
288
+ #decodeFailures = 0;
150
289
  #unsubscribe;
151
- constructor(track) {
290
+ stats() {
291
+ return {
292
+ rtpPackets: this.#rtp.count,
293
+ decodeFailures: this.#decodeFailures,
294
+ firstRtpAt: this.#rtp.firstAt,
295
+ lastRtpAt: this.#rtp.lastAt,
296
+ recentRtpPackets: this.#rtp.recent(),
297
+ };
298
+ }
299
+ constructor(track, format = { sampleRate: WERIFT_SAMPLE_RATE, channelCount: WERIFT_CHANNEL_COUNT }) {
300
+ const { sampleRate, channelCount } = format;
301
+ this.#decoder = new Decoder({ channels: channelCount, sample_rate: sampleRate });
152
302
  const { unSubscribe } = track.onReceiveRtp.subscribe((rtp) => {
303
+ this.#rtp.mark();
153
304
  const handler = this.ondata;
154
305
  if (!handler || !rtp.payload?.length)
155
306
  return;
@@ -159,16 +310,17 @@ class WeriftAudioSink {
159
310
  bytes = this.#decoder.decode(packet.payload);
160
311
  }
161
312
  catch {
313
+ this.#decodeFailures += 1;
162
314
  return;
163
315
  }
164
316
  const samples = new Int16Array(bytes.byteLength >> 1);
165
317
  new Uint8Array(samples.buffer).set(bytes.subarray(0, samples.byteLength));
166
318
  handler({
167
319
  samples,
168
- sampleRate: WERIFT_SAMPLE_RATE,
320
+ sampleRate,
169
321
  bitsPerSample: 16,
170
- channelCount: WERIFT_CHANNEL_COUNT,
171
- numberOfFrames: samples.length / WERIFT_CHANNEL_COUNT,
322
+ channelCount,
323
+ numberOfFrames: samples.length / channelCount,
172
324
  });
173
325
  });
174
326
  this.#unsubscribe = unSubscribe;
@@ -178,9 +330,19 @@ class WeriftAudioSink {
178
330
  this.#unsubscribe();
179
331
  }
180
332
  }
181
- export const createWeriftPeerConnection = () => new RTCPeerConnection({
333
+ /**
334
+ * Video codecs the peer can accept in a pull offer. Nothing decodes video: the
335
+ * transport only answers the person's `video` m-line receive-only and ignores
336
+ * the track (PROTOCOL.md section 5). werift matches a remote codec by MIME
337
+ * type alone (`findCodecByMimeType` in `TransceiverManager.setRemoteRTP`) and
338
+ * throws "negotiate codecs failed." for a media section with no local codec
339
+ * of its kind, so an audio-only codec list cannot answer a video m-line.
340
+ */
341
+ const RECEIVE_VIDEO_MIME_TYPES = ["video/VP8", "video/VP9", "video/H264", "video/AV1"];
342
+ export const createWeriftPeerConnection = (config = { iceServers: [], iceTransportPolicy: "all" }) => new RTCPeerConnection({
182
343
  bundlePolicy: "max-bundle",
183
- iceServers: [],
344
+ iceServers: config.iceServers,
345
+ iceTransportPolicy: config.iceTransportPolicy,
184
346
  codecs: {
185
347
  audio: [
186
348
  new RTCRtpCodecParameters({
@@ -189,11 +351,12 @@ export const createWeriftPeerConnection = () => new RTCPeerConnection({
189
351
  channels: WERIFT_CHANNEL_COUNT,
190
352
  }),
191
353
  ],
354
+ video: RECEIVE_VIDEO_MIME_TYPES.map((mimeType) => new RTCRtpCodecParameters({ mimeType, clockRate: 90_000 })),
192
355
  },
193
356
  });
194
357
  export const createWeriftWebRTCFactory = () => ({
195
- createPeerConnection: () => createWeriftPeerConnection(),
358
+ createPeerConnection: (config) => createWeriftPeerConnection(config),
196
359
  createAudioSource: () => new WeriftAudioSource(),
197
- createAudioSink: (track) => new WeriftAudioSink(track),
360
+ createAudioSink: (track, format) => new WeriftAudioSink(track, format),
198
361
  });
199
362
  //# sourceMappingURL=engine-werift.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"engine-werift.js","sourceRoot":"","sources":["../src/engine-werift.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,SAAS,EACT,SAAS,GACV,MAAM,QAAQ,CAAC;AAShB,sGAAsG;AACtG,MAAM,CAAC,MAAM,k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KitCall, createRelayLiveKitAudio, type RelayLiveKitAudio, type RelayLiveKitAudioOptions, type RelayLiveKitConnectOptions, } from "./livekit.js";
2
- export { RelayCallTransport, RelayCallTransportError, type RelayAudioFrame, type RelayCallEngine, type RelayCallTransportCloseEvent, type RelayCallTransportOptions, } from "./transport.js";
1
+ export { RelayAudioInput, RelayAudioOutput, LIVEKIT_ROOM_INPUT_AUDIO, RelayLiveKitCall, createRelayLiveKitAudio, type RelayLiveKitAudio, type RelayLiveKitAudioOptions, type RelayLiveKitConnectOptions, } from "./livekit.js";
2
+ export { RelayCallTransport, RelayCallTransportError, type RelayAudioFrame, type RelayCallEngine, type RelayCallIceDiagnostics, type RelayCallInboundDiagnostics, type RelayCallOutboundDiagnostics, type RelayCallRestartEvent, type RelayCallRestartReason, type RelayCallRoomDiagnostics, type RelayCallTransportCloseEvent, type RelayCallTransportOptions, type RelayIceServer, type RelayIceServersProvider, type RelayIceTransportPolicy, type RelayInboundAudioFormat, } from "./transport.js";
3
3
  export { createWeriftWebRTCFactory } from "./engine-werift.js";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,GAChC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,GAC/B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,GAChC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EAC9B,KAAK,cAAc,EACnB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,GAC7B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { RelayAudioInput, RelayAudioOutput, RelayLiveKitCall, createRelayLiveKitAudio, } from "./livekit.js";
1
+ export { RelayAudioInput, RelayAudioOutput, LIVEKIT_ROOM_INPUT_AUDIO, RelayLiveKitCall, createRelayLiveKitAudio, } from "./livekit.js";
2
2
  export { RelayCallTransport, RelayCallTransportError, } from "./transport.js";
3
3
  export { createWeriftWebRTCFactory } from "./engine-werift.js";
4
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,GAIxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,uBAAuB,GAKxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,GAIxB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,uBAAuB,GAexB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/livekit.d.ts CHANGED
@@ -2,7 +2,18 @@ import { AudioInput, AudioOutput, type AgentSession } from "@livekit/agents";
2
2
  import { AudioFrame } from "@livekit/rtc-node";
3
3
  import type Relay from "@relaymessenger/sdk";
4
4
  import type { CallRoomOptions } from "@relaymessenger/sdk";
5
- import { RelayCallTransport } from "./transport.js";
5
+ import { RelayCallTransport, type RelayCallIceDiagnostics, type RelayIceServer, type RelayIceServersProvider, type RelayInboundAudioFormat, type RelayIceTransportPolicy } from "./transport.js";
6
+ /**
7
+ * The format LiveKit's own room input hands an AgentSession:
8
+ * `@livekit/agents` dist/voice/room_io/room_io.js:46-48
9
+ * `DEFAULT_ROOM_INPUT_OPTIONS = { audioSampleRate: 24e3, audioNumChannels: 1 }`,
10
+ * passed to the participant `AudioStream` (room_io.js:373-374). Plugins
11
+ * resample assuming the channel count they construct with
12
+ * (`@livekit/agents-plugin-google` 1.9.0 realtime_api.js:1307-1329
13
+ * `new AudioResampler(frame.sampleRate, 16000, 1)`; rtc-node's resampler reads
14
+ * raw bytes and ignores `frame.channels`), so the session must receive mono.
15
+ */
16
+ export declare const LIVEKIT_ROOM_INPUT_AUDIO: Readonly<RelayInboundAudioFormat>;
6
17
  /** LiveKit Agents input backed by the remote Relay participant's WebRTC audio. */
7
18
  export declare class RelayAudioInput extends AudioInput {
8
19
  #private;
@@ -10,11 +21,21 @@ export declare class RelayAudioInput extends AudioInput {
10
21
  setAttached(attached: boolean): void;
11
22
  close(): Promise<void>;
12
23
  }
13
- /** LiveKit Agents output that publishes TTS PCM to the Relay participant. */
24
+ /**
25
+ * LiveKit Agents output that publishes TTS PCM to the Relay participant.
26
+ *
27
+ * Shape copied from `@livekit/agents` `ParticipantAudioOutput`
28
+ * (dist/voice/room_io/_output.js): `captureFrame` hands the frame to the
29
+ * transport and returns without waiting for playout, `flush()` starts a playout
30
+ * task that reports `onPlaybackFinished` only once the transport has drained,
31
+ * and `clearBuffer()` resolves the interruption future so that task reports
32
+ * `interrupted: true` with the position actually played.
33
+ */
14
34
  export declare class RelayAudioOutput extends AudioOutput {
15
35
  #private;
16
36
  constructor(transport: RelayCallTransport, sampleRate?: number);
17
37
  captureFrame(frame: AudioFrame): Promise<void>;
38
+ /** Mark the segment complete; `onPlaybackFinished` fires once the transport has drained. */
18
39
  flush(): void;
19
40
  clearBuffer(): void;
20
41
  close(): void;
@@ -32,7 +53,24 @@ export interface RelayLiveKitConnectOptions extends RelayLiveKitAudioOptions {
32
53
  relay: Relay;
33
54
  callId: string;
34
55
  room?: CallRoomOptions;
56
+ /**
57
+ * STUN and TURN servers for the agent's WebRTC peer. Defaults to none. A
58
+ * function is called again before every restart, to mint fresh TURN credentials.
59
+ */
60
+ iceServers?: RelayIceServer[] | RelayIceServersProvider;
61
+ /** `"relay"` forces TURN. Defaults to `"all"`. */
62
+ iceTransportPolicy?: RelayIceTransportPolicy;
63
+ /**
64
+ * How long one SFU session has to connect before the transport restarts onto
65
+ * a new one. Defaults to 5 seconds. `connect()` has no overall deadline.
66
+ */
67
+ sessionConnectTimeoutMs?: number;
68
+ /** @deprecated Use `sessionConnectTimeoutMs`; now the per-session wait, not a `connect()` deadline. */
69
+ mediaConnectTimeoutMs?: number;
70
+ /** @deprecated Use `sessionConnectTimeoutMs`. */
35
71
  connectionTimeoutMs?: number;
72
+ /** Aborting stops `connect()` and closes the transport; the Call itself is not ended. */
73
+ signal?: AbortSignal;
36
74
  }
37
75
  type AgentSessionAudioTarget = Pick<AgentSession, "input" | "output">;
38
76
  /**
@@ -49,6 +87,14 @@ export declare class RelayLiveKitCall {
49
87
  static connect(options: RelayLiveKitConnectOptions): Promise<RelayLiveKitCall>;
50
88
  attach(session: AgentSessionAudioTarget): void;
51
89
  detach(): void;
90
+ /**
91
+ * Resolves once the person's audio has arrived and the room shows them
92
+ * connected (the transport's `peerAudio`). Await it before starting the
93
+ * AgentSession so the greeting is heard.
94
+ */
95
+ waitForPeerAudio(timeoutMs: number): Promise<void>;
96
+ /** ICE candidates and state transitions for this call, with a one-line summary for logs. */
97
+ diagnostics(): RelayCallIceDiagnostics;
52
98
  setMuted(muted: boolean): void;
53
99
  end(): void;
54
100
  close(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"livekit.d.ts","sourceRoot":"","sources":["../src/livekit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,KAAK,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACL,kBAAkB,EAInB,MAAM,gBAAgB,CAAC;AAExB,kFAAkF;AAClF,qBAAa,eAAgB,SAAQ,UAAU;;gBAOjC,SAAS,EAAE,kBAAkB;IAmBhC,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAI9B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAOtC;AAED,6EAA6E;AAC7E,qBAAa,gBAAiB,SAAQ,WAAW;;gBAOnC,SAAS,EAAE,kBAAkB,EAAE,UAAU,SAAS;IAK/C,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBpD,KAAK,IAAI,IAAI;IAUb,WAAW,IAAI,IAAI;IAa5B,KAAK,IAAI,IAAI;CAWd;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,eAAe,CAAC;IACvB,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,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