@webex/plugin-meetings 3.12.0-next.171 → 3.12.0-next.172

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.
Files changed (36) hide show
  1. package/dist/aiEnableRequest/index.js +1 -1
  2. package/dist/annotation/index.js +53 -17
  3. package/dist/annotation/index.js.map +1 -1
  4. package/dist/breakouts/breakout.js +1 -1
  5. package/dist/breakouts/index.js +35 -9
  6. package/dist/breakouts/index.js.map +1 -1
  7. package/dist/interceptors/dataChannelAuthToken.js +41 -59
  8. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  9. package/dist/interpretation/index.js +1 -1
  10. package/dist/interpretation/siLanguage.js +1 -1
  11. package/dist/meeting/index.js +327 -292
  12. package/dist/meeting/index.js.map +1 -1
  13. package/dist/meeting/util.js +5 -1
  14. package/dist/meeting/util.js.map +1 -1
  15. package/dist/meetings/index.js +4 -1
  16. package/dist/meetings/index.js.map +1 -1
  17. package/dist/types/annotation/index.d.ts +19 -0
  18. package/dist/types/meeting/index.d.ts +46 -12
  19. package/dist/types/meeting/util.d.ts +3 -1
  20. package/dist/webinar/index.js +298 -255
  21. package/dist/webinar/index.js.map +1 -1
  22. package/package.json +9 -9
  23. package/src/annotation/index.ts +55 -25
  24. package/src/breakouts/index.ts +33 -11
  25. package/src/interceptors/dataChannelAuthToken.ts +48 -77
  26. package/src/meeting/index.ts +296 -289
  27. package/src/meeting/util.ts +2 -2
  28. package/src/meetings/index.ts +2 -1
  29. package/src/webinar/index.ts +168 -188
  30. package/test/unit/spec/annotation/index.ts +214 -182
  31. package/test/unit/spec/breakouts/index.ts +126 -25
  32. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +81 -99
  33. package/test/unit/spec/meeting/index.js +939 -705
  34. package/test/unit/spec/meeting/utils.js +16 -2
  35. package/test/unit/spec/meetings/index.js +5 -0
  36. package/test/unit/spec/webinar/index.ts +886 -718
@@ -34,6 +34,7 @@ import {
34
34
  } from '@webex/internal-media-core';
35
35
 
36
36
  import {DataChannelTokenType, type RegisterAndConnectTiming} from '@webex/internal-plugin-llm';
37
+ import type LLMChannel from '@webex/internal-plugin-llm';
37
38
 
