@webex/internal-plugin-ai-assistant 0.0.0-next.21 → 0.0.0-next.22

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.
@@ -445,7 +445,7 @@ var AIAssistant = _webexCore.WebexPlugin.extend({
445
445
  contentValue: options.question
446
446
  }));
447
447
  },
448
- version: "0.0.0-next.21"
448
+ version: "0.0.0-next.22"
449
449
  });
450
450
  var _default = exports.default = AIAssistant;
451
451
  //# sourceMappingURL=ai-assistant.js.map
package/dist/utils.js CHANGED
@@ -6,6 +6,7 @@ _Object$defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.decryptToolUse = exports.decryptMessage = exports.decryptCitedAnswer = void 0;
9
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
9
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
10
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
11
12
  var _lodash = require("lodash");
@@ -54,9 +55,18 @@ var decryptCitedAnswer = exports.decryptCitedAnswer = /*#__PURE__*/function () {
54
55
  return _regenerator.default.wrap(function _callee3$(_context3) {
55
56
  while (1) switch (_context3.prev = _context3.next) {
56
57
  case 0:
57
- _context3.next = 2;
58
+ if (!data.value.citations) {
59
+ _context3.next = 3;
60
+ break;
61
+ }
62
+ _context3.next = 3;
63
+ return _promise.default.all(data.value.citations.map(function (citation, index) {
64
+ return decryptInPlace(data, "value.citations.".concat(index, ".name"), 'encryptionKeyUrl', webex);
65
+ }));
66
+ case 3:
67
+ _context3.next = 5;
58
68
  return decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);
59
- case 2:
69
+ case 5:
60
70
  case "end":
61
71
  return _context3.stop();
62
72
  }
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_lodash","require","decryptInPlace","_ref","_asyncToGenerator2","default","_regenerator","mark","_callee","item","valuePath","keyPath","webex","encryptedValue","encryptionKeyUrl","decryptedValue","wrap","_callee$","_context","prev","next","get","internal","encryption","decryptText","sent","set","stop","_x","_x2","_x3","_x4","apply","arguments","decryptToolUse","exports","_ref2","_callee2","data","_callee2$","_context2","_x5","_x6","decryptCitedAnswer","_ref3","_callee3","_callee3$","_context3","_x7","_x8","decryptMessage","_ref4","_callee4","_callee4$","_context4","_x9","_x10"],"sources":["utils.ts"],"sourcesContent":["import {get, set} from 'lodash';\n\nconst decryptInPlace = async (item, valuePath, keyPath, webex) => {\n const encryptedValue = get(item, valuePath);\n const encryptionKeyUrl = get(item, keyPath);\n\n const decryptedValue = await webex.internal.encryption.decryptText(\n encryptionKeyUrl,\n encryptedValue\n );\n\n set(item, valuePath, decryptedValue);\n};\n\nexport const decryptToolUse = async (data, webex) => {\n await decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);\n};\n\nexport const decryptCitedAnswer = async (data, webex) => {\n await decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);\n};\n\nexport const decryptMessage = async (data, webex) => {\n await decryptInPlace(data, 'value', 'encryptionKeyUrl', webex);\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAMC,cAAc;EAAA,IAAAC,IAAA,OAAAC,kBAAA,CAAAC,OAAA,gBAAAC,YAAA,CAAAD,OAAA,CAAAE,IAAA,CAAG,SAAAC,QAAOC,IAAI,EAAEC,SAAS,EAAEC,OAAO,EAAEC,KAAK;IAAA,IAAAC,cAAA,EAAAC,gBAAA,EAAAC,cAAA;IAAA,OAAAT,YAAA,CAAAD,OAAA,CAAAW,IAAA,UAAAC,SAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UACrDP,cAAc,GAAG,IAAAQ,WAAG,EAACZ,IAAI,EAAEC,SAAS,CAAC;UACrCI,gBAAgB,GAAG,IAAAO,WAAG,EAACZ,IAAI,EA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,SAAAsC,SAAOP,IAAI,EAAE1B,KAAK;IAAA,OAAAN,YAAA,CAAAD,OAAA,CAAAW,IAAA,UAAA8B,UAAAC,SAAA;MAAA,kBAAAA,SAAA,CAAA5B,IAAA,GAAA4B,SAAA,CAAA3B,IAAA;QAAA;UAAA2B,SAAA,CAAA3B,IAAA;UAAA,OAC5ClB,cAAc,CAACoC,IAAI,EAAE,aAAa,EAAE,kBAAkB,EAAE1B,KAAK,CAAC;QAAA;QAAA;UAAA,OAAAmC,SAAA,CAAApB,IAAA;MAAA;IAAA,GAAAkB,QAAA;EAAA,CACrE;EAAA,gBAFYF,kBAAkBA,CAAAK,GAAA,EAAAC,GAAA;IAAA,OAAAL,KAAA,CAAAZ,KAAA,OAAAC,SAAA;EAAA;AAAA,GAE9B;AAEM,IAAMiB,cAAc,GAAAf,OAAA,CAAAe,cAAA;EAAA,IAAAC,KAAA,OAAA/C,kBAAA,CAAAC,OAAA,gBAAAC,YAAA,CAAAD,OAAA,CAAAE,IAAA,CAAG,SAAA6C,SAAOd,IAAI,EAAE1B,KAAK;IAAA,OAAAN,YAAA,CAAAD,OAAA,CAAAW,IAAA,UAAAqC,UAAAC,SAAA;MAAA,kBAAAA,SAAA,CAAAnC,IAAA,GAAAmC,SAAA,CAAAlC,IAAA;QAAA;UAAAkC,SAAA,CAAAlC,IAAA;UAAA,OACxClB,cAAc,CAACoC,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE1B,KAAK,CAAC;QAAA;QAAA;UAAA,OAAA0C,SAAA,CAAA3B,IAAA;MAAA;IAAA,GAAAyB,QAAA;EAAA,CAC/D;EAAA,gBAFYF,cAAcA,CAAAK,GAAA,EAAAC,IAAA;IAAA,OAAAL,KAAA,CAAAnB,KAAA,OAAAC,SAAA;EAAA;AAAA,GAE1B"}
1
+ {"version":3,"names":["_lodash","require","decryptInPlace","_ref","_asyncToGenerator2","default","_regenerator","mark","_callee","item","valuePath","keyPath","webex","encryptedValue","encryptionKeyUrl","decryptedValue","wrap","_callee$","_context","prev","next","get","internal","encryption","decryptText","sent","set","stop","_x","_x2","_x3","_x4","apply","arguments","decryptToolUse","exports","_ref2","_callee2","data","_callee2$","_context2","_x5","_x6","decryptCitedAnswer","_ref3","_callee3","_callee3$","_context3","value","citations","_promise","all","map","citation","index","concat","_x7","_x8","decryptMessage","_ref4","_callee4","_callee4$","_context4","_x9","_x10"],"sources":["utils.ts"],"sourcesContent":["import {get, set} from 'lodash';\n\nconst decryptInPlace = async (item, valuePath, keyPath, webex) => {\n const encryptedValue = get(item, valuePath);\n const encryptionKeyUrl = get(item, keyPath);\n\n const decryptedValue = await webex.internal.encryption.decryptText(\n encryptionKeyUrl,\n encryptedValue\n );\n\n set(item, valuePath, decryptedValue);\n};\n\nexport const decryptToolUse = async (data, webex) => {\n await decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);\n};\n\nexport const decryptCitedAnswer = async (data, webex) => {\n if (data.value.citations) {\n await Promise.all(\n data.value.citations.map((citation, index) => {\n return decryptInPlace(data, `value.citations.${index}.name`, 'encryptionKeyUrl', webex);\n })\n );\n }\n\n await decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);\n};\n\nexport const decryptMessage = async (data, webex) => {\n await decryptInPlace(data, 'value', 'encryptionKeyUrl', webex);\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAMC,cAAc;EAAA,IAAAC,IAAA,OAAAC,kBAAA,CAAAC,OAAA,gBAAAC,YAAA,CAAAD,OAAA,CAAAE,IAAA,CAAG,SAAAC,QAAOC,IAAI,EAAEC,SAAS,EAAEC,OAAO,EAAEC,KAAK;IAAA,IAAAC,cAAA,EAAAC,gBAAA,EAAAC,cAAA;IAAA,OAAAT,YAAA,CAAAD,OAAA,CAAAW,IAAA,UAAAC,SAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;UACrDP,cAAc,GAAG,IAAAQ,W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AAA,GAAA2C,SAAA,CAAA1C,IAAA;QAAA;UAAA0C,SAAA,CAAA1C,IAAA;UAAA,OACxClB,cAAc,CAACoC,IAAI,EAAE,OAAO,EAAE,kBAAkB,EAAE1B,KAAK,CAAC;QAAA;QAAA;UAAA,OAAAkD,SAAA,CAAAnC,IAAA;MAAA;IAAA,GAAAiC,QAAA;EAAA,CAC/D;EAAA,gBAFYF,cAAcA,CAAAK,GAAA,EAAAC,IAAA;IAAA,OAAAL,KAAA,CAAA3B,KAAA,OAAAC,SAAA;EAAA;AAAA,GAE1B"}
package/package.json CHANGED
@@ -49,5 +49,5 @@
49
49
  "test:style": "eslint ./src/**/*.*",
50
50
  "test:unit": "webex-legacy-tools test --unit --runner jest"
51
51
  },
52
- "version": "0.0.0-next.21"
52
+ "version": "0.0.0-next.22"
53
53
  }
