@webex/internal-plugin-ai-assistant 3.11.0 → 3.12.0

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.
package/package.json CHANGED
@@ -20,10 +20,10 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@webex/common": "3.11.0",
24
- "@webex/common-timers": "3.11.0",
25
- "@webex/internal-plugin-mercury": "3.11.0",
26
- "@webex/webex-core": "3.11.0",
23
+ "@webex/common": "3.12.0",
24
+ "@webex/common-timers": "3.12.0",
25
+ "@webex/internal-plugin-mercury": "3.12.0",
26
+ "@webex/webex-core": "3.12.0",
27
27
  "lodash": "^4.17.21",
28
28
  "uuid": "^3.3.2"
29
29
  },
@@ -33,9 +33,9 @@
33
33
  "@webex/eslint-config-legacy": "0.0.0",
34
34
  "@webex/jest-config-legacy": "0.0.0",
35
35
  "@webex/legacy-tools": "0.0.0",
36
- "@webex/test-helper-chai": "3.11.0",
37
- "@webex/test-helper-mock-webex": "3.11.0",
38
- "@webex/test-helper-test-users": "3.11.0",
36
+ "@webex/test-helper-chai": "3.12.0",
37
+ "@webex/test-helper-mock-webex": "3.12.0",
38
+ "@webex/test-helper-test-users": "3.12.0",
39
39
  "eslint": "^8.24.0",
40
40
  "prettier": "^2.7.1",
41
41
  "sinon": "^9.2.4"
@@ -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": "3.11.0"
52
+ "version": "3.12.0"
53
53
  }
@@ -22,12 +22,15 @@ import {
22
22
  AI_ASSISTANT_UNREGISTERED,
23
23
  AI_ASSISTANT_SERVICE_NAME,
24
24
  ASSISTANT_API_RESPONSE_EVENT,
25
+ ASSISTANT_API_ACTIVITY,
25
26
  ACTION_TYPES,
26
27
  CONTENT_TYPES,
27
28
  CONTEXT_RESOURCE_TYPES,
28
29
  RESPONSE_NAMES,
30
+ AI_ASSISTANT_ACTIVITY_RECEIVED,
29
31
  } from './constants';
