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.
@@ -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 timeout = setTimeout(() => {
943
+ const startTimeout = (ms) => setTimeout(() => {
942
944
  cleanup();
943
945
  reject(new Error("Timed out waiting for AI response"));
944
- }, timeoutMs);
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
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getExtForLang,
4
4
  serializeToYaml
5
- } from "./chunk-S6RDNSHY.js";
5
+ } from "./chunk-DJNY2PVR.js";
6
6
  import "./chunk-AXNRPVLE.js";
7
7
  export {
8
8
  getExtForLang,
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  getExtForLang,
8
8
  parseNewChatSuggestionText,
9
9
  serializeToYaml
10
- } from "./chunk-S6RDNSHY.js";
10
+ } from "./chunk-DJNY2PVR.js";
11
11
  import "./chunk-AXNRPVLE.js";
12
12
  export {
13
13
  MATE_NAMES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmates",
3
- "version": "0.11.0-alpha.19",
3
+ "version": "0.11.0-alpha.20",
4
4
  "description": "OpenMates CLI and SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",