openmates 0.14.8-alpha.8 → 0.14.8-alpha.9

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.
@@ -1214,6 +1214,31 @@ function websocketProtocolError(envelope) {
1214
1214
  }
1215
1215
  return null;
1216
1216
  }
1217
+ function errorFrameBelongsToAiResponse(envelope, userMessageId, chatId, recoveryTurnId) {
1218
+ if (envelope.type === "client_update_required") return true;
1219
+ if (envelope.type !== "error") return true;
1220
+ const payload = envelope.payload && typeof envelope.payload === "object" ? envelope.payload : {};
1221
+ let scoped = false;
1222
+ const errorChatId = typeof payload.chat_id === "string" ? payload.chat_id : null;
1223
+ if (errorChatId) {
1224
+ scoped = true;
1225
+ if (errorChatId !== chatId) return false;
1226
+ }
1227
+ const errorMessageId = typeof payload.user_message_id === "string" ? payload.user_message_id : typeof payload.userMessageId === "string" ? payload.userMessageId : typeof payload.message_id === "string" ? payload.message_id : null;
1228
+ if (errorMessageId) {
1229
+ scoped = true;
1230
+ if (errorMessageId !== userMessageId) return false;
1231
+ }
1232
+ const errorTurnId = typeof payload.turn_id === "string" ? payload.turn_id : null;
1233
+ if (errorTurnId) {
1234
+ scoped = true;
1235
+ if (recoveryTurnId !== errorTurnId) return false;
1236
+ }
1237
+ if (typeof payload.job_id === "string") {
1238
+ scoped = true;
1239
+ }
1240
+ return !scoped || Boolean(errorChatId || errorMessageId || errorTurnId);
1241
+ }
1217
1242
  function parseTaskProposals(value) {
1218
1243
  if (!Array.isArray(value)) return [];
1219
1244
  return value.flatMap((item) => {
@@ -1713,6 +1738,9 @@ var OpenMatesWsClient = class {
1713
1738
  const type = parsed.type;
1714
1739
  const protocolError = websocketProtocolError(parsed);
1715
1740
  if (protocolError) {
1741
+ if (!errorFrameBelongsToAiResponse(parsed, userMessageId, chatId, options?.recoveryTurnId)) {
1742
+ return;
1743
+ }
1716
1744
  cleanup();
1717
1745
  reject(protocolError);
1718
1746
  return;
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getExtForLang,
4
4
  serializeToYaml
5
- } from "./chunk-T57PL63X.js";
5
+ } from "./chunk-G7DDNKJL.js";
6
6
  import "./chunk-AXNRPVLE.js";
7
7
  export {
8
8
  getExtForLang,
package/dist/index.js CHANGED
@@ -29,7 +29,7 @@ import {
29
29
  renderSupportInfo,
30
30
  serializeToYaml,
31
31
  unwrapApiKeyMasterKey
32
- } from "./chunk-T57PL63X.js";
32
+ } from "./chunk-G7DDNKJL.js";
33
33
  import "./chunk-AXNRPVLE.js";
34
34
 
35
35
  // src/generated/appSkills.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmates",
3
- "version": "0.14.8-alpha.8",
3
+ "version": "0.14.8-alpha.9",
4
4
  "description": "OpenMates CLI and SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",