tevrocsdk 0.1.75 → 0.1.76
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/package.json +1 -1
- package/tevroc-sdk.cjs.js +16 -4
- package/tevroc-sdk.cjs.js.map +2 -2
- package/tevroc-sdk.esm.js +16 -4
- package/tevroc-sdk.esm.js.map +2 -2
- package/tevroc-sdk.min.js +24 -24
- package/tevroc-sdk.umd.js +300 -197
package/tevroc-sdk.esm.js
CHANGED
|
@@ -40777,8 +40777,17 @@ function createAgentNotificationService(client) {
|
|
|
40777
40777
|
const notify = (event) => listeners2.forEach((listener) => listener(event));
|
|
40778
40778
|
const getSessionId = (session) => session.sessionId || session.session_id || session.id;
|
|
40779
40779
|
const getMessages = async (sessionId, appId) => {
|
|
40780
|
-
const
|
|
40781
|
-
|
|
40780
|
+
const [bySessionId, byLegacySessionId] = await Promise.all([
|
|
40781
|
+
client.entities.ChatMessage.query({ filter: { appId, sessionId }, limit: 100 }),
|
|
40782
|
+
client.entities.ChatMessage.query({ filter: { appId, session_id: sessionId }, limit: 100 })
|
|
40783
|
+
]);
|
|
40784
|
+
const seenMessages = /* @__PURE__ */ new Set();
|
|
40785
|
+
return [...toList(bySessionId), ...toList(byLegacySessionId)].filter((message2) => {
|
|
40786
|
+
const key = message2?.id || `${message2?.createdAt || ""}:${message2?.content || ""}`;
|
|
40787
|
+
if (seenMessages.has(key)) return false;
|
|
40788
|
+
seenMessages.add(key);
|
|
40789
|
+
return true;
|
|
40790
|
+
});
|
|
40782
40791
|
};
|
|
40783
40792
|
const publish = (sessionId, payload) => {
|
|
40784
40793
|
const connection = client.realtime.room(sessionId, {}, { maxReconnects: 2 });
|
|
@@ -40830,8 +40839,11 @@ function createAgentNotificationService(client) {
|
|
|
40830
40839
|
};
|
|
40831
40840
|
const dispatchAction = async ({ action, sessionId, reply: text2 }) => {
|
|
40832
40841
|
const appId = client.appId;
|
|
40833
|
-
const
|
|
40834
|
-
|
|
40842
|
+
const [bySessionId, byLegacySessionId] = await Promise.all([
|
|
40843
|
+
client.entities.ChatSession.query({ filter: { appId, sessionId }, limit: 1 }),
|
|
40844
|
+
client.entities.ChatSession.query({ filter: { appId, session_id: sessionId }, limit: 1 })
|
|
40845
|
+
]);
|
|
40846
|
+
const session = toList(bySessionId)[0] || toList(byLegacySessionId)[0];
|
|
40835
40847
|
if (!session) return;
|
|
40836
40848
|
if (action === "open") return notify({ type: "open", sessionId, session });
|
|
40837
40849
|
if (action === "accept") return accept(session);
|