openmates 0.27.0-alpha.36 → 0.27.0-alpha.38

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.
@@ -472,6 +472,7 @@ function clearSessionLocked() {
472
472
  rmSync(filePath);
473
473
  }
474
474
  rmSync(join(getStateDir(), "tui_workspace_cache.json"), { force: true });
475
+ rmSync(join(getStateDir(), "chat_model_preferences.json"), { force: true });
475
476
  if (cleanupError) throw cleanupError;
476
477
  }
477
478
  function purgeLocalPrivateData() {
@@ -807,10 +807,14 @@ function normalizeTaskPriority(value) {
807
807
  function taskPriorityLevel(priority) {
808
808
  return PRIORITY_LEVELS[Math.max(0, Math.min(4, Math.trunc(priority ?? 0)))] ?? "none";
809
809
  }
810
- async function buildCreateUserTaskInput(masterKey, input) {
810
+ async function buildCreateUserTaskInput(masterKey, input, teamKey) {
811
811
  if (input.chatId && input.externalChat) throw new Error("A task cannot use both native chat and external chat context.");
812
+ if (input.teamId && !teamKey) throw new Error("Team Task creation requires the Team key.");
813
+ if (input.teamId && (input.chatId || input.projectIds?.length || input.planId || input.externalChat)) {
814
+ throw new Error("Team Task creation with linked chats, Projects, Plans or external chats is not supported.");
815
+ }
812
816
  const taskKey = randomBytes(32);
813
- const encryptedTaskKey = await encryptBytesWithAesGcm(taskKey, masterKey);
817
+ const workspaceTaskKey = await encryptBytesWithAesGcm(taskKey, teamKey ?? masterKey);
814
818
  const timestamp = nowSeconds();
815
819
  const assignee = parseAssignee(input.assign);
816
820
  const linkedProjectIds = input.projectIds ?? [];
@@ -819,20 +823,32 @@ async function buildCreateUserTaskInput(masterKey, input) {
819
823
  const slugMetadata = await buildEncryptedObjectSlugMetadata({
820
824
  value: input.slug ?? input.title,
821
825
  encryptionKey: taskKey,
822
- lookupKey: masterKey
826
+ lookupKey: teamKey ?? masterKey
823
827
  });
824
828
  return {
825
829
  task_id: input.taskId ?? randomUUIDCompat(),
826
830
  short_id: void 0,
827
831
  version: 1,
828
- encrypted_task_key: encryptedTaskKey,
832
+ encrypted_task_key: workspaceTaskKey,
833
+ ...input.teamId ? {
834
+ team_id: input.teamId,
835
+ key_wrappers: [
836
+ {
837
+ key_type: "team",
838
+ hashed_team_id: createHash2("sha256").update(input.teamId).digest("hex"),
839
+ team_key_epoch: 1,
840
+ encrypted_task_key: workspaceTaskKey,
841
+ created_at: timestamp
842
+ }
843
+ ]
844
+ } : {},
829
845
  encrypted_slug: slugMetadata.encrypted_slug,
830
846
  slug_lookup_hash: slugMetadata.slug_lookup_hash,
831
847
  encrypted_title: await encryptWithAesGcmCombined(input.title, taskKey),
832
848
  encrypted_description: await encryptWithAesGcmCombined(input.description ?? "", taskKey),
833
849
  encrypted_labels: await encryptWithAesGcmCombined(JSON.stringify(labels), taskKey),
834
850
  encrypted_tags: await encryptWithAesGcmCombined(JSON.stringify(labels), taskKey),
835
- label_hashes: labelHashes(masterKey, labels),
851
+ label_hashes: labelHashes(teamKey ?? masterKey, labels),
836
852
  encrypted_linked_project_ids: await encryptWithAesGcmCombined(JSON.stringify(linkedProjectIds), taskKey),
837
853
  status,
838
854
  assignee_type: assignee.assigneeType,