@questionbase/deskfree 0.3.0-alpha.28 → 0.3.0-alpha.29
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/index.js +22 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4705,6 +4705,15 @@ var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
|
4705
4705
|
var wrapper_default = import_websocket.default;
|
|
4706
4706
|
|
|
4707
4707
|
// src/gateway.ts
|
|
4708
|
+
var activeWs = null;
|
|
4709
|
+
function sendWsAck(messageId) {
|
|
4710
|
+
if (activeWs?.readyState === wrapper_default.OPEN) {
|
|
4711
|
+
try {
|
|
4712
|
+
activeWs.send(JSON.stringify({ action: "ack", messageId }));
|
|
4713
|
+
} catch {
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
}
|
|
4708
4717
|
var activeTaskId = null;
|
|
4709
4718
|
var completedTaskId = null;
|
|
4710
4719
|
var inboundThreadId = null;
|
|
@@ -4987,6 +4996,7 @@ async function runWebSocketConnection(opts) {
|
|
|
4987
4996
|
}, WS_CONNECTION_TIMEOUT_MS);
|
|
4988
4997
|
ws.on("open", async () => {
|
|
4989
4998
|
isConnected = true;
|
|
4999
|
+
activeWs = ws;
|
|
4990
5000
|
if (connectionTimer !== void 0) {
|
|
4991
5001
|
clearTimeout(connectionTimer);
|
|
4992
5002
|
connectionTimer = void 0;
|
|
@@ -5034,6 +5044,16 @@ async function runWebSocketConnection(opts) {
|
|
|
5034
5044
|
log,
|
|
5035
5045
|
account
|
|
5036
5046
|
);
|
|
5047
|
+
client.listMessages({ limit: 20 }).then((res) => {
|
|
5048
|
+
const humanMessages = res.items?.filter(
|
|
5049
|
+
(m) => m.authorType === "human"
|
|
5050
|
+
);
|
|
5051
|
+
const latest = humanMessages?.[humanMessages.length - 1];
|
|
5052
|
+
if (latest) {
|
|
5053
|
+
sendWsAck(latest.messageId);
|
|
5054
|
+
}
|
|
5055
|
+
}).catch(() => {
|
|
5056
|
+
});
|
|
5037
5057
|
});
|
|
5038
5058
|
ws.on("message", async (data) => {
|
|
5039
5059
|
try {
|
|
@@ -5080,6 +5100,7 @@ async function runWebSocketConnection(opts) {
|
|
|
5080
5100
|
ws.on("close", (code, reason) => {
|
|
5081
5101
|
cleanup();
|
|
5082
5102
|
isConnected = false;
|
|
5103
|
+
activeWs = null;
|
|
5083
5104
|
ctx.setStatus({ running: false, lastStopAt: Date.now() });
|
|
5084
5105
|
if (code === 1e3) {
|
|
5085
5106
|
log.info(`WebSocket closed normally: ${code} ${reason.toString()}`);
|
|
@@ -5265,6 +5286,7 @@ async function pollAndDeliver(client, ctx, cursor, log, account) {
|
|
|
5265
5286
|
await deliverMessageToAgent(ctx, message, client);
|
|
5266
5287
|
deliveredMessageIds.add(message.messageId);
|
|
5267
5288
|
deliveredCount++;
|
|
5289
|
+
sendWsAck(message.messageId);
|
|
5268
5290
|
}
|
|
5269
5291
|
if (deliveredMessageIds.size > 1e3) {
|
|
5270
5292
|
const entries = Array.from(deliveredMessageIds);
|