@webex/internal-plugin-ai-assistant 3.12.0-next.8 → 3.12.0-task-refactor.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.
package/package.json CHANGED
@@ -20,10 +20,10 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@webex/common": "3.11.0-next.1",
24
- "@webex/common-timers": "3.11.0-next.1",
25
- "@webex/internal-plugin-mercury": "3.12.0-next.8",
26
- "@webex/webex-core": "3.12.0-next.7",
23
+ "@webex/common": "3.12.0-task-refactor.1",
24
+ "@webex/common-timers": "3.12.0-task-refactor.1",
25
+ "@webex/internal-plugin-mercury": "3.12.0-task-refactor.1",
26
+ "@webex/webex-core": "3.12.0-task-refactor.1",
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-next.1",
37
- "@webex/test-helper-mock-webex": "3.11.0-next.1",
38
- "@webex/test-helper-test-users": "3.11.0-next.1",
36
+ "@webex/test-helper-chai": "3.12.0-task-refactor.1",
37
+ "@webex/test-helper-mock-webex": "3.12.0-task-refactor.1",
38
+ "@webex/test-helper-test-users": "3.12.0-task-refactor.1",
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.12.0-next.8"
52
+ "version": "3.12.0-task-refactor.1"
53
53
  }
@@ -22,15 +22,12 @@ import {
22
22
  AI_ASSISTANT_UNREGISTERED,
23
23
  AI_ASSISTANT_SERVICE_NAME,
24
24
  ASSISTANT_API_RESPONSE_EVENT,
25
- ASSISTANT_API_ACTIVITY,
26
25
  ACTION_TYPES,
27
26
  CONTENT_TYPES,
28
27
  CONTEXT_RESOURCE_TYPES,
29
28
  RESPONSE_NAMES,
30
- AI_ASSISTANT_ACTIVITY_RECEIVED,
31
29
  } from './constants';
