@webex/plugin-meetings 3.12.0 → 3.13.0-next.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 (320) hide show
  1. package/.sdd/manifest.json +1312 -0
  2. package/.sdd/templates/.source.json +30 -0
  3. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +111 -0
  4. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +321 -0
  5. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +59 -0
  6. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +49 -0
  7. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +42 -0
  8. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +120 -0
  9. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +206 -0
  10. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +90 -0
  11. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +68 -0
  12. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +111 -0
  13. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +57 -0
  14. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +69 -0
  15. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +96 -0
  16. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +84 -0
  17. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +82 -0
  18. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +94 -0
  19. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +64 -0
  20. package/.sdd/templates/component-repo/template-map.json +112 -0
  21. package/AGENTS.md +135 -0
  22. package/ai-docs/ARCHITECTURE.md +208 -0
  23. package/ai-docs/CONTRACTS.md +267 -0
  24. package/ai-docs/DATA_MODEL.md +64 -0
  25. package/ai-docs/GETTING_STARTED.md +73 -0
  26. package/ai-docs/GLOSSARY.md +56 -0
  27. package/ai-docs/REVIEW_CHECKLIST.md +45 -0
  28. package/ai-docs/RULES.md +79 -0
  29. package/ai-docs/SECURITY.md +74 -0
  30. package/ai-docs/SERVICE_STATE.md +59 -0
  31. package/ai-docs/SPEC_INDEX.md +85 -0
  32. package/ai-docs/TEST_INDEX.md +45 -0
  33. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +61 -0
  34. package/ai-docs/patterns/defensive-error-propagation.md +55 -0
  35. package/ai-docs/patterns/event-scope-emission.md +46 -0
  36. package/ai-docs/patterns/source-to-test-path-mirroring.md +45 -0
  37. package/ai-docs/patterns/stateless-plugin-request-classes.md +53 -0
  38. package/ai-docs/patterns/typed-constants-and-enum-values.md +47 -0
  39. package/assets/README.md +28 -0
  40. package/assets/e2ee-0.0.1.js +2 -0
  41. package/assets/e2ee-0.0.1.wasm +0 -0
  42. package/dist/aiEnableRequest/index.js +15 -2
  43. package/dist/aiEnableRequest/index.js.map +1 -1
  44. package/dist/annotation/index.js +55 -19
  45. package/dist/annotation/index.js.map +1 -1
  46. package/dist/assets/e2ee-0.0.1.js +2 -0
  47. package/dist/assets/e2ee-0.0.1.wasm +0 -0
  48. package/dist/breakouts/breakout.js +8 -3
  49. package/dist/breakouts/breakout.js.map +1 -1
  50. package/dist/breakouts/events.js +29 -14
  51. package/dist/breakouts/events.js.map +1 -1
  52. package/dist/breakouts/index.js +128 -7
  53. package/dist/breakouts/index.js.map +1 -1
  54. package/dist/common/errors/webex-errors.js +54 -5
  55. package/dist/common/errors/webex-errors.js.map +1 -1
  56. package/dist/config.js +4 -2
  57. package/dist/config.js.map +1 -1
  58. package/dist/constants.js +39 -11
  59. package/dist/constants.js.map +1 -1
  60. package/dist/controls-options-manager/constants.js +11 -1
  61. package/dist/controls-options-manager/constants.js.map +1 -1
  62. package/dist/controls-options-manager/index.js +67 -29
  63. package/dist/controls-options-manager/index.js.map +1 -1
  64. package/dist/controls-options-manager/util.js +91 -0
  65. package/dist/controls-options-manager/util.js.map +1 -1
  66. package/dist/hashTree/constants.js +13 -1
  67. package/dist/hashTree/constants.js.map +1 -1
  68. package/dist/hashTree/hashTreeParser.js +1245 -404
  69. package/dist/hashTree/hashTreeParser.js.map +1 -1
  70. package/dist/hashTree/utils.js +42 -0
  71. package/dist/hashTree/utils.js.map +1 -1
  72. package/dist/index.js +8 -0
  73. package/dist/index.js.map +1 -1
  74. package/dist/interceptors/dataChannelAuthToken.js +58 -16
  75. package/dist/interceptors/dataChannelAuthToken.js.map +1 -1
  76. package/dist/interceptors/locusRetry.js +24 -9
  77. package/dist/interceptors/locusRetry.js.map +1 -1
  78. package/dist/interpretation/index.js +55 -12
  79. package/dist/interpretation/index.js.map +1 -1
  80. package/dist/interpretation/interpretation.types.js +7 -0
  81. package/dist/interpretation/interpretation.types.js.map +1 -0
  82. package/dist/interpretation/siLanguage.js +1 -1
  83. package/dist/locus-info/controlsUtils.js +4 -1
  84. package/dist/locus-info/controlsUtils.js.map +1 -1
  85. package/dist/locus-info/index.js +914 -196
  86. package/dist/locus-info/index.js.map +1 -1
  87. package/dist/locus-info/infoUtils.js +36 -5
  88. package/dist/locus-info/infoUtils.js.map +1 -1
  89. package/dist/locus-info/types.js +20 -0
  90. package/dist/locus-info/types.js.map +1 -1
  91. package/dist/media/MediaConnectionAwaiter.js +229 -166
  92. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  93. package/dist/media/index.js +8 -2
  94. package/dist/media/index.js.map +1 -1
  95. package/dist/media/properties.js +4 -5
  96. package/dist/media/properties.js.map +1 -1
  97. package/dist/meeting/in-meeting-actions.js +5 -1
  98. package/dist/meeting/in-meeting-actions.js.map +1 -1
  99. package/dist/meeting/index.js +1931 -887
  100. package/dist/meeting/index.js.map +1 -1
  101. package/dist/meeting/locusMediaRequest.js +229 -82
  102. package/dist/meeting/locusMediaRequest.js.map +1 -1
  103. package/dist/meeting/muteState.js +10 -1
  104. package/dist/meeting/muteState.js.map +1 -1
  105. package/dist/meeting/request.js +5 -2
  106. package/dist/meeting/request.js.map +1 -1
  107. package/dist/meeting/util.js +42 -3
  108. package/dist/meeting/util.js.map +1 -1
  109. package/dist/meeting/voicea-meeting.js +2 -1
  110. package/dist/meeting/voicea-meeting.js.map +1 -1
  111. package/dist/meeting-info/meeting-info-v2.js +12 -5
  112. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  113. package/dist/meetings/index.js +322 -129
  114. package/dist/meetings/index.js.map +1 -1
  115. package/dist/meetings/meetings.types.js +6 -1
  116. package/dist/meetings/meetings.types.js.map +1 -1
  117. package/dist/meetings/request.js +39 -0
  118. package/dist/meetings/request.js.map +1 -1
  119. package/dist/meetings/util.js +116 -18
  120. package/dist/meetings/util.js.map +1 -1
  121. package/dist/member/index.js +10 -0
  122. package/dist/member/index.js.map +1 -1
  123. package/dist/member/types.js.map +1 -1
  124. package/dist/member/util.js +30 -0
  125. package/dist/member/util.js.map +1 -1
  126. package/dist/members/index.js +101 -43
  127. package/dist/members/index.js.map +1 -1
  128. package/dist/members/util.js +8 -1
  129. package/dist/members/util.js.map +1 -1
  130. package/dist/metrics/constants.js +11 -1
  131. package/dist/metrics/constants.js.map +1 -1
  132. package/dist/multistream/codec/constants.js +63 -0
  133. package/dist/multistream/codec/constants.js.map +1 -0
  134. package/dist/multistream/mediaRequestManager.js +62 -15
  135. package/dist/multistream/mediaRequestManager.js.map +1 -1
  136. package/dist/multistream/receiveSlot.js +9 -0
  137. package/dist/multistream/receiveSlot.js.map +1 -1
  138. package/dist/multistream/remoteMediaManager.js +32 -4
  139. package/dist/multistream/remoteMediaManager.js.map +1 -1
  140. package/dist/multistream/sendSlotManager.js +127 -3
  141. package/dist/multistream/sendSlotManager.js.map +1 -1
  142. package/dist/reachability/clusterReachability.js.map +1 -1
  143. package/dist/reachability/index.js +121 -83
  144. package/dist/reachability/index.js.map +1 -1
  145. package/dist/reachability/reachability.types.js +2 -0
  146. package/dist/reachability/reachability.types.js.map +1 -1
  147. package/dist/reachability/util.js +45 -0
  148. package/dist/reachability/util.js.map +1 -1
  149. package/dist/reactions/reactions.type.js.map +1 -1
  150. package/dist/recording-controller/index.js +1 -3
  151. package/dist/recording-controller/index.js.map +1 -1
  152. package/dist/roap/turnDiscovery.js +8 -1
  153. package/dist/roap/turnDiscovery.js.map +1 -1
  154. package/dist/types/annotation/index.d.ts +19 -0
  155. package/dist/types/common/errors/webex-errors.d.ts +36 -2
  156. package/dist/types/config.d.ts +4 -2
  157. package/dist/types/constants.d.ts +15 -2
  158. package/dist/types/controls-options-manager/constants.d.ts +6 -1
  159. package/dist/types/controls-options-manager/index.d.ts +16 -0
  160. package/dist/types/hashTree/constants.d.ts +2 -0
  161. package/dist/types/hashTree/hashTreeParser.d.ts +230 -18
  162. package/dist/types/hashTree/utils.d.ts +18 -0
  163. package/dist/types/index.d.ts +4 -0
  164. package/dist/types/interceptors/locusRetry.d.ts +4 -4
  165. package/dist/types/interpretation/interpretation.types.d.ts +10 -0
  166. package/dist/types/locus-info/index.d.ts +151 -15
  167. package/dist/types/locus-info/infoUtils.d.ts +8 -0
  168. package/dist/types/locus-info/types.d.ts +28 -1
  169. package/dist/types/media/MediaConnectionAwaiter.d.ts +66 -49
  170. package/dist/types/media/properties.d.ts +6 -2
  171. package/dist/types/meeting/in-meeting-actions.d.ts +4 -0
  172. package/dist/types/meeting/index.d.ts +247 -13
  173. package/dist/types/meeting/locusMediaRequest.d.ts +12 -0
  174. package/dist/types/meeting/request.d.ts +1 -0
  175. package/dist/types/meeting/util.d.ts +12 -1
  176. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  177. package/dist/types/meetings/index.d.ts +40 -19
  178. package/dist/types/meetings/meetings.types.d.ts +15 -0
  179. package/dist/types/meetings/request.d.ts +14 -0
  180. package/dist/types/member/index.d.ts +1 -0
  181. package/dist/types/member/types.d.ts +1 -0
  182. package/dist/types/member/util.d.ts +9 -0
  183. package/dist/types/members/index.d.ts +15 -2
  184. package/dist/types/members/util.d.ts +1 -5
  185. package/dist/types/metrics/constants.d.ts +10 -0
  186. package/dist/types/multistream/codec/constants.d.ts +7 -0
  187. package/dist/types/multistream/mediaRequestManager.d.ts +22 -5
  188. package/dist/types/multistream/remoteMediaManager.d.ts +18 -0
  189. package/dist/types/multistream/sendSlotManager.d.ts +28 -2
  190. package/dist/types/reachability/clusterReachability.d.ts +3 -3
  191. package/dist/types/reachability/index.d.ts +10 -3
  192. package/dist/types/reachability/reachability.types.d.ts +7 -0
  193. package/dist/types/reachability/util.d.ts +17 -0
  194. package/dist/types/reactions/reactions.type.d.ts +3 -0
  195. package/dist/webinar/index.js +539 -245
  196. package/dist/webinar/index.js.map +1 -1
  197. package/package.json +26 -24
  198. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +223 -0
  199. package/src/aiEnableRequest/index.ts +16 -0
  200. package/src/annotation/ai-docs/annotation-spec.md +236 -0
  201. package/src/annotation/index.ts +61 -29
  202. package/src/breakouts/ai-docs/breakouts-spec.md +324 -0
  203. package/src/breakouts/breakout.ts +3 -1
  204. package/src/breakouts/events.ts +33 -11
  205. package/src/breakouts/index.ts +145 -3
  206. package/src/common/errors/webex-errors.ts +56 -3
  207. package/src/config.ts +8 -3
  208. package/src/constants.ts +23 -4
  209. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +243 -0
  210. package/src/controls-options-manager/constants.ts +14 -1
  211. package/src/controls-options-manager/index.ts +87 -28
  212. package/src/controls-options-manager/util.ts +81 -1
  213. package/src/hashTree/ai-docs/hash-tree-spec.md +267 -0
  214. package/src/hashTree/constants.ts +16 -0
  215. package/src/hashTree/hashTreeParser.ts +1021 -214
  216. package/src/hashTree/utils.ts +36 -0
  217. package/src/index.ts +7 -0
  218. package/src/interceptors/ai-docs/interceptors-spec.md +247 -0
  219. package/src/interceptors/dataChannelAuthToken.ts +59 -12
  220. package/src/interceptors/locusRetry.ts +26 -5
  221. package/src/interpretation/ai-docs/interpretation-spec.md +256 -0
  222. package/src/interpretation/index.ts +65 -10
  223. package/src/interpretation/interpretation.types.ts +11 -0
  224. package/src/locus-info/ai-docs/locus-info-spec.md +293 -0
  225. package/src/locus-info/controlsUtils.ts +3 -1
  226. package/src/locus-info/index.ts +907 -184
  227. package/src/locus-info/infoUtils.ts +41 -6
  228. package/src/locus-info/types.ts +33 -1
  229. package/src/media/MediaConnectionAwaiter.ts +229 -196
  230. package/src/media/ai-docs/media-spec.md +267 -0
  231. package/src/media/index.ts +10 -1
  232. package/src/media/properties.ts +8 -3
  233. package/src/meeting/ai-docs/meeting-spec.md +404 -0
  234. package/src/meeting/in-meeting-actions.ts +8 -0
  235. package/src/meeting/index.ts +1237 -254
  236. package/src/meeting/locusMediaRequest.ts +106 -6
  237. package/src/meeting/muteState.ts +10 -1
  238. package/src/meeting/request.ts +11 -0
  239. package/src/meeting/util.ts +53 -8
  240. package/src/meeting/voicea-meeting.ts +1 -1
  241. package/src/meeting-info/ai-docs/meeting-info-spec.md +261 -0
  242. package/src/meeting-info/meeting-info-v2.ts +11 -4
  243. package/src/meetings/ai-docs/meetings-spec.md +296 -0
  244. package/src/meetings/index.ts +224 -80
  245. package/src/meetings/meetings.types.ts +19 -0
  246. package/src/meetings/request.ts +43 -0
  247. package/src/meetings/util.ts +117 -4
  248. package/src/member/ai-docs/member-spec.md +196 -0
  249. package/src/member/index.ts +10 -0
  250. package/src/member/types.ts +1 -0
  251. package/src/member/util.ts +29 -0
  252. package/src/members/ai-docs/members-spec.md +256 -0
  253. package/src/members/index.ts +70 -7
  254. package/src/members/util.ts +12 -4
  255. package/src/metrics/ai-docs/metrics-spec.md +185 -0
  256. package/src/metrics/constants.ts +11 -0
  257. package/src/multistream/ai-docs/multistream-spec.md +295 -0
  258. package/src/multistream/codec/constants.ts +58 -0
  259. package/src/multistream/mediaRequestManager.ts +119 -28
  260. package/src/multistream/receiveSlot.ts +18 -0
  261. package/src/multistream/remoteMediaManager.ts +23 -1
  262. package/src/multistream/sendSlotManager.ts +112 -4
  263. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +234 -0
  264. package/src/reachability/ai-docs/reachability-spec.md +261 -0
  265. package/src/reachability/clusterReachability.ts +3 -2
  266. package/src/reachability/index.ts +47 -16
  267. package/src/reachability/reachability.types.ts +11 -0
  268. package/src/reachability/util.ts +36 -0
  269. package/src/reactions/ai-docs/reactions-spec.md +198 -0
  270. package/src/reactions/reactions.type.ts +3 -0
  271. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +272 -0
  272. package/src/recording-controller/ai-docs/recording-controller-spec.md +223 -0
  273. package/src/recording-controller/index.ts +1 -2
  274. package/src/roap/ai-docs/roap-spec.md +241 -0
  275. package/src/roap/turnDiscovery.ts +9 -1
  276. package/src/webinar/ai-docs/webinar-spec.md +243 -0
  277. package/src/webinar/index.ts +333 -73
  278. package/test/unit/spec/aiEnableRequest/index.ts +86 -0
  279. package/test/unit/spec/annotation/index.ts +214 -182
  280. package/test/unit/spec/breakouts/breakout.ts +9 -3
  281. package/test/unit/spec/breakouts/events.ts +120 -2
  282. package/test/unit/spec/breakouts/index.ts +336 -15
  283. package/test/unit/spec/common/errors/webex-errors.ts +78 -0
  284. package/test/unit/spec/controls-options-manager/index.js +244 -29
  285. package/test/unit/spec/controls-options-manager/util.js +165 -0
  286. package/test/unit/spec/hashTree/hashTreeParser.ts +3126 -238
  287. package/test/unit/spec/hashTree/utils.ts +125 -1
  288. package/test/unit/spec/interceptors/dataChannelAuthToken.ts +179 -1
  289. package/test/unit/spec/interceptors/locusRetry.ts +234 -5
  290. package/test/unit/spec/interpretation/index.ts +119 -4
  291. package/test/unit/spec/locus-info/controlsUtils.js +172 -57
  292. package/test/unit/spec/locus-info/index.js +1880 -136
  293. package/test/unit/spec/locus-info/infoUtils.js +184 -1
  294. package/test/unit/spec/media/MediaConnectionAwaiter.ts +479 -17
  295. package/test/unit/spec/media/index.ts +92 -0
  296. package/test/unit/spec/media/properties.ts +26 -26
  297. package/test/unit/spec/meeting/in-meeting-actions.ts +4 -0
  298. package/test/unit/spec/meeting/index.js +3697 -501
  299. package/test/unit/spec/meeting/locusMediaRequest.ts +406 -4
  300. package/test/unit/spec/meeting/muteState.js +81 -0
  301. package/test/unit/spec/meeting/request.js +12 -0
  302. package/test/unit/spec/meeting/utils.js +206 -16
  303. package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
  304. package/test/unit/spec/meeting-info/meetinginfov2.js +88 -11
  305. package/test/unit/spec/meetings/index.js +586 -53
  306. package/test/unit/spec/meetings/request.js +141 -0
  307. package/test/unit/spec/meetings/utils.js +402 -51
  308. package/test/unit/spec/member/index.js +7 -0
  309. package/test/unit/spec/member/util.js +89 -0
  310. package/test/unit/spec/members/index.js +216 -0
  311. package/test/unit/spec/members/request.js +37 -1
  312. package/test/unit/spec/members/utils.js +63 -0
  313. package/test/unit/spec/multistream/mediaRequestManager.ts +501 -37
  314. package/test/unit/spec/multistream/remoteMediaManager.ts +46 -0
  315. package/test/unit/spec/multistream/sendSlotManager.ts +165 -38
  316. package/test/unit/spec/reachability/index.ts +128 -46
  317. package/test/unit/spec/reachability/util.ts +31 -0
  318. package/test/unit/spec/recording-controller/index.js +9 -8
  319. package/test/unit/spec/roap/turnDiscovery.ts +20 -0
  320. package/test/unit/spec/webinar/index.ts +982 -328
