openmates 0.11.0-alpha.19 → 0.11.0-alpha.20
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/{chunk-S6RDNSHY.js → chunk-DJNY2PVR.js} +18 -2
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -752,6 +752,8 @@ var SUB_CHAT_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
752
752
|
"sub_chat_completed",
|
|
753
753
|
"awaiting_user_input"
|
|
754
754
|
]);
|
|
755
|
+
var SUB_CHAT_PARENT_STATUS_MESSAGE = "I've started the sub-chats and will continue once they finish.";
|
|
756
|
+
var SUB_CHAT_COMPLETION_TIMEOUT_MS = 10 * 6e4;
|
|
755
757
|
var OpenMatesWsClient = class {
|
|
756
758
|
socket;
|
|
757
759
|
constructor(options) {
|
|
@@ -938,10 +940,16 @@ var OpenMatesWsClient = class {
|
|
|
938
940
|
const POST_PROCESSING_WINDOW_MS = 12e3;
|
|
939
941
|
let postProcessingTimer = null;
|
|
940
942
|
let asyncEmbedTimer = null;
|
|
941
|
-
const
|
|
943
|
+
const startTimeout = (ms) => setTimeout(() => {
|
|
942
944
|
cleanup();
|
|
943
945
|
reject(new Error("Timed out waiting for AI response"));
|
|
944
|
-
},
|
|
946
|
+
}, ms);
|
|
947
|
+
let timeout = startTimeout(timeoutMs);
|
|
948
|
+
let awaitingSubChatsCompletion = false;
|
|
949
|
+
const resetTimeout = (ms) => {
|
|
950
|
+
clearTimeout(timeout);
|
|
951
|
+
timeout = startTimeout(ms);
|
|
952
|
+
};
|
|
945
953
|
const capture = (p) => {
|
|
946
954
|
if (typeof p.message_id === "string" && p.message_id)
|
|
947
955
|
messageId = p.message_id;
|
|
@@ -1003,6 +1011,10 @@ var OpenMatesWsClient = class {
|
|
|
1003
1011
|
if (eventChatId && eventChatId !== chatId) return;
|
|
1004
1012
|
const event = { type, payload: p };
|
|
1005
1013
|
subChatEvents.push(event);
|
|
1014
|
+
if (type === "awaiting_sub_chats_completion") {
|
|
1015
|
+
awaitingSubChatsCompletion = true;
|
|
1016
|
+
resetTimeout(SUB_CHAT_COMPLETION_TIMEOUT_MS);
|
|
1017
|
+
}
|
|
1006
1018
|
const handler = options?.onSubChatEvent;
|
|
1007
1019
|
if (!handler) return;
|
|
1008
1020
|
const pending = Promise.resolve(handler(event));
|
|
@@ -1016,6 +1028,10 @@ var OpenMatesWsClient = class {
|
|
|
1016
1028
|
});
|
|
1017
1029
|
};
|
|
1018
1030
|
const scheduleResolve = (content) => {
|
|
1031
|
+
if (awaitingSubChatsCompletion && content.trim() === SUB_CHAT_PARENT_STATUS_MESSAGE) {
|
|
1032
|
+
latestContent = "";
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1019
1035
|
aiResponseDone = true;
|
|
1020
1036
|
latestContent = content;
|
|
1021
1037
|
clearTimeout(timeout);
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED