@copart/ops-tool-kit 1.10.20-alpha.13 → 1.10.20-alpha.14
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
|
@@ -33,7 +33,7 @@ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
|
33
33
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
34
34
|
|
|
35
35
|
const name$r = "@copart/ops-tool-kit";
|
|
36
|
-
const version$5 = "1.10.20-alpha.
|
|
36
|
+
const version$5 = "1.10.20-alpha.14";
|
|
37
37
|
const main$1 = "dist/ops-tool-kit.js";
|
|
38
38
|
const style = "dist/ops-tool-kit.css";
|
|
39
39
|
const files = [
|
|
@@ -38168,51 +38168,55 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
38168
38168
|
_useState18 = _slicedToArray(_useState17, 2),
|
|
38169
38169
|
currentContext = _useState18[0],
|
|
38170
38170
|
setCurrentContext = _useState18[1];
|
|
38171
|
-
var _useState19 = React.useState(
|
|
38171
|
+
var _useState19 = React.useState(null),
|
|
38172
38172
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
38173
|
-
|
|
38174
|
-
|
|
38175
|
-
var _useState21 = React.useState({
|
|
38173
|
+
lastSentFromApp = _useState20[0],
|
|
38174
|
+
setLastSentFromApp = _useState20[1];
|
|
38175
|
+
var _useState21 = React.useState({}),
|
|
38176
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
38177
|
+
feedbacks = _useState22[0],
|
|
38178
|
+
setFeedbacks = _useState22[1];
|
|
38179
|
+
var _useState23 = React.useState({
|
|
38176
38180
|
x: 0,
|
|
38177
38181
|
y: 0
|
|
38178
38182
|
}),
|
|
38179
|
-
|
|
38180
|
-
position =
|
|
38181
|
-
setPosition =
|
|
38182
|
-
var
|
|
38183
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
38184
|
+
position = _useState24[0],
|
|
38185
|
+
setPosition = _useState24[1];
|
|
38186
|
+
var _useState25 = React.useState({
|
|
38183
38187
|
x: 50,
|
|
38184
38188
|
y: -68
|
|
38185
38189
|
}),
|
|
38186
|
-
_useState24 = _slicedToArray(_useState23, 2),
|
|
38187
|
-
chatPosition = _useState24[0],
|
|
38188
|
-
setChatPosition = _useState24[1];
|
|
38189
|
-
var _useState25 = React.useState(false),
|
|
38190
38190
|
_useState26 = _slicedToArray(_useState25, 2),
|
|
38191
|
-
|
|
38192
|
-
|
|
38193
|
-
var _useState27 = React.useState(
|
|
38191
|
+
chatPosition = _useState26[0],
|
|
38192
|
+
setChatPosition = _useState26[1];
|
|
38193
|
+
var _useState27 = React.useState(false),
|
|
38194
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
38195
|
+
isDragging = _useState28[0],
|
|
38196
|
+
setIsDragging = _useState28[1];
|
|
38197
|
+
var _useState29 = React.useState({
|
|
38194
38198
|
x: 0,
|
|
38195
38199
|
y: 0
|
|
38196
38200
|
}),
|
|
38197
|
-
_useState28 = _slicedToArray(_useState27, 2),
|
|
38198
|
-
offset = _useState28[0],
|
|
38199
|
-
setOffset = _useState28[1];
|
|
38200
|
-
var _useState29 = React.useState(false),
|
|
38201
38201
|
_useState30 = _slicedToArray(_useState29, 2),
|
|
38202
|
-
|
|
38203
|
-
|
|
38204
|
-
var _useState31 = React.useState(
|
|
38202
|
+
offset = _useState30[0],
|
|
38203
|
+
setOffset = _useState30[1];
|
|
38204
|
+
var _useState31 = React.useState(false),
|
|
38205
38205
|
_useState32 = _slicedToArray(_useState31, 2),
|
|
38206
|
-
|
|
38207
|
-
|
|
38208
|
-
var _useState33 = React.useState(
|
|
38206
|
+
dragged = _useState32[0],
|
|
38207
|
+
setDragged = _useState32[1];
|
|
38208
|
+
var _useState33 = React.useState(500),
|
|
38209
38209
|
_useState34 = _slicedToArray(_useState33, 2),
|
|
38210
|
-
|
|
38211
|
-
|
|
38212
|
-
var _useState35 = React.useState(
|
|
38210
|
+
chatWindowWidth = _useState34[0],
|
|
38211
|
+
setChatWindowWidth = _useState34[1];
|
|
38212
|
+
var _useState35 = React.useState(0),
|
|
38213
38213
|
_useState36 = _slicedToArray(_useState35, 2),
|
|
38214
|
-
|
|
38215
|
-
|
|
38214
|
+
windowInnerWidthForMobile = _useState36[0],
|
|
38215
|
+
setWindowInnerWidthForMobile = _useState36[1];
|
|
38216
|
+
var _useState37 = React.useState(600),
|
|
38217
|
+
_useState38 = _slicedToArray(_useState37, 2),
|
|
38218
|
+
chatWindowHeight = _useState38[0],
|
|
38219
|
+
setchatWindowHeight = _useState38[1]; //update this if changed in css
|
|
38216
38220
|
|
|
38217
38221
|
var chatIconSize = 60; //update this if changed in css
|
|
38218
38222
|
|
|
@@ -38428,8 +38432,10 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
38428
38432
|
var conversationsToBeSaved = !isEmpty$2(conversationsFromSession) ? conversationsFromSession : [];
|
|
38429
38433
|
setConversations(conversationsToBeSaved);
|
|
38430
38434
|
var feedbacksFromSession = storage$1.getLocalItem('mihelpAgentFeedbacks');
|
|
38435
|
+
var lastSentApp = storage$1.getLocalItem('mihelpAgentLastSentApp');
|
|
38431
38436
|
var feedbacksToBeSaved = !isEmpty$2(feedbacksFromSession) ? feedbacksFromSession : {};
|
|
38432
38437
|
setFeedbacks(feedbacksToBeSaved);
|
|
38438
|
+
setLastSentFromApp(lastSentApp);
|
|
38433
38439
|
if (conversationsToBeSaved.length) {
|
|
38434
38440
|
saveCurrentContext(conversationsToBeSaved);
|
|
38435
38441
|
} else {
|
|
@@ -38463,6 +38469,9 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
38463
38469
|
var feedbacksToBeSaved = !isEmpty$2(feedbacksFromSession) ? feedbacksFromSession : {};
|
|
38464
38470
|
setFeedbacks(feedbacksToBeSaved);
|
|
38465
38471
|
}
|
|
38472
|
+
if (event.key === 'mihelpAgentLastSentApp') {
|
|
38473
|
+
setLastSentFromApp(event.newValue);
|
|
38474
|
+
}
|
|
38466
38475
|
};
|
|
38467
38476
|
window.addEventListener('storage', handleStorageChange);
|
|
38468
38477
|
return function () {
|
|
@@ -38491,7 +38500,7 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
38491
38500
|
};
|
|
38492
38501
|
var send = /*#__PURE__*/function () {
|
|
38493
38502
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(messages) {
|
|
38494
|
-
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;
|
|
38503
|
+
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;
|
|
38495
38504
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
38496
38505
|
while (1) switch (_context.prev = _context.next) {
|
|
38497
38506
|
case 0:
|
|
@@ -38499,6 +38508,18 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
38499
38508
|
setMessageError(false);
|
|
38500
38509
|
_context.prev = 2;
|
|
38501
38510
|
newMessages = _toConsumableArray(messages);
|
|
38511
|
+
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;
|
|
38512
|
+
appTiles = storage$1.getLocalItem('opsportal-core:config').tiles || [];
|
|
38513
|
+
appName = (_window$toolkitEnv2 = window.toolkitEnv) !== null && _window$toolkitEnv2 !== void 0 && _window$toolkitEnv2.APP_NAME ? window.toolkitEnv.APP_NAME : process.env.APP_NAME;
|
|
38514
|
+
appData = appTiles.find(function (tile) {
|
|
38515
|
+
if (tile.appName) {
|
|
38516
|
+
return tile.appName === appName;
|
|
38517
|
+
} else {
|
|
38518
|
+
return tile.path === "/".concat(appName);
|
|
38519
|
+
}
|
|
38520
|
+
});
|
|
38521
|
+
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;
|
|
38522
|
+
currentAppName = isCoreApp ? 'g2Home' : appAuthName;
|
|
38502
38523
|
if (systemPrompt && typeof systemPrompt === 'string') {
|
|
38503
38524
|
if (!currentContext) {
|
|
38504
38525
|
if (!newMessages.find(function (m) {
|
|
@@ -38512,7 +38533,7 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
38512
38533
|
if (!isEmpty$2(storage$1.appContext)) {
|
|
38513
38534
|
setCurrentContext(storage$1.appContext);
|
|
38514
38535
|
}
|
|
38515
|
-
} else if (!equals$1(currentContext, storage$1.appContext)) {
|
|
38536
|
+
} else if (!equals$1(currentContext, storage$1.appContext) || lastSentFromApp !== currentAppName) {
|
|
38516
38537
|
setCurrentContext(storage$1.appContext);
|
|
38517
38538
|
newMessages.splice(newMessages.length - 1, 0, {
|
|
38518
38539
|
role: 'system',
|
|
@@ -38520,17 +38541,6 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
38520
38541
|
});
|
|
38521
38542
|
}
|
|
38522
38543
|
}
|
|
38523
|
-
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;
|
|
38524
|
-
appTiles = storage$1.getLocalItem('opsportal-core:config').tiles || [];
|
|
38525
|
-
appName = (_window$toolkitEnv2 = window.toolkitEnv) !== null && _window$toolkitEnv2 !== void 0 && _window$toolkitEnv2.APP_NAME ? window.toolkitEnv.APP_NAME : process.env.APP_NAME;
|
|
38526
|
-
appData = appTiles.find(function (tile) {
|
|
38527
|
-
if (tile.appName) {
|
|
38528
|
-
return tile.appName === appName;
|
|
38529
|
-
} else {
|
|
38530
|
-
return tile.path === "/".concat(appName);
|
|
38531
|
-
}
|
|
38532
|
-
});
|
|
38533
|
-
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;
|
|
38534
38544
|
messagesWithOutId = newMessages.map(function (m) {
|
|
38535
38545
|
return {
|
|
38536
38546
|
role: m === null || m === void 0 ? void 0 : m.role,
|
|
@@ -38541,18 +38551,19 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
38541
38551
|
messages: messagesWithOutId,
|
|
38542
38552
|
// collection,
|
|
38543
38553
|
last_n: contextMessagesCount,
|
|
38544
|
-
app_name:
|
|
38554
|
+
app_name: currentAppName,
|
|
38545
38555
|
k: contextChunks
|
|
38546
38556
|
};
|
|
38547
38557
|
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;
|
|
38548
|
-
_context.next =
|
|
38558
|
+
_context.next = 16;
|
|
38549
38559
|
return fetcher.post(endpoint, payload, {
|
|
38550
38560
|
headers: {
|
|
38551
38561
|
'Content-Type': 'application/json'
|
|
38552
38562
|
}
|
|
38553
38563
|
});
|
|
38554
|
-
case
|
|
38564
|
+
case 16:
|
|
38555
38565
|
response = _context.sent;
|
|
38566
|
+
setLastSentFromApp(currentAppName);
|
|
38556
38567
|
setIsLoading(false);
|
|
38557
38568
|
newConversations = [].concat(_toConsumableArray(newMessages), [{
|
|
38558
38569
|
role: 'assistant',
|
|
@@ -38562,28 +38573,29 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
38562
38573
|
}]);
|
|
38563
38574
|
setConversations(newConversations);
|
|
38564
38575
|
storage$1.setLocalItem('mihelpAgentConversations', newConversations);
|
|
38565
|
-
|
|
38576
|
+
storage$1.setLocalItem('mihelpAgentLastSentApp', currentAppName);
|
|
38577
|
+
_context.next = 37;
|
|
38566
38578
|
break;
|
|
38567
|
-
case
|
|
38568
|
-
_context.prev =
|
|
38579
|
+
case 25:
|
|
38580
|
+
_context.prev = 25;
|
|
38569
38581
|
_context.t0 = _context["catch"](2);
|
|
38570
38582
|
if (!(retryCount.current < 3)) {
|
|
38571
|
-
_context.next =
|
|
38583
|
+
_context.next = 33;
|
|
38572
38584
|
break;
|
|
38573
38585
|
}
|
|
38574
38586
|
retryCount.current++;
|
|
38575
38587
|
send(messages);
|
|
38576
38588
|
return _context.abrupt("return");
|
|
38577
|
-
case
|
|
38589
|
+
case 33:
|
|
38578
38590
|
retryCount.current = 0;
|
|
38579
38591
|
setMessageError(true);
|
|
38580
38592
|
setIsLoading(false);
|
|
38581
38593
|
console.log(_context.t0);
|
|
38582
|
-
case
|
|
38594
|
+
case 37:
|
|
38583
38595
|
case "end":
|
|
38584
38596
|
return _context.stop();
|
|
38585
38597
|
}
|
|
38586
|
-
}, _callee, null, [[2,
|
|
38598
|
+
}, _callee, null, [[2, 25]]);
|
|
38587
38599
|
}));
|
|
38588
38600
|
return function send(_x) {
|
|
38589
38601
|
return _ref2.apply(this, arguments);
|
|
@@ -38641,6 +38653,7 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
|
|
|
38641
38653
|
setConversations([]);
|
|
38642
38654
|
storage$1.setLocalItem('mihelpAgentConversations', []);
|
|
38643
38655
|
storage$1.setLocalItem('mihelpAgentFeedbacks', {});
|
|
38656
|
+
storage$1.setLocalItem('mihelpAgentLastSentApp', '');
|
|
38644
38657
|
setMessageError(false);
|
|
38645
38658
|
setCurrentContext(null);
|
|
38646
38659
|
};
|