openmates 0.18.0-alpha.30 → 0.18.0-alpha.31

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.
@@ -10602,6 +10602,7 @@ var OpenMatesClient = class _OpenMatesClient {
10602
10602
  assertNoConnectedAccountSecretLeak(connectedAccountTokenRefs);
10603
10603
  const piiMappings = params.piiMappings ?? [];
10604
10604
  let chatKeyBytes = null;
10605
+ let activeFocusId = null;
10605
10606
  let encryptedChatKey = null;
10606
10607
  let chatSlugLookupKey = null;
10607
10608
  let baselineMessagesV = 0;
@@ -10632,6 +10633,14 @@ var OpenMatesClient = class _OpenMatesClient {
10632
10633
  if (encKey) {
10633
10634
  chatKeyBytes = await decryptBytesWithAesGcm(encKey, wrappingKey);
10634
10635
  encryptedChatKey = encKey;
10636
+ if (!chatKeyBytes) throw new Error("Could not decrypt the saved chat key.");
10637
+ const encryptedFocusId = chat.details.encrypted_active_focus_id;
10638
+ if (typeof encryptedFocusId === "string" && encryptedFocusId) {
10639
+ activeFocusId = await decryptWithAesGcmCombined(encryptedFocusId, chatKeyBytes);
10640
+ if (!activeFocusId) {
10641
+ throw new Error("Could not decrypt the chat's active focus. Sync before sending again.");
10642
+ }
10643
+ }
10635
10644
  }
10636
10645
  }
10637
10646
  if (!chatKeyBytes || !encryptedChatKey) {
@@ -10639,11 +10648,29 @@ var OpenMatesClient = class _OpenMatesClient {
10639
10648
  }
10640
10649
  }
10641
10650
  }
10651
+ let focusPersistence = Promise.resolve();
10652
+ let focusPersistenceError = null;
10653
+ ws.onMessageType("focus_mode_activated", (event) => {
10654
+ if (event.chat_id !== chatId || !event.focus_id || !chatKeyBytes || params.incognito) return;
10655
+ const focusId = event.focus_id;
10656
+ const key = chatKeyBytes;
10657
+ focusPersistence = focusPersistence.then(async () => {
10658
+ const encryptedFocusId = await encryptWithAesGcmCombined(focusId, key);
10659
+ await ws.sendAsync("update_encrypted_active_focus_id", {
10660
+ chat_id: chatId,
10661
+ encrypted_active_focus_id: encryptedFocusId
10662
+ });
10663
+ }).catch((error) => {
10664
+ focusPersistenceError = error;
10665
+ });
10666
+ });
10642
10667
  const clientCapabilities = taskUpdateJobsEnabled ? ["task_update_jobs"] : [];
10643
10668
  const messagePayload = {
10644
10669
  chat_id: chatId,
10645
10670
  ...teamId ? { team_id: teamId } : {},
10646
10671
  client_capabilities: clientCapabilities,
10672
+ // Only decrypted current metadata restores focus; history is never authority.
10673
+ active_focus_id: activeFocusId,
10647
10674
  is_incognito: Boolean(params.incognito),
10648
10675
  message: {
10649
10676
  message_id: messageId,
@@ -11393,8 +11420,10 @@ var OpenMatesClient = class _OpenMatesClient {
11393
11420
  clearSyncCache(teamId);
11394
11421
  }
11395
11422
  } finally {
11423
+ await focusPersistence;
11396
11424
  ws.close();
11397
11425
  }
11426
+ if (focusPersistenceError) throw focusPersistenceError;
11398
11427
  }
11399
11428
  const mateName = category ? MATE_NAMES[category] ?? null : null;
11400
11429
  return {
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  resolveProjectContext,
13
13
  serializeToYaml,
14
14
  shouldRequireTrustedAccountGuard
15
- } from "./chunk-QLI5D3XI.js";
15
+ } from "./chunk-R4YXGJWV.js";
16
16
  import "./chunk-IWKP55ZB.js";
17
17
  import "./chunk-BBKJZ23O.js";
18
18
  export {
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ import {
42
42
  selectAssistantMessagesForSpeech,
43
43
  serializeToYaml,
44
44
  summarizeAssistantSpeech
45
- } from "./chunk-QLI5D3XI.js";
45
+ } from "./chunk-R4YXGJWV.js";
46
46
  import "./chunk-IWKP55ZB.js";
47
47
  import "./chunk-BBKJZ23O.js";
48
48
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmates",
3
- "version": "0.18.0-alpha.30",
3
+ "version": "0.18.0-alpha.31",
4
4
  "description": "OpenMates CLI and SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",