tevrocsdk 0.1.74 → 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 +47 -47
- package/tevroc-sdk.umd.js +300 -197
package/package.json
CHANGED
package/tevroc-sdk.cjs.js
CHANGED
|
@@ -47258,8 +47258,17 @@ function createAgentNotificationService(client) {
|
|
|
47258
47258
|
const notify = (event) => listeners2.forEach((listener) => listener(event));
|
|
47259
47259
|
const getSessionId = (session) => session.sessionId || session.session_id || session.id;
|
|
47260
47260
|
const getMessages = async (sessionId, appId) => {
|
|
47261
|
-
const
|
|
47262
|
-
|
|
47261
|
+
const [bySessionId, byLegacySessionId] = await Promise.all([
|
|
47262
|
+
client.entities.ChatMessage.query({ filter: { appId, sessionId }, limit: 100 }),
|
|
47263
|
+
client.entities.ChatMessage.query({ filter: { appId, session_id: sessionId }, limit: 100 })
|
|
47264
|
+
]);
|
|
47265
|
+
const seenMessages = /* @__PURE__ */ new Set();
|
|
47266
|
+
return [...toList(bySessionId), ...toList(byLegacySessionId)].filter((message2) => {
|
|
47267
|
+
const key = message2?.id || `${message2?.createdAt || ""}:${message2?.content || ""}`;
|
|
47268
|
+
if (seenMessages.has(key)) return false;
|
|
47269
|
+
seenMessages.add(key);
|
|
47270
|
+
return true;
|
|
47271
|
+
});
|
|
47263
47272
|
};
|
|
47264
47273
|
const publish = (sessionId, payload) => {
|
|
47265
47274
|
const connection = client.realtime.room(sessionId, {}, { maxReconnects: 2 });
|
|
@@ -47311,8 +47320,11 @@ function createAgentNotificationService(client) {
|
|
|
47311
47320
|
};
|
|
47312
47321
|
const dispatchAction = async ({ action, sessionId, reply: text }) => {
|
|
47313
47322
|
const appId = client.appId;
|
|
47314
|
-
const
|
|
47315
|
-
|
|
47323
|
+
const [bySessionId, byLegacySessionId] = await Promise.all([
|
|
47324
|
+
client.entities.ChatSession.query({ filter: { appId, sessionId }, limit: 1 }),
|
|
47325
|
+
client.entities.ChatSession.query({ filter: { appId, session_id: sessionId }, limit: 1 })
|
|
47326
|
+
]);
|
|
47327
|
+
const session = toList(bySessionId)[0] || toList(byLegacySessionId)[0];
|
|
47316
47328
|
if (!session) return;
|
|
47317
47329
|
if (action === "open") return notify({ type: "open", sessionId, session });
|
|
47318
47330
|
if (action === "accept") return accept(session);
|