openmates 0.14.8-alpha.6 → 0.14.8-alpha.8

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.
@@ -1278,6 +1278,21 @@ function parsePendingTaskUpdateJobs(value) {
1278
1278
  return [job];
1279
1279
  });
1280
1280
  }
1281
+ function parseAvailableRecoveryJobs(value) {
1282
+ if (!Array.isArray(value)) return [];
1283
+ return value.flatMap((item) => {
1284
+ if (!item || typeof item !== "object" || Array.isArray(item)) return [];
1285
+ const raw = item;
1286
+ if (typeof raw.job_id !== "string" || typeof raw.chat_id !== "string" || typeof raw.turn_id !== "string" || typeof raw.assistant_message_id !== "string" || typeof raw.chat_key_version !== "number") return [];
1287
+ return [{
1288
+ job_id: raw.job_id,
1289
+ chat_id: raw.chat_id,
1290
+ turn_id: raw.turn_id,
1291
+ assistant_message_id: raw.assistant_message_id,
1292
+ chat_key_version: raw.chat_key_version
1293
+ }];
1294
+ });
1295
+ }
1281
1296
  var OpenMatesWsClient = class {
1282
1297
  socket;
1283
1298
  passiveTaskUpdateJobs = /* @__PURE__ */ new Map();
@@ -1740,6 +1755,16 @@ var OpenMatesWsClient = class {
1740
1755
  maybeResolve();
1741
1756
  return;
1742
1757
  }
1758
+ if (type === "recovery_jobs_available") {
1759
+ const job = parseAvailableRecoveryJobs(p.jobs).find(
1760
+ (candidate) => candidate.chat_id === chatId && (!options?.recoveryTurnId || candidate.turn_id === options.recoveryTurnId)
1761
+ );
1762
+ if (!job) return;
1763
+ recoveryJobId = job.job_id;
1764
+ messageId = job.assistant_message_id;
1765
+ scheduleResolve(latestContent);
1766
+ return;
1767
+ }
1743
1768
  if (type === "ai_message_update") {
1744
1769
  const msgId = p.user_message_id ?? p.userMessageId;
1745
1770
  if (msgId !== userMessageId && p.chat_id !== chatId) return;
@@ -3004,8 +3029,8 @@ async function buildTaskEventSystemMessage(params) {
3004
3029
  return message;
3005
3030
  }
3006
3031
  function taskUpdateJobBelongsToActiveTurn(job, activeChatId, taskEvents) {
3007
- if (taskEvents.some((event) => event.task_update_job_id === job.job_id)) return true;
3008
- return !job.chat_id || job.chat_id === activeChatId;
3032
+ void activeChatId;
3033
+ return taskEvents.some((event) => event.task_update_job_id === job.job_id);
3009
3034
  }
3010
3035
  function buildTaskUpdateJobPersistPayload(params) {
3011
3036
  const encryptedTaskPayload = pruneAbsentTaskPersistFields(params.encryptedTaskPayload);
@@ -5078,7 +5103,8 @@ var OpenMatesClient = class _OpenMatesClient {
5078
5103
  if (params.precollectResponse && !params.incognito) {
5079
5104
  precollectedResponse = ws.collectAiResponse(messageId, chatId, {
5080
5105
  onStream: params.onStream,
5081
- timeoutMs: params.responseTimeoutMs
5106
+ timeoutMs: params.responseTimeoutMs,
5107
+ recoveryTurnId: savedTurnId
5082
5108
  });
5083
5109
  }
5084
5110
  const confirmed = ws.waitForMessage(
@@ -5493,7 +5519,8 @@ var OpenMatesClient = class _OpenMatesClient {
5493
5519
  try {
5494
5520
  const resp = await (precollectedResponse ?? ws.collectAiResponse(messageId, chatId, {
5495
5521
  ...streamOpts,
5496
- timeoutMs: params.responseTimeoutMs
5522
+ timeoutMs: params.responseTimeoutMs,
5523
+ recoveryTurnId: savedTurnId
5497
5524
  }));
5498
5525
  assistantMessageId = resp.messageId;
5499
5526
  assistant = resp.content;
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getExtForLang,
4
4
  serializeToYaml
5
- } from "./chunk-7DQIT6E2.js";
5
+ } from "./chunk-T57PL63X.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-7DQIT6E2.js";
32
+ } from "./chunk-T57PL63X.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.6",
3
+ "version": "0.14.8-alpha.8",
4
4
  "description": "OpenMates CLI and SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",