@webex/internal-plugin-ai-assistant 0.0.0-next.9 → 3.11.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/README.md +44 -1
- package/dist/ai-assistant.js +113 -130
- package/dist/ai-assistant.js.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/constants.js +13 -3
- package/dist/constants.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.js +155 -0
- package/dist/utils.js.map +1 -0
- package/package.json +8 -8
- package/src/ai-assistant.ts +89 -86
- package/src/config.ts +1 -1
- package/src/constants.ts +9 -0
- package/src/types.ts +10 -1
- package/src/utils.ts +70 -0
- package/test/unit/data/messages.ts +720 -0
- package/test/unit/spec/ai-assistant.ts +933 -120
package/dist/constants.js
CHANGED
|
@@ -4,7 +4,7 @@ var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/defi
|
|
|
4
4
|
_Object$defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.CONTEXT_RESOURCE_TYPES = exports.CONTENT_TYPES = exports.ASSISTANT_API_RESPONSE_EVENT = exports.AI_ASSISTANT_UNREGISTERED = exports.AI_ASSISTANT_STREAM = exports.AI_ASSISTANT_SERVICE_NAME = exports.AI_ASSISTANT_RESULT = exports.AI_ASSISTANT_REGISTERED = exports.AI_ASSISTANT_ERROR_CODES = exports.AI_ASSISTANT_ERRORS = exports.ACTION_TYPES = void 0;
|
|
7
|
+
exports.RESPONSE_NAMES = exports.CONTEXT_RESOURCE_TYPES = exports.CONTENT_TYPES = exports.ASSISTANT_API_RESPONSE_EVENT = exports.AI_ASSISTANT_UNREGISTERED = exports.AI_ASSISTANT_STREAM = exports.AI_ASSISTANT_SERVICE_NAME = exports.AI_ASSISTANT_RESULT = exports.AI_ASSISTANT_REGISTERED = exports.AI_ASSISTANT_ERROR_CODES = exports.AI_ASSISTANT_ERRORS = exports.ACTION_TYPES = void 0;
|
|
8
8
|
var AI_ASSISTANT_REGISTERED = exports.AI_ASSISTANT_REGISTERED = 'aiassistant:registered';
|
|
9
9
|
var AI_ASSISTANT_UNREGISTERED = exports.AI_ASSISTANT_UNREGISTERED = 'aiassistant:unregistered';
|
|
10
10
|
var ASSISTANT_API_RESPONSE_EVENT = exports.ASSISTANT_API_RESPONSE_EVENT = 'event:assistant-api.response';
|
|
@@ -14,11 +14,12 @@ var AI_ASSISTANT_STREAM = exports.AI_ASSISTANT_STREAM = 'aiassistant:stream';
|
|
|
14
14
|
var AI_ASSISTANT_ERRORS = exports.AI_ASSISTANT_ERRORS = /*#__PURE__*/function (AI_ASSISTANT_ERRORS) {
|
|
15
15
|
AI_ASSISTANT_ERRORS["NOT_ENOUGH_CONTENT"] = "NO_ENOUGH_MEETING_TRANSCRIPT";
|
|
16
16
|
AI_ASSISTANT_ERRORS["TRANSCRIPT_AUTH_ERROR"] = "TRANSCRIPT_AUTH_ERROR";
|
|
17
|
-
AI_ASSISTANT_ERRORS["AI_ASSISTANT_TIMEOUT"] = "AI_ASSISTANT_TIMEOUT";
|
|
17
|
+
AI_ASSISTANT_ERRORS["AI_ASSISTANT_TIMEOUT"] = "AI_ASSISTANT_TIMEOUT"; // This one is generated by the plugin
|
|
18
18
|
return AI_ASSISTANT_ERRORS;
|
|
19
|
-
}({});
|
|
19
|
+
}({});
|
|
20
20
|
var AI_ASSISTANT_ERROR_CODES = exports.AI_ASSISTANT_ERROR_CODES = /*#__PURE__*/function (AI_ASSISTANT_ERROR_CODES) {
|
|
21
21
|
AI_ASSISTANT_ERROR_CODES[AI_ASSISTANT_ERROR_CODES["AI_ASSISTANT_TIMEOUT"] = 9408] = "AI_ASSISTANT_TIMEOUT";
|
|
22
|
+
// This one is generated by the plugin
|
|
22
23
|
AI_ASSISTANT_ERROR_CODES[AI_ASSISTANT_ERROR_CODES["NOT_ENOUGH_CONTENT"] = 204] = "NOT_ENOUGH_CONTENT";
|
|
23
24
|
AI_ASSISTANT_ERROR_CODES[AI_ASSISTANT_ERROR_CODES["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
24
25
|
AI_ASSISTANT_ERROR_CODES[AI_ASSISTANT_ERROR_CODES["LLM_TIMEOUT"] = 408] = "LLM_TIMEOUT";
|
|
@@ -43,4 +44,13 @@ var CONTEXT_RESOURCE_TYPES = exports.CONTEXT_RESOURCE_TYPES = /*#__PURE__*/funct
|
|
|
43
44
|
CONTEXT_RESOURCE_TYPES["MEETING"] = "meeting";
|
|
44
45
|
return CONTEXT_RESOURCE_TYPES;
|
|
45
46
|
}({});
|
|
47
|
+
var RESPONSE_NAMES = exports.RESPONSE_NAMES = /*#__PURE__*/function (RESPONSE_NAMES) {
|
|
48
|
+
RESPONSE_NAMES["TOOL_USE"] = "tool_use";
|
|
49
|
+
RESPONSE_NAMES["CITED_ANSWER"] = "cited_answer";
|
|
50
|
+
RESPONSE_NAMES["MESSAGE"] = "message";
|
|
51
|
+
RESPONSE_NAMES["TOOL_RESULT"] = "tool_result";
|
|
52
|
+
RESPONSE_NAMES["WORKSPACE"] = "workspace";
|
|
53
|
+
RESPONSE_NAMES["SCHEDULE_MEETING"] = "schedule_meeting";
|
|
54
|
+
return RESPONSE_NAMES;
|
|
55
|
+
}({});
|
|
46
56
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AI_ASSISTANT_REGISTERED","exports","AI_ASSISTANT_UNREGISTERED","ASSISTANT_API_RESPONSE_EVENT","AI_ASSISTANT_SERVICE_NAME","AI_ASSISTANT_RESULT","AI_ASSISTANT_STREAM","AI_ASSISTANT_ERRORS","AI_ASSISTANT_ERROR_CODES","ACTION_TYPES","CONTENT_TYPES","CONTEXT_RESOURCE_TYPES"],"sources":["constants.ts"],"sourcesContent":["export const AI_ASSISTANT_REGISTERED = 'aiassistant:registered';\nexport const AI_ASSISTANT_UNREGISTERED = 'aiassistant:unregistered';\nexport const ASSISTANT_API_RESPONSE_EVENT = 'event:assistant-api.response';\nexport const AI_ASSISTANT_SERVICE_NAME = 'assistant-api';\nexport const AI_ASSISTANT_RESULT = 'aiassistant:result';\nexport const AI_ASSISTANT_STREAM = 'aiassistant:stream';\n\nexport enum AI_ASSISTANT_ERRORS {\n NOT_ENOUGH_CONTENT = 'NO_ENOUGH_MEETING_TRANSCRIPT',\n TRANSCRIPT_AUTH_ERROR = 'TRANSCRIPT_AUTH_ERROR',\n AI_ASSISTANT_TIMEOUT = 'AI_ASSISTANT_TIMEOUT', // This one is generated by the plugin\n}\n\nexport enum AI_ASSISTANT_ERROR_CODES {\n AI_ASSISTANT_TIMEOUT = 9408, // This one is generated by the plugin\n NOT_ENOUGH_CONTENT = 204,\n FORBIDDEN = 403,\n LLM_TIMEOUT = 408,\n RATE_LIMIT = 429,\n GENERIC_ERROR = 10000,\n WAIT_PREVIOUS = 10001,\n EMPTY_SEARCH_RESULT = 10002,\n}\n\nexport enum ACTION_TYPES {\n SHOW_ALL_ACTION_ITEMS = 'SHOW_ALL_ACTION_ITEMS',\n WAS_MY_NAME_MENTIONED = 'WAS_MY_NAME_MENTIONED',\n SUMMARIZE_FOR_ME = 'SUMMARIZE_FOR_ME',\n}\n\nexport enum CONTENT_TYPES {\n ACTION = 'action',\n MESSAGE = 'message',\n}\n\nexport enum CONTEXT_RESOURCE_TYPES {\n MEETING = 'meeting',\n}\n"],"mappings":";;;;;;;AAAO,IAAMA,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,wBAAwB;AACxD,IAAME,yBAAyB,GAAAD,OAAA,CAAAC,yBAAA,GAAG,0BAA0B;AAC5D,IAAMC,4BAA4B,GAAAF,OAAA,CAAAE,4BAAA,GAAG,8BAA8B;AACnE,IAAMC,yBAAyB,GAAAH,OAAA,CAAAG,yBAAA,GAAG,eAAe;AACjD,IAAMC,mBAAmB,GAAAJ,OAAA,CAAAI,mBAAA,GAAG,oBAAoB;AAChD,IAAMC,mBAAmB,GAAAL,OAAA,CAAAK,mBAAA,GAAG,oBAAoB;AAAC,IAE5CC,mBAAmB,GAAAN,OAAA,CAAAM,mBAAA,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,
|
|
1
|
+
{"version":3,"names":["AI_ASSISTANT_REGISTERED","exports","AI_ASSISTANT_UNREGISTERED","ASSISTANT_API_RESPONSE_EVENT","AI_ASSISTANT_SERVICE_NAME","AI_ASSISTANT_RESULT","AI_ASSISTANT_STREAM","AI_ASSISTANT_ERRORS","AI_ASSISTANT_ERROR_CODES","ACTION_TYPES","CONTENT_TYPES","CONTEXT_RESOURCE_TYPES","RESPONSE_NAMES"],"sources":["constants.ts"],"sourcesContent":["export const AI_ASSISTANT_REGISTERED = 'aiassistant:registered';\nexport const AI_ASSISTANT_UNREGISTERED = 'aiassistant:unregistered';\nexport const ASSISTANT_API_RESPONSE_EVENT = 'event:assistant-api.response';\nexport const AI_ASSISTANT_SERVICE_NAME = 'assistant-api';\nexport const AI_ASSISTANT_RESULT = 'aiassistant:result';\nexport const AI_ASSISTANT_STREAM = 'aiassistant:stream';\n\nexport enum AI_ASSISTANT_ERRORS {\n NOT_ENOUGH_CONTENT = 'NO_ENOUGH_MEETING_TRANSCRIPT',\n TRANSCRIPT_AUTH_ERROR = 'TRANSCRIPT_AUTH_ERROR',\n AI_ASSISTANT_TIMEOUT = 'AI_ASSISTANT_TIMEOUT', // This one is generated by the plugin\n}\n\nexport enum AI_ASSISTANT_ERROR_CODES {\n AI_ASSISTANT_TIMEOUT = 9408, // This one is generated by the plugin\n NOT_ENOUGH_CONTENT = 204,\n FORBIDDEN = 403,\n LLM_TIMEOUT = 408,\n RATE_LIMIT = 429,\n GENERIC_ERROR = 10000,\n WAIT_PREVIOUS = 10001,\n EMPTY_SEARCH_RESULT = 10002,\n}\n\nexport enum ACTION_TYPES {\n SHOW_ALL_ACTION_ITEMS = 'SHOW_ALL_ACTION_ITEMS',\n WAS_MY_NAME_MENTIONED = 'WAS_MY_NAME_MENTIONED',\n SUMMARIZE_FOR_ME = 'SUMMARIZE_FOR_ME',\n}\n\nexport enum CONTENT_TYPES {\n ACTION = 'action',\n MESSAGE = 'message',\n}\n\nexport enum CONTEXT_RESOURCE_TYPES {\n MEETING = 'meeting',\n}\n\nexport enum RESPONSE_NAMES {\n TOOL_USE = 'tool_use',\n CITED_ANSWER = 'cited_answer',\n MESSAGE = 'message',\n TOOL_RESULT = 'tool_result',\n WORKSPACE = 'workspace',\n SCHEDULE_MEETING = 'schedule_meeting',\n}\n"],"mappings":";;;;;;;AAAO,IAAMA,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG,wBAAwB;AACxD,IAAME,yBAAyB,GAAAD,OAAA,CAAAC,yBAAA,GAAG,0BAA0B;AAC5D,IAAMC,4BAA4B,GAAAF,OAAA,CAAAE,4BAAA,GAAG,8BAA8B;AACnE,IAAMC,yBAAyB,GAAAH,OAAA,CAAAG,yBAAA,GAAG,eAAe;AACjD,IAAMC,mBAAmB,GAAAJ,OAAA,CAAAI,mBAAA,GAAG,oBAAoB;AAChD,IAAMC,mBAAmB,GAAAL,OAAA,CAAAK,mBAAA,GAAG,oBAAoB;AAAC,IAE5CC,mBAAmB,GAAAN,OAAA,CAAAM,mBAAA,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAnBA,mBAAmB,mDAGkB;EAAA,OAHrCA,mBAAmB;AAAA;AAAA,IAMnBC,wBAAwB,GAAAP,OAAA,CAAAO,wBAAA,0BAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EACL;EADnBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAxBA,wBAAwB,CAAxBA,wBAAwB;EAAA,OAAxBA,wBAAwB;AAAA;AAAA,IAWxBC,YAAY,GAAAR,OAAA,CAAAQ,YAAA,0BAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA;AAAA,IAMZC,aAAa,GAAAT,OAAA,CAAAS,aAAA,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA;AAAA,IAKbC,sBAAsB,GAAAV,OAAA,CAAAU,sBAAA,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAAA,IAItBC,cAAc,GAAAX,OAAA,CAAAW,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA","ignoreList":[]}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_webexCore","require","_aiAssistant","_interopRequireDefault","_config","registerInternalPlugin","AIAssistant","config"],"sources":["index.ts"],"sourcesContent":["import {registerInternalPlugin} from '@webex/webex-core';\n\nimport AIAssistant from './ai-assistant';\nimport config from './config';\n\nregisterInternalPlugin('aiassistant', AIAssistant, {config});\n\nexport {default} from './ai-assistant';\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,iCAAsB,EAAC,aAAa,EAAEC,oBAAW,EAAE;EAACC,MAAM,EAANA;AAAM,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"names":["_webexCore","require","_aiAssistant","_interopRequireDefault","_config","registerInternalPlugin","AIAssistant","config"],"sources":["index.ts"],"sourcesContent":["import {registerInternalPlugin} from '@webex/webex-core';\n\nimport AIAssistant from './ai-assistant';\nimport config from './config';\n\nregisterInternalPlugin('aiassistant', AIAssistant, {config});\n\nexport {default} from './ai-assistant';\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,iCAAsB,EAAC,aAAa,EAAEC,oBAAW,EAAE;EAACC,MAAM,EAANA;AAAM,CAAC,CAAC","ignoreList":[]}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export interface RequestResponse {\n sessionId: string;\n requestId: string;\n streamEventName: string;\n}\n\nexport interface StreamEvent {\n message: string;\n requestId: string;\n finished: boolean;\n error: string | null;\n}\n\nexport interface RequestOptions {\n resource: string;\n dataPath: string;\n foundPath?: string;\n notFoundPath?: string;\n params?: Record<string, unknown>;\n}\n\nexport interface ContextResource {\n id: string;\n type: string;\n url: string;\n}\n\nexport interface SummarizeMeetingOptions {\n assistant?: string;\n meetingInstanceId: string;\n meetingSite: string;\n sessionId: string;\n encryptionKeyUrl: string;\n lastMinutes?: number;\n}\n\nexport interface
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export interface RequestResponse {\n sessionId: string;\n requestId: string;\n streamEventName: string;\n id: string;\n url: string;\n sessionUrl: string;\n creatorId: string;\n createdAt: string;\n}\n\nexport interface StreamEvent {\n message: string;\n requestId: string;\n finished: boolean;\n error: string | null;\n}\n\nexport interface RequestOptions {\n resource: string;\n dataPath: string;\n foundPath?: string;\n notFoundPath?: string;\n params?: Record<string, unknown>;\n requestId?: string;\n}\n\nexport interface ContextResource {\n id: string;\n type: string;\n url: string;\n}\n\nexport interface SummarizeMeetingOptions {\n assistant?: string;\n meetingInstanceId: string;\n meetingSite: string;\n sessionId: string;\n encryptionKeyUrl: string;\n lastMinutes?: number;\n requestId?: string;\n}\n\nexport interface AiAssistantRequestOptions {\n sessionId: string;\n encryptionKeyUrl: string;\n contextResources: ContextResource[];\n contentType: 'action' | 'message';\n contentValue: string;\n parameters?: any;\n assistant?: string;\n locale?: string;\n requestId?: string;\n entryPoint?: string;\n}\n"],"mappings":"","ignoreList":[]}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.decryptWorkspace = exports.decryptToolUse = exports.decryptScheduleMeeting = exports.decryptMessage = exports.decryptCitedAnswer = void 0;
|
|
9
|
+
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
11
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
12
|
+
var _lodash = require("lodash");
|
|
13
|
+
var decryptInPlace = /*#__PURE__*/function () {
|
|
14
|
+
var _ref = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee(item, valuePath, keyPath, webex) {
|
|
15
|
+
var encryptedValue, encryptionKeyUrl, decryptedValue;
|
|
16
|
+
return _regenerator.default.wrap(function (_context) {
|
|
17
|
+
while (1) switch (_context.prev = _context.next) {
|
|
18
|
+
case 0:
|
|
19
|
+
encryptedValue = (0, _lodash.get)(item, valuePath);
|
|
20
|
+
encryptionKeyUrl = (0, _lodash.get)(item, keyPath);
|
|
21
|
+
if (!(!encryptedValue || !encryptionKeyUrl)) {
|
|
22
|
+
_context.next = 1;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
return _context.abrupt("return");
|
|
26
|
+
case 1:
|
|
27
|
+
_context.next = 2;
|
|
28
|
+
return webex.internal.encryption.decryptText(encryptionKeyUrl, encryptedValue);
|
|
29
|
+
case 2:
|
|
30
|
+
decryptedValue = _context.sent;
|
|
31
|
+
(0, _lodash.set)(item, valuePath, decryptedValue);
|
|
32
|
+
case 3:
|
|
33
|
+
case "end":
|
|
34
|
+
return _context.stop();
|
|
35
|
+
}
|
|
36
|
+
}, _callee);
|
|
37
|
+
}));
|
|
38
|
+
return function decryptInPlace(_x, _x2, _x3, _x4) {
|
|
39
|
+
return _ref.apply(this, arguments);
|
|
40
|
+
};
|
|
41
|
+
}();
|
|
42
|
+
var decryptToolUse = exports.decryptToolUse = /*#__PURE__*/function () {
|
|
43
|
+
var _ref2 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2(data, webex) {
|
|
44
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
45
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
46
|
+
case 0:
|
|
47
|
+
_context2.next = 1;
|
|
48
|
+
return decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);
|
|
49
|
+
case 1:
|
|
50
|
+
case "end":
|
|
51
|
+
return _context2.stop();
|
|
52
|
+
}
|
|
53
|
+
}, _callee2);
|
|
54
|
+
}));
|
|
55
|
+
return function decryptToolUse(_x5, _x6) {
|
|
56
|
+
return _ref2.apply(this, arguments);
|
|
57
|
+
};
|
|
58
|
+
}();
|
|
59
|
+
var decryptCitedAnswer = exports.decryptCitedAnswer = /*#__PURE__*/function () {
|
|
60
|
+
var _ref3 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3(data, webex) {
|
|
61
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
62
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
63
|
+
case 0:
|
|
64
|
+
if (!data.value.citations) {
|
|
65
|
+
_context3.next = 1;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
_context3.next = 1;
|
|
69
|
+
return _promise.default.all(data.value.citations.map(function (citation, index) {
|
|
70
|
+
return decryptInPlace(data, "value.citations.".concat(index, ".name"), 'encryptionKeyUrl', webex);
|
|
71
|
+
}));
|
|
72
|
+
case 1:
|
|
73
|
+
_context3.next = 2;
|
|
74
|
+
return decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);
|
|
75
|
+
case 2:
|
|
76
|
+
case "end":
|
|
77
|
+
return _context3.stop();
|
|
78
|
+
}
|
|
79
|
+
}, _callee3);
|
|
80
|
+
}));
|
|
81
|
+
return function decryptCitedAnswer(_x7, _x8) {
|
|
82
|
+
return _ref3.apply(this, arguments);
|
|
83
|
+
};
|
|
84
|
+
}();
|
|
85
|
+
var decryptScheduleMeeting = exports.decryptScheduleMeeting = /*#__PURE__*/function () {
|
|
86
|
+
var _ref4 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4(data, webex) {
|
|
87
|
+
var _data$value, _data$value$results;
|
|
88
|
+
var meetingData;
|
|
89
|
+
return _regenerator.default.wrap(function (_context4) {
|
|
90
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
_context4.next = 1;
|
|
93
|
+
return decryptInPlace(data, 'parameters.commentary', 'encryptionKeyUrl', webex);
|
|
94
|
+
case 1:
|
|
95
|
+
meetingData = (_data$value = data.value) === null || _data$value === void 0 ? void 0 : (_data$value$results = _data$value.results) === null || _data$value$results === void 0 ? void 0 : _data$value$results.data;
|
|
96
|
+
if (!meetingData) {
|
|
97
|
+
_context4.next = 3;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (!meetingData.attendees) {
|
|
101
|
+
_context4.next = 2;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
_context4.next = 2;
|
|
105
|
+
return _promise.default.all(meetingData.attendees.map(function (attendee, index) {
|
|
106
|
+
return decryptInPlace(data, "value.results.data.attendees.".concat(index, ".email"), 'encryptionKeyUrl', webex);
|
|
107
|
+
}));
|
|
108
|
+
case 2:
|
|
109
|
+
_context4.next = 3;
|
|
110
|
+
return _promise.default.all([decryptInPlace(data, 'value.results.data.title', 'encryptionKeyUrl', webex), decryptInPlace(data, 'value.results.data.inScopeReply', 'encryptionKeyUrl', webex), decryptInPlace(data, 'value.results.data.meetingLink', 'encryptionKeyUrl', webex), decryptInPlace(data, 'value.results.data.description', 'encryptionKeyUrl', webex)]);
|
|
111
|
+
case 3:
|
|
112
|
+
case "end":
|
|
113
|
+
return _context4.stop();
|
|
114
|
+
}
|
|
115
|
+
}, _callee4);
|
|
116
|
+
}));
|
|
117
|
+
return function decryptScheduleMeeting(_x9, _x0) {
|
|
118
|
+
return _ref4.apply(this, arguments);
|
|
119
|
+
};
|
|
120
|
+
}();
|
|
121
|
+
var decryptMessage = exports.decryptMessage = /*#__PURE__*/function () {
|
|
122
|
+
var _ref5 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(data, webex) {
|
|
123
|
+
return _regenerator.default.wrap(function (_context5) {
|
|
124
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
125
|
+
case 0:
|
|
126
|
+
_context5.next = 1;
|
|
127
|
+
return decryptInPlace(data, 'value', 'encryptionKeyUrl', webex);
|
|
128
|
+
case 1:
|
|
129
|
+
case "end":
|
|
130
|
+
return _context5.stop();
|
|
131
|
+
}
|
|
132
|
+
}, _callee5);
|
|
133
|
+
}));
|
|
134
|
+
return function decryptMessage(_x1, _x10) {
|
|
135
|
+
return _ref5.apply(this, arguments);
|
|
136
|
+
};
|
|
137
|
+
}();
|
|
138
|
+
var decryptWorkspace = exports.decryptWorkspace = /*#__PURE__*/function () {
|
|
139
|
+
var _ref6 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6(data, webex) {
|
|
140
|
+
return _regenerator.default.wrap(function (_context6) {
|
|
141
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
142
|
+
case 0:
|
|
143
|
+
_context6.next = 1;
|
|
144
|
+
return decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);
|
|
145
|
+
case 1:
|
|
146
|
+
case "end":
|
|
147
|
+
return _context6.stop();
|
|
148
|
+
}
|
|
149
|
+
}, _callee6);
|
|
150
|
+
}));
|
|
151
|
+
return function decryptWorkspace(_x11, _x12) {
|
|
152
|
+
return _ref6.apply(this, arguments);
|
|
153
|
+
};
|
|
154
|
+
}();
|
|
155
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_lodash","require","decryptInPlace","_ref","_asyncToGenerator2","default","_regenerator","mark","_callee","item","valuePath","keyPath","webex","encryptedValue","encryptionKeyUrl","decryptedValue","wrap","_context","prev","next","get","abrupt","internal","encryption","decryptText","sent","set","stop","_x","_x2","_x3","_x4","apply","arguments","decryptToolUse","exports","_ref2","_callee2","data","_context2","_x5","_x6","decryptCitedAnswer","_ref3","_callee3","_context3","value","citations","_promise","all","map","citation","index","concat","_x7","_x8","decryptScheduleMeeting","_ref4","_callee4","_data$value","_data$value$results","meetingData","_context4","results","attendees","attendee","_x9","_x0","decryptMessage","_ref5","_callee5","_context5","_x1","_x10","decryptWorkspace","_ref6","_callee6","_context6","_x11","_x12"],"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 if (!encryptedValue || !encryptionKeyUrl) {\n return;\n }\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};\nexport const decryptScheduleMeeting = async (data, webex) => {\n // Decrypt commentary in parameters\n await decryptInPlace(data, 'parameters.commentary', 'encryptionKeyUrl', webex);\n\n const meetingData = data.value?.results?.data;\n if (meetingData) {\n // Decrypt attendee emails\n if (meetingData.attendees) {\n await Promise.all(\n meetingData.attendees.map((attendee, index) => {\n return decryptInPlace(\n data,\n `value.results.data.attendees.${index}.email`,\n 'encryptionKeyUrl',\n webex\n );\n })\n );\n }\n\n // Decrypt other fields in the meeting data\n await Promise.all([\n decryptInPlace(data, 'value.results.data.title', 'encryptionKeyUrl', webex),\n decryptInPlace(data, 'value.results.data.inScopeReply', 'encryptionKeyUrl', webex),\n decryptInPlace(data, 'value.results.data.meetingLink', 'encryptionKeyUrl', webex),\n decryptInPlace(data, 'value.results.data.description', 'encryptionKeyUrl', webex),\n ]);\n }\n};\n\nexport const decryptMessage = async (data, webex) => {\n await decryptInPlace(data, 'value', 'encryptionKeyUrl', webex);\n};\n\nexport const decryptWorkspace = async (data, webex) => {\n await decryptInPlace(data, 'value.value', 'encryptionKeyUrl', webex);\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAMC,cAAc;EAAA,IAAAC,IAAA,OAAAC,kBAAA,CAAAC,OAAA,eAAAC,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,WAAAC,QAAA;MAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;QAAA;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AAA1D,IAAA;UAAA,OAC1CjB,cAAc,CAACoC,IAAI,EAAE,aAAa,EAAE,kBAAkB,EAAE1B,KAAK,CAAC;QAAA;QAAA;UAAA,OAAAiE,SAAA,CAAAlD,IAAA;MAAA;IAAA,GAAAiD,QAAA;EAAA,CACrE;EAAA,gBAFYF,gBAAgBA,CAAAI,IAAA,EAAAC,IAAA;IAAA,OAAAJ,KAAA,CAAA3C,KAAA,OAAAC,SAAA;EAAA;AAAA,GAE5B","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
]
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@webex/common": "3.
|
|
24
|
-
"@webex/common-timers": "3.
|
|
25
|
-
"@webex/internal-plugin-mercury": "3.
|
|
26
|
-
"@webex/webex-core": "3.
|
|
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",
|
|
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.
|
|
37
|
-
"@webex/test-helper-mock-webex": "3.
|
|
38
|
-
"@webex/test-helper-test-users": "3.
|
|
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",
|
|
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": "
|
|
52
|
+
"version": "3.11.0"
|
|
53
53
|
}
|
package/src/ai-assistant.ts
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
import uuid from 'uuid';
|
|
5
5
|
import {WebexPlugin} from '@webex/webex-core';
|
|
6
6
|
import '@webex/internal-plugin-mercury';
|
|
7
|
-
import {get} from 'lodash';
|
|
7
|
+
import {get, merge} from 'lodash';
|
|
8
8
|
import {Timer} from '@webex/common-timers';
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
|
|
11
|
+
AiAssistantRequestOptions,
|
|
12
12
|
RequestOptions,
|
|
13
13
|
RequestResponse,
|
|
14
14
|
SummarizeMeetingOptions,
|
|
@@ -25,7 +25,15 @@ import {
|
|
|
25
25
|
ACTION_TYPES,
|
|
26
26
|
CONTENT_TYPES,
|
|
27
27
|
CONTEXT_RESOURCE_TYPES,
|
|
28
|
+
RESPONSE_NAMES,
|
|
28
29
|
} from './constants';
|
|
30
|
+
import {
|
|
31
|
+
decryptCitedAnswer,
|
|
32
|
+
decryptMessage,
|
|
33
|
+
decryptScheduleMeeting,
|
|
34
|
+
decryptToolUse,
|
|
35
|
+
decryptWorkspace,
|
|
36
|
+
} from './utils';
|
|
29
37
|
|
|
30
38
|
const AIAssistant = WebexPlugin.extend({
|
|
31
39
|
namespace: 'AIAssistant',
|
|
@@ -153,16 +161,41 @@ const AIAssistant = WebexPlugin.extend({
|
|
|
153
161
|
},
|
|
154
162
|
|
|
155
163
|
/**
|
|
156
|
-
* Decrypts the
|
|
157
|
-
* @param {
|
|
158
|
-
* @
|
|
159
|
-
* @param {string} options.encryptionKeyUrl the encryption key URL to use for
|
|
160
|
-
* @returns {Promise<Object>} returns a promise that resolves with the decrypted value
|
|
164
|
+
* Decrypts the response content in place
|
|
165
|
+
* @param {any} responseContent the content object from the assistant-api response
|
|
166
|
+
* @returns {Promise} resolves once decryption is complete
|
|
161
167
|
*/
|
|
162
|
-
async
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
async _decryptContent(responseContent) {
|
|
169
|
+
switch (responseContent.name) {
|
|
170
|
+
case RESPONSE_NAMES.MESSAGE: {
|
|
171
|
+
await decryptMessage(responseContent, this.webex);
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
case RESPONSE_NAMES.CITED_ANSWER: {
|
|
175
|
+
await decryptCitedAnswer(responseContent, this.webex);
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
case RESPONSE_NAMES.SCHEDULE_MEETING: {
|
|
179
|
+
await decryptScheduleMeeting(responseContent, this.webex);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case RESPONSE_NAMES.TOOL_RESULT: {
|
|
183
|
+
// No encrypted content in tool_result
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
case RESPONSE_NAMES.TOOL_USE: {
|
|
187
|
+
await decryptToolUse(responseContent, this.webex);
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
case RESPONSE_NAMES.WORKSPACE: {
|
|
191
|
+
await decryptWorkspace(responseContent, this.webex);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
default:
|
|
195
|
+
this.logger.error(
|
|
196
|
+
`AI assistant->_decryptContent#ERROR, Unknown response content name: ${responseContent.name}`
|
|
197
|
+
);
|
|
198
|
+
}
|
|
166
199
|
},
|
|
167
200
|
|
|
168
201
|
/**
|
|
@@ -170,17 +203,15 @@ const AIAssistant = WebexPlugin.extend({
|
|
|
170
203
|
* @param {Object} options
|
|
171
204
|
* @param {string} options.resource the URL to query
|
|
172
205
|
* @param {Mixed} options.params additional params for the body of the request
|
|
173
|
-
* @param {string} options.dataPath the path to get the data in the result object
|
|
174
206
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
175
207
|
*/
|
|
176
208
|
_request(options: RequestOptions): Promise<RequestResponse> {
|
|
177
|
-
const {resource, params
|
|
209
|
+
const {resource, params} = options;
|
|
178
210
|
|
|
179
211
|
const timeout = this.config.requestTimeout;
|
|
180
|
-
const requestId = uuid.v4();
|
|
212
|
+
const requestId = options.requestId || uuid.v4();
|
|
181
213
|
const eventName = this._getResultEventName(requestId);
|
|
182
214
|
const streamEventName = this._getStreamEventName(requestId);
|
|
183
|
-
let concatenatedMessage = '';
|
|
184
215
|
|
|
185
216
|
// eslint-disable-next-line no-async-promise-executor
|
|
186
217
|
return new Promise((resolve, reject) => {
|
|
@@ -196,68 +227,36 @@ const AIAssistant = WebexPlugin.extend({
|
|
|
196
227
|
|
|
197
228
|
this.listenTo(this, eventName, async (data) => {
|
|
198
229
|
timer.reset();
|
|
199
|
-
const resultData = get(data,
|
|
230
|
+
const resultData = get(data, 'response.content', {});
|
|
200
231
|
const errorMessage = get(data, 'response.errorMessage');
|
|
201
232
|
const errorCode = get(data, 'response.errorCode');
|
|
233
|
+
const responseType = get(data, 'responseType');
|
|
202
234
|
|
|
203
235
|
if (data.finished) {
|
|
204
|
-
// For finished messages, decrypt and emit the final complete message
|
|
205
236
|
timer.cancel();
|
|
237
|
+
this.stopListening(this, eventName);
|
|
238
|
+
}
|
|
206
239
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
// Emit the final message
|
|
214
|
-
this.trigger(streamEventName, {
|
|
215
|
-
message: decryptedMessage || '',
|
|
216
|
-
requestId,
|
|
217
|
-
finished: true,
|
|
218
|
-
errorMessage,
|
|
219
|
-
errorCode,
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
this.stopListening(this, eventName);
|
|
223
|
-
} catch (decryptError) {
|
|
224
|
-
this.trigger(streamEventName, {
|
|
225
|
-
message: concatenatedMessage,
|
|
226
|
-
requestId,
|
|
227
|
-
finished: true,
|
|
228
|
-
errorMessage: errorMessage || decryptError.message,
|
|
229
|
-
errorCode,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
} else {
|
|
233
|
-
// For non-finished messages, concatenate and emit the accumulated message
|
|
234
|
-
try {
|
|
235
|
-
let decryptedMessage = '';
|
|
236
|
-
if (resultData?.value) {
|
|
237
|
-
decryptedMessage = await this._decryptData(resultData);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
concatenatedMessage += decryptedMessage;
|
|
241
|
-
|
|
242
|
-
// Emit the concatenated message so far
|
|
243
|
-
this.trigger(streamEventName, {
|
|
244
|
-
message: concatenatedMessage,
|
|
245
|
-
requestId,
|
|
246
|
-
finished: false,
|
|
247
|
-
errorMessage,
|
|
248
|
-
errorCode,
|
|
249
|
-
});
|
|
250
|
-
} catch (decryptError) {
|
|
251
|
-
// If decryption fails, we still want to continue listening for more messages
|
|
252
|
-
this.trigger(streamEventName, {
|
|
253
|
-
message: concatenatedMessage,
|
|
254
|
-
requestId,
|
|
255
|
-
finished: false,
|
|
256
|
-
errorMessage: errorMessage || decryptError.message,
|
|
257
|
-
errorCode,
|
|
258
|
-
});
|
|
240
|
+
let decryptErrorMessage;
|
|
241
|
+
|
|
242
|
+
try {
|
|
243
|
+
if (!errorCode) {
|
|
244
|
+
await this._decryptContent(resultData);
|
|
259
245
|
}
|
|
246
|
+
} catch (decryptError) {
|
|
247
|
+
decryptErrorMessage = decryptError.message;
|
|
260
248
|
}
|
|
249
|
+
|
|
250
|
+
this.trigger(
|
|
251
|
+
streamEventName,
|
|
252
|
+
merge({}, data.response, {
|
|
253
|
+
responseType,
|
|
254
|
+
requestId,
|
|
255
|
+
finished: data.finished,
|
|
256
|
+
errorMessage: errorMessage || decryptErrorMessage,
|
|
257
|
+
errorCode,
|
|
258
|
+
})
|
|
259
|
+
);
|
|
261
260
|
});
|
|
262
261
|
|
|
263
262
|
this.webex
|
|
@@ -268,19 +267,14 @@ const AIAssistant = WebexPlugin.extend({
|
|
|
268
267
|
contentType: 'application/json',
|
|
269
268
|
body: {clientRequestId: requestId, ...params},
|
|
270
269
|
})
|
|
270
|
+
.then(({body}) => {
|
|
271
|
+
resolve({...body, requestId, streamEventName});
|
|
272
|
+
})
|
|
271
273
|
.catch((error) => {
|
|
272
274
|
reject(error);
|
|
273
|
-
})
|
|
274
|
-
.then(({body}) => {
|
|
275
|
-
const {sessionId} = body;
|
|
276
|
-
|
|
277
|
-
resolve({
|
|
278
|
-
requestId,
|
|
279
|
-
sessionId,
|
|
280
|
-
streamEventName,
|
|
281
|
-
});
|
|
282
|
-
timer.start();
|
|
283
275
|
});
|
|
276
|
+
|
|
277
|
+
timer.start();
|
|
284
278
|
});
|
|
285
279
|
},
|
|
286
280
|
|
|
@@ -295,9 +289,13 @@ const AIAssistant = WebexPlugin.extend({
|
|
|
295
289
|
* @param {Object} options.parameters optional parameters to include in the request (for action type only)
|
|
296
290
|
* @param {Object} options.assistant optional parameter to specify the assistant to use
|
|
297
291
|
* @param {Object} options.locale optional locale to use for the request, defaults to 'en_US'
|
|
292
|
+
* @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
|
|
293
|
+
* @param {string} options.entryPoint optional entryPoint to use for this request
|
|
298
294
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
295
|
+
* @public
|
|
296
|
+
* @memberof AIAssistant
|
|
299
297
|
*/
|
|
300
|
-
async
|
|
298
|
+
async makeAiAssistantRequest(options: AiAssistantRequestOptions): Promise<RequestResponse> {
|
|
301
299
|
let value = options.contentValue;
|
|
302
300
|
|
|
303
301
|
if (options.contentType === 'message') {
|
|
@@ -316,19 +314,20 @@ const AIAssistant = WebexPlugin.extend({
|
|
|
316
314
|
value,
|
|
317
315
|
};
|
|
318
316
|
|
|
319
|
-
if (options.
|
|
317
|
+
if (options.parameters) {
|
|
320
318
|
content.parameters = options.parameters;
|
|
321
319
|
}
|
|
322
320
|
|
|
323
321
|
return this._request({
|
|
324
322
|
resource: options.sessionId ? `sessions/${options.sessionId}/messages` : 'sessions/messages',
|
|
325
|
-
dataPath: 'response.content',
|
|
326
323
|
params: {
|
|
327
324
|
async: 'chunked',
|
|
328
325
|
locale: options.locale || 'en_US',
|
|
329
326
|
content,
|
|
327
|
+
...(options.entryPoint ? {entryPoint: options.entryPoint} : {}),
|
|
330
328
|
...(options.assistant ? {assistant: options.assistant} : {}),
|
|
331
329
|
},
|
|
330
|
+
...(options.requestId ? {requestId: options.requestId} : {}),
|
|
332
331
|
});
|
|
333
332
|
},
|
|
334
333
|
|
|
@@ -340,10 +339,11 @@ const AIAssistant = WebexPlugin.extend({
|
|
|
340
339
|
* @param {string} options.sessionId the session ID for subsequent requests, not required for the first request
|
|
341
340
|
* @param {string} options.encryptionKeyUrl the encryption key URL for this meeting summary
|
|
342
341
|
* @param {number} options.lastMinutes Optional number of minutes to summarize from the end of the meeting. If not included, summarizes from the start.
|
|
342
|
+
* @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
|
|
343
343
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
344
344
|
*/
|
|
345
345
|
summarizeMeeting(options: SummarizeMeetingOptions): Promise<RequestResponse> {
|
|
346
|
-
return this.
|
|
346
|
+
return this.makeAiAssistantRequest({
|
|
347
347
|
...options,
|
|
348
348
|
contentType: CONTENT_TYPES.ACTION,
|
|
349
349
|
contentValue: ACTION_TYPES.SUMMARIZE_FOR_ME,
|
|
@@ -365,10 +365,11 @@ const AIAssistant = WebexPlugin.extend({
|
|
|
365
365
|
* @param {string} options.meetingSite the name.webex.com site for the meeting
|
|
366
366
|
* @param {string} options.sessionId the session ID for subsequent requests, not required for the first request
|
|
367
367
|
* @param {string} options.encryptionKeyUrl the encryption key URL for this meeting summary
|
|
368
|
+
* @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
|
|
368
369
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
369
370
|
*/
|
|
370
371
|
wasMyNameMentioned(options: SummarizeMeetingOptions): Promise<RequestResponse> {
|
|
371
|
-
return this.
|
|
372
|
+
return this.makeAiAssistantRequest({
|
|
372
373
|
...options,
|
|
373
374
|
contextResources: [
|
|
374
375
|
{
|
|
@@ -389,10 +390,11 @@ const AIAssistant = WebexPlugin.extend({
|
|
|
389
390
|
* @param {string} options.meetingSite the name.webex.com site for the meeting
|
|
390
391
|
* @param {string} options.sessionId the session ID for subsequent requests, not required for the first request
|
|
391
392
|
* @param {string} options.encryptionKeyUrl the encryption key URL for this meeting summary
|
|
393
|
+
* @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
|
|
392
394
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
393
395
|
*/
|
|
394
396
|
showAllActionItems(options: SummarizeMeetingOptions): Promise<RequestResponse> {
|
|
395
|
-
return this.
|
|
397
|
+
return this.makeAiAssistantRequest({
|
|
396
398
|
...options,
|
|
397
399
|
contextResources: [
|
|
398
400
|
{
|
|
@@ -427,10 +429,11 @@ const AIAssistant = WebexPlugin.extend({
|
|
|
427
429
|
* @param {string} options.sessionId the session ID for subsequent requests, not required for the first request
|
|
428
430
|
* @param {string} options.encryptionKeyUrl the encryption key URL for this meeting summary
|
|
429
431
|
* @param {string} options.question the question to ask about the meeting content
|
|
432
|
+
* @param {string} options.requestId optional request ID to use for this request, if not provided a new UUID will be generated
|
|
430
433
|
* @returns {Promise<Object>} Resolves with an object containing the requestId, sessionId and streamEventName
|
|
431
434
|
*/
|
|
432
435
|
askMeAnything(options: SummarizeMeetingOptions & {question: string}): Promise<RequestResponse> {
|
|
433
|
-
return this.
|
|
436
|
+
return this.makeAiAssistantRequest({
|
|
434
437
|
...options,
|
|
435
438
|
contextResources: [
|
|
436
439
|
{
|
package/src/config.ts
CHANGED
package/src/constants.ts
CHANGED
|
@@ -36,3 +36,12 @@ export enum CONTENT_TYPES {
|
|
|
36
36
|
export enum CONTEXT_RESOURCE_TYPES {
|
|
37
37
|
MEETING = 'meeting',
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
export enum RESPONSE_NAMES {
|
|
41
|
+
TOOL_USE = 'tool_use',
|
|
42
|
+
CITED_ANSWER = 'cited_answer',
|
|
43
|
+
MESSAGE = 'message',
|
|
44
|
+
TOOL_RESULT = 'tool_result',
|
|
45
|
+
WORKSPACE = 'workspace',
|
|
46
|
+
SCHEDULE_MEETING = 'schedule_meeting',
|
|
47
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -2,6 +2,11 @@ export interface RequestResponse {
|
|
|
2
2
|
sessionId: string;
|
|
3
3
|
requestId: string;
|
|
4
4
|
streamEventName: string;
|
|
5
|
+
id: string;
|
|
6
|
+
url: string;
|
|
7
|
+
sessionUrl: string;
|
|
8
|
+
creatorId: string;
|
|
9
|
+
createdAt: string;
|
|
5
10
|
}
|
|
6
11
|
|
|
7
12
|
export interface StreamEvent {
|
|
@@ -17,6 +22,7 @@ export interface RequestOptions {
|
|
|
17
22
|
foundPath?: string;
|
|
18
23
|
notFoundPath?: string;
|
|
19
24
|
params?: Record<string, unknown>;
|
|
25
|
+
requestId?: string;
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
export interface ContextResource {
|
|
@@ -32,9 +38,10 @@ export interface SummarizeMeetingOptions {
|
|
|
32
38
|
sessionId: string;
|
|
33
39
|
encryptionKeyUrl: string;
|
|
34
40
|
lastMinutes?: number;
|
|
41
|
+
requestId?: string;
|
|
35
42
|
}
|
|
36
43
|
|
|
37
|
-
export interface
|
|
44
|
+
export interface AiAssistantRequestOptions {
|
|
38
45
|
sessionId: string;
|
|
39
46
|
encryptionKeyUrl: string;
|
|
40
47
|
contextResources: ContextResource[];
|
|
@@ -43,4 +50,6 @@ export interface MakeMeetingRequestOptions {
|
|
|
43
50
|
parameters?: any;
|
|
44
51
|
assistant?: string;
|
|
45
52
|
locale?: string;
|
|
53
|
+
requestId?: string;
|
|
54
|
+
entryPoint?: string;
|
|
46
55
|
}
|