@@ -4,20 +4,23 @@
4
4
  import {WebexPlugin, config} from '@webex/webex-core';
5
5
  import uuid from 'uuid';
6
6
  import {get} from 'lodash';
7
- import {DataChannelTokenType} from '@webex/internal-plugin-llm';
7
+ import type LLMChannel from '@webex/internal-plugin-llm';
8
8
  import {
9
9
  _ID_,
10
+ EVENT_TRIGGERS,
10
11
  HEADERS,
11
12
  HTTP_VERBS,
12
13
  MEETINGS,
13
14
  SELF_ROLES,
14
15
  SHARE_STATUS,
15
16
  DEFAULT_LARGE_SCALE_WEBINAR_ATTENDEE_SEARCH_LIMIT,
16
- LLM_PRACTICE_SESSION,
17
+ LOCUS_LLM_EVENT,
17
18
  } from '../constants';
19
+ import Trigger from '../common/events/trigger-proxy';
18
20
 
19
21
  import WebinarCollection from './collection';
20
22
  import LoggerProxy from '../common/logs/logger-proxy';
23
+ import MeetingUtil from '../meeting/util';
21
24
  import {sanitizeParams} from './utils';
22
25
 
23
26
  /**
@@ -39,6 +42,21 @@ const Webinar = WebexPlugin.extend({
39
42
  meetingId: 'string',
40
43
  },
41
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
+
42
60
  /**
43
61
  * Calls this to clean up listeners
44
62
  * @returns {void}
@@ -98,13 +116,49 @@ const Webinar = WebexPlugin.extend({
98
116
  return {isPromoted, isDemoted};
99
117
  },
100
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
+
101
155
  /**
102
156
  * should join practice session data channel or not
103
157
  * @param {Object} {isPromoted: boolean, isDemoted: boolean}} Role transition states
104
158
  * @returns {void}
105
159
  */
