@webex/plugin-meetings 3.12.0-llmrefactor.1 → 3.12.0-llmrefactor.10

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 (54) hide show
  1. package/dist/aiEnableRequest/index.js +1 -1
  2. package/dist/annotation/index.js +2 -2
  3. package/dist/annotation/index.js.map +1 -1
  4. package/dist/breakouts/breakout.js +1 -1
  5. package/dist/breakouts/index.js +5 -1
  6. package/dist/breakouts/index.js.map +1 -1
  7. package/dist/hashTree/hashTreeParser.js +101 -48
  8. package/dist/hashTree/hashTreeParser.js.map +1 -1
  9. package/dist/interpretation/index.js +1 -1
  10. package/dist/interpretation/siLanguage.js +1 -1
  11. package/dist/locus-info/index.js +27 -2
  12. package/dist/locus-info/index.js.map +1 -1
  13. package/dist/locus-info/types.js +2 -1
  14. package/dist/locus-info/types.js.map +1 -1
  15. package/dist/meeting/index.js +139 -53
  16. package/dist/meeting/index.js.map +1 -1
  17. package/dist/meeting/util.js +5 -1
  18. package/dist/meeting/util.js.map +1 -1
  19. package/dist/meeting/voicea-meeting.js +2 -1
  20. package/dist/meeting/voicea-meeting.js.map +1 -1
  21. package/dist/meeting-info/meeting-info-v2.js +7 -1
  22. package/dist/meeting-info/meeting-info-v2.js.map +1 -1
  23. package/dist/meetings/index.js +44 -19
  24. package/dist/meetings/index.js.map +1 -1
  25. package/dist/types/hashTree/hashTreeParser.d.ts +12 -0
  26. package/dist/types/locus-info/index.d.ts +6 -0
  27. package/dist/types/locus-info/types.d.ts +1 -0
  28. package/dist/types/meeting/index.d.ts +9 -0
  29. package/dist/types/meeting/util.d.ts +3 -1
  30. package/dist/types/meeting-info/meeting-info-v2.d.ts +1 -0
  31. package/dist/webinar/index.js +42 -25
  32. package/dist/webinar/index.js.map +1 -1
  33. package/package.json +21 -21
  34. package/src/annotation/index.ts +6 -4
  35. package/src/breakouts/index.ts +2 -0
  36. package/src/hashTree/hashTreeParser.ts +67 -3
  37. package/src/locus-info/index.ts +20 -0
  38. package/src/locus-info/types.ts +1 -0
  39. package/src/meeting/index.ts +122 -36
  40. package/src/meeting/util.ts +2 -2
  41. package/src/meeting/voicea-meeting.ts +1 -1
  42. package/src/meeting-info/meeting-info-v2.ts +6 -2
  43. package/src/meetings/index.ts +23 -8
  44. package/src/webinar/index.ts +19 -6
  45. package/test/unit/spec/annotation/index.ts +1 -1
  46. package/test/unit/spec/breakouts/index.ts +34 -0
  47. package/test/unit/spec/hashTree/hashTreeParser.ts +212 -1
  48. package/test/unit/spec/locus-info/index.js +79 -0
  49. package/test/unit/spec/meeting/index.js +396 -13
  50. package/test/unit/spec/meeting/utils.js +16 -2
  51. package/test/unit/spec/meeting/voicea-meeting.ts +85 -1
  52. package/test/unit/spec/meeting-info/meetinginfov2.js +57 -0
  53. package/test/unit/spec/meetings/index.js +63 -19
  54. package/test/unit/spec/webinar/index.ts +48 -2