30
32
  import {
33
+ decryptAssistantActivity,
31
34
  decryptCitedAnswer,
32
35
  decryptMessage,
33
36
  decryptScheduleMeeting,
@@ -105,10 +108,10 @@ const AIAssistant = WebexPlugin.extend({
105
108
 
106
109
  this.stopListeningForEvents();
107
110
 
108
- return this.webex.internal.mercury.disconnect().then(() => {
109
- this.trigger(AI_ASSISTANT_UNREGISTERED);
110
- this.registered = false;
111
- });
111
+ this.trigger(AI_ASSISTANT_UNREGISTERED);
112
+ this.registered = false;
113
+
114
+ return Promise.resolve();
112
115
  },
113
116
 
114
117
  /**
@@ -120,6 +123,10 @@ const AIAssistant = WebexPlugin.extend({
120
123
  this.webex.internal.mercury.on(ASSISTANT_API_RESPONSE_EVENT, (envelope) => {
121
124
  this._handleEvent(envelope.data);
122
125
  });
126
+
127
+ this.webex.internal.mercury.on(ASSISTANT_API_ACTIVITY, (envelope) => {
128
+ this._handleAssistantActivity(envelope.data);
129
+ });
123
130
  },
124
131
 
125
132
  /**
@@ -129,6 +136,7 @@ const AIAssistant = WebexPlugin.extend({
129
136
  */
130
137
  stopListeningForEvents() {
131
138
  this.webex.internal.mercury.off(ASSISTANT_API_RESPONSE_EVENT);
139
+ this.webex.internal.mercury.off(ASSISTANT_API_ACTIVITY);
132
140
  },
133
141
 
134
142
  /**
@@ -160,6 +168,17 @@ const AIAssistant = WebexPlugin.extend({
160
168
  this.trigger(this._getResultEventName(data.clientRequestId), data);
161
169
  },
162
170
 
171
+ /**
172
+ * Handles an incoming activity event from the assistant API and triggers the correct event for consumers to listen to
173
+ * @param {Object} data the event data
174
+ * @returns {undefined}
175
+ */
176
+ async _handleAssistantActivity(data) {
177
+ await decryptAssistantActivity(data.activity, this.webex);
178
+
179
+ this.trigger(AI_ASSISTANT_ACTIVITY_RECEIVED, data);
180
+ },
181
+
163
182
  /**
164
183
  * Decrypts the response content in place
165
184
  * @param {any} responseContent the content object from the assistant-api response
@@ -206,7 +225,7 @@ const AIAssistant = WebexPlugin.extend({
206
225
  * @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
207
226
  */
208
227
  _request(options: RequestOptions): Promise<RequestResponse> {
209
- const {resource, params} = options;
228
+ const {resource, params, headers} = options;
210
229
 
211
230
  const timeout = this.config.requestTimeout;
212
231
  const requestId = options.requestId || uuid.v4();
@@ -266,6 +285,7 @@ const AIAssistant = WebexPlugin.extend({
266
285
  method: 'POST',
267
286
  contentType: 'application/json',
268
287
  body: {clientRequestId: requestId, ...params},
288
+ headers,
269
289
  })
270
290
  .then(({body}) => {
271
291
  resolve({...body, requestId, streamEventName});
@@ -291,6 +311,7 @@ const AIAssistant = WebexPlugin.extend({
291
311
  * @param {Object} options.locale optional locale to use for the request, defaults to 'en_US'
292
312
  * @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
293
313
  * @param {string} options.entryPoint optional entryPoint to use for this request
314
+ * @param {string} options.renderProtocolVersion optional render protocol version to use for this request
294
315
  * @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
295
316
  * @public
296
317
  * @memberof AIAssistant
@@ -318,6 +339,12 @@ const AIAssistant = WebexPlugin.extend({
318
339
  content.parameters = options.parameters;
319
340
  }
320
341
 
342
+ const headers = {};
343
+
344
+ if (options.renderProtocolVersion) {
345
+ headers['AI-Assistant-Render-Protocol'] = options.renderProtocolVersion;
346
+ }
347
+
321
348
  return this._request({
322
349
  resource: options.sessionId ? `sessions/${options.sessionId}/messages` : 'sessions/messages',
323
350
  params: {
@@ -328,6 +355,7 @@ const AIAssistant = WebexPlugin.extend({
328
355
  ...(options.assistant ? {assistant: options.assistant} : {}),
329
356
  },
330
357
  ...(options.requestId ? {requestId: options.requestId} : {}),
358
+ headers,
331
359
  });
332
360
  },
333
361
 
package/src/constants.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  export const AI_ASSISTANT_REGISTERED = 'aiassistant:registered';
2
2
  export const AI_ASSISTANT_UNREGISTERED = 'aiassistant:unregistered';
3
3
  export const ASSISTANT_API_RESPONSE_EVENT = 'event:assistant-api.response';
4
+ export const ASSISTANT_API_ACTIVITY = 'assistant-api.activity';
4
5
  export const AI_ASSISTANT_SERVICE_NAME = 'assistant-api';
5
6
  export const AI_ASSISTANT_RESULT = 'aiassistant:result';
7
+ export const AI_ASSISTANT_ACTIVITY_RECEIVED = 'aiassistant:activityReceived';
6
8
  export const AI_ASSISTANT_STREAM = 'aiassistant:stream';
7
9
 
8
10
  export enum AI_ASSISTANT_ERRORS {
package/src/types.ts CHANGED
@@ -23,6 +23,7 @@ export interface RequestOptions {
23
23
  notFoundPath?: string;
24
24
  params?: Record<string, unknown>;
25
25
  requestId?: string;
26
+ headers?: Record<string, string>;
26
27
  }
27
28
 
28
29
  export interface ContextResource {
@@ -52,4 +53,5 @@ export interface AiAssistantRequestOptions {
52
53
  locale?: string;
53
54
  requestId?: string;
54
55
  entryPoint?: string;
56
+ renderProtocolVersion?: string;
55
57
  }
package/src/utils.ts CHANGED
@@ -29,6 +29,14 @@ export const decryptCitedAnswer = async (data, webex) => {
29
29
  );
30
30
  }
31
31
 
32
+ if (data.value.sources) {
33
+ await Promise.all(
34
+ data.value.sources.map((source, index) => {
35
+ return decryptInPlace(data, `value.sources.${index}.name`, 'encryptionKeyUrl', webex);
36
+ })
37
+ );
38
+ }
39
+
32
40
  await decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);
33
41
  };
34
42
  export const decryptScheduleMeeting = async (data, webex) => {
@@ -68,3 +76,7 @@ export const decryptMessage = async (data, webex) => {
68
76
  export const decryptWorkspace = async (data, webex) => {
69
77
  await decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);
70
78
  };
79
+
80
+ export const decryptAssistantActivity = async (data, webex) => {
81
+ await decryptInPlace(data, 'content.value.message', 'encryptionKeyUrl', webex);
82
+ };
@@ -295,8 +295,7 @@ export const workspaceResponse = [
295
295
  type: 'json',
296
296
  encryptionKeyUrl: 'workspace_0_encryption_key_url',
297
297
  value: {
298
- value:
299
- 'workspace_0_encrypted_value',
298
+ value: 'workspace_0_encrypted_value',
300
299
  type: 'markdown',
301
300
  },
302
301
  },
@@ -328,8 +327,7 @@ export const workspaceResponse = [
328
327
  type: 'json',
329
328
  encryptionKeyUrl: 'workspace_1_encryption_key_url',
330
329
  value: {
331
- value:
332
- 'workspace_1_encrypted_value',
330
+ value: 'workspace_1_encrypted_value',
333
331
  type: 'markdown',
334
332
  },
335
333
  },
@@ -361,8 +359,7 @@ export const workspaceResponse = [
361
359
  type: 'json',
362
360
  encryptionKeyUrl: 'workspace_2_encryption_key_url',
363
361
  value: {
364
- value:
365
- 'workspace_2_encrypted_value',
362
+ value: 'workspace_2_encrypted_value',
366
363
  type: 'markdown',
367
364
  },
368
365
  },
@@ -394,8 +391,7 @@ export const workspaceResponse = [
394
391
  type: 'json',
395
392
  encryptionKeyUrl: 'workspace_3_encryption_key_url',
396
393
  value: {
397
- value:
398
- 'workspace_3_encrypted_value',
394
+ value: 'workspace_3_encrypted_value',
399
395
  type: 'markdown',
400
396
  },
401
397
  },
@@ -427,8 +423,7 @@ export const workspaceResponse = [
427
423
  type: 'json',
428
424
  encryptionKeyUrl: 'workspace_4_encryption_key_url',
429
425
  value: {
430
- value:
431
- 'workspace_4_encrypted_value',
426
+ value: 'workspace_4_encrypted_value',
432
427
  type: 'markdown',
433
428
  },
434
429
  },
@@ -460,8 +455,7 @@ export const workspaceResponse = [
460
455
  type: 'json',
461
456
  encryptionKeyUrl: 'workspace_5_encryption_key_url',
462
457
  value: {
463
- value:
464
- 'workspace_5_encrypted_value',
458
+ value: 'workspace_5_encrypted_value',
465
459
  type: 'markdown',
466
460
  },
467
461
  },
@@ -493,8 +487,7 @@ export const workspaceResponse = [
493
487
  type: 'json',
494
488
  encryptionKeyUrl: 'workspace_6_encryption_key_url',
495
489
  value: {
496
- value:
497
- 'workspace_6_encrypted_value',
490
+ value: 'workspace_6_encrypted_value',
498
491
  type: 'markdown',
499
492
  },
500
493
  },
@@ -526,8 +519,7 @@ export const workspaceResponse = [
526
519
  type: 'json',
527
520
  encryptionKeyUrl: 'workspace_7_encryption_key_url',
528
521
  value: {
529
- value:
530
- 'workspace_7_encrypted_value',
522
+ value: 'workspace_7_encrypted_value',
531
523
  type: 'markdown',
532
524
  },
533
525
  },
@@ -559,8 +551,7 @@ export const workspaceResponse = [
559
551
  type: 'json',
560
552
  encryptionKeyUrl: 'workspace_8_encryption_key_url',
561
553
  value: {
562
- value:
563
- 'workspace_8_encrypted_value',
554
+ value: 'workspace_8_encrypted_value',
564
555
  type: 'markdown',
565
556
  },
566
557
  },
@@ -592,8 +583,7 @@ export const workspaceResponse = [
592
583
  type: 'json',
593
584
  encryptionKeyUrl: 'workspace_9_encryption_key_url',
594
585
  value: {
595
- value:
596
- 'workspace_9_encrypted_value',
586
+ value: 'workspace_9_encrypted_value',
597
587
  type: 'markdown',
598
588
  },
599
589
  },
@@ -717,4 +707,115 @@ export const scheduleMeetingResponse = [
717
707
  creator: {role: 'assistant'},
718
708
  },
719
709
  },
720
- ];
710
+ ];
711
+
712
+ export const citedAnswerWithSourcesResponse = [
713
+ {
714
+ eventType: 'assistant-api.response',
715
+ sequence: 1,
716
+ finished: true,
717
+ clientRequestId: 'test-request-id',
718
+ responseId: '3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
719
+ responseType: 'response',
720
+ response: {
721
+ sessionId: '3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
722
+ sessionUrl:
723
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5',
724
+ messageId: '3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
725
+ messageUrl:
726
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c19fd10-92fe-11f0-8e9f-1bafc66fbbc5',
727
+ responseId: '3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
728
+ responseUrl:
729
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/3c1939c0-92fe-11f0-8e9f-1bafc66fbbc5/messages/3c1a4b30-92fe-11f0-8e9f-1bafc66fbbc5',
730
+ content: {
731
+ name: 'cited_answer',
732
+ type: 'json',
733
+ encryptionKeyUrl: 'kms://kms-us.wbx2.com/keys/9565506d-78b1-4742-b0fd-63719748282e',
734
+ value: {
735
+ value: 'json_1_encrypted_value',
736
+ type: 'markdown',
737
+ citations: [
738
+ {
739
+ id: '6ccc8286e2084e05a6b9a29faae77095',
740
+ index: 1,
741
+ name: 'json_1_encrypted_citation_0',
742
+ url: 'https://co.webex.com/webappng/sites/co/recording/playback/6ccc8286e2084e05a6b9a29faae77095',
743
+ metadata: {
744
+ provider: 'webex',
745
+ type: 'meeting_recording',
746
+ },
747
+ },
748
+ ],
749
+ sources: [
750
+ {
751
+ id: '6ccc8286e2084e05a6b9a29faae77096',
752
+ index: 1,
753
+ type: 'post_meeting',
754
+ name: 'json_1_encrypted_source_0',
755
+ metadata: {
756
+ meetingContainerId: 'mccc8286e2084e05a6b9a29faae77096',
757
+ },
758
+ },
759
+ {
760
+ id: '6ccc8286e2084e05a6b9a29faae77096',
761
+ index: 2,
762
+ type: 'post_call',
763
+ name: 'json_1_encrypted_source_1',
764
+ metadata: {
765
+ callContainerId: 'mccc8286e2084e05a6b9a29faae77096',
766
+ },
767
+ },
768
+ {
769
+ id: '6ccc8286e2084e05a6b9a29faae77096',
770
+ index: 3,
771
+ type: 'message',
772
+ name: 'json_1_encrypted_source_2',
773
+ metadata: {
774
+ spaceId: 'mccc8286e2084e05a6b9a29faae77096',
775
+ },
776
+ },
777
+ ],
778
+ },
779
+ },
780
+ createdAt: '2025-09-16T13:08:30.594220705Z',
781
+ creator: {
782
+ role: 'assistant',
783
+ },
784
+ },
785
+ },
786
+ ];
787
+
788
+ export const assistantActivity = [
789
+ {
790
+ eventType: 'assistant-api.activity',
791
+ sequence: 1,
792
+ finished: true,
793
+ clientRequestId: '',
794
+ responseId: '267533f0-566b-11f0-88f7-9bd287b85bcb',
795
+ responseType: 'activity',
796
+ activity: {
797
+ sessionId: '05779da0-566b-11f0-913c-035e874e536f',
798
+ sessionUrl:
799
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/05779da0-566b-11f0-913c-035e874e536f',
800
+ messageId: '2674e5d0-566b-11f0-88f7-9bd287b85bcb',
801
+ messageUrl:
802
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/05779da0-566b-11f0-913c-035e874e536f/messages/2674e5d0-566b-11f0-88f7-9bd287b85bcb',
803
+ responseId: '267533f0-566b-11f0-88f7-9bd287b85bcb',
804
+ responseUrl:
805
+ 'https://assistant-api-a.wbx2.com:443/assistant-api/api/v1/sessions/05779da0-566b-11f0-913c-035e874e536f/messages/267533f0-566b-11f0-88f7-9bd287b85bcb',
806
+ content: {
807
+ type: 'json',
808
+ name: 'alert_create_poll',
809
+ value: {
810
+ pollType: 'poll',
811
+ message: 'message_encrypted_value_for_activity',
812
+ },
813
+ },
814
+ encryptionKeyUrl: 'kms://kms-cisco.wbx2.com/keys/9b838423-f31b-49d5-a7c7-182572340a37',
815
+ createdAt: '2025-07-01T11:04:27.082430261Z',
816
+ creator: {
817
+ role: 'assistant',
818
+ },
819
+ },
820
+ },
821
+ ];