32
30
  import {
33
- decryptAssistantActivity,
34
31
  decryptCitedAnswer,
35
32
  decryptMessage,
36
33
  decryptScheduleMeeting,
@@ -108,10 +105,10 @@ const AIAssistant = WebexPlugin.extend({
108
105
 
109
106
  this.stopListeningForEvents();
110
107
 
111
- this.trigger(AI_ASSISTANT_UNREGISTERED);
112
- this.registered = false;
113
-
114
- return Promise.resolve();
108
+ return this.webex.internal.mercury.disconnect().then(() => {
109
+ this.trigger(AI_ASSISTANT_UNREGISTERED);
110
+ this.registered = false;
111
+ });
115
112
  },
116
113
 
117
114
  /**
@@ -123,10 +120,6 @@ const AIAssistant = WebexPlugin.extend({
123
120
  this.webex.internal.mercury.on(ASSISTANT_API_RESPONSE_EVENT, (envelope) => {
124
121
  this._handleEvent(envelope.data);
125
122
  });
126
-
127
- this.webex.internal.mercury.on(ASSISTANT_API_ACTIVITY, (envelope) => {
128
- this._handleAssistantActivity(envelope.data);
129
- });
130
123
  },
131
124
 
132
125
  /**
@@ -136,7 +129,6 @@ const AIAssistant = WebexPlugin.extend({
136
129
  */
137
130
  stopListeningForEvents() {
138
131
  this.webex.internal.mercury.off(ASSISTANT_API_RESPONSE_EVENT);
139
- this.webex.internal.mercury.off(ASSISTANT_API_ACTIVITY);
140
132
  },
141
133
 
142
134
  /**
@@ -168,17 +160,6 @@ const AIAssistant = WebexPlugin.extend({
168
160
  this.trigger(this._getResultEventName(data.clientRequestId), data);
169
161
  },
170
162
 
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
-
182
163
  /**
183
164
  * Decrypts the response content in place
184
165
  * @param {any} responseContent the content object from the assistant-api response
@@ -225,7 +206,7 @@ const AIAssistant = WebexPlugin.extend({
225
206
  * @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
226
207
  */
227
208
  _request(options: RequestOptions): Promise<RequestResponse> {
228
- const {resource, params, headers} = options;
209
+ const {resource, params} = options;
229
210
 
230
211
  const timeout = this.config.requestTimeout;
231
212
  const requestId = options.requestId || uuid.v4();
@@ -285,7 +266,6 @@ const AIAssistant = WebexPlugin.extend({
285
266
  method: 'POST',
286
267
  contentType: 'application/json',
287
268
  body: {clientRequestId: requestId, ...params},
288
- headers,
289
269
  })
290
270
  .then(({body}) => {
291
271
  resolve({...body, requestId, streamEventName});
@@ -311,7 +291,6 @@ const AIAssistant = WebexPlugin.extend({
311
291
  * @param {Object} options.locale optional locale to use for the request, defaults to 'en_US'
312
292
  * @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
313
293
  * @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
315
294
  * @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
316
295
  * @public
317
296
  * @memberof AIAssistant
@@ -339,12 +318,6 @@ const AIAssistant = WebexPlugin.extend({
339
318
  content.parameters = options.parameters;
340
319
  }
341
320
 
342
- const headers = {};
343
-
344
- if (options.renderProtocolVersion) {
345
- headers['AI-Assistant-Render-Protocol'] = options.renderProtocolVersion;
346
- }
347
-
348
321
  return this._request({
349
322
  resource: options.sessionId ? `sessions/${options.sessionId}/messages` : 'sessions/messages',
350
323
  params: {
@@ -355,7 +328,6 @@ const AIAssistant = WebexPlugin.extend({
355
328
  ...(options.assistant ? {assistant: options.assistant} : {}),
356
329
  },
357
330
  ...(options.requestId ? {requestId: options.requestId} : {}),
358
- headers,
359
331
  });
360
332
  },
361
333
 
package/src/constants.ts CHANGED
@@ -1,10 +1,8 @@
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';
5
4
  export const AI_ASSISTANT_SERVICE_NAME = 'assistant-api';
6
5
  export const AI_ASSISTANT_RESULT = 'aiassistant:result';
7
- export const AI_ASSISTANT_ACTIVITY_RECEIVED = 'aiassistant:activityReceived';
8
6
  export const AI_ASSISTANT_STREAM = 'aiassistant:stream';
9
7
 
10
8
  export enum AI_ASSISTANT_ERRORS {
package/src/types.ts CHANGED
@@ -23,7 +23,6 @@ export interface RequestOptions {
23
23
  notFoundPath?: string;
24
24
  params?: Record<string, unknown>;
25
25
  requestId?: string;
26
- headers?: Record<string, string>;
27
26
  }
28
27
 
29
28
  export interface ContextResource {
@@ -53,5 +52,4 @@ export interface AiAssistantRequestOptions {
53
52
  locale?: string;
54
53
  requestId?: string;
55
54
  entryPoint?: string;
56
- renderProtocolVersion?: string;
57
55
  }
package/src/utils.ts CHANGED
@@ -29,14 +29,6 @@ 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
-
40
32
  await decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);
41
33
  };
42
34
  export const decryptScheduleMeeting = async (data, webex) => {
@@ -76,7 +68,3 @@ export const decryptMessage = async (data, webex) => {
76
68
  export const decryptWorkspace = async (data, webex) => {
77
69
  await decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);
78
70
  };
79
-
80
- export const decryptAssistantActivity = async (data, webex) => {
81
- await decryptInPlace(data, 'content.value.message', 'encryptionKeyUrl', webex);
82
- };
@@ -295,7 +295,8 @@ export const workspaceResponse = [
295
295
  type: 'json',
296
296
  encryptionKeyUrl: 'workspace_0_encryption_key_url',
297
297
  value: {
298
- value: 'workspace_0_encrypted_value',
298
+ value:
299
+ 'workspace_0_encrypted_value',
299
300
  type: 'markdown',
300
301
  },
301
302
  },
@@ -327,7 +328,8 @@ export const workspaceResponse = [
327
328
  type: 'json',
328
329
  encryptionKeyUrl: 'workspace_1_encryption_key_url',
329
330
  value: {
330
- value: 'workspace_1_encrypted_value',
331
+ value:
332
+ 'workspace_1_encrypted_value',
331
333
  type: 'markdown',
332
334
  },
333
335
  },
@@ -359,7 +361,8 @@ export const workspaceResponse = [
359
361
  type: 'json',
360
362
  encryptionKeyUrl: 'workspace_2_encryption_key_url',
361
363
  value: {
362
- value: 'workspace_2_encrypted_value',
364
+ value:
365
+ 'workspace_2_encrypted_value',
363
366
  type: 'markdown',
364
367
  },
365
368
  },
@@ -391,7 +394,8 @@ export const workspaceResponse = [
391
394
  type: 'json',
392
395
  encryptionKeyUrl: 'workspace_3_encryption_key_url',
393
396
  value: {
394
- value: 'workspace_3_encrypted_value',
397
+ value:
398
+ 'workspace_3_encrypted_value',
395
399
  type: 'markdown',
396
400
  },
397
401
  },
@@ -423,7 +427,8 @@ export const workspaceResponse = [
423
427
  type: 'json',
424
428
  encryptionKeyUrl: 'workspace_4_encryption_key_url',
425
429
  value: {
426
- value: 'workspace_4_encrypted_value',
430
+ value:
431
+ 'workspace_4_encrypted_value',
427
432
  type: 'markdown',
428
433
  },
429
434
  },
@@ -455,7 +460,8 @@ export const workspaceResponse = [
455
460
  type: 'json',
456
461
  encryptionKeyUrl: 'workspace_5_encryption_key_url',
457
462
  value: {
458
- value: 'workspace_5_encrypted_value',
463
+ value:
464
+ 'workspace_5_encrypted_value',
459
465
  type: 'markdown',
460
466
  },
461
467
  },
@@ -487,7 +493,8 @@ export const workspaceResponse = [
487
493
  type: 'json',
488
494
  encryptionKeyUrl: 'workspace_6_encryption_key_url',
489
495
  value: {
490
- value: 'workspace_6_encrypted_value',
496
+ value:
497
+ 'workspace_6_encrypted_value',
491
498
  type: 'markdown',
492
499
  },
493
500
  },
@@ -519,7 +526,8 @@ export const workspaceResponse = [
519
526
  type: 'json',
520
527
  encryptionKeyUrl: 'workspace_7_encryption_key_url',
521
528
  value: {
522
- value: 'workspace_7_encrypted_value',
529
+ value:
530
+ 'workspace_7_encrypted_value',
523
531
  type: 'markdown',
524
532
  },
525
533
  },
@@ -551,7 +559,8 @@ export const workspaceResponse = [
551
559
  type: 'json',
552
560
  encryptionKeyUrl: 'workspace_8_encryption_key_url',
553
561
  value: {
554
- value: 'workspace_8_encrypted_value',
562
+ value:
563
+ 'workspace_8_encrypted_value',
555
564
  type: 'markdown',
556
565
  },
557
566
  },
@@ -583,7 +592,8 @@ export const workspaceResponse = [
583
592
  type: 'json',
584
593
  encryptionKeyUrl: 'workspace_9_encryption_key_url',
585
594
  value: {
586
- value: 'workspace_9_encrypted_value',
595
+ value:
596
+ 'workspace_9_encrypted_value',
587
597
  type: 'markdown',
588
598
  },
589
599
  },
@@ -707,115 +717,4 @@ export const scheduleMeetingResponse = [
707
717
  creator: {role: 'assistant'},
708
718
  },
709
719
  },
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
- ];
720
+ ];