@@ -88,6 +88,7 @@ describe('plugin-meetings', () => {
88
88
  webex = new MockWebex({});
89
89
  webex.internal.llm.on = sinon.stub();
90
90
  webex.internal.llm.isConnected = sinon.stub();
91
+ webex.internal.llm.getLocusUrl = sinon.stub().returns('newUrl');
91
92
  webex.internal.mercury.on = sinon.stub();
92
93
  breakouts = new Breakouts({}, {parent: webex});
93
94
  breakouts.groupId = 'groupId';
@@ -723,6 +724,15 @@ describe('plugin-meetings', () => {
723
724
  assert.notCalled(listenToSpy);
724
725
  });
725
726
 
727
+ it('do not subscribe message if the connected llm does not belong to this meeting', () => {
728
+ webex.internal.llm.isConnected = sinon.stub().returns(true);
729
+ webex.internal.llm.getLocusUrl = sinon.stub().returns('anotherMeetingLocusUrl');
730
+ breakouts.listenTo = sinon.stub();
731
+ breakouts.locusUrlUpdate('newUrl');
732
+ assert.equal(breakouts.locusUrl, 'newUrl');
733
+ assert.notCalled(breakouts.listenTo);
734
+ });
735
+
726
736
  it('do not subscribe message if already done', () => {
727
737
  const mockChannel = {
728
738
  isConnected: sinon.stub().returns(true),
@@ -787,6 +797,30 @@ describe('plugin-meetings', () => {
787
797
  sessionId: 'sessionId',
788
798
  });
789
799
  });
800
+
801
+ it('re-checks the subscription when the llm emits online', () => {
802
+ const onlineCall = webex.internal.llm.on.getCalls().find((c) => c.args[0] === 'online');
803
+ assert.exists(onlineCall, 'expected an online listener to be registered');
804
+ const onlineHandler = onlineCall.args[1];
805
+
806
+ // Set up _llmChannel so listenToBroadcastMessages can subscribe
807
+ const mockChannel = {
808
+ isConnected: sinon.stub().returns(true),
809
+ on: sinon.stub(),
810
+ off: sinon.stub(),
811
+ };
812
+ breakouts._llmChannel = mockChannel;
813
+
814
+ const listenToSpy = sinon.spy(breakouts, 'listenTo');
815
+
816
+ onlineHandler.call(breakouts);
817
+
818
+ const call = listenToSpy
819
+ .getCalls()
820
+ .find((c) => c.args[0] === mockChannel && c.args[1] === 'event:breakout.message');
821
+ assert.exists(call, 'expected broadcast message subscription after online');
822
+ assert.isTrue(breakouts.hasSubscribedToMessage);
823
+ });
790
824
  });
791
825
 
792
826
  describe('#updateCanManageBreakouts', () => {
@@ -184,7 +184,8 @@ describe('HashTreeParser', () => {
184
184
  excludedDataSets?: string[],
185
185
  syncLatencyTracker?: any,
186
186
  syncLatencyMeetingId = 'meeting-1',
187
- generateTrackingId?: any
187
+ generateTrackingId?: any,
188
+ isLlmExpected?: () => boolean
188
189
  ) {
189
190
  return new HashTreeParser({
190
191
  initialLocus,
@@ -194,6 +195,7 @@ describe('HashTreeParser', () => {
194
195
  locusInfoUpdateCallback: callback,
195
196
  syncLatencyTracker,
196
197
  generateTrackingId,
198
+ isLlmExpected,
197
199
  },
198
200
  debugId: 'test',
199
201
  excludedDataSets,
@@ -3519,6 +3521,193 @@ describe('HashTreeParser', () => {
3519
3521
  expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3520
3522
  });
3521
3523
 
3524
+ it('skips watchdog timers for LLM datasets when current meeting LLM is not expected', async () => {
3525
+ const parser = createHashTreeParser(
3526
+ undefined,
3527
+ undefined,
3528
+ undefined,
3529
+ undefined,
3530
+ 'meeting-1',
3531
+ undefined,
3532
+ () => false
3533
+ );
3534
+
3535
+ const heartbeatMessage = {
3536
+ dataSets: [
3537
+ {
3538
+ ...createDataSet('main', 16, 1100),
3539
+ root: parser.dataSets.main.hashTree.getRootHash(),
3540
+ },
3541
+ {
3542
+ ...createDataSet('self', 1, 2100),
3543
+ url: parser.dataSets.self.url,
3544
+ root: parser.dataSets.self.hashTree.getRootHash(),
3545
+ },
3546
+ {
3547
+ ...createDataSet('atd-unmuted', 16, 3100),
3548
+ url: parser.dataSets['atd-unmuted'].url,
3549
+ root: parser.dataSets['atd-unmuted'].hashTree.getRootHash(),
3550
+ },
3551
+ ],
3552
+ visibleDataSetsUrl,
3553
+ locusUrl,
3554
+ };
3555
+
3556
+ parser.handleMessage(heartbeatMessage, 'heartbeat with meeting-scoped llm not expected');
3557
+
3558
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3559
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3560
+ expect(parser.dataSets.self.heartbeatWatchdogTimer).to.not.be.undefined;
3561
+ });
3562
+
3563
+ it('arms skipped LLM watchdog timers when reevaluateLlmWatchdogs is called after LLM becomes expected', async () => {
3564
+ let llmExpected = false;
3565
+ const parser = createHashTreeParser(
3566
+ undefined,
3567
+ undefined,
3568
+ undefined,
3569
+ undefined,
3570
+ 'meeting-1',
3571
+ undefined,
3572
+ () => llmExpected
3573
+ );
3574
+
3575
+ const heartbeatMessage = {
3576
+ dataSets: [
3577
+ {
3578
+ ...createDataSet('main', 16, 1100),
3579
+ root: parser.dataSets.main.hashTree.getRootHash(),
3580
+ },
3581
+ {
3582
+ ...createDataSet('self', 1, 2100),
3583
+ url: parser.dataSets.self.url,
3584
+ root: parser.dataSets.self.hashTree.getRootHash(),
3585
+ },
3586
+ {
3587
+ ...createDataSet('atd-unmuted', 16, 3100),
3588
+ url: parser.dataSets['atd-unmuted'].url,
3589
+ root: parser.dataSets['atd-unmuted'].hashTree.getRootHash(),
3590
+ },
3591
+ ],
3592
+ visibleDataSetsUrl,
3593
+ locusUrl,
3594
+ };
3595
+
3596
+ // LLM data set messages arrive before LLM is expected, so their watchdogs are skipped
3597
+ parser.handleMessage(heartbeatMessage, 'heartbeat before llm expected');
3598
+
3599
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3600
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3601
+ const selfTimerBefore = parser.dataSets.self.heartbeatWatchdogTimer;
3602
+ expect(selfTimerBefore).to.not.be.undefined;
3603
+
3604
+ // LLM becomes expected and we re-evaluate the watchdogs
3605
+ llmExpected = true;
3606
+ parser.reevaluateLlmWatchdogs();
3607
+
3608
+ // the previously skipped LLM watchdogs are now armed
3609
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.not.be.undefined;
3610
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.not.be.undefined;
3611
+ // the self (non-LLM) watchdog timer is left untouched
3612
+ expect(parser.dataSets.self.heartbeatWatchdogTimer).to.equal(selfTimerBefore);
3613
+
3614
+ // the pending set is consumed, so a second call after clearing the timers is a no-op
3615
+ clearTimeout(parser.dataSets.main.heartbeatWatchdogTimer);
3616
+ clearTimeout(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer);
3617
+ parser.dataSets.main.heartbeatWatchdogTimer = undefined;
3618
+ parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer = undefined;
3619
+
3620
+ parser.reevaluateLlmWatchdogs();
3621
+
3622
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3623
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3624
+ });
3625
+
3626
+ it('only arms watchdogs for LLM data sets that were actually received in a message', async () => {
3627
+ let llmExpected = false;
3628
+ const parser = createHashTreeParser(
3629
+ undefined,
3630
+ undefined,
3631
+ undefined,
3632
+ undefined,
3633
+ 'meeting-1',
3634
+ undefined,
3635
+ () => llmExpected
3636
+ );
3637
+
3638
+ // only 'main' is received in a message (atd-unmuted exists in this.dataSets with a hash
3639
+ // tree but is never received in any message)
3640
+ const heartbeatMessage = {
3641
+ dataSets: [
3642
+ {
3643
+ ...createDataSet('main', 16, 1100),
3644
+ root: parser.dataSets.main.hashTree.getRootHash(),
3645
+ },
3646
+ ],
3647
+ visibleDataSetsUrl,
3648
+ locusUrl,
3649
+ };
3650
+
3651
+ parser.handleMessage(heartbeatMessage, 'only main received before llm expected');
3652
+
3653
+ // sanity: atd-unmuted has a hash tree but was never received
3654
+ expect(parser.dataSets['atd-unmuted'].hashTree).to.not.be.undefined;
3655
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3656
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3657
+
3658
+ llmExpected = true;
3659
+ parser.reevaluateLlmWatchdogs();
3660
+
3661
+ // 'main' was received, so its watchdog is armed
3662
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.not.be.undefined;
3663
+ // 'atd-unmuted' was never received, so no watchdog is armed even though it has a hash tree
3664
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3665
+ });
3666
+
3667
+ it('does not re-arm or reset an already active LLM watchdog timer when reevaluateLlmWatchdogs is called', async () => {
3668
+ const parser = createHashTreeParser(
3669
+ undefined,
3670
+ undefined,
3671
+ undefined,
3672
+ undefined,
3673
+ 'meeting-1',
3674
+ undefined,
3675
+ () => true
3676
+ );
3677
+
3678
+ parser.handleMessage(
3679
+ createHeartbeatMessage('main', 16, 1100, parser.dataSets.main.hashTree.getRootHash()),
3680
+ 'heartbeat with llm expected'
3681
+ );
3682
+
3683
+ const mainTimerBefore = parser.dataSets.main.heartbeatWatchdogTimer;
3684
+ expect(mainTimerBefore).to.not.be.undefined;
3685
+
3686
+ parser.reevaluateLlmWatchdogs();
3687
+
3688
+ // existing active timer must not be cleared/reset (that would extend its deadline)
3689
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.equal(mainTimerBefore);
3690
+ });
3691
+
3692
+ it('does nothing when reevaluateLlmWatchdogs is called on a stopped parser', async () => {
3693
+ const parser = createHashTreeParser(
3694
+ undefined,
3695
+ undefined,
3696
+ undefined,
3697
+ undefined,
3698
+ 'meeting-1',
3699
+ undefined,
3700
+ () => true
3701
+ );
3702
+
3703
+ parser.stop();
3704
+
3705
+ parser.reevaluateLlmWatchdogs();
3706
+
3707
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3708
+ expect(parser.dataSets['atd-unmuted'].heartbeatWatchdogTimer).to.be.undefined;
3709
+ });
3710
+
3522
3711
  it('stops all watchdog timers when meeting ends via sentinel message', async () => {
3523
3712
  const parser = createHashTreeParser();
3524
3713
 
@@ -3679,6 +3868,28 @@ describe('HashTreeParser', () => {
3679
3868
  expect(parser.dataSets['atd-active']?.heartbeatWatchdogTimer).to.be.undefined;
3680
3869
  });
3681
3870
 
3871
+ it('does not set watchdog for a data set that has a hash tree but is not in visibleDataSets', async () => {
3872
+ const parser = createHashTreeParser();
3873
+
3874
+ // simulate a dataset that still has a hash tree but is no longer visible
3875
+ parser.visibleDataSets = parser.visibleDataSets.filter((vds) => vds.name !== 'main');
3876
+
3877
+ const heartbeatMessage = {
3878
+ dataSets: [
3879
+ {
3880
+ ...createDataSet('main', 16, 1100),
3881
+ root: parser.dataSets.main.hashTree.getRootHash(),
3882
+ },
3883
+ ],
3884
+ visibleDataSetsUrl,
3885
+ locusUrl,
3886
+ };
3887
+
3888
+ parser.handleMessage(heartbeatMessage, 'heartbeat for non-visible dataset with hash tree');
3889
+
3890
+ expect(parser.dataSets.main.heartbeatWatchdogTimer).to.be.undefined;
3891
+ });
3892
+
3682
3893
  it('restarts the watchdog timer after it fires so that future missed heartbeats still trigger syncs', async () => {
3683
3894
  const parser = createHashTreeParser();
3684
3895
  const heartbeatIntervalMs = 5000;
@@ -195,6 +195,38 @@ describe('plugin-meetings', () => {
195
195
  );
196
196
  });
197
197
 
198
+ it('passes an isLlmExpected callback that is true when current device is joined', async () => {
199
+ locusInfo.parsedLocus.self = {
200
+ state: 'LEFT',
201
+ joinedWith: {state: 'JOINED'},
202
+ };
203
+
204
+ await locusInfo.initialSetup({
205
+ trigger: 'locus-message',
206
+ hashTreeMessage: createHashTreeMessage(['dataset1']),
207
+ });
208
+
209
+ const {isLlmExpected} = HashTreeParserStub.firstCall.args[0].callbacks;
210
+
211
+ assert.equal(isLlmExpected(), true);
212
+ });
213
+
214
+ it('passes an isLlmExpected callback that is false when self is joined but current device is not joined', async () => {
215
+ locusInfo.parsedLocus.self = {
216
+ state: 'JOINED',
217
+ joinedWith: {state: 'LEFT'},
218
+ };
219
+
220
+ await locusInfo.initialSetup({
221
+ trigger: 'locus-message',
222
+ hashTreeMessage: createHashTreeMessage(['dataset1']),
223
+ });
224
+
225
+ const {isLlmExpected} = HashTreeParserStub.firstCall.args[0].callbacks;
226
+
227
+ assert.equal(isLlmExpected(), false);
228
+ });
229
+
198
230
  it('should not initialize the hash tree when triggered from a non-hash tree locus message', async () => {
199
231
  const locus = {url: 'http://locus-url.com', participants: []};
200
232
 
@@ -2023,6 +2055,53 @@ describe('plugin-meetings', () => {
2023
2055
  });
2024
2056
 
2025
2057
  describe('#updateSelf', () => {
2058
+ describe('LLM watchdog re-evaluation', () => {
2059
+ it('re-evaluates LLM watchdogs on all hash tree parsers when self transitions to joined', () => {
2060
+ const parserA = {reevaluateLlmWatchdogs: sinon.stub()};
2061
+ const parserB = {reevaluateLlmWatchdogs: sinon.stub()};
2062
+ locusInfo.hashTreeParsers.set('urlA', {parser: parserA});
2063
+ locusInfo.hashTreeParsers.set('urlB', {parser: parserB});
2064
+
2065
+ // start with LLM not expected (no self yet)
2066
+ locusInfo.parsedLocus.self = undefined;
2067
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2068
+
2069
+ // the self fixture's joined device has state JOINED -> isLlmExpected becomes true
2070
+ locusInfo.updateSelf(cloneDeep(self));
2071
+
2072
+ assert.calledOnceWithExactly(parserA.reevaluateLlmWatchdogs);
2073
+ assert.calledOnceWithExactly(parserB.reevaluateLlmWatchdogs);
2074
+ });
2075
+
2076
+ it('does not re-evaluate LLM watchdogs when LLM was already expected before the update', () => {
2077
+ const parser = {reevaluateLlmWatchdogs: sinon.stub()};
2078
+ locusInfo.hashTreeParsers.set('urlA', {parser});
2079
+ locusInfo.webex.internal.device.url = self.deviceUrl;
2080
+
2081
+ // first update establishes the JOINED state (LLM already expected)
2082
+ locusInfo.updateSelf(cloneDeep(self));
2083
+ parser.reevaluateLlmWatchdogs.resetHistory();
2084
+
2085
+ // second update while already joined must not re-trigger re-evaluation
2086
+ locusInfo.updateSelf(cloneDeep(self));
2087
+
2088
+ assert.notCalled(parser.reevaluateLlmWatchdogs);
2089
+ });
2090
+
2091
+ it('does not re-evaluate LLM watchdogs when the self update does not make LLM expected', () => {
2092
+ const parser = {reevaluateLlmWatchdogs: sinon.stub()};
2093
+ locusInfo.hashTreeParsers.set('urlA', {parser});
2094
+
2095
+ locusInfo.parsedLocus.self = undefined;
2096
+ // device url does not match any of self's devices -> joinedWith is undefined -> not expected
2097
+ locusInfo.webex.internal.device.url = 'https://some-other-device-url.com';
2098
+
2099
+ locusInfo.updateSelf(cloneDeep(self));
2100
+
2101
+ assert.notCalled(parser.reevaluateLlmWatchdogs);
2102
+ });
2103
+ });
2104
+
2026
2105
  it('should trigger SELF_MEETING_BRB_CHANGED when brb state changed', () => {
2027
2106
  locusInfo.self = undefined;
2028
2107