@webex/plugin-meetings 3.12.0-llmrefactor.6 → 3.12.0-llmrefactor.8

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.
@@ -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
 
@@ -1230,6 +1230,78 @@ describe('plugin-meetings', () => {
1230
1230
  assert.calledWith(suspendDestroyMeetingStub.thirdCall, false);
1231
1231
  });
1232
1232
 
1233
+ it('should not retry if join() fails because the Locus user capacity is full', async () => {
1234
+ const error = new Error('Error Joining Meeting');
1235
+ error.error = {
1236
+ statusCode: 423,
1237
+ body: {errorCode: 2423001},
1238
+ };
1239
+ meeting.join = sinon.stub().rejects(error);
1240
+
1241
+ const thrownError = await assert.isRejected(
1242
+ meeting.joinWithMedia({joinOptions, mediaOptions})
1243
+ );
1244
+
1245
+ assert.equal(thrownError, error);
1246
+ assert.calledOnce(meeting.join);
1247
+ assert.calledOnce(generateTurnDiscoveryRequestMessageStub);
1248
+ assert.calledOnce(Metrics.sendBehavioralMetric);
1249
+ assert.calledTwice(suspendDestroyMeetingStub);
1250
+ assert.calledWith(suspendDestroyMeetingStub.firstCall, true);
1251
+ assert.calledWith(suspendDestroyMeetingStub.secondCall, false);
1252
+ });
1253
+
1254
+ it('should still retry if join() fails with another HTTP 423 Locus error', async () => {
1255
+ const error = new Error('Error Joining Meeting');
1256
+ error.error = {
1257
+ statusCode: 423,
1258
+ body: {errorCode: 2423028},
1259
+ };
1260
+ meeting.join = sinon.stub().rejects(error);
1261
+
1262
+ const thrownError = await assert.isRejected(
1263
+ meeting.joinWithMedia({joinOptions, mediaOptions})
1264
+ );
1265
+
1266
+ assert.equal(thrownError, error);
1267
+ assert.calledTwice(meeting.join);
1268
+ assert.calledTwice(generateTurnDiscoveryRequestMessageStub);
1269
+ assert.calledTwice(Metrics.sendBehavioralMetric);
1270
+ });
1271
+
1272
+ it('should throw the Locus user full error over firstError when the retry hits full capacity', async () => {
1273
+ const firstJoinError = new Error('first join error');
1274
+ const capacityError = new Error('Error Joining Meeting');
1275
+ capacityError.error = {
1276
+ statusCode: 423,
1277
+ body: {errorCode: 2423001},
1278
+ };
1279
+
1280
+ meeting.join = sinon
1281
+ .stub()
1282
+ .onFirstCall()
1283
+ .rejects(firstJoinError)
1284
+ .onSecondCall()
1285
+ .rejects(capacityError);
1286
+ meeting.locusUrl = null; // join never succeeds
1287
+
1288
+ const thrownError = await assert.isRejected(
1289
+ meeting.joinWithMedia({joinOptions, mediaOptions})
1290
+ );
1291
+
1292
+ // join() runs once for the first attempt and once for the re-join
1293
+ assert.calledTwice(meeting.join);
1294
+ // the capacity error must take precedence over the stored firstError
1295
+ assert.equal(thrownError, capacityError);
1296
+
1297
+ assert.deepEqual(meeting.joinWithMediaRetryInfo, {
1298
+ retryCount: 0,
1299
+ prevJoinResponse: undefined,
1300
+ firstError: undefined,
1301
+ prevError: undefined,
1302
+ });
1303
+ });
1304
+
1233
1305
  it('should re-join on retry when join() fails on first attempt, and throw the first error if join fails again', async () => {
1234
1306
  const firstJoinError = new Error('first join error');
1235
1307
  const secondJoinError = new Error('second join error');
@@ -150,6 +150,90 @@ describe('plugin-meetings', () => {
150
150
  });
151
151
 
152
152
  describe('processNewCaptions', () => {
153
+ const processCaptions = () => processNewCaptions({
154
+ data: fakeVoiceaPayload,
155
+ meeting: fakeMeeting
156
+ });
157
+
158
+ it('should process a final-only caption without an existing interim caption', () => {
159
+ const transcriptData = fakeMeeting.transcription;
160
+ const transcriptId = fakeVoiceaPayload.transcriptId;
161
+
162
+ delete transcriptData.interimCaptions[transcriptId];
163
+
164
+ assert.doesNotThrow(processCaptions);
165
+
166
+ const finalCaption = transcriptData.captions.find(caption => caption.id === transcriptId);
167
+
168
+ assert.exists(finalCaption);
169
+ assert.deepEqual(transcriptData.interimCaptions[transcriptId], []);
170
+ });
171
+
172
+ it('should process an interim caption received after a final caption', () => {
173
+ const transcriptData = fakeMeeting.transcription;
174
+ const transcriptId = fakeVoiceaPayload.transcriptId;
175
+
176
+ delete transcriptData.interimCaptions[transcriptId];
177
+
178
+ assert.doesNotThrow(processCaptions);
179
+
180
+ fakeVoiceaPayload.isFinal = false;
181
+
182
+ assert.doesNotThrow(processCaptions);
183
+
184
+ const speakerId = fakeMeeting.members.membersCollection.members[fakeMemberId].participant.person.id;
185
+ const interimId = `${transcriptId}_${speakerId}`;
186
+
187
+ assert.exists(transcriptData.captions.find(caption => caption.id === transcriptId));
188
+ assert.exists(transcriptData.captions.find(caption => caption.id === interimId));
189
+ assert.deepEqual(transcriptData.interimCaptions[transcriptId], [interimId]);
190
+ });
191
+
192
+ it('should process repeated final captions without throwing', () => {
193
+ const transcriptData = fakeMeeting.transcription;
194
+ const transcriptId = fakeVoiceaPayload.transcriptId;
195
+
196
+ delete transcriptData.interimCaptions[transcriptId];
197
+
198
+ assert.doesNotThrow(() => {
199
+ processCaptions();
200
+ processCaptions();
201
+ });
202
+
203
+ assert.exists(transcriptData.captions.find(caption => caption.id === transcriptId));
204
+ });
205
+
206
+ it('should process a final payload containing transcript entries for multiple CSIs without throwing', () => {
207
+ const transcriptData = fakeMeeting.transcription;
208
+ const transcriptId = fakeVoiceaPayload.transcriptId;
209
+ const firstCsi = 1234867712;
210
+ const secondCsi = 1234867713;
211
+ const secondCaptionText = 'Caption from a second CSI';
212
+
213
+ fakeVoiceaPayload.transcripts = [
214
+ {
215
+ ...fakeVoiceaPayload.transcripts[0],
216
+ csis: [firstCsi]
217
+ },
218
+ {
219
+ text: secondCaptionText,
220
+ csis: [secondCsi],
221
+ transcript_language_code: 'en'
222
+ }
223
+ ];
224
+
225
+ assert.doesNotThrow(processCaptions);
226
+
227
+ const finalCaptionTexts = transcriptData.captions
228
+ .filter(caption => caption.id === transcriptId)
229
+ .map(caption => caption.text);
230
+
231
+ assert.deepEqual(finalCaptionTexts, [
232
+ fakeVoiceaPayload.transcripts[0].text,
233
+ secondCaptionText
234
+ ]);
235
+ });
236
+
153
237
  it('should process new final captions correctly', () => {
154
238
  let transcriptData = fakeMeeting.transcription;
155
239
  let transcriptId = fakeVoiceaPayload.transcriptId;
@@ -254,4 +338,4 @@ describe('plugin-meetings', () => {
254
338
  });
255
339
  });
256
340
  });
257
- });
341
+ });