38
39
  import {
39
40
  LocalStream,
@@ -50,6 +51,7 @@ import {
50
51
  EVENT_TRIGGERS as VOICEAEVENTS,
51
52
  TURN_ON_CAPTION_STATUS,
52
53
  type MeetingTranscriptPayload,
54
+ type VoiceaChannel,
53
55
  } from '@webex/internal-plugin-voicea';
54
56
 
55
57
  import {
@@ -139,8 +141,6 @@ import {
139
141
  STAGE_MANAGER_TYPE,
140
142
  LOCUSEVENT,
141
143
  LOCUS_LLM_EVENT,
142
- LLM_DEFAULT_SESSION,
143
- LLM_PRACTICE_SESSION,
144
144
  } from '../constants';
145
145
  import BEHAVIORAL_METRICS from '../metrics/constants';
146
146
  import ParameterError from '../common/errors/parameter';
@@ -742,6 +742,26 @@ export default class Meeting extends StatelessWebexPlugin {
742
742
  turnDiscoverySkippedReason: TurnDiscoverySkipReason;
743
743
  turnServerUsed: boolean;
744
744
  areVoiceaEventsSetup = false;
745
+ /**
746
+ * Returns the initial transcription object shape.
747
+ * Used by constructor and reset paths to ensure consistent initialization.
748
+ * @private
749
+ * @returns {Transcription}
750
+ */
751
+ private getInitialTranscription(): Transcription {
752
+ return {
753
+ captions: [],
754
+ isListening: false,
755
+ commandText: '',
756
+ languageOptions: {currentSpokenLanguage: 'en'},
757
+ showCaptionBox: false,
758
+ transcribingRequestStatus: 'INACTIVE',
759
+ isCaptioning: false,
760
+ interimCaptions: {} as Map<string, CaptionData>,
761
+ speakerProxy: {} as Map<string, any>,
762
+ } as Transcription;
763
+ }
764
+
745
765
  isMoveToInProgress = false;
746
766
  registrationIdStatus: string;
747
767
  brbState: BrbState;
@@ -751,6 +771,7 @@ export default class Meeting extends StatelessWebexPlugin {
751
771
  voiceaListenerCallbacks: object = {
752
772
  [VOICEAEVENTS.VOICEA_ANNOUNCEMENT]: (payload: Transcription['languageOptions']) => {
753
773
  this.transcription.languageOptions = payload;
774
+ const eventPayload = {...payload};
754
775
 
755
776
  LoggerProxy.logger.debug(
756
777
  `${EventsUtil.getScopeLog({
@@ -760,11 +781,11 @@ export default class Meeting extends StatelessWebexPlugin {
760
781
  );
761
782
 
762
783
  if (this.getCurUserType() !== 'host') {
763
- delete payload.spokenLanguages;
784
+ delete eventPayload.spokenLanguages;
764
785
  }
765
786
 
766
787
  // @ts-ignore
767
- this.trigger(EVENT_TRIGGERS.MEETING_STARTED_RECEIVING_TRANSCRIPTION, payload);
788
+ this.trigger(EVENT_TRIGGERS.MEETING_STARTED_RECEIVING_TRANSCRIPTION, eventPayload);
768
789
  },
769
790
  [VOICEAEVENTS.CAPTIONS_TURNED_ON]: () => {
770
791
  this.transcription.status = TURN_ON_CAPTION_STATUS.ENABLED;
@@ -819,6 +840,22 @@ export default class Meeting extends StatelessWebexPlugin {
819
840
  private mediaServerIp: string;
820
841
  private llmHealthCheckTimer?: ReturnType<typeof setTimeout>;
821
842
 
843
+ /**
844
+ * The LLM channel owned by this meeting for datachannel communication.
845
+ * Created in updateLLMConnection, cleaned up in cleanupLLMConneciton.
846
+ */
847
+ private llmChannel?: LLMChannel;
848
+
849
+ /**
850
+ * The Voicea channel for transcription/captions, bound to this meeting's LLM channel.
851
+ */
852
+ voiceaChannel?: VoiceaChannel;
853
+
854
+ /**
855
+ * Pending datachannel token saved from join response, used when creating the LLM channel.
856
+ */
857
+ private _pendingDatachannelToken?: string;
858
+
822
859
  /**
823
860
  * @param {Object} attrs
824
861
  * @param {Object} options
@@ -972,6 +1009,16 @@ export default class Meeting extends StatelessWebexPlugin {
972
1009
  */
973
1010
  // @ts-ignore
974
1011
  this.webinar = new Webinar({meetingId: this.id}, {parent: this.webex});
1012
+ /**
1013
+ * VoiceaChannel for transcription/captions. Created without llmChannel;
1014
+ * switchLLMChannel() is called in updateLLMConnection() when LLM connects.
1015
+ * @instance
1016
+ * @type {VoiceaChannel}
1017
+ * @public
1018
+ * @memberof Meeting
1019
+ */
1020
+ // @ts-ignore - Fix type
1021
+ this.voiceaChannel = this.webex.internal.voicea.createChannel();
975
1022
  /**
976
1023
  * helper class for managing receive slots (for multistream media connections)
977
1024
  */
@@ -1495,17 +1542,7 @@ export default class Meeting extends StatelessWebexPlugin {
1495
1542
  * @private
1496
1543
  * @memberof Meeting
1497
1544
  */
1498
- this.transcription = {
1499
- captions: [],
1500
- isListening: false,
1501
- commandText: '',
1502
- languageOptions: {currentSpokenLanguage: 'en'},
1503
- showCaptionBox: false,
1504
- transcribingRequestStatus: 'INACTIVE',
1505
- isCaptioning: false,
1506
- interimCaptions: {} as Map<string, CaptionData>,
1507
- speakerProxy: {} as Map<string, any>,
1508
- } as Transcription;
1545
+ this.transcription = this.getInitialTranscription();
1509
1546
 
1510
1547
  /**
1511
1548
  * Password status. If it's PASSWORD_STATUS.REQUIRED then verifyPassword() needs to be called
@@ -2667,29 +2704,28 @@ export default class Meeting extends StatelessWebexPlugin {
2667
2704
  * @memberof Meeting
2668
2705
  */
2669
2706
  private setUpVoiceaListeners() {
2670
- // @ts-ignore
2671
- this.webex.internal.voicea.listenToEvents();
2707
+ if (!this.voiceaChannel) {
2708
+ LoggerProxy.logger.warn('Meeting:index#setUpVoiceaListeners --> voiceaChannel not available');
2672
2709
 
2673
- // @ts-ignore
2674
- this.webex.internal.voicea.on(
2710
+ return;
2711
+ }
2712
+
2713
+ this.voiceaChannel.on(
2675
2714
  VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
2676
2715
  this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
2677
2716
  );
2678
2717
 
2679
- // @ts-ignore
2680
- this.webex.internal.voicea.on(
2718
+ this.voiceaChannel.on(
2681
2719
  VOICEAEVENTS.CAPTIONS_TURNED_ON,
2682
2720
  this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
2683
2721
  );
2684
2722
 
2685
- // @ts-ignore
2686
- this.webex.internal.voicea.on(
2723
+ this.voiceaChannel.on(
2687
2724
  VOICEAEVENTS.EVA_COMMAND,
2688
2725
  this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
2689
2726
  );
2690
2727
 
2691
- // @ts-ignore
2692
- this.webex.internal.voicea.on(
2728
+ this.voiceaChannel.on(
2693
2729
  VOICEAEVENTS.NEW_CAPTION,
2694
2730
  this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
2695
2731
  );
@@ -3034,18 +3070,22 @@ export default class Meeting extends StatelessWebexPlugin {
3034
3070
  // user need to be joined to start the llm and receive transcription
3035
3071
  if (this.isJoined()) {
3036
3072
  // @ts-ignore - config coming from registerPlugin
3037
- if (transcribing && !this.transcription) {
3038
- this.startTranscription();
3039
- } else if (!transcribing && this.transcription) {
3040
- Trigger.trigger(
3041
- this,
3042
- {
3043
- file: 'meeting/index',
3044
- function: 'setupLocusControlsListener',
3045
- },
3046
- EVENT_TRIGGERS.MEETING_STOPPED_RECEIVING_TRANSCRIPTION,
3047
- {caption, transcribing}
3048
- );
3073
+ if (transcribing && !this.areVoiceaEventsSetup) {
3074
+ if (this.voiceaChannel?.isLLMConnected()) {
3075
+ this.startTranscription();
3076
+ }
3077
+ } else if (!transcribing) {
3078
+ if (this.areVoiceaEventsSetup) {
3079
+ Trigger.trigger(
3080
+ this,
3081
+ {
3082
+ file: 'meeting/index',
3083
+ function: 'setupLocusControlsListener',
3084
+ },
3085
+ EVENT_TRIGGERS.MEETING_STOPPED_RECEIVING_TRANSCRIPTION,
3086
+ {caption, transcribing}
3087
+ );
3088
+ }
3049
3089
  }
3050
3090
  }
3051
3091
  }
@@ -3058,8 +3098,7 @@ export default class Meeting extends StatelessWebexPlugin {
3058
3098
  if (this.transcription?.languageOptions) {
3059
3099
  this.transcription.languageOptions.currentSpokenLanguage = spokenLanguage;
3060
3100
  }
3061
- // @ts-ignore
3062
- this.webex.internal.voicea.onSpokenLanguageUpdate(spokenLanguage, this.id);
3101
+ this.voiceaChannel?.onSpokenLanguageUpdate(spokenLanguage, this.id);
3063
3102
 
3064
3103
  Trigger.trigger(
3065
3104
  this,
@@ -3088,8 +3127,7 @@ export default class Meeting extends StatelessWebexPlugin {
3088
3127
 
3089
3128
  this.locusInfo.on(LOCUSINFO.EVENTS.CONTROLS_MEETING_HESIOD_LLM_ID_UPDATED, ({hesiodLlmId}) => {
3090
3129
  if (hesiodLlmId) {
3091
- // @ts-ignore
3092
- this.webex.internal.voicea.onCaptionServiceIdUpdate(hesiodLlmId);
3130
+ this.voiceaChannel?.onCaptionServiceIdUpdate(hesiodLlmId);
3093
3131
  }
3094
3132
  });
3095
3133
 
@@ -3954,7 +3992,6 @@ export default class Meeting extends StatelessWebexPlugin {
3954
3992
  }`
3955
3993
  );
3956
3994
  }
3957
-
3958
3995
  this.updateLLMConnection();
3959
3996
  });
3960
3997
 
@@ -6043,8 +6080,7 @@ export default class Meeting extends StatelessWebexPlugin {
6043
6080
 
6044
6081
  try {
6045
6082
  const voiceaListenerCaptionUpdate = (payload) => {
6046
- // @ts-ignore
6047
- this.webex.internal.voicea.off(
6083
+ this.voiceaChannel?.off(
6048
6084
  VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE,
6049
6085
  voiceaListenerCaptionUpdate
6050
6086
  );
@@ -6060,13 +6096,8 @@ export default class Meeting extends StatelessWebexPlugin {
6060
6096
  reject(payload);
6061
6097
  }
6062
6098
  };
6063
- // @ts-ignore
6064
- this.webex.internal.voicea.on(
6065
- VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE,
6066
- voiceaListenerCaptionUpdate
6067
- );
6068
- // @ts-ignore
6069
- this.webex.internal.voicea.requestLanguage(language);
6099
+ this.voiceaChannel?.on(VOICEAEVENTS.CAPTION_LANGUAGE_UPDATE, voiceaListenerCaptionUpdate);
6100
+ this.voiceaChannel?.requestLanguage(language);
6070
6101
  } catch (error) {
6071
6102
  LoggerProxy.logger.error(`Meeting:index#setCaptionLanguage --> ${error}`);
6072
6103
 
@@ -6100,8 +6131,7 @@ export default class Meeting extends StatelessWebexPlugin {
6100
6131
 
6101
6132
  try {
6102
6133
  const voiceaListenerLanguageUpdate = (payload) => {
6103
- // @ts-ignore
6104
- this.webex.internal.voicea.off(
6134
+ this.voiceaChannel?.off(
6105
6135
  VOICEAEVENTS.SPOKEN_LANGUAGE_UPDATE,
6106
6136
  voiceaListenerLanguageUpdate
6107
6137
  );
@@ -6118,14 +6148,9 @@ export default class Meeting extends StatelessWebexPlugin {
6118
6148
  }
6119
6149
  };
6120
6150
 
6121
- // @ts-ignore
6122
- this.webex.internal.voicea.on(
6123
- VOICEAEVENTS.SPOKEN_LANGUAGE_UPDATE,
6124
- voiceaListenerLanguageUpdate
6125
- );
6151
+ this.voiceaChannel?.on(VOICEAEVENTS.SPOKEN_LANGUAGE_UPDATE, voiceaListenerLanguageUpdate);
6126
6152
 
6127
- // @ts-ignore
6128
- this.webex.internal.voicea.setSpokenLanguage(language);
6153
+ this.voiceaChannel?.setSpokenLanguage(language);
6129
6154
  } catch (error) {
6130
6155
  LoggerProxy.logger.error(`Meeting:index#setSpokenLanguage --> ${error}`);
6131
6156
 
@@ -6147,12 +6172,18 @@ export default class Meeting extends StatelessWebexPlugin {
6147
6172
  );
6148
6173
 
6149
6174
  try {
6175
+ if (!this.voiceaChannel) {
6176
+ LoggerProxy.logger.warn(
6177
+ 'Meeting:index#startTranscription --> voiceaChannel not available'
6178
+ );
6179
+
6180
+ return;
6181
+ }
6182
+
6150
6183
  if (!this.areVoiceaEventsSetup) {
6151
6184
  this.setUpVoiceaListeners();
6152
6185
  }
6153
-
6154
- // @ts-ignore
6155
- await this.webex.internal.voicea.turnOnCaptions(options?.spokenLanguage);
6186
+ await this.voiceaChannel.turnOnCaptions(options?.spokenLanguage);
6156
6187
  } catch (error) {
6157
6188
  LoggerProxy.logger.error(`Meeting:index#startTranscription --> ${error}`);
6158
6189
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.RECEIVE_TRANSCRIPTION_FAILURE, {
@@ -6169,6 +6200,22 @@ export default class Meeting extends StatelessWebexPlugin {
6169
6200
  }
6170
6201
  }
6171
6202
 
6203
+ /**
6204
+ * Starts transcription when requested by the current Locus controls and an
6205
+ * active LLM channel is ready.
6206
+ * @internal
6207
+ * @returns {void}
6208
+ */
6209
+ public startTranscriptionIfNeeded(): void {
6210
+ if (
6211
+ this.locusInfo.controls?.transcribe?.transcribing &&
6212
+ !this.areVoiceaEventsSetup &&
6213
+ this.voiceaChannel?.isLLMConnected()
6214
+ ) {
6215
+ this.startTranscription();
6216
+ }
6217
+ }
6218
+
6172
6219
  /** Handles Locus LLM events
6173
6220
  *
6174
6221
  * @param {LocusLLMEvent} event - The Locus LLM event to process
@@ -6202,6 +6249,8 @@ export default class Meeting extends StatelessWebexPlugin {
6202
6249
 
6203
6250
  /**
6204
6251
  * Verifies the relay event was delivered for the active LLM session binding.
6252
+ * With the factory pattern, each meeting owns its channel, so we just verify
6253
+ * the route matches our channel's binding or the practice session binding.
6205
6254
  * @param {RelayEvent} event Event object coming from LLM Connection
6206
6255
  * @returns {boolean}
6207
6256
  */
@@ -6212,11 +6261,13 @@ export default class Meeting extends StatelessWebexPlugin {
6212
6261
  return true;
6213
6262
  }
6214
6263
 
6215
- const {llm} = (this as any).webex.internal;
6216
- const isPracticeSession = llm.isConnected(LLM_PRACTICE_SESSION);
6264
+ // With the factory pattern, both channels may be connected simultaneously.
6265
+ // Determine which session is "active" based on whether PS channel is connected.
6266
+ const isPracticeSession = this.webinar?.isPracticeSessionLLMChannelConnected() ?? false;
6267
+
6217
6268
  const expectedBinding = isPracticeSession
6218
- ? llm.getBinding(LLM_PRACTICE_SESSION)
6219
- : llm.getBinding();
6269
+ ? this.webinar?.getPracticeSessionBinding()
6270
+ : this.llmChannel?.getBinding();
6220
6271
 
6221
6272
  if (!expectedBinding || route === expectedBinding) {
6222
6273
  return true;
@@ -6237,9 +6288,10 @@ export default class Meeting extends StatelessWebexPlugin {
6237
6288
  }
6238
6289
  switch (e.data.relayType) {
6239
6290
  case REACTION_RELAY_TYPES.REACTION:
6291
+ // @ts-ignore - config coming from registerPlugin
6240
6292
  if (
6241
6293
  // @ts-ignore - config coming from registerPlugin
6242
- (this.config.receiveReactions || options.receiveReactions) &&
6294
+ this.config.receiveReactions &&
6243
6295
  this.isReactionsSupported()
6244
6296
  ) {
6245
6297
  const member = this.members.membersCollection.get(e.data.sender.participantId);
@@ -6280,32 +6332,27 @@ export default class Meeting extends StatelessWebexPlugin {
6280
6332
  * @returns {void}
6281
6333
  */
6282
6334
  stopTranscription() {
6283
- // @ts-ignore
6284
- this.webex.internal.voicea.off(
6335
+ this.voiceaChannel?.off(
6285
6336
  VOICEAEVENTS.VOICEA_ANNOUNCEMENT,
6286
6337
  this.voiceaListenerCallbacks[VOICEAEVENTS.VOICEA_ANNOUNCEMENT]
6287
6338
  );
6288
6339
 
6289
- // @ts-ignore
6290
- this.webex.internal.voicea.off(
6340
+ this.voiceaChannel?.off(
6291
6341
  VOICEAEVENTS.CAPTIONS_TURNED_ON,
6292
6342
  this.voiceaListenerCallbacks[VOICEAEVENTS.CAPTIONS_TURNED_ON]
6293
6343
  );
6294
6344
 
6295
- // @ts-ignore
6296
- this.webex.internal.voicea.off(
6345
+ this.voiceaChannel?.off(
6297
6346
  VOICEAEVENTS.EVA_COMMAND,
6298
6347
  this.voiceaListenerCallbacks[VOICEAEVENTS.EVA_COMMAND]
6299
6348
  );
6300
6349
 
6301
- // @ts-ignore
6302
- this.webex.internal.voicea.off(
6350
+ this.voiceaChannel?.off(
6303
6351
  VOICEAEVENTS.NEW_CAPTION,
6304
6352
  this.voiceaListenerCallbacks[VOICEAEVENTS.NEW_CAPTION]
6305
6353
  );
6306
6354
 
6307
- // @ts-ignore
6308
- this.webex.internal.voicea.deregisterEvents();
6355
+ this.voiceaChannel?.deregisterEvents();
6309
6356
 
6310
6357
  this.areVoiceaEventsSetup = false;
6311
6358
  this.triggerStopReceivingTranscriptionEvent();
@@ -6338,16 +6385,13 @@ export default class Meeting extends StatelessWebexPlugin {
6338
6385
  */
6339
6386
  private restoreLLMSubscriptionsIfNeeded(): void {
6340
6387
  try {
6341
- const keepTranscriptionSubscribed =
6342
- // @ts-ignore
6343
- this.webex.internal.voicea?.getKeepTranscriptionSubscribed?.();
6388
+ const keepTranscriptionSubscribed = this.voiceaChannel?.getKeepTranscriptionSubscribed();
6344
6389
 
6345
6390
  if (!keepTranscriptionSubscribed) {
6346
6391
  return;
6347
6392
  }
6348
6393
 
6349
- // @ts-ignore
6350
- this.webex.internal.voicea.updateSubchannelSubscriptions({subscribe: ['transcription']});
6394
+ this.voiceaChannel?.updateSubchannelSubscriptions({subscribe: ['transcription']});
6351
6395
  } catch (error) {
6352
6396
  const msg = error?.message || String(error);
6353
6397
 
@@ -6598,10 +6642,6 @@ export default class Meeting extends StatelessWebexPlugin {
6598
6642
  this.saveDataChannelToken(join);
6599
6643
  // @ts-ignore - config coming from registerPlugin
6600
6644
  if (this.config.enableAutomaticLLM) {
6601
- // @ts-ignore
6602
- this.webex.internal.llm.off('online', this.handleLLMOnline);
6603
- // @ts-ignore
6604
- this.webex.internal.llm.on('online', this.handleLLMOnline);
6605
6645
  this.updateLLMConnection({isInitialJoinPhase: true})
6606
6646
  .catch((error) => {
6607
6647
  LoggerProxy.logger.error(
@@ -6636,12 +6676,10 @@ export default class Meeting extends StatelessWebexPlugin {
6636
6676
  this.clearLLMHealthCheckTimer();
6637
6677
 
6638
6678
  this.llmHealthCheckTimer = setTimeout(() => {
6639
- // @ts-ignore
6640
- const isConnected = this.webex.internal.llm.isConnected();
6679
+ const isConnected = this.llmChannel?.isConnected() ?? false;
6641
6680
 
6642
6681
  if (!isConnected) {
6643
- // @ts-ignore
6644
- const {hasEverConnected} = this.webex.internal.llm;
6682
+ const hasEverConnected = this.llmChannel?.hasEverConnected ?? false;
6645
6683
 
6646
6684
  // only send metric if not connected - to avoid too many metrics
6647
6685
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.LLM_HEALTHCHECK_FAILURE, {
@@ -6676,10 +6714,11 @@ export default class Meeting extends StatelessWebexPlugin {
6676
6714
  * @returns {void}
6677
6715
  */
6678
6716
  private stopListeningForLLMEvents() {
6679
- // @ts-ignore - fix types
6680
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
6681
- // @ts-ignore - fix types
6682
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6717
+ this.llmChannel?.off('event:relay.event', this.processRelayEvent);
6718
+ this.llmChannel?.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6719
+ this.llmChannel?.off('online', this.handleLLMOnline);
6720
+ this.breakouts?.unregisterLLMChannel();
6721
+ // voiceaChannel persists across LLM reconnects; switchLLMChannel() handles re-subscribing
6683
6722
  this.clearLLMHealthCheckTimer();
6684
6723
  }
6685
6724
 
@@ -6702,59 +6741,52 @@ export default class Meeting extends StatelessWebexPlugin {
6702
6741
  private stopListeningForMeetingEvents() {
6703
6742
  this.stopListeningForLLMEvents();
6704
6743
  this.stopListeningForMercuryEvents();
6705
- if (this.transcription) {
6744
+ if (this.areVoiceaEventsSetup) {
6706
6745
  this.stopTranscription();
6707
- this.transcription = undefined;
6708
6746
  }
6747
+ // Reset to initial shape instead of null - transcription is always a valid object
6748
+ this.transcription = this.getInitialTranscription();
6709
6749
  this.annotation.deregisterEvents();
6710
6750
  }
6711
6751
 
6712
6752
  /**
6713
- * Disconnects and cleans up the default LLM session listeners/timers.
6714
- *
6715
- * Ownership-aware: only calls `disconnectLLM` when this meeting is the
6716
- * current owner of the default LLM session (or when no owner is recorded).
6717
- * Event listeners belonging to this meeting instance are always detached
6718
- * so they do not receive another meeting's relay events.
6753
+ * Disconnects and cleans up the LLM channel owned by this meeting.
6719
6754
  *
6720
6755
  * @param {Object} options
6721
- * @param {boolean} [options.removeOnlineListener=true] removes the one-time online listener
6722
6756
  * @param {boolean} [options.throwOnError=true] rethrows disconnect errors when true
6757
+ * @param {boolean} [options.preserveVoiceaChannel=false] when true, keeps voiceaChannel for switchLLMChannel() during reconnects
6723
6758
  * @returns {Promise<void>}
6724
6759
  */
6725
6760
  private cleanupLLMConneciton = async ({
6726
- removeOnlineListener = true,
6727
6761
  throwOnError = true,
6762
+ preserveVoiceaChannel = false,
6728
6763
  }: {
6729
- removeOnlineListener?: boolean;
6730
6764
  throwOnError?: boolean;
6765
+ preserveVoiceaChannel?: boolean;
6731
6766
  } = {}): Promise<void> => {
6732
- // @ts-ignore - Fix type
6733
- // @ts-ignore - Fix type
6734
- const {currentOwner, isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6735
- this.id,
6736
- LLM_DEFAULT_SESSION
6737
- );
6767
+ // Always clear the timer, even if there's no channel
6768
+ this.clearLLMHealthCheckTimer();
6769
+
6770
+ // Permanent cleanup must deregister voiceaChannel regardless of LLM presence.
6771
+ // When a transient reconnect fails (LLM registration error), llmChannel is undefined
6772
+ // but voiceaChannel may still exist with listeners attached to the old emitter.
6773
+ if (!preserveVoiceaChannel) {
6774
+ this.voiceaChannel?.deregisterEvents();
6775
+ this.voiceaChannel = undefined;
6776
+ }
6777
+
6778
+ if (!this.llmChannel) {
6779
+ return;
6780
+ }
6738
6781
 
6739
6782
  try {
6740
- if (isOwner) {
6741
- // @ts-ignore - Fix type
6742
- await this.webex.internal.llm.disconnectLLM(
6743
- {
6744
- code: 3050,
6745
- reason: 'done (permanent)',
6746
- },
6747
- LLM_DEFAULT_SESSION,
6748
- this.id
6749
- );
6750
- } else {
6751
- LoggerProxy.logger.info(
6752
- `Meeting:index#cleanupLLMConneciton --> skipping disconnect; LLM owned by meeting ${currentOwner}, not ${this.id}`
6753
- );
6754
- }
6783
+ await this.llmChannel.disconnect({
6784
+ code: 3050,
6785
+ reason: 'done (permanent)',
6786
+ });
6755
6787
  } catch (error) {
6756
6788
  LoggerProxy.logger.error(
6757
- 'Meeting:index#cleanupLLMConneciton --> Failed to disconnect default LLM session',
6789
+ 'Meeting:index#cleanupLLMConneciton --> Failed to disconnect LLM channel',
6758
6790
  error
6759
6791
  );
6760
6792
 
@@ -6762,42 +6794,25 @@ export default class Meeting extends StatelessWebexPlugin {
6762
6794
  throw error;
6763
6795
  }
6764
6796
  } finally {
6765
- if (removeOnlineListener) {
6766
- // @ts-ignore - Fix type
6767
- this.webex.internal.llm.off('online', this.handleLLMOnline);
6768
- }
6769
6797
  this.stopListeningForLLMEvents();
6770
-
6771
- // Re-check ownership after awaiting disconnectLLM. If ownership changed
6772
- // while cleanup was in flight, do not clear another meeting's owner tag.
6773
- if (isOwner) {
6774
- const {currentOwner: currentOwnerAfterCleanup} =
6775
- // @ts-ignore - Fix type
6776
- this.webex.internal.llm.resolveSessionOwnership(this.id, LLM_DEFAULT_SESSION);
6777
-
6778
- if (currentOwnerAfterCleanup === this.id) {
6779
- // @ts-ignore - Fix type
6780
- this.webex.internal.llm.setOwnerMeetingId?.(undefined);
6781
- }
6782
- }
6798
+ this.llmChannel = undefined;
6783
6799
  }
6784
6800
  };
6785
6801
 
6786
6802
  /**
6787
- * Clears data channel tokens associated with this meeting ownership.
6788
- * Ownership checks are enforced in internal-plugin-llm.
6803
+ * Sets the datachannel token on the meeting's LLM channel.
6804
+ * Used by the DataChannelAuthTokenInterceptor after refreshing tokens.
6805
+ * @param {string} token - The new datachannel token
6789
6806
  * @returns {void}
6790
6807
  */
6791
- clearDataChannelToken(): void {
6792
- // @ts-ignore
6793
- this.webex.internal.llm.clearDatachannelToken(LLM_DEFAULT_SESSION, this.id);
6794
- // @ts-ignore
6795
- this.webex.internal.llm.clearDatachannelToken(LLM_PRACTICE_SESSION, this.id);
6808
+ setLLMChannelDataToken(token: string): void {
6809
+ this.llmChannel?.setDatachannelToken(token);
6796
6810
  }
6797
6811
 
6798
6812
  /**
6799
- * Saves the data channel tokens from the join response into LLM so that
6800
- * updateLLMConnection / updatePSDataChannel don't need to fetch them from locusInfo.
6813
+ * Saves the data channel tokens from the join response.
6814
+ * Default session token is stored on this.llmChannel when available.
6815
+ * Practice session token is stored on the webinar's practice LLM channel.
6801
6816
  * @param {Object} join - The parsed join response (from MeetingUtil.parseLocusJoin)
6802
6817
  * @returns {void}
6803
6818
  */
@@ -6805,18 +6820,19 @@ export default class Meeting extends StatelessWebexPlugin {
6805
6820
  const datachannelToken = join?.locus?.self?.datachannelToken;
6806
6821
  const practiceSessionDatachannelToken = join?.locus?.self?.practiceSessionDatachannelToken;
6807
6822
 
6823
+ // Store default session token on our LLM channel if it exists
6824
+ if (datachannelToken && this.llmChannel) {
6825
+ this.llmChannel.setDatachannelToken(datachannelToken);
6826
+ }
6827
+
6828
+ // Store the token temporarily for use when channel is created
6808
6829
  if (datachannelToken) {
6809
- // @ts-ignore
6810
- this.webex.internal.llm.setDatachannelToken(datachannelToken, LLM_DEFAULT_SESSION, this.id);
6830
+ this._pendingDatachannelToken = datachannelToken;
6811
6831
  }
6812
6832
 
6833
+ // Practice session token is handled by webinar
6813
6834
  if (practiceSessionDatachannelToken) {
6814
- // @ts-ignore
6815
- this.webex.internal.llm.setDatachannelToken(
6816
- practiceSessionDatachannelToken,
6817
- LLM_PRACTICE_SESSION,
6818
- this.id
6819
- );
6835
+ this.webinar.setPracticeSessionDatachannelToken(practiceSessionDatachannelToken);
6820
6836
  }
6821
6837
  }
6822
6838
 
@@ -6827,11 +6843,8 @@ export default class Meeting extends StatelessWebexPlugin {
6827
6843
  */
6828
6844
  private async ensureDefaultDatachannelTokenAfterAdmit(): Promise<boolean> {
6829
6845
  try {
6830
- // @ts-ignore
6831
- const datachannelToken = this.webex.internal.llm.getDatachannelToken(
6832
- LLM_DEFAULT_SESSION,
6833
- this.id
6834
- );
6846
+ const datachannelToken =
6847
+ this.llmChannel?.getDatachannelToken() ?? this._pendingDatachannelToken;
6835
6848
  // @ts-ignore
6836
6849
  const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
6837
6850
 
@@ -6850,12 +6863,12 @@ export default class Meeting extends StatelessWebexPlugin {
6850
6863
  return false;
6851
6864
  }
6852
6865
 
6853
- // @ts-ignore
6854
- this.webex.internal.llm.setDatachannelToken(
6855
- fetchedDatachannelToken,
6856
- LLM_DEFAULT_SESSION,
6857
- this.id
6858
- );
6866
+ // Store on channel if exists, otherwise save as pending
6867
+ if (this.llmChannel) {
6868
+ this.llmChannel.setDatachannelToken(fetchedDatachannelToken);
6869
+ } else {
6870
+ this._pendingDatachannelToken = fetchedDatachannelToken;
6871
+ }
6859
6872
 
6860
6873
  return true;
6861
6874
  } catch (error) {
@@ -6882,139 +6895,104 @@ export default class Meeting extends StatelessWebexPlugin {
6882
6895
  const {url = undefined, info: {datachannelUrl = undefined} = {}} = this.locusInfo || {};
6883
6896
 
6884
6897
  const isJoined = this.isJoined();
6885
-
6886
6898
  const dataChannelUrl = datachannelUrl;
6887
6899
 
6888
- // Ownership guard: when the default LLM session is already connected and
6889
- // owned by a *different* Meeting instance, do not disconnect or reconfigure
6890
- // it. Another meeting's `updateLLMConnection` must be ignored here to
6891
- // avoid killing the socket it relies on. We only proceed to manage the
6892
- // connection when this meeting is the current owner, or when no owner is
6893
- // set yet (first claim).
6894
- // @ts-ignore - Fix type
6895
- const {currentOwner} = this.webex.internal.llm.resolveSessionOwnership(
6896
- this.id,
6897
- LLM_DEFAULT_SESSION
6898
- );
6899
-
6900
- // Capture connectivity before any reconnect attempt. If LLM was already
6901
- // connected, we must respect current ownership. If it was disconnected,
6902
- // this flow may reclaim stale owner tags after a fresh connect.
6903
- // @ts-ignore - Fix type
6904
- const wasConnected = this.webex.internal.llm.isConnected();
6905
-
6906
- // Prefer ownership-scoped token read. For disconnected stale-owner reclaim
6907
- // flows, fallback to ownerless read so initial register can still carry a
6908
- // token and recover from stale ownership without 401/403 dead-end.
6909
- // @ts-ignore - Fix type
6910
- let datachannelToken = this.webex.internal.llm.getDatachannelToken(
6911
- LLM_DEFAULT_SESSION,
6912
- this.id
6913
- );
6914
-
6915
- if (!datachannelToken && !wasConnected && currentOwner && currentOwner !== this.id) {
6916
- // @ts-ignore - Fix type
6917
- datachannelToken = this.webex.internal.llm.getDatachannelToken(LLM_DEFAULT_SESSION);
6918
- }
6919
-
6920
- // @ts-ignore - Fix type
6921
- if (wasConnected) {
6922
- if (currentOwner && currentOwner !== this.id) {
6923
- // Another meeting owns the live LLM socket. We must not disconnect
6924
- // or reconfigure it -- doing so would tear down a session the
6925
- // owning meeting still relies on. Locus/datachannel URL mismatch is
6926
- // expected here (each meeting has its own locus URL) and is NOT a
6927
- // valid signal of staleness, so we never reclaim from this path.
6928
- // The only safe reclaim mechanism is the `finally`-block owner-tag
6929
- // release in `cleanupLLMConneciton`, which fires when this meeting
6930
- // itself is being torn down.
6931
- LoggerProxy.logger.info(
6932
- `Meeting:index#updateLLMConnection --> skipping; LLM owned by meeting ${currentOwner}, not ${this.id}`
6933
- );
6900
+ // If we have an existing channel, check if we should reuse it or clean it up
6901
+ if (this.llmChannel) {
6902
+ const isSameUrls =
6903
+ url === this.llmChannel.getLocusUrl() &&
6904
+ dataChannelUrl === this.llmChannel.getDatachannelUrl();
6934
6905
 
6906
+ // If already connected to same URLs, skip reconnect
6907
+ if (this.llmChannel.isConnected() && isSameUrls && isJoined) {
6935
6908
  return undefined;
6936
6909
  }
6937
6910
 
6938
- if (
6939
- // @ts-ignore - Fix type
6940
- url === this.webex.internal.llm.getLocusUrl() &&
6941
- // @ts-ignore - Fix type
6942
- dataChannelUrl === this.webex.internal.llm.getDatachannelUrl() &&
6943
- isJoined
6944
- ) {
6911
+ // If currently connecting to same URLs, wait for that to complete
6912
+ if (this.llmChannel.isConnecting() && isSameUrls && isJoined) {
6945
6913
  return undefined;
6946
6914
  }
6947
- await this.cleanupLLMConneciton({removeOnlineListener: false});
6915
+
6916
+ // URLs changed or not joined, disconnect existing channel
6917
+ await this.cleanupLLMConneciton({preserveVoiceaChannel: true});
6948
6918
  }
6949
6919
 
6950
6920
  if (!isJoined) {
6951
6921
  return undefined;
6952
6922
  }
6953
6923
 
6954
- // Bind refresh handler before registration so interceptor-triggered token
6955
- // refresh during register POST can resolve a valid handler.
6956
- // Prefer this meeting as owner, but allow owner-less fallback when a stale
6957
- // foreign owner tag is present on a disconnected session.
6958
- const refreshHandlerOwnerMeetingId =
6959
- currentOwner && currentOwner !== this.id ? undefined : this.id;
6960
- const shouldAlignRefreshHandlerAfterOwnershipClaim = refreshHandlerOwnerMeetingId !== this.id;
6924
+ // Create a new LLM channel for this meeting
6961
6925
  // @ts-ignore - Fix type
6962
- this.webex.internal.llm.setRefreshHandler(
6963
- () => this.refreshDataChannelToken(),
6964
- LLM_DEFAULT_SESSION,
6965
- refreshHandlerOwnerMeetingId
6966
- );
6926
+ this.llmChannel = this.webex.internal.llm.createChannel();
6967
6927
 
6968
- // @ts-ignore - Fix type
6969
- return this.webex.internal.llm
6928
+ // Get token from pending (saved from join response) or channel
6929
+ const datachannelToken = this._pendingDatachannelToken ?? this.llmChannel.getDatachannelToken();
6930
+
6931
+ // Set up refresh handler before registration so interceptor-triggered token
6932
+ // refresh during register POST can resolve a valid handler.
6933
+ this.llmChannel.setRefreshHandler(() => this.refreshDataChannelToken());
6934
+
6935
+ // If we have a pending token, store it on the channel
6936
+ if (this._pendingDatachannelToken) {
6937
+ this.llmChannel.setDatachannelToken(this._pendingDatachannelToken);
6938
+ this._pendingDatachannelToken = undefined;
6939
+ }
6940
+
6941
+ return this.llmChannel
6970
6942
  .registerAndConnect(url, dataChannelUrl, datachannelToken)
6971
6943
  .then((registerAndConnectResult) => {
6972
6944
  this.locusInfo.syncAllHashTreeDatasets({onlyLLM: true});
6973
- // Record ownership of the default LLM session for this meeting so
6974
- // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6975
- // calls can detect and skip work that doesn't belong to them.
6976
- // @ts-ignore - Fix type
6977
- const {isOwner} = this.webex.internal.llm.resolveSessionOwnership(
6978
- this.id,
6979
- LLM_DEFAULT_SESSION
6980
- );
6981
- const canReclaimAfterDisconnectedStart = !wasConnected;
6982
-
6983
- // Refresh handler is pre-bound before registerAndConnect so token
6984
- // refresh can work even during the registration request itself.
6985
- if (isOwner || canReclaimAfterDisconnectedStart) {
6986
- // Record ownership of the default LLM session for this meeting so
6987
- // subsequent cross-meeting `updateLLMConnection` / `cleanupLLMConneciton`
6988
- // calls can detect and skip work that doesn't belong to them.
6989
- // @ts-ignore - Fix type
6990
- this.webex.internal.llm.setOwnerMeetingId?.(this.id);
6991
-
6992
- // If we pre-bound refresh ownerlessly (stale-owner reclaim path),
6993
- // align the handler with the newly claimed owner immediately after
6994
- // ownership is updated.
6995
- if (shouldAlignRefreshHandlerAfterOwnershipClaim) {
6996
- // @ts-ignore - Fix type
6997
- this.webex.internal.llm.setRefreshHandler(
6998
- () => this.refreshDataChannelToken(),
6999
- LLM_DEFAULT_SESSION,
7000
- this.id
7001
- );
7002
- }
6945
+
6946
+ // Register event listeners on the channel
6947
+ this.llmChannel.off('event:relay.event', this.processRelayEvent);
6948
+ this.llmChannel.on('event:relay.event', this.processRelayEvent);
6949
+ this.llmChannel.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6950
+ this.llmChannel.on(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6951
+ this.llmChannel.off('online', this.handleLLMOnline);
6952
+ this.llmChannel.on('online', this.handleLLMOnline);
6953
+
6954
+ // Register annotation channel only if not in practice session
6955
+ // (practice session manages its own annotation channel via updatePSDataChannel)
6956
+ if (!this.webinar?.isJoinPracticeSessionDataChannel()) {
6957
+ this.annotation.registerChannel(this.llmChannel);
7003
6958
  }
7004
- // @ts-ignore - Fix type
7005
- this.webex.internal.llm.off('event:relay.event', this.processRelayEvent);
7006
- // @ts-ignore - Fix type
7007
- this.webex.internal.llm.on('event:relay.event', this.processRelayEvent);
7008
- // @ts-ignore - Fix type
7009
- this.webex.internal.llm.off(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
7010
- // @ts-ignore - Fix type
7011
- this.webex.internal.llm.on(LOCUS_LLM_EVENT, this.processLocusLLMEvent);
6959
+
6960
+ // Register breakouts channel
6961
+ this.breakouts.registerLLMChannel(this.llmChannel);
6962
+
7012
6963
  LoggerProxy.logger.info(
7013
6964
  'Meeting:index#updateLLMConnection --> enabled to receive relay events!'
7014
6965
  );
7015
-
7016
6966
  this.startLLMHealthCheckTimer();
7017
6967
 
6968
+ // Switch voiceaChannel to use the new LLM channel (preserves transcription state).
6969
+ // Skip if practice session is active - practice session manages its own voicea binding
6970
+ // via updatePSDataChannel, and switching here would break practice session captions.
6971
+ const isPracticeSessionActive =
6972
+ this.webinar?.isPracticeSessionLLMChannelConnected() ?? false;
6973
+
6974
+ if (!this.voiceaChannel) {
6975
+ // @ts-ignore - Fix type
6976
+ this.voiceaChannel = this.webex.internal.voicea.createChannel();
6977
+ }
6978
+
6979
+ if (!isPracticeSessionActive) {
6980
+ // Fire-and-forget: caption restoration shouldn't block LLM connection result.
6981
+ // transcription is always initialized (reset to initial shape, never null),
6982
+ // so no re-init needed here.
6983
+ this.voiceaChannel
6984
+ .switchLLMChannel(this.llmChannel)
6985
+ .then(() => {
6986
+ this.startTranscriptionIfNeeded();
6987
+ })
6988
+ .catch((error) => {
6989
+ LoggerProxy.logger.warn(
6990
+ 'Meeting:index#updateLLMConnection --> failed to switch voicea channel:',
6991
+ error
6992
+ );
6993
+ });
6994
+ }
6995
+
7018
6996
  if (registerAndConnectResult) {
7019
6997
  if (isInitialJoinPhase) {
7020
6998
  this.sendLLMConnectMetric(registerAndConnectResult);
@@ -7046,6 +7024,9 @@ export default class Meeting extends StatelessWebexPlugin {
7046
7024
  error,
7047
7025
  });
7048
7026
 
7027
+ // Clean up the channel on failure
7028
+ this.llmChannel = undefined;
7029
+
7049
7030
  return Promise.reject(error);
7050
7031
  });
7051
7032
  }
@@ -10548,14 +10529,12 @@ export default class Meeting extends StatelessWebexPlugin {
10548
10529
 
10549
10530
  // Listener teardown (transcription, annotation, llm/mercury) runs in
10550
10531
  // stopListeningForMeetingEvents() before /leave and /end so events
10551
- // received mid-teardown do not trigger Locus syncs. Calling it here
10552
- // again would double-emit MEETING_STOPPED_RECEIVING_TRANSCRIPTION
10553
- // because stopTranscription() always fires its trigger.
10554
- //
10555
- // Ownership-aware token clear is encapsulated inside clearDataChannelToken().
10556
- this.clearDataChannelToken();
10557
-
10558
- await this.cleanupLLMConneciton({throwOnError: false});
10532
+ // received mid-teardown do not trigger Locus syncs.
10533
+ // Token cleanup happens automatically when cleanupLLMConneciton destroys the channel.
10534
+ // A new voiceaChannel is created on the next join. In-session LLM reconnects and
10535
+ // practice-session transitions use their own cleanup paths and preserve the channel.
10536
+
10537
+ await this.cleanupLLMConneciton({throwOnError: false, preserveVoiceaChannel: false});
10559
10538
  };
10560
10539
 
10561
10540
  /**
@@ -11291,6 +11270,34 @@ export default class Meeting extends StatelessWebexPlugin {
11291
11270
  }
11292
11271
  }
11293
11272
 
11273
+ /**
11274
+ * Checks if the LLM channel is connected.
11275
+ * Handles practice session context automatically - returns practice session
11276
+ * LLM channel status when in practice session, main LLM channel status otherwise.
11277
+ * @returns {boolean} True if the appropriate LLM channel is connected
11278
+ */
11279
+ public isLLMConnected(): boolean {
11280
+ if (this.webinar?.isJoinPracticeSessionDataChannel()) {
11281
+ return this.webinar.isPracticeSessionLLMChannelConnected();
11282
+ }
11283
+
11284
+ return this.llmChannel?.isConnected() ?? false;
11285
+ }
11286
+
11287
+ /**
11288
+ * Gets the locus URL from the LLM channel.
11289
+ * Handles practice session context automatically - returns practice session
11290
+ * LLM channel's locus URL when in practice session, main LLM channel's locus URL otherwise.
11291
+ * @returns {string | undefined} The locus URL or undefined
11292
+ */
11293
+ public getLLMLocusUrl(): string | undefined {
11294
+ if (this.webinar?.isJoinPracticeSessionDataChannel()) {
11295
+ return this.webinar.getPracticeSessionLocusUrl();
11296
+ }
11297
+
11298
+ return this.llmChannel?.getLocusUrl();
11299
+ }
11300
+
11294
11301
  /**
11295
11302
  * Determines the current data channel token type based on the meeting state.
11296
11303
  *