diff --git a/.changeset/single-peer-connection.md b/.changeset/single-peer-connection.md new file mode 100644 index 000000000..feb1bd5c2 --- /dev/null +++ b/.changeset/single-peer-connection.md @@ -0,0 +1,5 @@ +--- +'@livekit/agents': patch +--- + +Expose `singlePeerConnection` in `JobContext.connect` and pass it through to the underlying LiveKit room connection options. diff --git a/agents/src/job.ts b/agents/src/job.ts index efbd02fb6..58bd9850a 100644 --- a/agents/src/job.ts +++ b/agents/src/job.ts @@ -73,6 +73,10 @@ export enum AutoSubscribe { AUDIO_ONLY, } +type RoomConnectOptions = NonNullable[2]> & { + singlePeerConnection?: boolean; +}; + export type JobAcceptArguments = { name: string; identity: string; @@ -239,21 +243,24 @@ export class JobContext> { * * @see {@link https://github.com/livekit/node-sdks/tree/main/packages/livekit-rtc#readme | * @livekit/rtc-node} for more information about the parameters. + * @param singlePeerConnection - Use a single peer connection for publishing and subscribing. */ async connect( e2ee?: E2EEOptions, autoSubscribe: AutoSubscribe = AutoSubscribe.SUBSCRIBE_ALL, rtcConfig?: RtcConfiguration, + singlePeerConnection?: boolean, ) { if (this.connected) { return; } - const opts = { + const opts: RoomConnectOptions = { e2ee, autoSubscribe: autoSubscribe == AutoSubscribe.SUBSCRIBE_ALL, rtcConfig, dynacast: false, + singlePeerConnection, }; await this.#room.connect(this.#info.url, this.#info.token, opts);