@elqnt/chat 3.0.3 → 3.1.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/dist/api/index.d.mts +17 -2
- package/dist/api/index.d.ts +17 -2
- package/dist/api/index.js +44 -14
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +35 -14
- package/dist/api/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +38 -3
- package/dist/hooks/index.d.ts +38 -3
- package/dist/hooks/index.js +106 -12
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +105 -12
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +109 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -12
- package/dist/index.mjs.map +1 -1
- package/dist/models/index.d.mts +43 -1
- package/dist/models/index.d.ts +43 -1
- package/dist/models/index.js +3 -0
- package/dist/models/index.js.map +1 -1
- package/dist/models/index.mjs +2 -0
- package/dist/models/index.mjs.map +1 -1
- package/dist/transport/index.js +2 -1
- package/dist/transport/index.js.map +1 -1
- package/dist/transport/index.mjs +2 -1
- package/dist/transport/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -242,7 +242,8 @@ function createSSETransport(options = {}) {
|
|
|
242
242
|
orgId: event.orgId,
|
|
243
243
|
chatKey: event.chatKey,
|
|
244
244
|
userId: event.userId,
|
|
245
|
-
message: event.message
|
|
245
|
+
message: event.message,
|
|
246
|
+
...event.data ? { data: event.data } : {}
|
|
246
247
|
});
|
|
247
248
|
break;
|
|
248
249
|
case "typing":
|
|
@@ -1102,9 +1103,21 @@ function useChat(options) {
|
|
|
1102
1103
|
import { useMemo } from "react";
|
|
1103
1104
|
|
|
1104
1105
|
// api/index.ts
|
|
1106
|
+
import { browserApiRequest as browserApiRequest2 } from "@elqnt/api-client/browser";
|
|
1107
|
+
|
|
1108
|
+
// api/memory.ts
|
|
1105
1109
|
import { browserApiRequest } from "@elqnt/api-client/browser";
|
|
1110
|
+
var patchProfileApi = (patch, o) => browserApiRequest("/api/v1/memory/profile", { method: "PATCH", body: patch, ...o });
|
|
1111
|
+
var replaceProfileApi = (p, o) => browserApiRequest("/api/v1/memory/profile", { method: "PUT", body: p, ...o });
|
|
1112
|
+
var clearProfileApi = (o) => browserApiRequest("/api/v1/memory/profile", { method: "DELETE", ...o });
|
|
1113
|
+
var deleteContactApi = (name, o) => browserApiRequest(`/api/v1/memory/profile/contacts/${encodeURIComponent(name)}`, { method: "DELETE", ...o });
|
|
1114
|
+
var deleteNoteApi = (index, o) => browserApiRequest(`/api/v1/memory/profile/notes/${index}`, { method: "DELETE", ...o });
|
|
1115
|
+
var clearSummaryApi = (chatKey, o) => browserApiRequest(`/api/v1/chats/${chatKey}/summary`, { method: "DELETE", ...o });
|
|
1116
|
+
var regenerateSummaryApi = (chatKey, o) => browserApiRequest(`/api/v1/chats/${chatKey}/summary/regenerate`, { method: "POST", ...o });
|
|
1117
|
+
|
|
1118
|
+
// api/index.ts
|
|
1106
1119
|
async function getChatHistoryApi(options) {
|
|
1107
|
-
return
|
|
1120
|
+
return browserApiRequest2("/api/v1/chats", {
|
|
1108
1121
|
method: "POST",
|
|
1109
1122
|
body: {
|
|
1110
1123
|
limit: options.limit || 15,
|
|
@@ -1115,26 +1128,26 @@ async function getChatHistoryApi(options) {
|
|
|
1115
1128
|
});
|
|
1116
1129
|
}
|
|
1117
1130
|
async function getChatApi(chatKey, options) {
|
|
1118
|
-
return
|
|
1131
|
+
return browserApiRequest2(`/api/v1/chats/${chatKey}`, {
|
|
1119
1132
|
method: "GET",
|
|
1120
1133
|
...options
|
|
1121
1134
|
});
|
|
1122
1135
|
}
|
|
1123
1136
|
async function updateChatApi(chatKey, updates, options) {
|
|
1124
|
-
return
|
|
1137
|
+
return browserApiRequest2(`/api/v1/chats/${chatKey}`, {
|
|
1125
1138
|
method: "PATCH",
|
|
1126
1139
|
body: updates,
|
|
1127
1140
|
...options
|
|
1128
1141
|
});
|
|
1129
1142
|
}
|
|
1130
1143
|
async function deleteChatApi(chatKey, options) {
|
|
1131
|
-
return
|
|
1144
|
+
return browserApiRequest2(`/api/v1/chats/${chatKey}`, {
|
|
1132
1145
|
method: "DELETE",
|
|
1133
1146
|
...options
|
|
1134
1147
|
});
|
|
1135
1148
|
}
|
|
1136
1149
|
async function getActiveChatsCountApi(options) {
|
|
1137
|
-
return
|
|
1150
|
+
return browserApiRequest2("/api/v1/chats/active/count", {
|
|
1138
1151
|
method: "GET",
|
|
1139
1152
|
...options
|
|
1140
1153
|
});
|
|
@@ -1143,37 +1156,37 @@ async function getActiveChatsApi(options) {
|
|
|
1143
1156
|
const params = new URLSearchParams();
|
|
1144
1157
|
if (options.pastHours) params.set("pastHours", String(options.pastHours));
|
|
1145
1158
|
const queryString = params.toString();
|
|
1146
|
-
return
|
|
1159
|
+
return browserApiRequest2(`/api/v1/chats/active${queryString ? `?${queryString}` : ""}`, {
|
|
1147
1160
|
method: "GET",
|
|
1148
1161
|
...options
|
|
1149
1162
|
});
|
|
1150
1163
|
}
|
|
1151
1164
|
async function getWaitingChatsCountApi(options) {
|
|
1152
|
-
return
|
|
1165
|
+
return browserApiRequest2("/api/v1/chats/waiting/count", {
|
|
1153
1166
|
method: "GET",
|
|
1154
1167
|
...options
|
|
1155
1168
|
});
|
|
1156
1169
|
}
|
|
1157
1170
|
async function getChatsByUserApi(userEmail, options) {
|
|
1158
|
-
return
|
|
1171
|
+
return browserApiRequest2(`/api/v1/chats/user/${encodeURIComponent(userEmail)}`, {
|
|
1159
1172
|
method: "GET",
|
|
1160
1173
|
...options
|
|
1161
1174
|
});
|
|
1162
1175
|
}
|
|
1163
1176
|
async function listQueuesApi(options) {
|
|
1164
|
-
return
|
|
1177
|
+
return browserApiRequest2("/api/v1/queues", {
|
|
1165
1178
|
method: "GET",
|
|
1166
1179
|
...options
|
|
1167
1180
|
});
|
|
1168
1181
|
}
|
|
1169
1182
|
async function getOnlineSessionsApi(options) {
|
|
1170
|
-
return
|
|
1183
|
+
return browserApiRequest2("/api/v1/agents/sessions/online", {
|
|
1171
1184
|
method: "GET",
|
|
1172
1185
|
...options
|
|
1173
1186
|
});
|
|
1174
1187
|
}
|
|
1175
1188
|
async function getAgentSessionApi(agentId, options) {
|
|
1176
|
-
return
|
|
1189
|
+
return browserApiRequest2(`/api/v1/agents/sessions/${agentId}`, {
|
|
1177
1190
|
method: "GET",
|
|
1178
1191
|
...options
|
|
1179
1192
|
});
|
|
@@ -1308,6 +1321,85 @@ function useHumanAgentSessions(options) {
|
|
|
1308
1321
|
);
|
|
1309
1322
|
}
|
|
1310
1323
|
|
|
1324
|
+
// hooks/use-memory.ts
|
|
1325
|
+
import { useCallback as useCallback2, useRef as useRef3, useState as useState2 } from "react";
|
|
1326
|
+
function useMemory(options, initialProfile = null) {
|
|
1327
|
+
const [profile, setProfile] = useState2(initialProfile);
|
|
1328
|
+
const [loading, setLoading] = useState2(false);
|
|
1329
|
+
const requestCountRef = useRef3(0);
|
|
1330
|
+
const runProfileMutation = useCallback2(
|
|
1331
|
+
async (fn) => {
|
|
1332
|
+
requestCountRef.current += 1;
|
|
1333
|
+
setLoading(true);
|
|
1334
|
+
try {
|
|
1335
|
+
const response = await fn();
|
|
1336
|
+
if (!response.error && response.data) {
|
|
1337
|
+
setProfile(response.data);
|
|
1338
|
+
return response.data;
|
|
1339
|
+
}
|
|
1340
|
+
return null;
|
|
1341
|
+
} catch {
|
|
1342
|
+
return null;
|
|
1343
|
+
} finally {
|
|
1344
|
+
requestCountRef.current -= 1;
|
|
1345
|
+
if (requestCountRef.current === 0) {
|
|
1346
|
+
setLoading(false);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
},
|
|
1350
|
+
[]
|
|
1351
|
+
);
|
|
1352
|
+
const optionsRef = useRef3(options);
|
|
1353
|
+
optionsRef.current = options;
|
|
1354
|
+
const patchProfile = useCallback2(
|
|
1355
|
+
(patch) => runProfileMutation(() => patchProfileApi(patch, optionsRef.current)),
|
|
1356
|
+
[runProfileMutation]
|
|
1357
|
+
);
|
|
1358
|
+
const replaceProfile = useCallback2(
|
|
1359
|
+
(p) => runProfileMutation(() => replaceProfileApi(p, optionsRef.current)),
|
|
1360
|
+
[runProfileMutation]
|
|
1361
|
+
);
|
|
1362
|
+
const clearProfile = useCallback2(
|
|
1363
|
+
() => runProfileMutation(() => clearProfileApi(optionsRef.current)),
|
|
1364
|
+
[runProfileMutation]
|
|
1365
|
+
);
|
|
1366
|
+
const deleteContact = useCallback2(
|
|
1367
|
+
(name) => runProfileMutation(() => deleteContactApi(name, optionsRef.current)),
|
|
1368
|
+
[runProfileMutation]
|
|
1369
|
+
);
|
|
1370
|
+
const deleteNote = useCallback2(
|
|
1371
|
+
(index) => runProfileMutation(() => deleteNoteApi(index, optionsRef.current)),
|
|
1372
|
+
[runProfileMutation]
|
|
1373
|
+
);
|
|
1374
|
+
const clearSummary = useCallback2(
|
|
1375
|
+
async (chatKey) => {
|
|
1376
|
+
await clearSummaryApi(chatKey, optionsRef.current);
|
|
1377
|
+
},
|
|
1378
|
+
[]
|
|
1379
|
+
);
|
|
1380
|
+
const regenerateSummary = useCallback2(
|
|
1381
|
+
async (chatKey) => {
|
|
1382
|
+
const response = await regenerateSummaryApi(chatKey, optionsRef.current);
|
|
1383
|
+
if (!response.error && response.data) {
|
|
1384
|
+
return response.data;
|
|
1385
|
+
}
|
|
1386
|
+
return null;
|
|
1387
|
+
},
|
|
1388
|
+
[]
|
|
1389
|
+
);
|
|
1390
|
+
return {
|
|
1391
|
+
profile,
|
|
1392
|
+
loading,
|
|
1393
|
+
patchProfile,
|
|
1394
|
+
replaceProfile,
|
|
1395
|
+
clearProfile,
|
|
1396
|
+
deleteContact,
|
|
1397
|
+
deleteNote,
|
|
1398
|
+
clearSummary,
|
|
1399
|
+
regenerateSummary
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1311
1403
|
// hooks/index.ts
|
|
1312
1404
|
import { useApiAsync as useApiAsync4 } from "@elqnt/api-client/hooks";
|
|
1313
1405
|
|
|
@@ -1502,6 +1594,7 @@ var GetOnlineUsersSubject = "chat.users.online.get";
|
|
|
1502
1594
|
var TriggerAnalyticsScanSubject = "chat.analytics.trigger-scan";
|
|
1503
1595
|
var SetupOrgSubject = "chat.org.setup";
|
|
1504
1596
|
var GetAgentContextSubject = "chat.agent-context.get";
|
|
1597
|
+
var TriggerMemorySummarizationSubject = "chat.memory.summarize.nightly";
|
|
1505
1598
|
export {
|
|
1506
1599
|
AgentStatusAway,
|
|
1507
1600
|
AgentStatusBusy,
|
|
@@ -1680,6 +1773,7 @@ export {
|
|
|
1680
1773
|
SetupOrgSubject,
|
|
1681
1774
|
StartAgentSessionSubject,
|
|
1682
1775
|
TriggerAnalyticsScanSubject,
|
|
1776
|
+
TriggerMemorySummarizationSubject,
|
|
1683
1777
|
UpdateAgentLastActivitySubject,
|
|
1684
1778
|
UpdateAgentQueueSubject,
|
|
1685
1779
|
UpdateAgentStatusSubject,
|
|
@@ -1693,6 +1787,7 @@ export {
|
|
|
1693
1787
|
useChatHistory,
|
|
1694
1788
|
useChatMonitoring,
|
|
1695
1789
|
useHumanAgentSessions,
|
|
1790
|
+
useMemory,
|
|
1696
1791
|
useOptionsRef
|
|
1697
1792
|
};
|
|
1698
1793
|
//# sourceMappingURL=index.mjs.map
|