@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.js
CHANGED
|
@@ -198,6 +198,7 @@ __export(index_exports, {
|
|
|
198
198
|
SetupOrgSubject: () => SetupOrgSubject,
|
|
199
199
|
StartAgentSessionSubject: () => StartAgentSessionSubject,
|
|
200
200
|
TriggerAnalyticsScanSubject: () => TriggerAnalyticsScanSubject,
|
|
201
|
+
TriggerMemorySummarizationSubject: () => TriggerMemorySummarizationSubject,
|
|
201
202
|
UpdateAgentLastActivitySubject: () => UpdateAgentLastActivitySubject,
|
|
202
203
|
UpdateAgentQueueSubject: () => UpdateAgentQueueSubject,
|
|
203
204
|
UpdateAgentStatusSubject: () => UpdateAgentStatusSubject,
|
|
@@ -211,6 +212,7 @@ __export(index_exports, {
|
|
|
211
212
|
useChatHistory: () => useChatHistory,
|
|
212
213
|
useChatMonitoring: () => useChatMonitoring,
|
|
213
214
|
useHumanAgentSessions: () => useHumanAgentSessions,
|
|
215
|
+
useMemory: () => useMemory,
|
|
214
216
|
useOptionsRef: () => useOptionsRef
|
|
215
217
|
});
|
|
216
218
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -457,7 +459,8 @@ function createSSETransport(options = {}) {
|
|
|
457
459
|
orgId: event.orgId,
|
|
458
460
|
chatKey: event.chatKey,
|
|
459
461
|
userId: event.userId,
|
|
460
|
-
message: event.message
|
|
462
|
+
message: event.message,
|
|
463
|
+
...event.data ? { data: event.data } : {}
|
|
461
464
|
});
|
|
462
465
|
break;
|
|
463
466
|
case "typing":
|
|
@@ -1317,9 +1320,21 @@ function useChat(options) {
|
|
|
1317
1320
|
var import_react3 = require("react");
|
|
1318
1321
|
|
|
1319
1322
|
// api/index.ts
|
|
1323
|
+
var import_browser2 = require("@elqnt/api-client/browser");
|
|
1324
|
+
|
|
1325
|
+
// api/memory.ts
|
|
1320
1326
|
var import_browser = require("@elqnt/api-client/browser");
|
|
1327
|
+
var patchProfileApi = (patch, o) => (0, import_browser.browserApiRequest)("/api/v1/memory/profile", { method: "PATCH", body: patch, ...o });
|
|
1328
|
+
var replaceProfileApi = (p, o) => (0, import_browser.browserApiRequest)("/api/v1/memory/profile", { method: "PUT", body: p, ...o });
|
|
1329
|
+
var clearProfileApi = (o) => (0, import_browser.browserApiRequest)("/api/v1/memory/profile", { method: "DELETE", ...o });
|
|
1330
|
+
var deleteContactApi = (name, o) => (0, import_browser.browserApiRequest)(`/api/v1/memory/profile/contacts/${encodeURIComponent(name)}`, { method: "DELETE", ...o });
|
|
1331
|
+
var deleteNoteApi = (index, o) => (0, import_browser.browserApiRequest)(`/api/v1/memory/profile/notes/${index}`, { method: "DELETE", ...o });
|
|
1332
|
+
var clearSummaryApi = (chatKey, o) => (0, import_browser.browserApiRequest)(`/api/v1/chats/${chatKey}/summary`, { method: "DELETE", ...o });
|
|
1333
|
+
var regenerateSummaryApi = (chatKey, o) => (0, import_browser.browserApiRequest)(`/api/v1/chats/${chatKey}/summary/regenerate`, { method: "POST", ...o });
|
|
1334
|
+
|
|
1335
|
+
// api/index.ts
|
|
1321
1336
|
async function getChatHistoryApi(options) {
|
|
1322
|
-
return (0,
|
|
1337
|
+
return (0, import_browser2.browserApiRequest)("/api/v1/chats", {
|
|
1323
1338
|
method: "POST",
|
|
1324
1339
|
body: {
|
|
1325
1340
|
limit: options.limit || 15,
|
|
@@ -1330,26 +1345,26 @@ async function getChatHistoryApi(options) {
|
|
|
1330
1345
|
});
|
|
1331
1346
|
}
|
|
1332
1347
|
async function getChatApi(chatKey, options) {
|
|
1333
|
-
return (0,
|
|
1348
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/chats/${chatKey}`, {
|
|
1334
1349
|
method: "GET",
|
|
1335
1350
|
...options
|
|
1336
1351
|
});
|
|
1337
1352
|
}
|
|
1338
1353
|
async function updateChatApi(chatKey, updates, options) {
|
|
1339
|
-
return (0,
|
|
1354
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/chats/${chatKey}`, {
|
|
1340
1355
|
method: "PATCH",
|
|
1341
1356
|
body: updates,
|
|
1342
1357
|
...options
|
|
1343
1358
|
});
|
|
1344
1359
|
}
|
|
1345
1360
|
async function deleteChatApi(chatKey, options) {
|
|
1346
|
-
return (0,
|
|
1361
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/chats/${chatKey}`, {
|
|
1347
1362
|
method: "DELETE",
|
|
1348
1363
|
...options
|
|
1349
1364
|
});
|
|
1350
1365
|
}
|
|
1351
1366
|
async function getActiveChatsCountApi(options) {
|
|
1352
|
-
return (0,
|
|
1367
|
+
return (0, import_browser2.browserApiRequest)("/api/v1/chats/active/count", {
|
|
1353
1368
|
method: "GET",
|
|
1354
1369
|
...options
|
|
1355
1370
|
});
|
|
@@ -1358,37 +1373,37 @@ async function getActiveChatsApi(options) {
|
|
|
1358
1373
|
const params = new URLSearchParams();
|
|
1359
1374
|
if (options.pastHours) params.set("pastHours", String(options.pastHours));
|
|
1360
1375
|
const queryString = params.toString();
|
|
1361
|
-
return (0,
|
|
1376
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/chats/active${queryString ? `?${queryString}` : ""}`, {
|
|
1362
1377
|
method: "GET",
|
|
1363
1378
|
...options
|
|
1364
1379
|
});
|
|
1365
1380
|
}
|
|
1366
1381
|
async function getWaitingChatsCountApi(options) {
|
|
1367
|
-
return (0,
|
|
1382
|
+
return (0, import_browser2.browserApiRequest)("/api/v1/chats/waiting/count", {
|
|
1368
1383
|
method: "GET",
|
|
1369
1384
|
...options
|
|
1370
1385
|
});
|
|
1371
1386
|
}
|
|
1372
1387
|
async function getChatsByUserApi(userEmail, options) {
|
|
1373
|
-
return (0,
|
|
1388
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/chats/user/${encodeURIComponent(userEmail)}`, {
|
|
1374
1389
|
method: "GET",
|
|
1375
1390
|
...options
|
|
1376
1391
|
});
|
|
1377
1392
|
}
|
|
1378
1393
|
async function listQueuesApi(options) {
|
|
1379
|
-
return (0,
|
|
1394
|
+
return (0, import_browser2.browserApiRequest)("/api/v1/queues", {
|
|
1380
1395
|
method: "GET",
|
|
1381
1396
|
...options
|
|
1382
1397
|
});
|
|
1383
1398
|
}
|
|
1384
1399
|
async function getOnlineSessionsApi(options) {
|
|
1385
|
-
return (0,
|
|
1400
|
+
return (0, import_browser2.browserApiRequest)("/api/v1/agents/sessions/online", {
|
|
1386
1401
|
method: "GET",
|
|
1387
1402
|
...options
|
|
1388
1403
|
});
|
|
1389
1404
|
}
|
|
1390
1405
|
async function getAgentSessionApi(agentId, options) {
|
|
1391
|
-
return (0,
|
|
1406
|
+
return (0, import_browser2.browserApiRequest)(`/api/v1/agents/sessions/${agentId}`, {
|
|
1392
1407
|
method: "GET",
|
|
1393
1408
|
...options
|
|
1394
1409
|
});
|
|
@@ -1523,6 +1538,85 @@ function useHumanAgentSessions(options) {
|
|
|
1523
1538
|
);
|
|
1524
1539
|
}
|
|
1525
1540
|
|
|
1541
|
+
// hooks/use-memory.ts
|
|
1542
|
+
var import_react6 = require("react");
|
|
1543
|
+
function useMemory(options, initialProfile = null) {
|
|
1544
|
+
const [profile, setProfile] = (0, import_react6.useState)(initialProfile);
|
|
1545
|
+
const [loading, setLoading] = (0, import_react6.useState)(false);
|
|
1546
|
+
const requestCountRef = (0, import_react6.useRef)(0);
|
|
1547
|
+
const runProfileMutation = (0, import_react6.useCallback)(
|
|
1548
|
+
async (fn) => {
|
|
1549
|
+
requestCountRef.current += 1;
|
|
1550
|
+
setLoading(true);
|
|
1551
|
+
try {
|
|
1552
|
+
const response = await fn();
|
|
1553
|
+
if (!response.error && response.data) {
|
|
1554
|
+
setProfile(response.data);
|
|
1555
|
+
return response.data;
|
|
1556
|
+
}
|
|
1557
|
+
return null;
|
|
1558
|
+
} catch {
|
|
1559
|
+
return null;
|
|
1560
|
+
} finally {
|
|
1561
|
+
requestCountRef.current -= 1;
|
|
1562
|
+
if (requestCountRef.current === 0) {
|
|
1563
|
+
setLoading(false);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
},
|
|
1567
|
+
[]
|
|
1568
|
+
);
|
|
1569
|
+
const optionsRef = (0, import_react6.useRef)(options);
|
|
1570
|
+
optionsRef.current = options;
|
|
1571
|
+
const patchProfile = (0, import_react6.useCallback)(
|
|
1572
|
+
(patch) => runProfileMutation(() => patchProfileApi(patch, optionsRef.current)),
|
|
1573
|
+
[runProfileMutation]
|
|
1574
|
+
);
|
|
1575
|
+
const replaceProfile = (0, import_react6.useCallback)(
|
|
1576
|
+
(p) => runProfileMutation(() => replaceProfileApi(p, optionsRef.current)),
|
|
1577
|
+
[runProfileMutation]
|
|
1578
|
+
);
|
|
1579
|
+
const clearProfile = (0, import_react6.useCallback)(
|
|
1580
|
+
() => runProfileMutation(() => clearProfileApi(optionsRef.current)),
|
|
1581
|
+
[runProfileMutation]
|
|
1582
|
+
);
|
|
1583
|
+
const deleteContact = (0, import_react6.useCallback)(
|
|
1584
|
+
(name) => runProfileMutation(() => deleteContactApi(name, optionsRef.current)),
|
|
1585
|
+
[runProfileMutation]
|
|
1586
|
+
);
|
|
1587
|
+
const deleteNote = (0, import_react6.useCallback)(
|
|
1588
|
+
(index) => runProfileMutation(() => deleteNoteApi(index, optionsRef.current)),
|
|
1589
|
+
[runProfileMutation]
|
|
1590
|
+
);
|
|
1591
|
+
const clearSummary = (0, import_react6.useCallback)(
|
|
1592
|
+
async (chatKey) => {
|
|
1593
|
+
await clearSummaryApi(chatKey, optionsRef.current);
|
|
1594
|
+
},
|
|
1595
|
+
[]
|
|
1596
|
+
);
|
|
1597
|
+
const regenerateSummary = (0, import_react6.useCallback)(
|
|
1598
|
+
async (chatKey) => {
|
|
1599
|
+
const response = await regenerateSummaryApi(chatKey, optionsRef.current);
|
|
1600
|
+
if (!response.error && response.data) {
|
|
1601
|
+
return response.data;
|
|
1602
|
+
}
|
|
1603
|
+
return null;
|
|
1604
|
+
},
|
|
1605
|
+
[]
|
|
1606
|
+
);
|
|
1607
|
+
return {
|
|
1608
|
+
profile,
|
|
1609
|
+
loading,
|
|
1610
|
+
patchProfile,
|
|
1611
|
+
replaceProfile,
|
|
1612
|
+
clearProfile,
|
|
1613
|
+
deleteContact,
|
|
1614
|
+
deleteNote,
|
|
1615
|
+
clearSummary,
|
|
1616
|
+
regenerateSummary
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1526
1620
|
// hooks/index.ts
|
|
1527
1621
|
var import_hooks4 = require("@elqnt/api-client/hooks");
|
|
1528
1622
|
|
|
@@ -1717,6 +1811,7 @@ var GetOnlineUsersSubject = "chat.users.online.get";
|
|
|
1717
1811
|
var TriggerAnalyticsScanSubject = "chat.analytics.trigger-scan";
|
|
1718
1812
|
var SetupOrgSubject = "chat.org.setup";
|
|
1719
1813
|
var GetAgentContextSubject = "chat.agent-context.get";
|
|
1814
|
+
var TriggerMemorySummarizationSubject = "chat.memory.summarize.nightly";
|
|
1720
1815
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1721
1816
|
0 && (module.exports = {
|
|
1722
1817
|
AgentStatusAway,
|
|
@@ -1896,6 +1991,7 @@ var GetAgentContextSubject = "chat.agent-context.get";
|
|
|
1896
1991
|
SetupOrgSubject,
|
|
1897
1992
|
StartAgentSessionSubject,
|
|
1898
1993
|
TriggerAnalyticsScanSubject,
|
|
1994
|
+
TriggerMemorySummarizationSubject,
|
|
1899
1995
|
UpdateAgentLastActivitySubject,
|
|
1900
1996
|
UpdateAgentQueueSubject,
|
|
1901
1997
|
UpdateAgentStatusSubject,
|
|
@@ -1909,6 +2005,7 @@ var GetAgentContextSubject = "chat.agent-context.get";
|
|
|
1909
2005
|
useChatHistory,
|
|
1910
2006
|
useChatMonitoring,
|
|
1911
2007
|
useHumanAgentSessions,
|
|
2008
|
+
useMemory,
|
|
1912
2009
|
useOptionsRef
|
|
1913
2010
|
});
|
|
1914
2011
|
//# sourceMappingURL=index.js.map
|