@webex/plugin-meetings 3.11.0-webex-services-ready.1 → 3.12.0-llmrefactor.1

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 (294) hide show
  1. package/AGENTS.md +9 -0
  2. package/dist/aiEnableRequest/index.js +197 -0
  3. package/dist/aiEnableRequest/index.js.map +1 -0
  4. package/dist/aiEnableRequest/utils.js +36 -0
  5. package/dist/aiEnableRequest/utils.js.map +1 -0
  6. package/dist/annotation/index.js +58 -13
  7. package/dist/annotation/index.js.map +1 -1
  8. package/dist/breakouts/breakout.js +8 -3
  9. package/dist/breakouts/breakout.js.map +1 -1
  10. package/dist/breakouts/events.js +29 -14
  11. package/dist/breakouts/events.js.map +1 -1
  12. package/dist/breakouts/index.js +124 -7
  13. package/dist/breakouts/index.js.map +1 -1
  14. package/dist/common/errors/webex-errors.js +49 -5
  15. package/dist/common/errors/webex-errors.js.map +1 -1
  16. package/dist/config.js +8 -3
  17. package/dist/config.js.map +1 -1
  18. package/dist/constants.js +60 -11
  19. package/dist/constants.js.map +1 -1
  20. package/dist/controls-options-manager/constants.js +11 -1
  21. package/dist/controls-options-manager/constants.js.map +1 -1
  22. package/dist/controls-options-manager/index.js +67 -29
  23. package/dist/controls-options-manager/index.js.map +1 -1
  24. package/dist/controls-options-manager/util.js +91 -0
  25. package/dist/controls-options-manager/util.js.map +1 -1
  26. package/dist/hashTree/constants.js +16 -2
  27. package/dist/hashTree/constants.js.map +1 -1
  28. package/dist/hashTree/hashTree.js +18 -0
  29. package/dist/hashTree/hashTree.js.map +1 -1
  30. package/dist/hashTree/hashTreeParser.js +1655 -538
  31. package/dist/hashTree/hashTreeParser.js.map +1 -1
  32. package/dist/hashTree/types.js +4 -2
  33. package/dist/hashTree/types.js.map +1 -1
  34. package/dist/hashTree/utils.js +52 -0
  35. package/dist/hashTree/utils.js.map +1 -1
  36. package/dist/index.js +18 -2
  37. package/dist/index.js.map +1 -1
  38. package/dist/interceptors/constant.js +12 -0
  39. package/dist/interceptors/constant.js.map +1 -0
  40. package/dist/interceptors/dataChannelAuthToken.js +332 -0
  41. package/dist/interceptors/dataChannelAuthToken.js.map +1 -0
  42. package/dist/interceptors/index.js +7 -0
  43. package/dist/interceptors/index.js.map +1 -1
  44. package/dist/interceptors/locusRetry.js +23 -8
  45. package/dist/interceptors/locusRetry.js.map +1 -1
  46. package/dist/interceptors/utils.js +27 -0
  47. package/dist/interceptors/utils.js.map +1 -0
  48. package/dist/interpretation/index.js +11 -2
  49. package/dist/interpretation/index.js.map +1 -1
  50. package/dist/interpretation/interpretation.types.js +7 -0
  51. package/dist/interpretation/interpretation.types.js.map +1 -0
  52. package/dist/interpretation/siLanguage.js +1 -1
  53. package/dist/locus-info/controlsUtils.js +9 -4
  54. package/dist/locus-info/controlsUtils.js.map +1 -1
  55. package/dist/locus-info/index.js +914 -212
  56. package/dist/locus-info/index.js.map +1 -1
  57. package/dist/locus-info/infoUtils.js +36 -5
  58. package/dist/locus-info/infoUtils.js.map +1 -1
  59. package/dist/locus-info/selfUtils.js +1 -0
  60. package/dist/locus-info/selfUtils.js.map +1 -1
  61. package/dist/locus-info/types.js +19 -0
  62. package/dist/locus-info/types.js.map +1 -1
  63. package/dist/media/MediaConnectionAwaiter.js +72 -3
  64. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  65. package/dist/media/index.js +8 -2
  66. package/dist/media/index.js.map +1 -1
  67. package/dist/media/properties.js +8 -7
  68. package/dist/media/properties.js.map +1 -1
  69. package/dist/meeting/in-meeting-actions.js +11 -1
  70. package/dist/meeting/in-meeting-actions.js.map +1 -1
  71. package/dist/meeting/index.js +2286 -1129
  72. package/dist/meeting/index.js.map +1 -1
  73. package/dist/meeting/locusMediaRequest.js +229 -82
  74. package/dist/meeting/locusMediaRequest.js.map +1 -1
  75. package/dist/meeting/muteState.js +10 -1
  76. package/dist/meeting/muteState.js.map +1 -1
  77. package/dist/meeting/request.js +55 -2
  78. package/dist/meeting/request.js.map +1 -1
  79. package/dist/meeting/request.type.js.map +1 -1
  80. package/dist/meeting/util.js +168 -5
  81. package/dist/meeting/util.js.map +1 -1
  82. package/dist/meeting-info/meeting-info-v2.js +2 -2
  83. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  84. package/dist/meetings/index.js +369 -162
  85. package/dist/meetings/index.js.map +1 -1
  86. package/dist/meetings/meetings.types.js +6 -1
  87. package/dist/meetings/meetings.types.js.map +1 -1
  88. package/dist/meetings/request.js +39 -0
  89. package/dist/meetings/request.js.map +1 -1
  90. package/dist/meetings/util.js +116 -18
  91. package/dist/meetings/util.js.map +1 -1
  92. package/dist/member/index.js +20 -0
  93. package/dist/member/index.js.map +1 -1
  94. package/dist/member/types.js.map +1 -1
  95. package/dist/member/util.js +40 -0
  96. package/dist/member/util.js.map +1 -1
  97. package/dist/members/index.js +101 -43
  98. package/dist/members/index.js.map +1 -1
  99. package/dist/members/util.js +8 -1
  100. package/dist/members/util.js.map +1 -1
  101. package/dist/metrics/constants.js +12 -1
  102. package/dist/metrics/constants.js.map +1 -1
  103. package/dist/multistream/codec/constants.js +63 -0
  104. package/dist/multistream/codec/constants.js.map +1 -0
  105. package/dist/multistream/mediaRequestManager.js +64 -68
  106. package/dist/multistream/mediaRequestManager.js.map +1 -1
  107. package/dist/multistream/receiveSlot.js +9 -0
  108. package/dist/multistream/receiveSlot.js.map +1 -1
  109. package/dist/multistream/remoteMediaManager.js +11 -0
  110. package/dist/multistream/remoteMediaManager.js.map +1 -1
  111. package/dist/multistream/sendSlotManager.js +116 -2
  112. package/dist/multistream/sendSlotManager.js.map +1 -1
  113. package/dist/reachability/clusterReachability.js.map +1 -1
  114. package/dist/reachability/index.js +121 -83
  115. package/dist/reachability/index.js.map +1 -1
  116. package/dist/reachability/reachability.types.js +2 -0
  117. package/dist/reachability/reachability.types.js.map +1 -1
  118. package/dist/reachability/util.js +45 -0
  119. package/dist/reachability/util.js.map +1 -1
  120. package/dist/reactions/reactions.type.js.map +1 -1
  121. package/dist/reconnection-manager/index.js +0 -1
  122. package/dist/reconnection-manager/index.js.map +1 -1
  123. package/dist/recording-controller/index.js +1 -3
  124. package/dist/recording-controller/index.js.map +1 -1
  125. package/dist/roap/turnDiscovery.js +8 -1
  126. package/dist/roap/turnDiscovery.js.map +1 -1
  127. package/dist/types/aiEnableRequest/index.d.ts +5 -0
  128. package/dist/types/aiEnableRequest/utils.d.ts +2 -0
  129. package/dist/types/annotation/index.d.ts +19 -0
  130. package/dist/types/common/errors/webex-errors.d.ts +32 -2
  131. package/dist/types/config.d.ts +6 -2
  132. package/dist/types/constants.d.ts +35 -1
  133. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  134. package/dist/types/controls-options-manager/index.d.ts +16 -0
  135. package/dist/types/hashTree/constants.d.ts +3 -0
  136. package/dist/types/hashTree/hashTree.d.ts +7 -0
  137. package/dist/types/hashTree/hashTreeParser.d.ts +315 -30
  138. package/dist/types/hashTree/types.d.ts +3 -0
  139. package/dist/types/hashTree/utils.d.ts +24 -0
  140. package/dist/types/index.d.ts +4 -0
  141. package/dist/types/interceptors/constant.d.ts +5 -0
  142. package/dist/types/interceptors/dataChannelAuthToken.d.ts +43 -0
  143. package/dist/types/interceptors/index.d.ts +2 -1
  144. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  145. package/dist/types/interceptors/utils.d.ts +1 -0
  146. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  147. package/dist/types/locus-info/index.d.ts +126 -15
  148. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  149. package/dist/types/locus-info/types.d.ts +28 -1
  150. package/dist/types/media/MediaConnectionAwaiter.d.ts +20 -2
  151. package/dist/types/media/properties.d.ts +8 -3
  152. package/dist/types/meeting/in-meeting-actions.d.ts +10 -0
  153. package/dist/types/meeting/index.d.ts +271 -16
  154. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  155. package/dist/types/meeting/request.d.ts +17 -1
  156. package/dist/types/meeting/request.type.d.ts +5 -0
  157. package/dist/types/meeting/util.d.ts +40 -0
  158. package/dist/types/meetings/index.d.ts +42 -20
  159. package/dist/types/meetings/meetings.types.d.ts +15 -0
  160. package/dist/types/meetings/request.d.ts +14 -0
  161. package/dist/types/member/index.d.ts +2 -0
  162. package/dist/types/member/types.d.ts +1 -0
  163. package/dist/types/member/util.d.ts +14 -0
  164. package/dist/types/members/index.d.ts +15 -2
  165. package/dist/types/members/util.d.ts +1 -5
  166. package/dist/types/metrics/constants.d.ts +11 -0
  167. package/dist/types/multistream/codec/constants.d.ts +7 -0
  168. package/dist/types/multistream/mediaRequestManager.d.ts +20 -26
  169. package/dist/types/multistream/sendSlotManager.d.ts +23 -1
  170. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  171. package/dist/types/reachability/index.d.ts +10 -3
  172. package/dist/types/reachability/reachability.types.d.ts +7 -0
  173. package/dist/types/reachability/util.d.ts +17 -0
  174. package/dist/types/reactions/reactions.type.d.ts +4 -0
  175. package/dist/types/webinar/utils.d.ts +6 -0
  176. package/dist/webinar/index.js +611 -164
  177. package/dist/webinar/index.js.map +1 -1
  178. package/dist/webinar/utils.js +25 -0
  179. package/dist/webinar/utils.js.map +1 -0
  180. package/package.json +24 -23
  181. package/src/aiEnableRequest/README.md +84 -0
  182. package/src/aiEnableRequest/index.ts +186 -0
  183. package/src/aiEnableRequest/utils.ts +25 -0
  184. package/src/annotation/index.ts +62 -12
  185. package/src/breakouts/breakout.ts +3 -1
  186. package/src/breakouts/events.ts +33 -11
  187. package/src/breakouts/index.ts +143 -3
  188. package/src/common/errors/webex-errors.ts +50 -3
  189. package/src/config.ts +6 -2
  190. package/src/constants.ts +49 -3
  191. package/src/controls-options-manager/constants.ts +14 -1
  192. package/src/controls-options-manager/index.ts +87 -28
  193. package/src/controls-options-manager/util.ts +81 -1
  194. package/src/hashTree/constants.ts +17 -0
  195. package/src/hashTree/hashTree.ts +17 -0
  196. package/src/hashTree/hashTreeParser.ts +1482 -361
  197. package/src/hashTree/types.ts +4 -0
  198. package/src/hashTree/utils.ts +45 -0
  199. package/src/index.ts +14 -1
  200. package/src/interceptors/constant.ts +6 -0
  201. package/src/interceptors/dataChannelAuthToken.ts +217 -0
  202. package/src/interceptors/index.ts +2 -1
  203. package/src/interceptors/locusRetry.ts +25 -4
  204. package/src/interceptors/utils.ts +16 -0
  205. package/src/interpretation/index.ts +29 -11
  206. package/src/interpretation/interpretation.types.ts +11 -0
  207. package/src/locus-info/controlsUtils.ts +14 -1
  208. package/src/locus-info/index.ts +976 -203
  209. package/src/locus-info/infoUtils.ts +41 -6
  210. package/src/locus-info/selfUtils.ts +1 -0
  211. package/src/locus-info/types.ts +33 -1
  212. package/src/media/MediaConnectionAwaiter.ts +62 -5
  213. package/src/media/index.ts +10 -1
  214. package/src/media/properties.ts +11 -4
  215. package/src/meeting/in-meeting-actions.ts +20 -0
  216. package/src/meeting/index.ts +1244 -224
  217. package/src/meeting/locusMediaRequest.ts +106 -6
  218. package/src/meeting/muteState.ts +10 -1
  219. package/src/meeting/request.ts +53 -0
  220. package/src/meeting/request.type.ts +6 -0
  221. package/src/meeting/util.ts +207 -7
  222. package/src/meeting-info/meeting-info-v2.ts +4 -2
  223. package/src/meetings/index.ts +319 -117
  224. package/src/meetings/meetings.types.ts +19 -0
  225. package/src/meetings/request.ts +43 -0
  226. package/src/meetings/util.ts +117 -4
  227. package/src/member/index.ts +20 -0
  228. package/src/member/types.ts +1 -0
  229. package/src/member/util.ts +41 -0
  230. package/src/members/index.ts +70 -7
  231. package/src/members/util.ts +12 -4
  232. package/src/metrics/constants.ts +12 -0
  233. package/src/multistream/codec/constants.ts +58 -0
  234. package/src/multistream/mediaRequestManager.ts +117 -76
  235. package/src/multistream/receiveSlot.ts +18 -0
  236. package/src/multistream/remoteMediaManager.ts +13 -0
  237. package/src/multistream/sendSlotManager.ts +97 -3
  238. package/src/reachability/clusterReachability.ts +3 -2
  239. package/src/reachability/index.ts +47 -16
  240. package/src/reachability/reachability.types.ts +11 -0
  241. package/src/reachability/util.ts +36 -0
  242. package/src/reactions/reactions.type.ts +4 -0
  243. package/src/reconnection-manager/index.ts +0 -1
  244. package/src/recording-controller/index.ts +1 -2
  245. package/src/roap/turnDiscovery.ts +9 -1
  246. package/src/webinar/index.ts +415 -11
  247. package/src/webinar/utils.ts +16 -0
  248. package/test/unit/spec/aiEnableRequest/index.ts +1067 -0
  249. package/test/unit/spec/aiEnableRequest/utils.ts +130 -0
  250. package/test/unit/spec/annotation/index.ts +228 -134
  251. package/test/unit/spec/breakouts/breakout.ts +9 -3
  252. package/test/unit/spec/breakouts/events.ts +120 -2
  253. package/test/unit/spec/breakouts/index.ts +305 -18
  254. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  255. package/test/unit/spec/controls-options-manager/index.js +244 -29
  256. package/test/unit/spec/controls-options-manager/util.js +165 -0
  257. package/test/unit/spec/hashTree/hashTree.ts +66 -0
  258. package/test/unit/spec/hashTree/hashTreeParser.ts +4528 -171
  259. package/test/unit/spec/hashTree/utils.ts +125 -1
  260. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +388 -0
  261. package/test/unit/spec/interceptors/locusRetry.ts +205 -4
  262. package/test/unit/spec/interceptors/utils.ts +75 -0
  263. package/test/unit/spec/interpretation/index.ts +26 -4
  264. package/test/unit/spec/locus-info/controlsUtils.js +200 -56
  265. package/test/unit/spec/locus-info/index.js +1861 -149
  266. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  267. package/test/unit/spec/media/MediaConnectionAwaiter.ts +96 -1
  268. package/test/unit/spec/media/index.ts +92 -0
  269. package/test/unit/spec/media/properties.ts +35 -26
  270. package/test/unit/spec/meeting/in-meeting-actions.ts +12 -2
  271. package/test/unit/spec/meeting/index.js +3573 -353
  272. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  273. package/test/unit/spec/meeting/muteState.js +81 -0
  274. package/test/unit/spec/meeting/request.js +82 -0
  275. package/test/unit/spec/meeting/utils.js +595 -27
  276. package/test/unit/spec/meeting-info/meetinginfov2.js +19 -10
  277. package/test/unit/spec/meetings/index.js +1138 -86
  278. package/test/unit/spec/meetings/request.js +141 -0
  279. package/test/unit/spec/meetings/utils.js +402 -51
  280. package/test/unit/spec/member/index.js +35 -4
  281. package/test/unit/spec/member/util.js +154 -27
  282. package/test/unit/spec/members/index.js +216 -0
  283. package/test/unit/spec/members/request.js +37 -1
  284. package/test/unit/spec/members/utils.js +63 -0
  285. package/test/unit/spec/multistream/mediaRequestManager.ts +503 -122
  286. package/test/unit/spec/multistream/remoteMediaManager.ts +30 -0
  287. package/test/unit/spec/multistream/sendSlotManager.ts +135 -36
  288. package/test/unit/spec/reachability/index.ts +128 -46
  289. package/test/unit/spec/reachability/util.ts +31 -0
  290. package/test/unit/spec/reconnection-manager/index.js +4 -8
  291. package/test/unit/spec/recording-controller/index.js +9 -8
  292. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  293. package/test/unit/spec/webinar/index.ts +1087 -167
  294. package/test/unit/spec/webinar/utils.ts +39 -0