106
160
  updateStatusByRole({isPromoted, isDemoted}) {
107
- const meeting = this.webex.meetings.getMeetingByType(_ID_, this.meetingId);
161
+ const meeting = this.getValidatedWebinarMeeting();
108
162
 
109
163
  if (
110
164
  (isDemoted && meeting?.shareStatus === SHARE_STATUS.WHITEBOARD_SHARE_ACTIVE) ||
@@ -127,34 +181,161 @@ const Webinar = WebexPlugin.extend({
127
181
  },
128
182
 
129
183
  /**
130
- * Disconnects the practice session data channel and removes its relay listener.
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.
131
219
  * @returns {Promise<void>}
132
220
  */
133
221
  async cleanupPSDataChannel() {
134
- const meeting = this.webex.meetings.getMeetingByType(_ID_, this.meetingId);
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
+ }
135
228
 
136
- // @ts-ignore - Fix type
137
- await this.webex.internal.llm.disconnectLLM(
138
- {
229
+ const meeting = this.getValidatedWebinarMeeting();
230
+
231
+ if (!this._practiceSessionLLMChannel) {
232
+ // Even without PS channel, ensure voicea is bound to main channel
233
+ if (meeting?.voiceaChannel && meeting?.llmChannel) {
234
+ await meeting.voiceaChannel.switchLLMChannel(meeting.llmChannel);
235
+ meeting.startTranscriptionIfNeeded();
236
+ }
237
+
238
+ return;
239
+ }
240
+
241
+ try {
242
+ await this._practiceSessionLLMChannel.disconnect({
139
243
  code: 3050,
140
244
  reason: 'done (permanent)',
141
- },
142
- LLM_PRACTICE_SESSION
143
- );
144
- // @ts-ignore - Fix type
145
- this.webex.internal.llm.off(
146
- `event:relay.event:${LLM_PRACTICE_SESSION}`,
147
- meeting?.processRelayEvent
148
- );
245
+ });
246
+ } catch (error) {
247
+ LoggerProxy.logger.error(
248
+ 'Webinar:index#cleanupPSDataChannel --> Failed to disconnect practice session LLM channel',
249
+ error
250
+ );
251
+ throw error;
252
+ } finally {
253
+ // Remove listeners from the channel
254
+ if (meeting) {
255
+ this._practiceSessionLLMChannel?.off('event:relay.event', meeting.processRelayEvent);
256
+ this._practiceSessionLLMChannel?.off(LOCUS_LLM_EVENT, meeting.processLocusLLMEvent);
257
+ this._practiceSessionLLMChannel?.off('online', meeting.handleLLMOnline);
258
+
259
+ // Switch annotation back to the meeting's default channel
260
+ if (meeting.llmChannel) {
261
+ meeting.annotation.registerChannel(meeting.llmChannel);
262
+ }
263
+ }
264
+ this._practiceSessionLLMChannel = undefined;
265
+
266
+ // Switch voicea to current main channel. Switching after disconnect ensures:
267
+ // - If main channel was replaced during disconnect (concurrent updateLLMConnection),
268
+ // meeting.llmChannel will be the new channel
269
+ // - If the channel is still connecting, switchLLMChannel waits for it to come online
270
+ if (meeting?.voiceaChannel && meeting?.llmChannel) {
271
+ await meeting.voiceaChannel.switchLLMChannel(meeting.llmChannel);
272
+ meeting.startTranscriptionIfNeeded();
273
+ }
274
+ }
149
275
  },
150
276
 
151
277
  /**
152
- * Connects to low latency mercury and reconnects if the address has changed
153
- * It will also disconnect if called when the meeting has ended
278
+ * Ensures practice-session token exists before registering the practice LLM channel.
279
+ * Caller is responsible for passing a meeting that has already been resolved via
280
+ * getValidatedWebinarMeeting() — this method does not re-validate ownership.
281
+ * @param {object} meeting
282
+ * @returns {Promise<string|undefined>}
283
+ */
284
+ async ensurePracticeSessionDatachannelToken(meeting) {
285
+ // @ts-ignore
286
+ const isDataChannelTokenEnabled = await this.webex.internal.llm.isDataChannelTokenEnabled();
287
+
288
+ if (!isDataChannelTokenEnabled) {
289
+ return undefined;
290
+ }
291
+
292
+ // Check for cached token on the channel or pending token
293
+ const cachedToken =
294
+ this._practiceSessionLLMChannel?.getDatachannelToken() ??
295
+ this._pendingPracticeSessionDatachannelToken;
296
+
297
+ if (cachedToken) {
298
+ return cachedToken;
299
+ }
300
+
301
+ try {
302
+ const refreshResponse = await meeting.refreshDataChannelToken();
303
+ const {datachannelToken} = refreshResponse?.body ?? {};
304
+
305
+ if (!datachannelToken) {
306
+ return undefined;
307
+ }
308
+
309
+ // Store token on the channel if it exists, otherwise save for later
310
+ if (this._practiceSessionLLMChannel) {
311
+ this._practiceSessionLLMChannel.setDatachannelToken(datachannelToken);
312
+ } else {
313
+ this._pendingPracticeSessionDatachannelToken = datachannelToken;
314
+ }
315
+
316
+ return datachannelToken;
317
+ } catch (error) {
318
+ LoggerProxy.logger.warn(
319
+ `Webinar:index#ensurePracticeSessionDatachannelToken --> failed to proactively refresh practice-session token: ${
320
+ error?.message || String(error)
321
+ }`
322
+ );
323
+
324
+ return undefined;
325
+ }
326
+ },
327
+
328
+ /**
329
+ * Connects practice session LLM channel. Creates a new channel if needed.
330
+ * Will disconnect if the meeting has ended or is no longer in practice session mode.
331
+ * Waits for the main LLM channel to be connected before connecting practice session.
154
332
  * @returns {Promise}
155
333
  */
156
334
  async updatePSDataChannel() {
157
- const meeting = this.webex.meetings.getMeetingByType(_ID_, this.meetingId);
335
+ this._updatePSDataChannelSequence = (this._updatePSDataChannelSequence || 0) + 1;
336
+ const invocationSequence = this._updatePSDataChannelSequence;
337
+
338
+ const meeting = this.getValidatedWebinarMeeting();
158
339
  const isPracticeSession = meeting?.isJoined() && this.isJoinPracticeSessionDataChannel();
159
340
 
160
341
  if (!isPracticeSession) {
@@ -164,71 +345,134 @@ const Webinar = WebexPlugin.extend({
164
345
  }
165
346
 
166
347
  // @ts-ignore - Fix type
167
- const {
168
- url = undefined,
169
- info: {practiceSessionDatachannelUrl = undefined} = {},
170
- self: {practiceSessionDatachannelToken = undefined} = {},
171
- } = meeting?.locusInfo || {};
348
+ const {url = undefined, info: {practiceSessionDatachannelUrl = undefined} = {}} =
349
+ meeting?.locusInfo || {};
172
350
 
173
- // @ts-ignore
174
- const currentToken = this.webex.internal.llm.getDatachannelToken(
175
- DataChannelTokenType.PracticeSession
176
- );
351
+ if (!practiceSessionDatachannelUrl) {
352
+ return undefined;
353
+ }
177
354
 
178
- const finalToken = currentToken ?? practiceSessionDatachannelToken;
355
+ // If already connected to same URLs, skip reconnect
356
+ if (this._practiceSessionLLMChannel?.isConnected()) {
357
+ if (
358
+ url === this._practiceSessionLLMChannel.getLocusUrl() &&
359
+ practiceSessionDatachannelUrl === this._practiceSessionLLMChannel.getDatachannelUrl()
360
+ ) {
361
+ return undefined;
362
+ }
363
+ // URLs changed, disconnect existing channel
364
+ await this.cleanupPSDataChannel();
365
+ }
179
366
 
180
- const isCaptionBoxOn = this.webex.internal.voicea.getIsCaptionBoxOn();
367
+ // Ensure the default session LLM channel is connected before connecting the practice session.
368
+ // Subscribe before checking isConnected() to avoid a race where the 'online' event fires
369
+ // between the check and the subscription — the channel does not replay missed events.
370
+ if (!this._pendingOnlineListener && meeting?.llmChannel) {
371
+ const onDefaultSessionConnected = () => {
372
+ this._pendingOnlineListener = null;
373
+ meeting.llmChannel?.off('online', onDefaultSessionConnected);
374
+ this.updatePSDataChannel();
375
+ };
376
+ this._pendingOnlineListener = onDefaultSessionConnected;
377
+ meeting.llmChannel.on('online', onDefaultSessionConnected);
378
+ }
181
379
 
182
- if (!currentToken && practiceSessionDatachannelToken) {
183
- // @ts-ignore
184
- this.webex.internal.llm.setDatachannelToken(
185
- practiceSessionDatachannelToken,
186
- DataChannelTokenType.PracticeSession
380
+ if (!meeting?.llmChannel?.isConnected()) {
381
+ LoggerProxy.logger.info(
382
+ 'Webinar:index#updatePSDataChannel --> default session not yet connected, deferring practice session connect.'
187
383
  );
384
+
385
+ return undefined;
188
386
  }
189
387
 
190
- if (!practiceSessionDatachannelUrl) {
388
+ // Default session is already connected — cancel the pending listener and proceed
389
+ if (this._pendingOnlineListener) {
390
+ meeting.llmChannel.off('online', this._pendingOnlineListener);
391
+ this._pendingOnlineListener = null;
392
+ }
393
+
394
+ // Get token from pending or refresh if needed
395
+ let practiceSessionDatachannelToken =
396
+ this._pendingPracticeSessionDatachannelToken ??
397
+ this._practiceSessionLLMChannel?.getDatachannelToken();
398
+
399
+ const refreshedToken = await this.ensurePracticeSessionDatachannelToken(meeting);
400
+
401
+ const latestPracticeSessionDatachannelUrl = get(
402
+ meeting,
403
+ 'locusInfo.info.practiceSessionDatachannelUrl'
404
+ );
405
+ const isStillPracticeSession = meeting?.isJoined() && this.isJoinPracticeSessionDataChannel();
406
+
407
+ // Skip stale invocations after async refresh to avoid reconnecting a session
408
+ // that was already updated/cleaned by a newer state transition.
409
+ if (
410
+ invocationSequence !== this._updatePSDataChannelSequence ||
411
+ !isStillPracticeSession ||
412
+ !latestPracticeSessionDatachannelUrl ||
413
+ latestPracticeSessionDatachannelUrl !== practiceSessionDatachannelUrl
414
+ ) {
191
415
  return undefined;
192
416
  }
193
- // @ts-ignore - Fix type
194
- if (this.webex.internal.llm.isConnected(LLM_PRACTICE_SESSION)) {
195
- if (
196
- // @ts-ignore - Fix type
197
- url === this.webex.internal.llm.getLocusUrl(LLM_PRACTICE_SESSION) &&
198
- // @ts-ignore - Fix type
199
- practiceSessionDatachannelUrl ===
200
- this.webex.internal.llm.getDatachannelUrl(LLM_PRACTICE_SESSION)
201
- ) {
202
- return undefined;
203
- }
204
417
 
205
- await this.cleanupPSDataChannel();
418
+ if (refreshedToken) {
419
+ practiceSessionDatachannelToken = refreshedToken;
206
420
  }
207
421
 
422
+ // Create a new practice session LLM channel
208
423
  // @ts-ignore - Fix type
209
- return this.webex.internal.llm
210
- .registerAndConnect(url, practiceSessionDatachannelUrl, finalToken, LLM_PRACTICE_SESSION)
211
- .then((registerAndConnectResult) => {
212
- // @ts-ignore - Fix type
213
- this.webex.internal.llm.off(
214
- `event:relay.event:${LLM_PRACTICE_SESSION}`,
215
- meeting?.processRelayEvent
216
- );
217
- // @ts-ignore - Fix type
218
- this.webex.internal.llm.on(
219
- `event:relay.event:${LLM_PRACTICE_SESSION}`,
220
- meeting?.processRelayEvent
221
- );
222
- // @ts-ignore - Fix type
223
- this.webex.internal.voicea?.announce?.();
224
- if (isCaptionBoxOn) {
225
- this.webex.internal.voicea.updateSubchannelSubscriptions({subscribe: ['transcription']});
424
+ const psChannel = this.webex.internal.llm.createChannel();
425
+ this._practiceSessionLLMChannel = psChannel;
426
+
427
+ // Set up refresh handler before registration
428
+ psChannel.setRefreshHandler(() => meeting.refreshDataChannelToken());
429
+
430
+ // If we have a pending token, store it on the channel
431
+ if (this._pendingPracticeSessionDatachannelToken) {
432
+ psChannel.setDatachannelToken(this._pendingPracticeSessionDatachannelToken);
433
+ this._pendingPracticeSessionDatachannelToken = undefined;
434
+ }
435
+
436
+ return psChannel
437
+ .registerAndConnect(url, practiceSessionDatachannelUrl, practiceSessionDatachannelToken)
438
+ .then(async (registerAndConnectResult) => {
439
+ // Check if this channel is still the current one (race condition guard)
440
+ if (this._practiceSessionLLMChannel !== psChannel) {
441
+ psChannel.disconnect({code: 3050, reason: 'replaced'}).catch(() => {});
442
+
443
+ return undefined;
226
444
  }
445
+ // Register event listeners on the practice session channel
446
+ psChannel.off('event:relay.event', meeting.processRelayEvent);
447
+ psChannel.on('event:relay.event', meeting.processRelayEvent);
448
+ psChannel.off(LOCUS_LLM_EVENT, meeting.processLocusLLMEvent);
449
+ psChannel.on(LOCUS_LLM_EVENT, meeting.processLocusLLMEvent);
450
+ psChannel.off('online', meeting.handleLLMOnline);
451
+ psChannel.on('online', meeting.handleLLMOnline);
452
+
453
+ // Switch annotation to practice session channel
454
+ meeting.annotation.registerChannel(psChannel);
455
+
456
+ // Switch meeting's voicea channel to use the PS LLM connection.
457
+ // The reconciler pattern preserves caption state and handles all timing.
458
+ // transcription is always initialized (reset to initial shape, never null).
459
+ if (meeting.voiceaChannel) {
460
+ await meeting.voiceaChannel.switchLLMChannel(psChannel);
461
+ meeting.startTranscriptionIfNeeded();
462
+ }
463
+
227
464
  LoggerProxy.logger.info(
228
- `Webinar:index#updatePSDataChannel --> enabled to receive relay events for default session for ${LLM_PRACTICE_SESSION}!`
465
+ 'Webinar:index#updatePSDataChannel --> enabled to receive relay events for practice session!'
229
466
  );
230
467
 
231
468
  return Promise.resolve(registerAndConnectResult);
469
+ })
470
+ .catch((error) => {
471
+ // Clean up the channel on failure, but only if it's still the current one
472
+ if (this._practiceSessionLLMChannel === psChannel) {
473
+ this._practiceSessionLLMChannel = undefined;
474
+ }
475
+ throw error;
232
476
  });
233
477
  },
234
478
 
@@ -238,6 +482,8 @@ const Webinar = WebexPlugin.extend({
238
482
  * @returns {Promise}
239
483
  */
240
484
  setPracticeSessionState(enabled) {
485
+ const meeting = this.getValidatedWebinarMeeting();
486
+
241
487
  return this.request({
242
488
  method: HTTP_VERBS.PATCH,
243
489
  uri: `${this.locusUrl}/controls`,
@@ -246,10 +492,16 @@ const Webinar = WebexPlugin.extend({
246
492
  enabled,
247
493
  },
248
494
  },
249
- }).catch((error) => {
250
- LoggerProxy.logger.error('Meeting:webinar#setPracticeSessionState failed', error);
251
- throw error;
252
- });
495
+ })
496
+ .then((response) => {
497
+ MeetingUtil.updateLocusFromApiResponse(meeting, response);
498
+
499
+ return response;
500
+ })
501
+ .catch((error) => {
502
+ LoggerProxy.logger.error('Meeting:webinar#setPracticeSessionState failed', error);
503
+ throw error;
504
+ });
253
505
  },
254
506
 
255
507
  /**
@@ -366,7 +618,6 @@ const Webinar = WebexPlugin.extend({
366
618
 
367
619
  /**
368
620
  * view all webcast attendees
369
- * @param {string} queryString
370
621
  * @returns {Promise}
371
622
  */
372
623
  async viewAllWebcastAttendees() {
@@ -430,7 +681,14 @@ const Webinar = WebexPlugin.extend({
430
681
  * @returns {Promise}
431
682
  */
432
683
  async searchLargeScaleWebinarAttendees(payload) {
433
- const meeting = this.webex.meetings.getMeetingByType(_ID_, this.meetingId);
684
+ const meeting = this.getValidatedWebinarMeeting();
685
+ if (!meeting) {
686
+ LoggerProxy.logger.error(
687
+ 'Meeting:webinar5k#searchLargeScaleWebinarAttendees failed --> webinar meeting could not be validated'
688
+ );
689
+ throw new Error('Meeting:webinar5k#Webinar meeting is not resolvable for the current locus');
690
+ }
691
+
434
692
  const rawParams = {
435
693
  search_text: payload?.queryString,
436
694
  limit: payload?.limit ?? DEFAULT_LARGE_SCALE_WEBINAR_ATTENDEE_SEARCH_LIMIT,
@@ -438,7 +696,9 @@ const Webinar = WebexPlugin.extend({
438
696
  };
439
697
  const attendeeSearchUrl = meeting?.locusInfo?.links?.resources?.attendeeSearch?.url;
440
698
  if (!attendeeSearchUrl) {
441
- LoggerProxy.logger.error(`Meeting:webinar5k#searchLargeScaleWebinarAttendees failed`);
699
+ LoggerProxy.logger.error(
700
+ 'Meeting:webinar5k#searchLargeScaleWebinarAttendees failed --> attendee search url unavailable'
701
+ );
442
702
  throw new Error('Meeting:webinar5k#Attendee search url is not available');
443
703
  }
444
704
 
@@ -55,6 +55,27 @@ describe('plugin-meetings', () => {
55
55
  });
56
56
  });
57
57
 
58
+ describe('#locusUrlUpdate', () => {
59
+ it('should update the locusUrl property', () => {
60
+ const testLocusUrl = 'https://locus-a.wbx2.com/locus/api/v1/loci/test-id';
61
+
62
+ aiEnableRequest.locusUrlUpdate(testLocusUrl);
63
+
64
+ assert.equal(aiEnableRequest.locusUrl, testLocusUrl);
65
+ });
66
+
67
+ it('should handle updating locusUrl multiple times', () => {
68
+ const firstUrl = 'https://locus-a.wbx2.com/locus/api/v1/loci/test-id-1';
69
+ const secondUrl = 'https://locus-a.wbx2.com/locus/api/v1/loci/test-id-2';
70
+
71
+ aiEnableRequest.locusUrlUpdate(firstUrl);
72
+ assert.equal(aiEnableRequest.locusUrl, firstUrl);
73
+
74
+ aiEnableRequest.locusUrlUpdate(secondUrl);
75
+ assert.equal(aiEnableRequest.locusUrl, secondUrl);
76
+ });
77
+ });
78
+
58
79
  describe('#selfParticipantIdUpdate', () => {
59
80
  it('should update the selfParticipantId property', () => {
60
81
  const testSelfParticipantId = 'participant-123';
@@ -254,6 +275,71 @@ describe('plugin-meetings', () => {
254
275
  sinon.assert.notCalled(triggerSpy);
255
276
  });
256
277
 
278
+ it('should not trigger event when locusUrl does not match', () => {
279
+ const testLocusUrl = 'https://locus-a.wbx2.com/locus/api/v1/loci/test-id';
280
+ const differentLocusUrl = 'https://locus-a.wbx2.com/locus/api/v1/loci/different-id';
281
+
282
+ aiEnableRequest.locusUrl = testLocusUrl;
283
+
284
+ // Reset the spy after setting locusUrl to avoid counting property change events
285
+ triggerSpy.resetHistory();
286
+
287
+ aiEnableRequest.listenToApprovalRequests();
288
+
289
+ const event = {
290
+ data: {
291
+ locusUrl: differentLocusUrl,
292
+ approval: {
293
+ resourceType: AI_ENABLE_REQUEST.RESOURCE_TYPE,
294
+ receivers: [{participantId: testSelfParticipantId}],
295
+ initiator: {participantId: testInitiatorId},
296
+ actionType: AI_ENABLE_REQUEST.ACTION_TYPE.REQUESTED,
297
+ url: testUrl,
298
+ },
299
+ },
300
+ };
301
+
302
+ webex.internal.mercury.emit(`event:${LOCUSEVENT.APPROVAL_REQUEST}`, event);
303
+
304
+ sinon.assert.notCalled(triggerSpy);
305
+ });
306
+
307
+ it('should trigger event when locusUrl matches', () => {
308
+ const testLocusUrl = 'https://locus-a.wbx2.com/locus/api/v1/loci/test-id';
309
+
310
+ aiEnableRequest.locusUrl = testLocusUrl;
311
+
312
+ // Reset the spy after setting locusUrl to avoid counting property change events
313
+ triggerSpy.resetHistory();
314
+
315
+ aiEnableRequest.listenToApprovalRequests();
316
+
317
+ const event = {
318
+ data: {
319
+ locusUrl: testLocusUrl,
320
+ approval: {
321
+ resourceType: AI_ENABLE_REQUEST.RESOURCE_TYPE,
322
+ receivers: [{participantId: testSelfParticipantId}],
323
+ initiator: {participantId: testInitiatorId},
324
+ actionType: AI_ENABLE_REQUEST.ACTION_TYPE.REQUESTED,
325
+ url: testUrl,
326
+ },
327
+ },
328
+ };
329
+
330
+ webex.internal.mercury.emit(`event:${LOCUSEVENT.APPROVAL_REQUEST}`, event);
331
+
332
+ sinon.assert.calledOnce(triggerSpy);
333
+ sinon.assert.calledWith(triggerSpy, AI_ENABLE_REQUEST.EVENTS.APPROVAL_REQUEST_ARRIVED, {
334
+ actionType: AI_ENABLE_REQUEST.ACTION_TYPE.REQUESTED,
335
+ isApprover: true,
336
+ isInitiator: false,
337
+ initiatorId: testInitiatorId,
338
+ approverId: testSelfParticipantId,
339
+ url: testUrl,
340
+ });
341
+ });
342
+
257
343
  it('should handle events with different action types', () => {
258
344
  aiEnableRequest.listenToApprovalRequests();
259
345