@convai/web-sdk 1.9.0-beta.5 → 1.9.0-beta.7
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 +32 -40
- package/dist/core/ConvaiClient.d.ts +36 -1
- package/dist/core/ConvaiClient.d.ts.map +1 -1
- package/dist/core/ConvaiClient.js +91 -1
- package/dist/core/ConvaiClient.js.map +1 -1
- package/dist/core/types.d.ts +64 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/embed/index.d.ts +9 -2
- package/dist/embed/index.d.ts.map +1 -1
- package/dist/embed/index.js +9 -2
- package/dist/embed/index.js.map +1 -1
- package/dist/react/components/ConvaiWidget.d.ts.map +1 -1
- package/dist/react/components/ConvaiWidget.js +6 -19
- package/dist/react/components/ConvaiWidget.js.map +1 -1
- package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/FloatingVideo.js +1 -2
- package/dist/react/components/rtc-widget/components/FloatingVideo.js.map +1 -1
- package/dist/react/components/rtc-widget/components/UserMessage.js +1 -1
- package/dist/react/components/rtc-widget/components/UserMessage.js.map +1 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +1 -2
- package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js.map +1 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +1 -2
- package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js.map +1 -1
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts.map +1 -1
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +1 -3
- package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js.map +1 -1
- package/dist/react/hooks/useConvaiClient.d.ts.map +1 -1
- package/dist/react/hooks/useConvaiClient.js +2 -0
- package/dist/react/hooks/useConvaiClient.js.map +1 -1
- package/dist/react/icons.d.ts +38 -0
- package/dist/react/icons.d.ts.map +1 -0
- package/dist/react/icons.js +54 -0
- package/dist/react/icons.js.map +1 -0
- package/dist/vanilla/ConvaiWidget.d.ts.map +1 -1
- package/dist/vanilla/ConvaiWidget.js +4 -10
- package/dist/vanilla/ConvaiWidget.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +19 -25
- package/dist/embed/ConvaiChatElement.d.ts +0 -103
- package/dist/embed/ConvaiChatElement.d.ts.map +0 -1
- package/dist/embed/ConvaiChatElement.js +0 -679
- package/dist/embed/ConvaiChatElement.js.map +0 -1
- package/dist/embed/browser.d.ts +0 -3
- package/dist/embed/browser.d.ts.map +0 -1
- package/dist/embed/browser.js +0 -5
- package/dist/embed/browser.js.map +0 -1
- package/dist/embed/chat-embed-v1.js +0 -199
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ Install the beta with `npm install @convai/web-sdk@beta`.
|
|
|
16
16
|
|
|
17
17
|
- **Multi-character rooms** — connect a roster of characters with the `characters` config option (two copies of one character are two independent members), switch who answers with `setInteractionTarget()`, add or remove members live with `updateCharacterRoster()`, and let other participants join the same room with `joinRoom()`. Every transcript line, audio track and readiness event is attributed to a `membershipId`. [Usage below.](#multi-character-rooms-beta)
|
|
18
18
|
- **Agentic actions and canonical model output (v2)** — opt in with `capabilities`, declare client-executed tools in `actionConfig.tools`, consume typed `modelOutput` envelopes, return results with `sendActionResultAndWait()` for a correlated server acknowledgement, and read the raw provider stream through `botLlmTextRaw`. `visionPromptMode: "disabled"` keeps scene context without advertising visual perception. [Usage below.](#agentic-actions-and-canonical-model-output-v2)
|
|
19
|
-
- **Published text chat** — a credential-free, text-only connection for public chat pages: `connectWithPublicationGrant()
|
|
19
|
+
- **Published text chat** — a credential-free, text-only connection for public chat pages: `connectWithPublicationGrant()` and `connectionType: "text"`. For a copy/paste embed, pair it with [`@convai/web-widget`](https://www.npmjs.com/package/@convai/web-widget). [Usage below.](#published-text-chat)
|
|
20
20
|
- **Typed events** — `client.on(event, callback)` infers each callback's payload from the exported `ConvaiEventMap`, so `botReady`, `modelOutput`, `characterStatus` and the rest are checked at compile time. See the [events reference](docs/convai_events.md).
|
|
21
21
|
- **Local transcript lines and usage updates** — `appendMessage()` inserts a line into the transcript without sending anything, and `toggleUsageUpdates(true)` opts into per-turn `usageUpdate` cost breakdowns.
|
|
22
22
|
- **Character versioning** — connect to a character's editable draft, its promoted latest release, or an immutable tag with the `characterVersion` config option, and list, compare, release, promote, fork and discard versions through `client.characterVersions`. [Usage below.](#character-versioning-beta)
|
|
@@ -50,7 +50,7 @@ Install the beta with `npm install @convai/web-sdk@beta`.
|
|
|
50
50
|
- **Long-term memory** — persistent cross-session memories scoped to each end user
|
|
51
51
|
- **Multi-character rooms** — a roster of characters in one room, per-member attribution, live roster changes
|
|
52
52
|
- **Agentic actions (v2)** — client-executed tools, canonical model output, acknowledged action results, raw provider stream
|
|
53
|
-
- **Published text chat** — grant-based, credential-free text sessions
|
|
53
|
+
- **Published text chat** — grant-based, credential-free text sessions
|
|
54
54
|
- **Typed events** — every `client.on` payload typed through `ConvaiEventMap`
|
|
55
55
|
- **Character versioning** — connect to a draft, latest, or tagged version, and manage releases from the client
|
|
56
56
|
- **File upload** — send images to the character during a live session
|
|
@@ -171,55 +171,48 @@ to reuse the consumed token:
|
|
|
171
171
|
/>
|
|
172
172
|
```
|
|
173
173
|
|
|
174
|
-
For copy/paste installation without an application build step,
|
|
175
|
-
|
|
176
|
-
custom element
|
|
174
|
+
For copy/paste installation without an application build step, use
|
|
175
|
+
[`@convai/web-widget`](https://www.npmjs.com/package/@convai/web-widget). Its
|
|
176
|
+
`<convai-widget>` custom element reads the same publication attributes, mints
|
|
177
|
+
its own grant per session, and labels itself from the public descriptor:
|
|
177
178
|
|
|
178
179
|
```html
|
|
179
|
-
<script
|
|
180
|
-
type="module"
|
|
181
|
-
src="https://cdn.jsdelivr.net/npm/@convai/web-sdk@<SDK_VERSION>/dist/embed/chat-embed-v1.js"
|
|
182
|
-
></script>
|
|
183
|
-
<convai-chat publication-id="PUBLICATION_UUID"></convai-chat>
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
The element renders directly in the host page with Shadow DOM style isolation,
|
|
187
|
-
automatically mints a fresh grant per connection, and emits `convai-ready`,
|
|
188
|
-
`convai-disconnect`, `convai-error`, `convai-copy`, and `convai-session-reset`
|
|
189
|
-
DOM events. It accepts `full-window`, `display-name` and `image-url` alongside
|
|
190
|
-
the endpoint attributes, and is themed through `--convai-chat-*` custom
|
|
191
|
-
properties — see [the published chat guide](docs/convai_published_chat.md#the-convai-chat-element). The production bundle uses
|
|
192
|
-
`https://api.convai.com` and `https://realtime-api.convai.com` only as defaults
|
|
193
|
-
for a hand-written SaaS integration. Platform-generated snippets always emit
|
|
194
|
-
the deployment's public Character API and Core endpoints explicitly, so an
|
|
195
|
-
on-prem or non-production embed never falls through to another deployment and
|
|
196
|
-
still requires no credential:
|
|
180
|
+
<script src="https://cdn.jsdelivr.net/npm/@convai/web-widget/v1.js" async></script>
|
|
197
181
|
|
|
198
|
-
|
|
199
|
-
<convai-chat
|
|
182
|
+
<convai-widget
|
|
200
183
|
publication-id="PUBLICATION_UUID"
|
|
201
184
|
publication-api-url="https://character-api.example.com"
|
|
202
185
|
core-url="https://realtime.example.com"
|
|
203
|
-
|
|
186
|
+
placement="inline"
|
|
187
|
+
style="display:block;width:100%;height:640px">
|
|
188
|
+
</convai-widget>
|
|
204
189
|
```
|
|
205
190
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
191
|
+
Two details are load-bearing, and each renders nothing when wrong: the script
|
|
192
|
+
tag must **not** be `type="module"` (the loader reads `document.currentScript`,
|
|
193
|
+
which is `null` in a module script), and a panel sized by `style` needs
|
|
194
|
+
`placement="inline"` — the widget otherwise defaults to a floating bubble.
|
|
195
|
+
Always pin an exact widget version rather than `latest`: generated embed
|
|
196
|
+
snippets must stay bound to the version validated for their target
|
|
197
|
+
environment. Platform-generated snippets emit the deployment's public
|
|
198
|
+
Character API and Core endpoints explicitly, so an on-prem or non-production
|
|
199
|
+
embed never falls through to another deployment and still requires no
|
|
200
|
+
credential.
|
|
201
|
+
|
|
202
|
+
The SDK used to ship this element itself, as `<convai-chat>` at
|
|
203
|
+
`@convai/web-sdk/embed/browser`. It re-bundled the whole SDK — 588 KB, 43% of
|
|
204
|
+
everything this package published — to render a chat panel the vanilla widget
|
|
205
|
+
already renders, so it was removed in favour of the widget package. The
|
|
206
|
+
server-safe publication helpers at `@convai/web-sdk/embed` are unchanged.
|
|
209
207
|
|
|
210
208
|
Descriptor and grant endpoints must allow credential-free cross-origin `GET`
|
|
211
209
|
and `POST` requests. The embed never receives a publisher API key, character
|
|
212
210
|
configuration, or reusable launch token.
|
|
213
211
|
|
|
214
|
-
For customer-managed and GovCloud deployments, the
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
requires an immutable semver tag matching `package.json`, refuses to overwrite
|
|
219
|
-
an existing Docker Hub tag, and publishes both amd64 and arm64 images. Pin the
|
|
220
|
-
resulting digest in the deployment repository; do not make an on-prem browser
|
|
221
|
-
depend on jsDelivr, npm availability, GCP workload identity, or the Experience
|
|
222
|
-
application image.
|
|
212
|
+
For customer-managed and GovCloud deployments, the browser artifact and its
|
|
213
|
+
on-prem image now live with [`@convai/web-widget`](https://www.npmjs.com/package/@convai/web-widget).
|
|
214
|
+
This package no longer builds `deploy/published-chat`, because it no longer
|
|
215
|
+
ships a browser bundle to serve.
|
|
223
216
|
|
|
224
217
|
---
|
|
225
218
|
|
|
@@ -246,7 +239,7 @@ Full documentation is at **<a href="https://docs.convai.com/api-docs/plugins-and
|
|
|
246
239
|
| <a href="https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-web-sdk" target="_blank" rel="noopener noreferrer">SSE Transport</a> | Text-only interaction transport; the one that runs under Node |
|
|
247
240
|
| [Character Versioning](docs/convai_character_versioning.md) | Connect to a draft, latest, or tagged version; list, compare, release and promote versions |
|
|
248
241
|
| [Multi-Character Rooms](docs/convai_multi_character.md) | Rosters, `joinRoom`, interaction targets, live roster updates, per-member attribution |
|
|
249
|
-
| [Published Text Chat](docs/convai_published_chat.md) | Grant-based text-only sessions,
|
|
242
|
+
| [Published Text Chat](docs/convai_published_chat.md) | Grant-based text-only sessions, the copy/paste embed, lifecycle and API reference |
|
|
250
243
|
| [Link Previews](docs/convai_link_previews.md) | Rendering links the character sends: previews, custom chat UIs, the scheme allowlist |
|
|
251
244
|
| [Events Reference (local)](docs/convai_events.md) | Every event with its typed payload, including the v2 and multi-character events |
|
|
252
245
|
|
|
@@ -261,7 +254,6 @@ Full documentation is at **<a href="https://docs.convai.com/api-docs/plugins-and
|
|
|
261
254
|
| `@convai/web-sdk/vanilla` | `ConvaiClient`, `createConvaiWidget`, `AudioRenderer` |
|
|
262
255
|
| `@convai/web-sdk/core` | Framework-agnostic `ConvaiClient`, managers, and all types |
|
|
263
256
|
| `@convai/web-sdk/embed` | Server-safe publication descriptor and grant helpers |
|
|
264
|
-
| `@convai/web-sdk/embed/browser` | Self-contained browser bundle that registers `<convai-chat>` |
|
|
265
257
|
| `@convai/web-sdk/lipsync-helpers` | Blendshape format utilities and queue helpers |
|
|
266
258
|
| `@convai/web-sdk/vanilla/websocket` | **Opt-in.** Registers the WebSocket transport. Import alongside `/vanilla` when using `transport: "websocket"`. |
|
|
267
259
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Room } from "livekit-client";
|
|
2
|
-
import { ConvaiConfig, ConvaiClientState, ChatMessage, IConvaiClient, PublishedChatConnectOptions, AudioControls, VideoControls, ScreenShareControls, DynamicInfo, ContextUpdateOptions, UploadFileOptions, ServerResponse, WebSocketSessionFactory, RespondModeUpdateOptions, UpdateSceneMetadataOptions, VisionStatusOptions, VisionTriggerOptions, ConnectionData, SendUserTextMessageOptions, ConvaiCharacterInstance, ConvaiRoomSession, JoinRoomOptions, ActiveCharacterChange, CharacterRosterChange, UpdateCharacterRosterOptions, AppendMessageOptions, ConvaiEventMap, ActionResult, ActionResultAck, ActionResultAckFailureReason, ActionResultAckOptions } from "./types.js";
|
|
2
|
+
import { ConvaiConfig, ConvaiClientState, ChatMessage, IConvaiClient, PublishedChatConnectOptions, AudioControls, CharacterMuteOptions, VideoControls, ScreenShareControls, DynamicInfo, ContextUpdateOptions, UploadFileOptions, ServerResponse, WebSocketSessionFactory, RespondModeUpdateOptions, UpdateSceneMetadataOptions, VisionStatusOptions, VisionTriggerOptions, ConnectionData, SendUserTextMessageOptions, ConvaiCharacterInstance, ConvaiRoomSession, JoinRoomOptions, ActiveCharacterChange, CharacterRosterChange, UpdateCharacterRosterOptions, AppendMessageOptions, ConvaiEventMap, ActionResult, ActionResultAck, ActionResultAckFailureReason, ActionResultAckOptions } from "./types.js";
|
|
3
3
|
import { EventEmitter } from "./EventEmitter.js";
|
|
4
4
|
import { BlendshapeQueue } from "./BlendshapeQueue.js";
|
|
5
5
|
import { MemoryManager } from "./MemoryManager.js";
|
|
@@ -73,6 +73,19 @@ export declare class ConvaiClient extends EventEmitter implements IConvaiClient
|
|
|
73
73
|
private _characterSessionId;
|
|
74
74
|
/** Roster state for multi-character rooms. Empty for single-character sessions. */
|
|
75
75
|
private _roster;
|
|
76
|
+
/**
|
|
77
|
+
* Desired output-mute state, session-wide. Held rather than applied once, so
|
|
78
|
+
* it reaches tracks that arrive after the call — a member joining a roster
|
|
79
|
+
* room, or a track republished by a reconnect.
|
|
80
|
+
*/
|
|
81
|
+
private _characterMuted;
|
|
82
|
+
/**
|
|
83
|
+
* Per-membership overrides of `_characterMuted`. A session-wide call clears
|
|
84
|
+
* this, so "mute everything" never leaves a member behind as an exception.
|
|
85
|
+
*/
|
|
86
|
+
private _characterMutedByMembership;
|
|
87
|
+
/** The WebSocket transport's bot audio track, so mute can reach it too. */
|
|
88
|
+
private _wsBotAudioTrack;
|
|
76
89
|
/** Roster commands awaiting their ack, keyed by command id. */
|
|
77
90
|
private _pendingRosterCommands;
|
|
78
91
|
private _rosterCommandSeq;
|
|
@@ -167,6 +180,28 @@ export declare class ConvaiClient extends EventEmitter implements IConvaiClient
|
|
|
167
180
|
get requestTraceId(): string | null;
|
|
168
181
|
get isBotReady(): boolean;
|
|
169
182
|
get audioControls(): AudioControls;
|
|
183
|
+
/**
|
|
184
|
+
* Silence the character's voice, or bring it back. See
|
|
185
|
+
* {@link IConvaiClient.setCharacterMuted}.
|
|
186
|
+
*/
|
|
187
|
+
setCharacterMuted(muted: boolean, options?: CharacterMuteOptions): void;
|
|
188
|
+
/**
|
|
189
|
+
* Whether the character's voice is currently silenced. See
|
|
190
|
+
* {@link IConvaiClient.isCharacterMuted}.
|
|
191
|
+
*/
|
|
192
|
+
isCharacterMuted(membershipId?: string): boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Push the desired state onto every track that can carry the character's
|
|
195
|
+
* voice right now.
|
|
196
|
+
*
|
|
197
|
+
* `MediaStreamTrack.enabled` is the lever, not LiveKit's
|
|
198
|
+
* `RemoteTrack.setMuted` (marked `@internal`, and it reports the publisher as
|
|
199
|
+
* muted) and not the `<audio>` elements (core holds no DOM, and a headless
|
|
200
|
+
* consumer has no elements to find). A disabled receiving track yields
|
|
201
|
+
* silence while the stream keeps flowing, which is what a speaker mute is:
|
|
202
|
+
* nothing is renegotiated and no turn is interrupted.
|
|
203
|
+
*/
|
|
204
|
+
private _applyCharacterMute;
|
|
170
205
|
get videoControls(): VideoControls;
|
|
171
206
|
get screenShareControls(): ScreenShareControls;
|
|
172
207
|
get blendshapeQueue(): BlendshapeQueue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConvaiClient.d.ts","sourceRoot":"","sources":["../../src/core/ConvaiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAML,MAAM,gBAAgB,CAAC;AAGxB,OA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,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAmB/C;;;OAGG;IACH,mBAAmB,CACjB,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,EACnD,OAAO,GAAE,0BAA+B,GACvC,IAAI;IAaP,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,qBAAqB;IAe7B;;;;;OAKG;IACG,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB5E;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAYjC;;OAEG;IACH,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAKjC;;;;OAIG;IACH,cAAc,IAAI,IAAI;CASvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Room, RoomEvent, DefaultReconnectPolicy, setLogLevel, } from "livekit-client";
|
|
1
|
+
import { Room, RoomEvent, ConnectionState, DefaultReconnectPolicy, setLogLevel, } from "livekit-client";
|
|
2
2
|
setLogLevel("warn");
|
|
3
3
|
import { DisconnectReasonEnum, } from "./types.js";
|
|
4
4
|
import { AudioManager } from "./AudioManager.js";
|
|
@@ -121,6 +121,19 @@ export class ConvaiClient extends EventEmitter {
|
|
|
121
121
|
this._characterSessionId = "-1";
|
|
122
122
|
/** Roster state for multi-character rooms. Empty for single-character sessions. */
|
|
123
123
|
this._roster = new CharacterRoster();
|
|
124
|
+
/**
|
|
125
|
+
* Desired output-mute state, session-wide. Held rather than applied once, so
|
|
126
|
+
* it reaches tracks that arrive after the call — a member joining a roster
|
|
127
|
+
* room, or a track republished by a reconnect.
|
|
128
|
+
*/
|
|
129
|
+
this._characterMuted = false;
|
|
130
|
+
/**
|
|
131
|
+
* Per-membership overrides of `_characterMuted`. A session-wide call clears
|
|
132
|
+
* this, so "mute everything" never leaves a member behind as an exception.
|
|
133
|
+
*/
|
|
134
|
+
this._characterMutedByMembership = new Map();
|
|
135
|
+
/** The WebSocket transport's bot audio track, so mute can reach it too. */
|
|
136
|
+
this._wsBotAudioTrack = null;
|
|
124
137
|
/** Roster commands awaiting their ack, keyed by command id. */
|
|
125
138
|
this._pendingRosterCommands = new Map();
|
|
126
139
|
this._rosterCommandSeq = 0;
|
|
@@ -332,6 +345,74 @@ export class ConvaiClient extends EventEmitter {
|
|
|
332
345
|
get audioControls() {
|
|
333
346
|
return this._audioManager;
|
|
334
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* Silence the character's voice, or bring it back. See
|
|
350
|
+
* {@link IConvaiClient.setCharacterMuted}.
|
|
351
|
+
*/
|
|
352
|
+
setCharacterMuted(muted, options) {
|
|
353
|
+
const membershipId = options?.membershipId;
|
|
354
|
+
if (membershipId) {
|
|
355
|
+
this._characterMutedByMembership.set(membershipId, muted);
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
// A session-wide call is authoritative: clearing the overrides is what
|
|
359
|
+
// keeps `setCharacterMuted(false)` from leaving a member still silent
|
|
360
|
+
// because something muted it individually earlier.
|
|
361
|
+
this._characterMuted = muted;
|
|
362
|
+
this._characterMutedByMembership.clear();
|
|
363
|
+
}
|
|
364
|
+
this._applyCharacterMute();
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Whether the character's voice is currently silenced. See
|
|
368
|
+
* {@link IConvaiClient.isCharacterMuted}.
|
|
369
|
+
*/
|
|
370
|
+
isCharacterMuted(membershipId) {
|
|
371
|
+
if (membershipId === undefined)
|
|
372
|
+
return this._characterMuted;
|
|
373
|
+
return this._characterMutedByMembership.get(membershipId) ?? this._characterMuted;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Push the desired state onto every track that can carry the character's
|
|
377
|
+
* voice right now.
|
|
378
|
+
*
|
|
379
|
+
* `MediaStreamTrack.enabled` is the lever, not LiveKit's
|
|
380
|
+
* `RemoteTrack.setMuted` (marked `@internal`, and it reports the publisher as
|
|
381
|
+
* muted) and not the `<audio>` elements (core holds no DOM, and a headless
|
|
382
|
+
* consumer has no elements to find). A disabled receiving track yields
|
|
383
|
+
* silence while the stream keeps flowing, which is what a speaker mute is:
|
|
384
|
+
* nothing is renegotiated and no turn is interrupted.
|
|
385
|
+
*/
|
|
386
|
+
_applyCharacterMute() {
|
|
387
|
+
if (this._wsBotAudioTrack) {
|
|
388
|
+
// The WebSocket transport has one bot track and no roster, so the
|
|
389
|
+
// session-wide setting is the only one that can apply to it.
|
|
390
|
+
this._wsBotAudioTrack.enabled = !this._characterMuted;
|
|
391
|
+
}
|
|
392
|
+
if (this._room.state !== ConnectionState.Connected)
|
|
393
|
+
return;
|
|
394
|
+
this._room.remoteParticipants.forEach((participant) => {
|
|
395
|
+
const identity = participant.identity;
|
|
396
|
+
// Same attribution rule as the TrackSubscribed handler: in a roster room
|
|
397
|
+
// a track belongs to the exact member named by its identity, and an
|
|
398
|
+
// unattributable participant is left alone rather than guessed at.
|
|
399
|
+
let membershipId;
|
|
400
|
+
if (this._roster.isMultiCharacter) {
|
|
401
|
+
if (!identity.startsWith("character:"))
|
|
402
|
+
return;
|
|
403
|
+
const candidate = identity.slice("character:".length);
|
|
404
|
+
if (!this._roster.find(candidate))
|
|
405
|
+
return;
|
|
406
|
+
membershipId = candidate;
|
|
407
|
+
}
|
|
408
|
+
const muted = this.isCharacterMuted(membershipId);
|
|
409
|
+
participant.audioTrackPublications.forEach((publication) => {
|
|
410
|
+
const track = publication.track?.mediaStreamTrack;
|
|
411
|
+
if (track)
|
|
412
|
+
track.enabled = !muted;
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
}
|
|
335
416
|
get videoControls() {
|
|
336
417
|
return this._videoManager;
|
|
337
418
|
}
|
|
@@ -361,6 +442,10 @@ export class ConvaiClient extends EventEmitter {
|
|
|
361
442
|
if (track.kind !== "audio")
|
|
362
443
|
return;
|
|
363
444
|
const identity = participant.identity;
|
|
445
|
+
// Re-apply before surfacing the track: a member who joins while the
|
|
446
|
+
// session is muted, or a track republished by a reconnect, must arrive
|
|
447
|
+
// silent rather than audible until the next setCharacterMuted call.
|
|
448
|
+
this._applyCharacterMute();
|
|
364
449
|
if (!this._roster.isMultiCharacter) {
|
|
365
450
|
this.emit("characterAudioTrack", {
|
|
366
451
|
membershipId: null,
|
|
@@ -1427,6 +1512,8 @@ export class ConvaiClient extends EventEmitter {
|
|
|
1427
1512
|
}
|
|
1428
1513
|
const wsSession = this._wsSession;
|
|
1429
1514
|
wsSession.on("botAudioTrack", (track) => {
|
|
1515
|
+
this._wsBotAudioTrack = track;
|
|
1516
|
+
this._applyCharacterMute();
|
|
1430
1517
|
this.emit("botAudioTrack", track);
|
|
1431
1518
|
});
|
|
1432
1519
|
wsSession.on("disconnected", () => {
|
|
@@ -1862,6 +1949,9 @@ export class ConvaiClient extends EventEmitter {
|
|
|
1862
1949
|
this._connectionType = null;
|
|
1863
1950
|
this._activeTransport = null;
|
|
1864
1951
|
this._wsSession = null;
|
|
1952
|
+
// The track dies with the session; the mute *setting* deliberately does
|
|
1953
|
+
// not, so reconnecting does not hand the user back an unmuted character.
|
|
1954
|
+
this._wsBotAudioTrack = null;
|
|
1865
1955
|
this._failPendingRosterCommands("Disconnected before the roster command was acknowledged; its outcome is unknown");
|
|
1866
1956
|
this._roster.reset();
|
|
1867
1957
|
this._sseSession = null;
|