@copart/ops-tool-kit 1.12.1-alpha.34 → 1.12.1-alpha.35
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/dist/ops-tool-kit.js +67 -54
- package/dist/ops-tool-kit.js.map +1 -1
- package/package.json +1 -1
package/dist/ops-tool-kit.js
CHANGED
|
@@ -32,7 +32,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
32
32
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
33
33
|
|
|
34
34
|
const name$r = "@copart/ops-tool-kit";
|
|
35
|
-
const version$7 = "1.12.1-alpha.
|
|
35
|
+
const version$7 = "1.12.1-alpha.35";
|
|
36
36
|
const main$1 = "dist/ops-tool-kit.js";
|
|
37
37
|
const style = "dist/ops-tool-kit.css";
|
|
38
38
|
const files = [
|
|
@@ -35899,51 +35899,55 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
35899
35899
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
35900
35900
|
currentContext = _useState18[0],
|
|
35901
35901
|
setCurrentContext = _useState18[1];
|
|
35902
|
-
var _useState19 = React.useState(
|
|
35902
|
+
var _useState19 = React.useState(null),
|
|
35903
35903
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
35904
|
-
|
|
35905
|
-
|
|
35906
|
-
var _useState21 = React.useState({
|
|
35904
|
+
lastSentFromApp = _useState20[0],
|
|
35905
|
+
setLastSentFromApp = _useState20[1];
|
|
35906
|
+
var _useState21 = React.useState({}),
|
|
35907
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
35908
|
+
feedbacks = _useState22[0],
|
|
35909
|
+
setFeedbacks = _useState22[1];
|
|
35910
|
+
var _useState23 = React.useState({
|
|
35907
35911
|
x: 0,
|
|
35908
35912
|
y: 0
|
|
35909
35913
|
}),
|
|
35910
|
-
|
|
35911
|
-
position =
|
|
35912
|
-
setPosition =
|
|
35913
|
-
var
|
|
35914
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
35915
|
+
position = _useState24[0],
|
|
35916
|
+
setPosition = _useState24[1];
|
|
35917
|
+
var _useState25 = React.useState({
|
|
35914
35918
|
x: 50,
|
|
35915
35919
|
y: -68
|
|
35916
35920
|
}),
|
|
35917
|
-
_useState24 = _slicedToArray(_useState23, 2),
|
|
35918
|
-
chatPosition = _useState24[0],
|
|
35919
|
-
setChatPosition = _useState24[1];
|
|
35920
|
-
var _useState25 = React.useState(false),
|
|
35921
35921
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
35922
|
-
|
|
35923
|
-
|
|
35924
|
-
var _useState27 = React.useState(
|
|
35922
|
+
chatPosition = _useState26[0],
|
|
35923
|
+
setChatPosition = _useState26[1];
|
|
35924
|
+
var _useState27 = React.useState(false),
|
|
35925
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
35926
|
+
isDragging = _useState28[0],
|
|
35927
|
+
setIsDragging = _useState28[1];
|
|
35928
|
+
var _useState29 = React.useState({
|
|
35925
35929
|
x: 0,
|
|
35926
35930
|
y: 0
|
|
35927
35931
|
}),
|
|
35928
|
-
_useState28 = _slicedToArray(_useState27, 2),
|
|
35929
|
-
offset = _useState28[0],
|
|
35930
|
-
setOffset = _useState28[1];
|
|
35931
|
-
var _useState29 = React.useState(false),
|
|
35932
35932
|
_useState30 = _slicedToArray(_useState29, 2),
|
|
35933
|
-
|
|
35934
|
-
|
|
35935
|
-
var _useState31 = React.useState(
|
|
35933
|
+
offset = _useState30[0],
|
|
35934
|
+
setOffset = _useState30[1];
|
|
35935
|
+
var _useState31 = React.useState(false),
|
|
35936
35936
|
_useState32 = _slicedToArray(_useState31, 2),
|
|
35937
|
-
|
|
35938
|
-
|
|
35939
|
-
var _useState33 = React.useState(
|
|
35937
|
+
dragged = _useState32[0],
|
|
35938
|
+
setDragged = _useState32[1];
|
|
35939
|
+
var _useState33 = React.useState(500),
|
|
35940
35940
|
_useState34 = _slicedToArray(_useState33, 2),
|
|
35941
|
-
|
|
35942
|
-
|
|
35943
|
-
var _useState35 = React.useState(
|
|
35941
|
+
chatWindowWidth = _useState34[0],
|
|
35942
|
+
setChatWindowWidth = _useState34[1];
|
|
35943
|
+
var _useState35 = React.useState(0),
|
|
35944
35944
|
_useState36 = _slicedToArray(_useState35, 2),
|
|
35945
|
-
|
|
35946
|
-
|
|
35945
|
+
windowInnerWidthForMobile = _useState36[0],
|
|
35946
|
+
setWindowInnerWidthForMobile = _useState36[1];
|
|
35947
|
+
var _useState37 = React.useState(600),
|
|
35948
|
+
_useState38 = _slicedToArray(_useState37, 2),
|
|
35949
|
+
chatWindowHeight = _useState38[0],
|
|
35950
|
+
setchatWindowHeight = _useState38[1]; //update this if changed in css
|
|
35947
35951
|
|
|
35948
35952
|
var chatIconSize = 60; //update this if changed in css
|
|
35949
35953
|
|
|
@@ -36159,8 +36163,10 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
36159
36163
|
var conversationsToBeSaved = !isEmpty$2(conversationsFromSession) ? conversationsFromSession : [];
|
|
36160
36164
|
setConversations(conversationsToBeSaved);
|
|
36161
36165
|
var feedbacksFromSession = storage$1.getLocalItem('mihelpAgentFeedbacks');
|
|
36166
|
+
var lastSentApp = storage$1.getLocalItem('mihelpAgentLastSentApp');
|
|
36162
36167
|
var feedbacksToBeSaved = !isEmpty$2(feedbacksFromSession) ? feedbacksFromSession : {};
|
|
36163
36168
|
setFeedbacks(feedbacksToBeSaved);
|
|
36169
|
+
setLastSentFromApp(lastSentApp);
|
|
36164
36170
|
if (conversationsToBeSaved.length) {
|
|
36165
36171
|
saveCurrentContext(conversationsToBeSaved);
|
|
36166
36172
|
} else {
|
|
@@ -36194,6 +36200,9 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
36194
36200
|
var feedbacksToBeSaved = !isEmpty$2(feedbacksFromSession) ? feedbacksFromSession : {};
|
|
36195
36201
|
setFeedbacks(feedbacksToBeSaved);
|
|
36196
36202
|
}
|
|
36203
|
+
if (event.key === 'mihelpAgentLastSentApp') {
|
|
36204
|
+
setLastSentFromApp(event.newValue);
|
|
36205
|
+
}
|
|
36197
36206
|
};
|
|
36198
36207
|
window.addEventListener('storage', handleStorageChange);
|
|
36199
36208
|
return function () {
|
|
@@ -36222,7 +36231,7 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
36222
36231
|
};
|
|
36223
36232
|
var send = /*#__PURE__*/function () {
|
|
36224
36233
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(messages) {
|
|
36225
|
-
var _window$toolkitEnv, _window$toolkitEnv2, _window$toolkitEnv3, _storage$getLocalItem, _storage$getLocalItem2, _response$data, _response$data2, newMessages, isCoreApp, appTiles, appName, appData, appAuthName, messagesWithOutId, payload, endpoint, response, newConversations;
|
|
36234
|
+
var _window$toolkitEnv, _window$toolkitEnv2, _window$toolkitEnv3, _storage$getLocalItem, _storage$getLocalItem2, _response$data, _response$data2, newMessages, isCoreApp, appTiles, appName, appData, appAuthName, currentAppName, messagesWithOutId, payload, endpoint, response, newConversations;
|
|
36226
36235
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
36227
36236
|
while (1) switch (_context.prev = _context.next) {
|
|
36228
36237
|
case 0:
|
|
@@ -36230,6 +36239,18 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
36230
36239
|
setMessageError(false);
|
|
36231
36240
|
_context.prev = 2;
|
|
36232
36241
|
newMessages = _toConsumableArray(messages);
|
|
36242
|
+
isCoreApp = (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
|
|
36243
|
+
appTiles = storage$1.getLocalItem('opsportal-core:config').tiles || [];
|
|
36244
|
+
appName = (_window$toolkitEnv2 = window.toolkitEnv) !== null && _window$toolkitEnv2 !== void 0 && _window$toolkitEnv2.APP_NAME ? window.toolkitEnv.APP_NAME : process.env.APP_NAME;
|
|
36245
|
+
appData = appTiles.find(function (tile) {
|
|
36246
|
+
if (tile.appName) {
|
|
36247
|
+
return tile.appName === appName;
|
|
36248
|
+
} else {
|
|
36249
|
+
return tile.path === "/".concat(appName);
|
|
36250
|
+
}
|
|
36251
|
+
});
|
|
36252
|
+
appAuthName = appData ? appData.appAuthName : (_window$toolkitEnv3 = window.toolkitEnv) !== null && _window$toolkitEnv3 !== void 0 && _window$toolkitEnv3.APP_AUTH_NAME ? window.toolkitEnv.APP_AUTH_NAME : process.env.APP_AUTH_NAME;
|
|
36253
|
+
currentAppName = isCoreApp ? 'g2Home' : appAuthName;
|
|
36233
36254
|
if (systemPrompt && typeof systemPrompt === 'string') {
|
|
36234
36255
|
if (!currentContext) {
|
|
36235
36256
|
if (!newMessages.find(function (m) {
|
|
@@ -36243,7 +36264,7 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
36243
36264
|
if (!isEmpty$2(storage$1.appContext)) {
|
|
36244
36265
|
setCurrentContext(storage$1.appContext);
|
|
36245
36266
|
}
|
|
36246
|
-
} else if (!equals$1(currentContext, storage$1.appContext)) {
|
|
36267
|
+
} else if (!equals$1(currentContext, storage$1.appContext) || lastSentFromApp !== currentAppName) {
|
|
36247
36268
|
setCurrentContext(storage$1.appContext);
|
|
36248
36269
|
newMessages.splice(newMessages.length - 1, 0, {
|
|
36249
36270
|
role: 'system',
|
|
@@ -36251,17 +36272,6 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
36251
36272
|
});
|
|
36252
36273
|
}
|
|
36253
36274
|
}
|
|
36254
|
-
isCoreApp = (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
|
|
36255
|
-
appTiles = storage$1.getLocalItem('opsportal-core:config').tiles || [];
|
|
36256
|
-
appName = (_window$toolkitEnv2 = window.toolkitEnv) !== null && _window$toolkitEnv2 !== void 0 && _window$toolkitEnv2.APP_NAME ? window.toolkitEnv.APP_NAME : process.env.APP_NAME;
|
|
36257
|
-
appData = appTiles.find(function (tile) {
|
|
36258
|
-
if (tile.appName) {
|
|
36259
|
-
return tile.appName === appName;
|
|
36260
|
-
} else {
|
|
36261
|
-
return tile.path === "/".concat(appName);
|
|
36262
|
-
}
|
|
36263
|
-
});
|
|
36264
|
-
appAuthName = appData ? appData.appAuthName : (_window$toolkitEnv3 = window.toolkitEnv) !== null && _window$toolkitEnv3 !== void 0 && _window$toolkitEnv3.APP_AUTH_NAME ? window.toolkitEnv.APP_AUTH_NAME : process.env.APP_AUTH_NAME;
|
|
36265
36275
|
messagesWithOutId = newMessages.map(function (m) {
|
|
36266
36276
|
return {
|
|
36267
36277
|
role: m === null || m === void 0 ? void 0 : m.role,
|
|
@@ -36272,18 +36282,19 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
36272
36282
|
messages: messagesWithOutId,
|
|
36273
36283
|
// collection,
|
|
36274
36284
|
last_n: contextMessagesCount,
|
|
36275
|
-
app_name:
|
|
36285
|
+
app_name: currentAppName,
|
|
36276
36286
|
k: contextChunks
|
|
36277
36287
|
};
|
|
36278
36288
|
endpoint = (_storage$getLocalItem = storage$1.getLocalItem('opsportal-core:config')) === null || _storage$getLocalItem === void 0 ? void 0 : (_storage$getLocalItem2 = _storage$getLocalItem.endpoints) === null || _storage$getLocalItem2 === void 0 ? void 0 : _storage$getLocalItem2.mihelpChat;
|
|
36279
|
-
_context.next =
|
|
36289
|
+
_context.next = 16;
|
|
36280
36290
|
return fetcher.post(endpoint, payload, {
|
|
36281
36291
|
headers: {
|
|
36282
36292
|
'Content-Type': 'application/json'
|
|
36283
36293
|
}
|
|
36284
36294
|
});
|
|
36285
|
-
case
|
|
36295
|
+
case 16:
|
|
36286
36296
|
response = _context.sent;
|
|
36297
|
+
setLastSentFromApp(currentAppName);
|
|
36287
36298
|
setIsLoading(false);
|
|
36288
36299
|
newConversations = [].concat(_toConsumableArray(newMessages), [{
|
|
36289
36300
|
role: 'assistant',
|
|
@@ -36293,28 +36304,29 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
36293
36304
|
}]);
|
|
36294
36305
|
setConversations(newConversations);
|
|
36295
36306
|
storage$1.setLocalItem('mihelpAgentConversations', newConversations);
|
|
36296
|
-
|
|
36307
|
+
storage$1.setLocalItem('mihelpAgentLastSentApp', currentAppName);
|
|
36308
|
+
_context.next = 37;
|
|
36297
36309
|
break;
|
|
36298
|
-
case
|
|
36299
|
-
_context.prev =
|
|
36310
|
+
case 25:
|
|
36311
|
+
_context.prev = 25;
|
|
36300
36312
|
_context.t0 = _context["catch"](2);
|
|
36301
36313
|
if (!(retryCount.current < 3)) {
|
|
36302
|
-
_context.next =
|
|
36314
|
+
_context.next = 33;
|
|
36303
36315
|
break;
|
|
36304
36316
|
}
|
|
36305
36317
|
retryCount.current++;
|
|
36306
36318
|
send(messages);
|
|
36307
36319
|
return _context.abrupt("return");
|
|
36308
|
-
case
|
|
36320
|
+
case 33:
|
|
36309
36321
|
retryCount.current = 0;
|
|
36310
36322
|
setMessageError(true);
|
|
36311
36323
|
setIsLoading(false);
|
|
36312
36324
|
console.log(_context.t0);
|
|
36313
|
-
case
|
|
36325
|
+
case 37:
|
|
36314
36326
|
case "end":
|
|
36315
36327
|
return _context.stop();
|
|
36316
36328
|
}
|
|
36317
|
-
}, _callee, null, [[2,
|
|
36329
|
+
}, _callee, null, [[2, 25]]);
|
|
36318
36330
|
}));
|
|
36319
36331
|
return function send(_x) {
|
|
36320
36332
|
return _ref2.apply(this, arguments);
|
|
@@ -36372,6 +36384,7 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
36372
36384
|
setConversations([]);
|
|
36373
36385
|
storage$1.setLocalItem('mihelpAgentConversations', []);
|
|
36374
36386
|
storage$1.setLocalItem('mihelpAgentFeedbacks', {});
|
|
36387
|
+
storage$1.setLocalItem('mihelpAgentLastSentApp', '');
|
|
36375
36388
|
setMessageError(false);
|
|
36376
36389
|
setCurrentContext(null);
|
|
36377
36390
|
};
|