@@ -1,4 +1,40 @@
1
1
  /* eslint-disable import/prefer-default-export */
2
+ import {EnableReachabilityChecksConfig, ResolvedReachabilityProtocols} from './reachability.types';
3
+
4
+ /**
5
+ * Resolves `enableReachabilityChecks` into explicit per-protocol flags.
6
+ * Defaults to all protocols enabled when not configured.
7
+ * UDP is always tested unless reachability is disabled entirely (`false`).
8
+ *
9
+ * @param {EnableReachabilityChecksConfig} enabled value of config.meetings.enableReachabilityChecks
10
+ * @returns {ResolvedReachabilityProtocols} resolved per-protocol flags
11
+ */
12
+ export function resolveReachabilityProtocols(
13
+ enabled: EnableReachabilityChecksConfig = true
14
+ ): ResolvedReachabilityProtocols {
15
+ if (typeof enabled === 'object') {
16
+ return {
17
+ udp: true,
18
+ tcp: enabled.tcp ?? true,
19
+ tls: enabled.tls ?? true,
20
+ };
21
+ }
22
+
23
+ return {udp: enabled, tcp: enabled, tls: enabled};
24
+ }
25
+
26
+ /**
27
+ * Whether any reachability protocol is enabled.
28
+ *
29
+ * @param {EnableReachabilityChecksConfig} config value of config.meetings.enableReachabilityChecks
30
+ * @returns {boolean} true if any protocol is enabled
31
+ */
32
+ export function isReachabilityEnabled(config: EnableReachabilityChecksConfig = true): boolean {
33
+ const {udp, tcp, tls} = resolveReachabilityProtocols(config);
34
+
35
+ return udp || tcp || tls;
36
+ }
37
+
2
38
  /**
3
39
  * Converts a stun url to a turn url
4
40
  *
@@ -40,6 +40,7 @@ export enum SkinToneType {
40
40
  }
41
41
 
42
42
  export type Sender = {
43
+ displayName: string;
43
44
  participantId: string;
44
45
  };
45
46
 
@@ -59,4 +60,7 @@ type RelayEventData = {
59
60
 
60
61
  export type RelayEvent = {
61
62
  data: RelayEventData;
63
+ headers?: {
64
+ route?: string;
65
+ };
62
66
  };
@@ -609,7 +609,6 @@ export default class ReconnectionManager {
609
609
  if (this.meeting.isMultistream) {
610
610
  Object.values(this.meeting.mediaRequestManagers).forEach(
611
611
  (mediaRequestManager: MediaRequestManager) => {
612
- mediaRequestManager.clearPreviousRequests();
613
612
  mediaRequestManager.commit();
614
613
  }
615
614
  );
@@ -261,8 +261,7 @@ export default class RecordingController {
261
261
 
262
262
  LoggerProxy.logger.log(`RecordingController:index#recordingControls --> ${record}`);
263
263
 
264
- // @ts-ignore
265
- return this.request.request({
264
+ return this.request.locusDeltaRequest({
266
265
  uri: `${this.locusUrl}/${CONTROLS}`,
267
266
  body: {
268
267
  record,
@@ -229,9 +229,17 @@ export default class TurnDiscovery {
229
229
  * @returns {TurnDiscoveryResult}
230
230
  */