package/src/utils.ts CHANGED
@@ -17,6 +17,14 @@ export const decryptToolUse = async (data, webex) => {
17
17
  };
18
18
 
19
19
  export const decryptCitedAnswer = async (data, webex) => {
20
+ if (data.value.citations) {
21
+ await Promise.all(
22
+ data.value.citations.map((citation, index) => {
23
+ return decryptInPlace(data, `value.citations.${index}.name`, 'encryptionKeyUrl', webex);
24
+ })
25
+ );
26
+ }
27
+
20
28
  await decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);
21
29
  };
22
30
 
@@ -254,7 +254,7 @@ export const jsonResponse = [
254
254
  {
255
255
  id: '6ccc8286e2084e05a6b9a29faae77095',
256
256
  index: 1,
257
- name: 'Meeting name',
257
+ name: 'json_5_encrypted_citation_0',
258
258
  url: 'https://co.webex.com/webappng/sites/co/recording/playback/6ccc8286e2084e05a6b9a29faae77095',
259
259
  metadata: {
260
260
  provider: 'webex',
@@ -296,59 +296,267 @@ describe('plugin-ai-assistant', () => {
296
296
  // first event is a tool use with an encrypted value
297
297
  await webex.internal.aiAssistant._handleEvent(cloneDeep(jsonResponse[0]));
298
298
 
299
- expect(triggerSpy.getCall(0).args[0]).to.equal(`aiassistant:result:${jsonResponse[0].clientRequestId}`);
300
-
301
- let expectedResult = set(
302
- cloneDeep(jsonResponse[0]),
303
- 'response.content.value.value',
304
- 'decrypted-with-kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e-json_0_encrypted_value'
305
- );
306
-
307
- expect(triggerSpy.getCall(0).args[1]).to.deep.equal(
299
+ await waitForAsync();
300
+
301
+ let expectedResult: any = {
302
+ sessionId: '3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
303
+ sessionUrl:
304
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
305
+ messageId: '3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
306
+ messageUrl:
307
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
308
+ responseId: '3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
309
+ responseUrl:
310
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
311
+ content: {
312
+ name: 'tool_use',
313
+ type: 'json',
314
+ value: {
315
+ id: 'call_vrnUKW2CLWVN1O40qcY0Y4tD',
316
+ name: '',
317
+ type: 'markdown',
318
+ value:
319
+ 'decrypted-with-kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e-json_0_encrypted_value',
320
+ },
321
+ encryptionKeyUrl: 'kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e',
322
+ },
323
+ createdAt: '2025-09-16T13:08:28.714399642Z',
324
+ creator: {
325
+ role: 'assistant',
326
+ },
327
+ // the below fields are added by the SDK
328
+ errorCode: undefined,
329
+ errorMessage: undefined,
330
+ finished: false,
331
+ requestId: 'test-request-id',
332
+ responseType: 'thought',
333
+ };
334
+ expect(triggerSpy.getCall(1).args[0]).to.deep.equal('aiassistant:stream:test-request-id');
335
+ expect(triggerSpy.getCall(1).args[1]).to.deep.equal(
308
336
  expectedResult
309
337
  );
310
338
 
339
+ triggerSpy.resetHistory();
340
+
311
341
  // second event is a tool result which has no encrypted value
312
342
  await webex.internal.aiAssistant._handleEvent(cloneDeep(jsonResponse[1]));
313
343
 
314
- expectedResult = cloneDeep(jsonResponse[1]);
344
+ await waitForAsync();
345
+
346
+ expectedResult = {
347
+ sessionId: '3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
348
+ sessionUrl:
349
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
350
+ messageId: '3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
351
+ messageUrl:
352
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
353
+ responseId: '3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
354
+ responseUrl:
355
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
356
+ content: {
357
+ name: 'tool_result',
358
+ type: 'json',
359
+ value: {
360
+ id: 'call_vrnUKW2CLWVN1O40qcY0Y4tD',
361
+ name: '',
362
+ type: 'markdown',
363
+ status: 'success',
364
+ },
365
+ },
366
+ createdAt: '2025-09-16T13:08:28.857717340Z',
367
+ creator: {
368
+ role: 'assistant',
369
+ },
370
+ // the below fields are added by the SDK
371
+ errorCode: undefined,
372
+ errorMessage: undefined,
373
+ finished: false,
374
+ requestId: 'test-request-id',
375
+ responseType: 'thought',
376
+ };
377
+ expect(triggerSpy.getCall(1).args[0]).to.deep.equal('aiassistant:stream:test-request-id');
315
378
  expect(triggerSpy.getCall(1).args[1]).to.deep.equal(expectedResult);
316
379
 
380
+ triggerSpy.resetHistory();
381
+
317
382
  // third event is another tool use with an encrypted value
318
383
  await webex.internal.aiAssistant._handleEvent(cloneDeep(jsonResponse[2]));
319
384
 
320
- expectedResult = set(
321
- cloneDeep(jsonResponse[2]),
322
- 'response.content.value.value',
323
- 'decrypted-with-kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e-json_2_encrypted_value'
324
- );
325
- expect(triggerSpy.getCall(3).args[1]).to.deep.equal(expectedResult);
385
+ await waitForAsync();
386
+
387
+ expectedResult = {
388
+ sessionId: '3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
389
+ sessionUrl:
390
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
391
+ messageId: '3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
392
+ messageUrl:
393
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
394
+ responseId: '3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
395
+ responseUrl:
396
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
397
+ content: {
398
+ name: 'tool_use',
399
+ type: 'json',
400
+ value: {
401
+ id: 'call_Ay3G8P0WYtIltRYZOtz6qXDz',
402
+ name: '',
403
+ type: 'markdown',
404
+ value:
405
+ 'decrypted-with-kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e-json_2_encrypted_value',
406
+ },
407
+ encryptionKeyUrl: 'kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e',
408
+ },
409
+ createdAt: '2025-09-16T13:08:29.597605274Z',
410
+ creator: {
411
+ role: 'assistant',
412
+ },
413
+ // the below fields are added by the SDK
414
+ errorCode: undefined,
415
+ errorMessage: undefined,
416
+ finished: false,
417
+ requestId: 'test-request-id',
418
+ responseType: 'thought',
419
+ };
420
+
421
+ expect(triggerSpy.getCall(1).args[0]).to.deep.equal('aiassistant:stream:test-request-id');
422
+ expect(triggerSpy.getCall(1).args[1]).to.deep.equal(expectedResult);
423
+
424
+ triggerSpy.resetHistory();
326
425
 
327
426
  // fourth event is a cited answer with an encrypted value
328
427
  await webex.internal.aiAssistant._handleEvent(cloneDeep(jsonResponse[3]));
329
428
 
330
- expectedResult = set(
331
- cloneDeep(jsonResponse[3]),
332
- 'response.content.value.value',
333
- 'decrypted-with-kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e-json_3_encrypted_value'
334
- );
335
- expect(triggerSpy.getCall(4).args[1]).to.deep.equal(expectedResult);
429
+ await waitForAsync();
430
+
431
+ expectedResult = {
432
+ sessionId: '3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
433
+ sessionUrl:
434
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
435
+ messageId: '3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
436
+ messageUrl:
437
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
438
+ responseId: '3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
439
+ responseUrl:
440
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
441
+ content: {
442
+ name: 'cited_answer',
443
+ type: 'json',
444
+ encryptionKeyUrl: 'kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e',
445
+ value: {
446
+ value: 'decrypted-with-kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e-json_3_encrypted_value',
447
+ type: 'markdown',
448
+ },
449
+ },
450
+ createdAt: '2025-09-16T13:08:30.566298862Z',
451
+ creator: {
452
+ role: 'assistant',
453
+ },
454
+ // the below fields are added by the SDK
455
+ errorCode: undefined,
456
+ errorMessage: undefined,
457
+ finished: false,
458
+ requestId: 'test-request-id',
459
+ responseType: 'response',
460
+ };
461
+
462
+ expect(triggerSpy.getCall(1).args[0]).to.deep.equal('aiassistant:stream:test-request-id');
463
+ expect(triggerSpy.getCall(1).args[1]).to.deep.equal(expectedResult);
464
+
465
+ triggerSpy.resetHistory();
336
466
 
337
467
  // fifth event is a tool result which has no encrypted value
338
468
  await webex.internal.aiAssistant._handleEvent(cloneDeep(jsonResponse[4]));
339
469
 
340
- expectedResult = cloneDeep(jsonResponse[4]);
341
- expect(triggerSpy.getCall(6).args[1]).to.deep.equal(expectedResult);
470
+ expectedResult = {
471
+ sessionId: '3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
472
+ sessionUrl:
473
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
474
+ messageId: '3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
475
+ messageUrl:
476
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
477
+ responseId: '3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
478
+ responseUrl:
479
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
480
+ content: {
481
+ name: 'tool_result',
482
+ type: 'json',
483
+ value: {
484
+ id: 'call_Ay3G8P0WYtIltRYZOtz6qXDz',
485
+ name: '',
486
+ type: 'markdown',
487
+ status: 'success',
488
+ },
489
+ },
490
+ createdAt: '2025-09-16T13:08:30.574636837Z',
491
+ creator: {
492
+ role: 'assistant',
493
+ },
494
+ // the below fields are added by the SDK
495
+ errorCode: undefined,
496
+ errorMessage: undefined,
497
+ finished: false,
498
+ requestId: 'test-request-id',
499
+ responseType: 'thought',
500
+ };
501
+
502
+ await waitForAsync();
503
+
504
+ expect(triggerSpy.getCall(1).args[0]).to.deep.equal('aiassistant:stream:test-request-id');
505
+ expect(triggerSpy.getCall(1).args[1]).to.deep.equal(expectedResult);
506
+
507
+ triggerSpy.resetHistory();
342
508
 
343
509
  // sixth event is a cited answer with an encrypted value
344
510
  await webex.internal.aiAssistant._handleEvent(cloneDeep(jsonResponse[5]));
345
511
 
346
- expectedResult = set(
347
- cloneDeep(jsonResponse[5]),
348
- 'response.content.value.value',
349
- 'decrypted-with-kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e-json_5_encrypted_value'
350
- );
351
- expect(triggerSpy.getCall(8).args[1]).to.deep.equal(expectedResult);
512
+ await waitForAsync();
513
+
514
+ expectedResult = {
515
+ sessionId: '3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
516
+ sessionUrl:
517
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
518
+ messageId: '3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
519
+ messageUrl:
520
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
521
+ responseId: '3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
522
+ responseUrl:
523
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
524
+ content: {
525
+ name: 'cited_answer',
526
+ type: 'json',
527
+ encryptionKeyUrl: 'kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e',
528
+ value: {
529
+ value:
530
+ 'decrypted-with-kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e-json_5_encrypted_value',
531
+ type: 'markdown',
532
+ citations: [
533
+ {
534
+ id: '6ccc8286e2084e05a6b9a29faae77095',
535
+ index: 1,
536
+ name: 'decrypted-with-kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e-json_5_encrypted_citation_0',
537
+ url: 'https://co.webex.com/webappng/sites/co/recording/playback/6ccc8286e2084e05a6b9a29faae77095',
538
+ metadata: {
539
+ provider: 'webex',
540
+ type: 'meeting_recording',
541
+ },
542
+ },
543
+ ],
544
+ },
545
+ },
546
+ createdAt: '2025-09-16T13:08:30.594220705Z',
547
+ creator: {
548
+ role: 'assistant',
549
+ },
550
+ // the below fields are added by the SDK
551
+ errorCode: undefined,
552
+ errorMessage: undefined,
553
+ finished: true,
554
+ requestId: 'test-request-id',
555
+ responseType: 'response',
556
+ };
557
+
558
+ expect(triggerSpy.getCall(1).args[0]).to.deep.equal('aiassistant:stream:test-request-id');
559
+ expect(triggerSpy.getCall(1).args[1]).to.deep.equal(expectedResult);
352
560
  });
353
561
 
354
562
  it('decrypts and emits data when receiving event data', async () => {