231
231
  private handleTurnDiscoveryFailure(meeting: Meeting, error: Error): TurnDiscoveryResult {
232
+ // if we got a 409/403 from Locus, it means we've been dropped from the meeting,
233
+ // so there's no point continuing with the media connection attempt
234
+ if ((error as any).statusCode === 409 || (error as any).statusCode === 403) {
235
+ this.defer = undefined;
236
+ throw error;
237
+ }
238
+
232
239
  // we catch any errors and resolve with no turn information so that the normal call join flow can continue without TURN
233
240
  LoggerProxy.logger.info(
234
- `Roap:turnDiscovery#doTurnDiscovery --> TURN discovery failed, continuing without TURN: ${error}`
241
+ `Roap:turnDiscovery#doTurnDiscovery --> TURN discovery failed, continuing without TURN:`,
242
+ error
235
243
  );
236
244
 
237
245
  Metrics.sendBehavioralMetric(BEHAVIORAL_METRICS.TURN_DISCOVERY_FAILURE, {
@@ -4,10 +4,24 @@
4
4
  import {WebexPlugin, config} from '@webex/webex-core';
5
5
  import uuid from 'uuid';
6
6
  import {get} from 'lodash';
7
- import {_ID_, HEADERS, HTTP_VERBS, MEETINGS, SELF_ROLES, SHARE_STATUS} from '../constants';
7
+ import type LLMChannel from '@webex/internal-plugin-llm';
8
+ import {
9
+ _ID_,
10
+ EVENT_TRIGGERS,
11
+ HEADERS,
12
+ HTTP_VERBS,
13
+ MEETINGS,
14
+ SELF_ROLES,
15
+ SHARE_STATUS,
16
+ DEFAULT_LARGE_SCALE_WEBINAR_ATTENDEE_SEARCH_LIMIT,
17
+ LOCUS_LLM_EVENT,
18
+ } from '../constants';
19
+ import Trigger from '../common/events/trigger-proxy';
8
20
 
9
21
  import WebinarCollection from './collection';
10
22
  import LoggerProxy from '../common/logs/logger-proxy';
23
+ import MeetingUtil from '../meeting/util';
24
+ import {sanitizeParams} from './utils';
11
25
 
12
26
  /**
13
27
  * @class Webinar
@@ -28,6 +42,29 @@ const Webinar = WebexPlugin.extend({
28
42
  meetingId: 'string',
29
43
  },
30
44
 
45
+ /**
46
+ * LLM channel for practice session, owned by this webinar instance.
47
+ * @private
48
+ * @type {LLMChannel|undefined}
49
+ */
50
+ _practiceSessionLLMChannel: undefined as LLMChannel | undefined,
51
+
52
+ /**
53
+ * Pending practice session datachannel token, saved from join response.
54
+ * Used when creating the practice session LLM channel.
55
+ * @private
56
+ * @type {string|undefined}
57
+ */
58
+ _pendingPracticeSessionDatachannelToken: undefined as string | undefined,
59
+
60
+ /**
61
+ * Calls this to clean up listeners
62
+ * @returns {void}
63
+ */
64
+ cleanUp() {
65
+ this.cleanupPSDataChannel();
66
+ },
67
+
31
68
  /**
32
69
  * Update the current locus url of the webinar
33
70
  * @param {string} locusUrl
@@ -79,13 +116,49 @@ const Webinar = WebexPlugin.extend({
79
116
  return {isPromoted, isDemoted};
80
117
  },
81
118
 
119
+ /**
120
+ * Resolves the meeting associated with this webinar instance, guarded against the
121
+ * meetingId pointer drifting onto an unrelated transient meeting (e.g. an inbound
122
+ * 1:1 call) that may exist in the meeting collection. Returns the meeting only when
123
+ * its locusUrl matches this webinar's tracked locusUrl. Returns undefined (with a
124
+ * warning) when the meeting cannot be resolved or when the webinar's locusUrl has
125
+ * not been initialized yet — callers must treat this as "no owned meeting" rather
126
+ * than fall through to an unvalidated lookup.
127
+ * @returns {object|undefined}
128
+ */
129
+ getValidatedWebinarMeeting() {
130
+ const meeting = this.webex.meetings.getMeetingByType(_ID_, this.meetingId);
131
+
132
+ if (!meeting) {
133
+ return undefined;
134
+ }
135
+
136
+ if (!this.locusUrl) {
137
+ LoggerProxy.logger.warn(
138
+ `Webinar:index#getValidatedWebinarMeeting --> skipping; webinar locusUrl is not yet initialized for meetingId ${this.meetingId}`
139
+ );
140
+
141
+ return undefined;
142
+ }
143
+
144
+ if (meeting.locusUrl !== this.locusUrl) {
145
+ LoggerProxy.logger.warn(
146
+ `Webinar:index#getValidatedWebinarMeeting --> skipping; meeting ${this.meetingId} locusUrl ${meeting.locusUrl} does not match webinar locusUrl ${this.locusUrl}`
147
+ );
148
+
149
+ return undefined;
150
+ }
151
+
152
+ return meeting;
153
+ },
154
+
82
155
  /**
83
156
  * should join practice session data channel or not
84
157
  * @param {Object} {isPromoted: boolean, isDemoted: boolean}} Role transition states
85
158
  * @returns {void}
86
159
  */
87
160
  updateStatusByRole({isPromoted, isDemoted}) {
88
- const meeting = this.webex.meetings.getMeetingByType(_ID_, this.meetingId);
161
+ const meeting = this.getValidatedWebinarMeeting();
89
162
 
90
163
  if (
91
164
  (isDemoted && meeting?.shareStatus === SHARE_STATUS.WHITEBOARD_SHARE_ACTIVE) ||
@@ -96,10 +169,7 @@ const Webinar = WebexPlugin.extend({
96
169
  meeting?.locusInfo?.updateMediaShares(meeting?.locusInfo?.mediaShares, true);
97
170
  }
98
171
 
99
- if (this.practiceSessionEnabled) {
100
- // may need change data channel in practice session
101
- meeting?.updateLLMConnection();
102
- }
172
+ this.updatePSDataChannel();
103
173
  },
104
174
 
105
175
  /**
@@ -110,12 +180,297 @@ const Webinar = WebexPlugin.extend({
110
180
  return this.selfIsPanelist && this.practiceSessionEnabled;
111
181
  },
112
182
 
183
+ /**
184
+ * Returns the practice session LLM channel binding, if connected.
185
+ * @returns {string|undefined}
186
+ */
187
+ getPracticeSessionBinding() {
188
+ return this._practiceSessionLLMChannel?.getBinding();
189
+ },
190
+
191
+ /**
192
+ * Returns whether the practice session LLM channel is connected.
193
+ * @returns {boolean}
194
+ */
195
+ isPracticeSessionLLMChannelConnected() {
196
+ return this._practiceSessionLLMChannel?.isConnected() ?? false;
197
+ },
198
+
199
+ /**
200
+ * Returns the practice session LLM channel's locus URL, if available.
201
+ * @returns {string|undefined}
202
+ */
203
+ getPracticeSessionLocusUrl() {
204
+ return this._practiceSessionLLMChannel?.getLocusUrl();
205
+ },
206
+
207
+ /**
208
+ * Stores the practice session datachannel token for later use when
209
+ * creating the practice session LLM channel.
210
+ * @param {string} token - The datachannel token to store
211
+ * @returns {void}
212
+ */
213
+ setPracticeSessionDatachannelToken(token: string) {
214
+ this._pendingPracticeSessionDatachannelToken = token;
215
+ },
216
+
217
+ /**
218
+ * Disconnects the practice session LLM channel and cleans up listeners.
219
+ * @returns {Promise<void>}
220
+ */
221
+ async cleanupPSDataChannel() {
222
+ // Remove pending online listener if any
223
+ if (this._pendingOnlineListener) {
224
+ const meeting = this.getValidatedWebinarMeeting();
225
+ meeting?.llmChannel?.off('online', this._pendingOnlineListener);
226
+ this._pendingOnlineListener = null;
227
+ }
228
+
229
+ // Switch voicea back to main meeting LLM channel before disconnecting PS channel
230
+ const meeting = this.getValidatedWebinarMeeting();
231
+ if (meeting?.voiceaChannel && meeting?.llmChannel) {
232
+ await meeting.voiceaChannel.switchLLMChannel(meeting.llmChannel);
233
+ }
234
+
235
+ if (!this._practiceSessionLLMChannel) {
236
+ return;
237
+ }
238
+
239
+ try {
240
+ await this._practiceSessionLLMChannel.disconnect({
241
+ code: 3050,
242
+ reason: 'done (permanent)',
243
+ });
244
+ } catch (error) {
245
+ LoggerProxy.logger.error(
246
+ 'Webinar:index#cleanupPSDataChannel --> Failed to disconnect practice session LLM channel',
247
+ error
248
+ );
249
+ throw error;
250
+ } finally {
251
+ // Remove listeners from the channel
252
+ if (meeting) {
253
+ this._practiceSessionLLMChannel?.off('event:relay.event', meeting.processRelayEvent);
254
+ this._practiceSessionLLMChannel?.off(LOCUS_LLM_EVENT, meeting.processLocusLLMEvent);
255
+ this._practiceSessionLLMChannel?.off('online', meeting.handleLLMOnline);
256
+
257
+ // Switch annotation back to the meeting's default channel
258
+ if (meeting.llmChannel) {
259
+ meeting.annotation.registerChannel(meeting.llmChannel);
260
+ }
261
+ }
262
+ this._practiceSessionLLMChannel = undefined;
263
+ }
264
+ },
265
+
266
+ /**
267
+ * Ensures practice-session token exists before registering the practice LLM channel.
268
+ * Caller is responsible for passing a meeting that has already been resolved via
269
+ * getValidatedWebinarMeeting() — this method does not re-validate ownership.
270
+ * @param {object} meeting
271
+ * @returns {Promise<string|undefined>}
272
+ */
273
+ async ensurePracticeSessionDatachannelToken(meeting) {
274
+ // @ts-ignore
275
+ const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
276
+
277
+ if (!isDataChannelTokenEnabled) {
278
+ return undefined;
279
+ }
280
+
281
+ // Check for cached token on the channel or pending token
282
+ const cachedToken =
283
+ this._practiceSessionLLMChannel?.getDatachannelToken() ??
284
+ this._pendingPracticeSessionDatachannelToken;
285
+
286
+ if (cachedToken) {
287
+ return cachedToken;
288
+ }
289
+
290
+ try {
291
+ const refreshResponse = await meeting.refreshDataChannelToken();
292
+ const {datachannelToken} = refreshResponse?.body ?? {};
293
+
294
+ if (!datachannelToken) {
295
+ return undefined;
296
+ }
297
+
298
+ // Store token on the channel if it exists, otherwise save for later
299
+ if (this._practiceSessionLLMChannel) {
300
+ this._practiceSessionLLMChannel.setDatachannelToken(datachannelToken);
301
+ } else {
302
+ this._pendingPracticeSessionDatachannelToken = datachannelToken;
303
+ }
304
+
305
+ return datachannelToken;
306
+ } catch (error) {
307
+ LoggerProxy.logger.warn(
308
+ `Webinar:index#ensurePracticeSessionDatachannelToken --> failed to proactively refresh practice-session token: ${
309
+ error?.message || String(error)
310
+ }`
311
+ );
312
+
313
+ return undefined;
314
+ }
315
+ },
316
+
317
+ /**
318
+ * Connects practice session LLM channel. Creates a new channel if needed.
319
+ * Will disconnect if the meeting has ended or is no longer in practice session mode.
320
+ * Waits for the main LLM channel to be connected before connecting practice session.
321
+ * @returns {Promise}
322
+ */
323
+ async updatePSDataChannel() {
324
+ this._updatePSDataChannelSequence = (this._updatePSDataChannelSequence || 0) + 1;
325
+ const invocationSequence = this._updatePSDataChannelSequence;
326
+
327
+ const meeting = this.getValidatedWebinarMeeting();
328
+ const isPracticeSession = meeting?.isJoined() && this.isJoinPracticeSessionDataChannel();
329
+
330
+ if (!isPracticeSession) {
331
+ await this.cleanupPSDataChannel();
332
+
333
+ return undefined;
334
+ }
335
+
336
+ // @ts-ignore - Fix type
337
+ const {url = undefined, info: {practiceSessionDatachannelUrl = undefined} = {}} =
338
+ meeting?.locusInfo || {};
339
+
340
+ if (!practiceSessionDatachannelUrl) {
341
+ return undefined;
342
+ }
343
+
344
+ // If already connected to same URLs, skip reconnect
345
+ if (this._practiceSessionLLMChannel?.isConnected()) {
346
+ if (
347
+ url === this._practiceSessionLLMChannel.getLocusUrl() &&
348
+ practiceSessionDatachannelUrl === this._practiceSessionLLMChannel.getDatachannelUrl()
349
+ ) {
350
+ return undefined;
351
+ }
352
+ // URLs changed, disconnect existing channel
353
+ await this.cleanupPSDataChannel();
354
+ }
355
+
356
+ // Ensure the default session LLM channel is connected before connecting the practice session.
357
+ // Subscribe before checking isConnected() to avoid a race where the 'online' event fires
358
+ // between the check and the subscription — the channel does not replay missed events.
359
+ if (!this._pendingOnlineListener && meeting?.llmChannel) {
360
+ const onDefaultSessionConnected = () => {
361
+ this._pendingOnlineListener = null;
362
+ meeting.llmChannel?.off('online', onDefaultSessionConnected);
363
+ this.updatePSDataChannel();
364
+ };
365
+ this._pendingOnlineListener = onDefaultSessionConnected;
366
+ meeting.llmChannel.on('online', onDefaultSessionConnected);
367
+ }
368
+
369
+ if (!meeting?.llmChannel?.isConnected()) {
370
+ LoggerProxy.logger.info(
371
+ 'Webinar:index#updatePSDataChannel --> default session not yet connected, deferring practice session connect.'
372
+ );
373
+
374
+ return undefined;
375
+ }
376
+
377
+ // Default session is already connected — cancel the pending listener and proceed
378
+ if (this._pendingOnlineListener) {
379
+ meeting.llmChannel.off('online', this._pendingOnlineListener);
380
+ this._pendingOnlineListener = null;
381
+ }
382
+
383
+ // Get token from pending or refresh if needed
384
+ let practiceSessionDatachannelToken =
385
+ this._pendingPracticeSessionDatachannelToken ??
386
+ this._practiceSessionLLMChannel?.getDatachannelToken();
387
+
388
+ const refreshedToken = await this.ensurePracticeSessionDatachannelToken(meeting);
389
+
390
+ const latestPracticeSessionDatachannelUrl = get(
391
+ meeting,
392
+ 'locusInfo.info.practiceSessionDatachannelUrl'
393
+ );
394
+ const isStillPracticeSession = meeting?.isJoined() && this.isJoinPracticeSessionDataChannel();
395
+
396
+ // Skip stale invocations after async refresh to avoid reconnecting a session
397
+ // that was already updated/cleaned by a newer state transition.
398
+ if (
399
+ invocationSequence !== this._updatePSDataChannelSequence ||
400
+ !isStillPracticeSession ||
401
+ !latestPracticeSessionDatachannelUrl ||
402
+ latestPracticeSessionDatachannelUrl !== practiceSessionDatachannelUrl
403
+ ) {
404
+ return undefined;
405
+ }
406
+
407
+ if (refreshedToken) {
408
+ practiceSessionDatachannelToken = refreshedToken;
409
+ }
410
+
411
+ // Create a new practice session LLM channel
412
+ // @ts-ignore - Fix type
413
+ const psChannel = this.webex.internal.llm.createChannel();
414
+ this._practiceSessionLLMChannel = psChannel;
415
+
416
+ // Set up refresh handler before registration
417
+ psChannel.setRefreshHandler(() => meeting.refreshDataChannelToken());
418
+
419
+ // If we have a pending token, store it on the channel
420
+ if (this._pendingPracticeSessionDatachannelToken) {
421
+ psChannel.setDatachannelToken(this._pendingPracticeSessionDatachannelToken);
422
+ this._pendingPracticeSessionDatachannelToken = undefined;
423
+ }
424
+
425
+ return psChannel
426
+ .registerAndConnect(url, practiceSessionDatachannelUrl, practiceSessionDatachannelToken)
427
+ .then(async (registerAndConnectResult) => {
428
+ // Check if this channel is still the current one (race condition guard)
429
+ if (this._practiceSessionLLMChannel !== psChannel) {
430
+ psChannel.disconnect({code: 3050, reason: 'replaced'}).catch(() => {});
431
+
432
+ return undefined;
433
+ }
434
+ // Register event listeners on the practice session channel
435
+ psChannel.off('event:relay.event', meeting.processRelayEvent);
436
+ psChannel.on('event:relay.event', meeting.processRelayEvent);
437
+ psChannel.off(LOCUS_LLM_EVENT, meeting.processLocusLLMEvent);
438
+ psChannel.on(LOCUS_LLM_EVENT, meeting.processLocusLLMEvent);
439
+ psChannel.off('online', meeting.handleLLMOnline);
440
+ psChannel.on('online', meeting.handleLLMOnline);
441
+
442
+ // Switch annotation to practice session channel
443
+ meeting.annotation.registerChannel(psChannel);
444
+
445
+ // Switch meeting's voicea channel to use the PS LLM connection
446
+ // This preserves caption state and re-announces automatically
447
+ if (meeting.voiceaChannel) {
448
+ await meeting.voiceaChannel.switchLLMChannel(psChannel);
449
+ }
450
+
451
+ LoggerProxy.logger.info(
452
+ 'Webinar:index#updatePSDataChannel --> enabled to receive relay events for practice session!'
453
+ );
454
+
455
+ return Promise.resolve(registerAndConnectResult);
456
+ })
457
+ .catch((error) => {
458
+ // Clean up the channel on failure, but only if it's still the current one
459
+ if (this._practiceSessionLLMChannel === psChannel) {
460
+ this._practiceSessionLLMChannel = undefined;
461
+ }
462
+ throw error;
463
+ });
464
+ },
465
+
113
466
  /**
114
467
  * start or stop practice session for webinar
115
468
  * @param {boolean} enabled
116
469
  * @returns {Promise}
117
470
  */
118
471
  setPracticeSessionState(enabled) {
472
+ const meeting = this.getValidatedWebinarMeeting();
473
+
119
474
  return this.request({
120
475
  method: HTTP_VERBS.PATCH,
121
476
  uri: `${this.locusUrl}/controls`,
@@ -124,10 +479,16 @@ const Webinar = WebexPlugin.extend({
124
479
  enabled,
125
480
  },
126
481
  },
127
- }).catch((error) => {
128
- LoggerProxy.logger.error('Meeting:webinar#setPracticeSessionState failed', error);
129
- throw error;
130
- });
482
+ })
483
+ .then((response) => {
484
+ MeetingUtil.updateLocusFromApiResponse(meeting, response);
485
+
486
+ return response;
487
+ })
488
+ .catch((error) => {
489
+ LoggerProxy.logger.error('Meeting:webinar#setPracticeSessionState failed', error);
490
+ throw error;
491
+ });
131
492
  },
132
493
 
133
494
  /**
@@ -137,6 +498,7 @@ const Webinar = WebexPlugin.extend({
137
498
  */
138
499
  updatePracticeSessionStatus(payload) {
139
500
  this.set('practiceSessionEnabled', !!payload?.enabled);
501
+ this.updatePSDataChannel().then(() => {});
140
502
  },
141
503
 
142
504
  /**
@@ -243,7 +605,6 @@ const Webinar = WebexPlugin.extend({
243
605
 
244
606
  /**
245
607
  * view all webcast attendees
246
- * @param {string} queryString
247
608
  * @returns {Promise}
248
609
  */
249
610
  async viewAllWebcastAttendees() {
@@ -297,6 +658,49 @@ const Webinar = WebexPlugin.extend({
297
658
  throw error;
298
659
  });
299
660
  },
661
+
662
+ /**
663
+ * search large scale webinar attendees
664
+ * @param {object} payload
665
+ * @param {string} payload.queryString
666
+ * @param {number} payload.limit
667
+ * @param {string} payload.next
668
+ * @returns {Promise}
669
+ */
670
+ async searchLargeScaleWebinarAttendees(payload) {
671
+ const meeting = this.getValidatedWebinarMeeting();
672
+ if (!meeting) {
673
+ LoggerProxy.logger.error(
674
+ 'Meeting:webinar5k#searchLargeScaleWebinarAttendees failed --> webinar meeting could not be validated'
675
+ );
676
+ throw new Error('Meeting:webinar5k#Webinar meeting is not resolvable for the current locus');
677
+ }
678
+
679
+ const rawParams = {
680
+ search_text: payload?.queryString,
681
+ limit: payload?.limit ?? DEFAULT_LARGE_SCALE_WEBINAR_ATTENDEE_SEARCH_LIMIT,
682
+ next: payload?.next,
683
+ };
684
+ const attendeeSearchUrl = meeting?.locusInfo?.links?.resources?.attendeeSearch?.url;
685
+ if (!attendeeSearchUrl) {
686
+ LoggerProxy.logger.error(
687
+ 'Meeting:webinar5k#searchLargeScaleWebinarAttendees failed --> attendee search url unavailable'
688
+ );
689
+ throw new Error('Meeting:webinar5k#Attendee search url is not available');
690
+ }
691
+
692
+ return this.request({
693
+ method: HTTP_VERBS.GET,
694
+ uri: `${attendeeSearchUrl}?${new URLSearchParams(sanitizeParams(rawParams)).toString()}`,
695
+ headers: {
696
+ authorization: await this.webex.credentials.getUserToken(),
697
+ trackingId: `${config.trackingIdPrefix}_${uuid.v4().toString()}`,
698
+ },
699
+ }).catch((error) => {
700
+ LoggerProxy.logger.error('Meeting:webinar5k#searchLargeScaleWebinarAttendees failed', error);
701
+ throw error;
702
+ });
703
+ },
300
704
  });
301
705
 
302
706
  export default Webinar;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Remove null/undefined/empty string values from an object
3
+ * @param {object} params
4
+ * @returns {object}
5
+ */
6
+ export const sanitizeParams = (params: Record<string, any>) => {
7
+ const result: Record<string, any> = {};
8
+ Object.keys(params).forEach((key) => {
9
+ const value = params[key];
10
+ if (value !== null && value !== undefined && value !== '') {
11
+ result[key] = value;
12
+ }
13
+ });
14
+
15
+ return result;
16
+ };