@meistrari/chat-nuxt 1.1.2 → 1.2.0

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.
Files changed (151) hide show
  1. package/README.md +95 -11
  2. package/dist/module.d.mts +5 -0
  3. package/dist/module.json +2 -2
  4. package/dist/module.mjs +96 -23
  5. package/dist/runtime/components/chat/conversation-list.d.vue.ts +1 -0
  6. package/dist/runtime/components/chat/conversation-list.vue +22 -2
  7. package/dist/runtime/components/chat/conversation-list.vue.d.ts +1 -0
  8. package/dist/runtime/components/chat/message-list.d.vue.ts +1 -0
  9. package/dist/runtime/components/chat/message-list.vue +23 -2
  10. package/dist/runtime/components/chat/message-list.vue.d.ts +1 -0
  11. package/dist/runtime/composables/useChat.d.ts +2 -1
  12. package/dist/runtime/composables/useChat.js +32 -3
  13. package/dist/runtime/composables/useChatApi.js +2 -1
  14. package/dist/runtime/composables/useConversations.d.ts +3 -2
  15. package/dist/runtime/composables/useConversations.js +99 -11
  16. package/dist/runtime/composables/useEmbedConfig.d.ts +11 -6
  17. package/dist/runtime/composables/useEmbedConfig.js +35 -7
  18. package/dist/runtime/composables/useIDB.js +4 -0
  19. package/dist/runtime/composables/usePdf.d.ts +840 -1
  20. package/dist/runtime/composables/usePdf.js +21 -3
  21. package/dist/runtime/composables/useWorkspaceContextFiles.d.ts +3 -3
  22. package/dist/runtime/composables/useWorkspaceContextFiles.js +19 -10
  23. package/dist/runtime/composables/useWorkspaceCredentials.d.ts +3 -3
  24. package/dist/runtime/composables/useWorkspaceExternalSkills.d.ts +1 -1
  25. package/dist/runtime/composables/useWorkspaceExternalSkills.js +5 -6
  26. package/dist/runtime/composables/useWorkspacePersonalization.d.ts +1 -1
  27. package/dist/runtime/composables/useWorkspacePersonalization.js +4 -5
  28. package/dist/runtime/composables/useWorkspaceSettings.js +12 -9
  29. package/dist/runtime/embed/components/ChatConfigurationModal.d.vue.ts +25 -0
  30. package/dist/runtime/embed/components/ChatConfigurationModal.vue +373 -0
  31. package/dist/runtime/embed/components/ChatConfigurationModal.vue.d.ts +25 -0
  32. package/dist/runtime/embed/components/ChatEmbed.vue +12 -1
  33. package/dist/runtime/embed/components/ChatEmbedInner.vue +31 -16
  34. package/dist/runtime/embed/components/configuration/ChatConfigurationContextFilesTab.d.vue.ts +22 -0
  35. package/dist/runtime/embed/components/configuration/ChatConfigurationContextFilesTab.vue +133 -0
  36. package/dist/runtime/embed/components/configuration/ChatConfigurationContextFilesTab.vue.d.ts +22 -0
  37. package/dist/runtime/embed/components/configuration/ChatConfigurationCredentialsTab.d.vue.ts +10 -0
  38. package/dist/runtime/embed/components/configuration/ChatConfigurationCredentialsTab.vue +220 -0
  39. package/dist/runtime/embed/components/configuration/ChatConfigurationCredentialsTab.vue.d.ts +10 -0
  40. package/dist/runtime/embed/components/configuration/ChatConfigurationExternalSkillsTab.d.vue.ts +32 -0
  41. package/dist/runtime/embed/components/configuration/ChatConfigurationExternalSkillsTab.vue +222 -0
  42. package/dist/runtime/embed/components/configuration/ChatConfigurationExternalSkillsTab.vue.d.ts +32 -0
  43. package/dist/runtime/embed/components/configuration/ChatConfigurationKnowledgeSourcesTab.d.vue.ts +18 -0
  44. package/dist/runtime/embed/components/configuration/ChatConfigurationKnowledgeSourcesTab.vue +142 -0
  45. package/dist/runtime/embed/components/configuration/ChatConfigurationKnowledgeSourcesTab.vue.d.ts +18 -0
  46. package/dist/runtime/embed/components/configuration/ChatConfigurationPersonalizationTab.d.vue.ts +10 -0
  47. package/dist/runtime/embed/components/configuration/ChatConfigurationPersonalizationTab.vue +37 -0
  48. package/dist/runtime/embed/components/configuration/ChatConfigurationPersonalizationTab.vue.d.ts +10 -0
  49. package/dist/runtime/embed/components/configuration/ChatConfigurationTelaToolsTab.d.vue.ts +20 -0
  50. package/dist/runtime/embed/components/configuration/ChatConfigurationTelaToolsTab.vue +146 -0
  51. package/dist/runtime/embed/components/configuration/ChatConfigurationTelaToolsTab.vue.d.ts +20 -0
  52. package/dist/runtime/server/api/admin/trigger-usage-report.post.d.ts +4 -1
  53. package/dist/runtime/server/api/admin/trigger-usage-report.post.js +2 -0
  54. package/dist/runtime/server/api/chat/workspace/settings.get.d.ts +1 -1
  55. package/dist/runtime/server/api/chat/workspace/settings.get.js +1 -0
  56. package/dist/runtime/server/api/conversations/[id]/cancel.post.d.ts +4 -1
  57. package/dist/runtime/server/api/conversations/[id]/cancel.post.js +1 -0
  58. package/dist/runtime/server/api/conversations/[id]/clear.post.d.ts +1 -1
  59. package/dist/runtime/server/api/conversations/[id]/clear.post.js +1 -0
  60. package/dist/runtime/server/api/conversations/[id]/duplicate.post.d.ts +1 -1
  61. package/dist/runtime/server/api/conversations/[id]/duplicate.post.js +46 -12
  62. package/dist/runtime/server/api/conversations/[id]/files.get.d.ts +1 -1
  63. package/dist/runtime/server/api/conversations/[id]/files.get.js +2 -0
  64. package/dist/runtime/server/api/conversations/[id]/index.delete.d.ts +3 -1
  65. package/dist/runtime/server/api/conversations/[id]/index.delete.js +1 -0
  66. package/dist/runtime/server/api/conversations/[id]/index.get.d.ts +1 -1
  67. package/dist/runtime/server/api/conversations/[id]/index.get.js +1 -0
  68. package/dist/runtime/server/api/conversations/[id]/index.patch.d.ts +1 -1
  69. package/dist/runtime/server/api/conversations/[id]/index.patch.js +1 -0
  70. package/dist/runtime/server/api/conversations/[id]/messages/[messageId]/retry.post.d.ts +1 -1
  71. package/dist/runtime/server/api/conversations/[id]/messages/[messageId]/retry.post.js +2 -0
  72. package/dist/runtime/server/api/conversations/[id]/messages/index.get.d.ts +14 -1
  73. package/dist/runtime/server/api/conversations/[id]/messages/index.get.js +2 -0
  74. package/dist/runtime/server/api/conversations/[id]/messages/index.post.d.ts +4 -1
  75. package/dist/runtime/server/api/conversations/[id]/messages/index.post.js +2 -0
  76. package/dist/runtime/server/api/conversations/[id]/usage.get.d.ts +1 -1
  77. package/dist/runtime/server/api/conversations/[id]/usage.get.js +1 -0
  78. package/dist/runtime/server/api/conversations/generate-title.post.d.ts +3 -1
  79. package/dist/runtime/server/api/conversations/generate-title.post.js +2 -0
  80. package/dist/runtime/server/api/conversations/index.get.d.ts +1 -1
  81. package/dist/runtime/server/api/conversations/index.get.js +1 -0
  82. package/dist/runtime/server/api/conversations/index.post.d.ts +1 -1
  83. package/dist/runtime/server/api/conversations/index.post.js +1 -0
  84. package/dist/runtime/server/api/external-skills/discover.post.d.ts +1 -1
  85. package/dist/runtime/server/api/external-skills/discover.post.js +2 -0
  86. package/dist/runtime/server/api/github/disconnect.post.d.ts +3 -1
  87. package/dist/runtime/server/api/github/disconnect.post.js +2 -0
  88. package/dist/runtime/server/api/github/status.get.d.ts +1 -1
  89. package/dist/runtime/server/api/github/status.get.js +2 -0
  90. package/dist/runtime/server/api/tela/canvas.get.d.ts +1 -1
  91. package/dist/runtime/server/api/tela/canvas.get.js +1 -0
  92. package/dist/runtime/server/api/tela/projects.get.d.ts +1 -1
  93. package/dist/runtime/server/api/tela/projects.get.js +1 -0
  94. package/dist/runtime/server/api/tela/workspaces.get.d.ts +1 -1
  95. package/dist/runtime/server/api/tela/workspaces.get.js +1 -0
  96. package/dist/runtime/server/api/tela/workstations.get.d.ts +1 -1
  97. package/dist/runtime/server/api/tela/workstations.get.js +1 -0
  98. package/dist/runtime/server/api/vault/permalink-metadata.post.d.ts +5 -1
  99. package/dist/runtime/server/api/vault/permalink-metadata.post.js +2 -0
  100. package/dist/runtime/server/api/vault/resolve.post.d.ts +9 -1
  101. package/dist/runtime/server/api/vault/resolve.post.js +2 -0
  102. package/dist/runtime/server/api/vault/upload.post.d.ts +6 -1
  103. package/dist/runtime/server/api/vault/upload.post.js +2 -0
  104. package/dist/runtime/server/api/workspace/credentials/[id].delete.d.ts +3 -1
  105. package/dist/runtime/server/api/workspace/credentials/[id].delete.js +1 -0
  106. package/dist/runtime/server/api/workspace/credentials/[id].put.d.ts +1 -1
  107. package/dist/runtime/server/api/workspace/credentials/[id].put.js +1 -0
  108. package/dist/runtime/server/api/workspace/credentials/index.get.d.ts +1 -1
  109. package/dist/runtime/server/api/workspace/credentials/index.get.js +1 -0
  110. package/dist/runtime/server/api/workspace/credentials/index.post.d.ts +1 -1
  111. package/dist/runtime/server/api/workspace/credentials/index.post.js +1 -0
  112. package/dist/runtime/server/api/workspace/settings.get.d.ts +1 -1
  113. package/dist/runtime/server/api/workspace/settings.get.js +1 -0
  114. package/dist/runtime/server/api/workspace/settings.patch.d.ts +1 -1
  115. package/dist/runtime/server/api/workspace/settings.patch.js +1 -0
  116. package/dist/runtime/server/api/workspace/usage.get.d.ts +1 -1
  117. package/dist/runtime/server/api/workspace/usage.get.js +1 -0
  118. package/dist/runtime/server/db/index.js +1 -0
  119. package/dist/runtime/server/middleware/domain-validation.d.ts +1 -1
  120. package/dist/runtime/server/middleware/domain-validation.js +2 -0
  121. package/dist/runtime/server/middleware/request-logger.d.ts +1 -1
  122. package/dist/runtime/server/middleware/request-logger.js +1 -0
  123. package/dist/runtime/server/tasks/send-daily-usage-report.d.ts +1 -1
  124. package/dist/runtime/server/tasks/send-daily-usage-report.js +1 -0
  125. package/dist/runtime/server/utils/agent-api.d.ts +1 -1
  126. package/dist/runtime/server/utils/agent-api.js +2 -0
  127. package/dist/runtime/server/utils/auth-api.js +2 -0
  128. package/dist/runtime/server/utils/auth.d.ts +1 -1
  129. package/dist/runtime/server/utils/auth.js +1 -0
  130. package/dist/runtime/server/utils/tela-api.d.ts +1 -1
  131. package/dist/runtime/server/utils/tela-api.js +2 -0
  132. package/dist/runtime/server/utils/workspace.js +1 -0
  133. package/dist/runtime/types/chat.d.ts +2 -1
  134. package/dist/runtime/types/workspace-settings.d.ts +3 -0
  135. package/dist/runtime/types/workspace-settings.js +0 -0
  136. package/dist/runtime/utils/conversation-list-skeleton.d.ts +31 -0
  137. package/dist/runtime/utils/conversation-list-skeleton.js +12 -0
  138. package/dist/runtime/utils/file.js +42 -42
  139. package/dist/types.d.mts +2 -0
  140. package/package.json +24 -12
  141. package/dist/runtime/composables/PageNavigation.d.ts +0 -13
  142. package/dist/runtime/composables/PageNavigation.js +0 -18
  143. /package/dist/runtime/components/{TelaChat.d.vue.ts → MeistrariChatEmbed.d.vue.ts} +0 -0
  144. /package/dist/runtime/components/{TelaChat.vue → MeistrariChatEmbed.vue} +0 -0
  145. /package/dist/runtime/components/{TelaChat.vue.d.ts → MeistrariChatEmbed.vue.d.ts} +0 -0
  146. /package/dist/runtime/components/{pdf-preview.d.vue.ts → pdf-preview.client.d.vue.ts} +0 -0
  147. /package/dist/runtime/components/{pdf-preview.vue → pdf-preview.client.vue} +0 -0
  148. /package/dist/runtime/components/{pdf-preview.vue.d.ts → pdf-preview.client.vue.d.ts} +0 -0
  149. /package/dist/runtime/components/{pdf-viewer.d.vue.ts → pdf-viewer.client.d.vue.ts} +0 -0
  150. /package/dist/runtime/components/{pdf-viewer.vue → pdf-viewer.client.vue} +0 -0
  151. /package/dist/runtime/components/{pdf-viewer.vue.d.ts → pdf-viewer.client.vue.d.ts} +0 -0
@@ -1,7 +1,17 @@
1
1
  import * as Sentry from "@sentry/nuxt";
2
- import * as pdfjsLib from "pdfjs-dist";
3
- import { markRaw } from "vue";
4
- pdfjsLib.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${pdfjsLib.version}/build/pdf.worker.min.mjs`;
2
+ import { markRaw, onUnmounted, reactive, watch } from "vue";
3
+ let pdfjsLibPromise = null;
4
+ async function loadPdfjs() {
5
+ if (!import.meta.client)
6
+ return null;
7
+ if (!pdfjsLibPromise) {
8
+ pdfjsLibPromise = import("pdfjs-dist").then((lib) => {
9
+ lib.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${lib.version}/build/pdf.worker.min.mjs`;
10
+ return lib;
11
+ });
12
+ }
13
+ return pdfjsLibPromise;
14
+ }
5
15
  export function usePdf(url) {
6
16
  const state = reactive({
7
17
  pdfDoc: null,
@@ -13,6 +23,11 @@ export function usePdf(url) {
13
23
  async function loadPdf() {
14
24
  if (isUnmounted)
15
25
  return null;
26
+ const pdfjsLib = await loadPdfjs();
27
+ if (!pdfjsLib) {
28
+ state.isLoading = false;
29
+ return null;
30
+ }
16
31
  state.isLoading = true;
17
32
  state.loadError = null;
18
33
  try {
@@ -68,6 +83,9 @@ export function usePdf(url) {
68
83
  async function renderTextLayer(page, viewport, textLayer, highlight, highlightPage, pageNum) {
69
84
  if (isUnmounted)
70
85
  return;
86
+ const pdfjsLib = await loadPdfjs();
87
+ if (!pdfjsLib)
88
+ return;
71
89
  textLayer.innerHTML = "";
72
90
  textLayer.style.width = `${viewport.width}px`;
73
91
  textLayer.style.height = `${viewport.height}px`;
@@ -1,8 +1,7 @@
1
1
  import type { ContextFile } from '../server/db/schema.js';
2
- import type { WorkspaceSettings, WorkspaceSettingsUpdate } from './useWorkspaceSettings.js';
3
2
  export declare const MAX_FILES = 10;
4
3
  export declare const MAX_FILE_SIZE: number;
5
- export declare function useWorkspaceContextFiles(searchQuery: Ref<string>, currentContextFiles: Ref<readonly ContextFile[] | null | undefined> | ComputedRef<readonly ContextFile[] | null | undefined>, updateSettings: (updates: WorkspaceSettingsUpdate) => Promise<WorkspaceSettings>): {
4
+ export declare function useWorkspaceContextFiles(searchQuery: Ref<string>, currentContextFiles: Ref<readonly ContextFile[] | null | undefined> | ComputedRef<readonly ContextFile[] | null | undefined>): {
6
5
  pendingFiles: any;
7
6
  filteredContextFiles: any;
8
7
  filteredPendingFiles: any;
@@ -11,9 +10,10 @@ export declare function useWorkspaceContextFiles(searchQuery: Ref<string>, curre
11
10
  maxFiles: number;
12
11
  handleFileSelect: (event: Event) => void;
13
12
  removePendingFile: (file: File) => void;
14
- removeContextFile: (url: string) => Promise<void>;
13
+ removeContextFile: (url: string) => void;
15
14
  getFileType: (fileName: string) => string;
16
15
  initialize: () => void;
17
16
  getPendingFiles: () => File[];
17
+ getKeptContextFiles: () => ContextFile[];
18
18
  clearPendingFiles: () => void;
19
19
  };
@@ -1,14 +1,16 @@
1
1
  export const MAX_FILES = 10;
2
2
  export const MAX_FILE_SIZE = 10 * 1024 * 1024;
3
- export function useWorkspaceContextFiles(searchQuery, currentContextFiles, updateSettings) {
3
+ export function useWorkspaceContextFiles(searchQuery, currentContextFiles) {
4
4
  const pendingFiles = ref([]);
5
+ const removedUrls = ref(/* @__PURE__ */ new Set());
6
+ const effectiveContextFiles = computed(
7
+ () => (currentContextFiles.value ?? []).filter((file) => !removedUrls.value.has(file.url))
8
+ );
5
9
  const filteredContextFiles = computed(() => {
6
- if (!currentContextFiles.value)
7
- return [];
8
10
  if (!searchQuery.value.trim())
9
- return currentContextFiles.value;
11
+ return effectiveContextFiles.value;
10
12
  const query = searchQuery.value.toLowerCase();
11
- return currentContextFiles.value.filter(
13
+ return effectiveContextFiles.value.filter(
12
14
  (file) => file.name.toLowerCase().includes(query)
13
15
  );
14
16
  });
@@ -21,10 +23,10 @@ export function useWorkspaceContextFiles(searchQuery, currentContextFiles, updat
21
23
  );
22
24
  });
23
25
  const currentFileCount = computed(
24
- () => (currentContextFiles.value?.length ?? 0) + pendingFiles.value.length
26
+ () => effectiveContextFiles.value.length + pendingFiles.value.length
25
27
  );
26
28
  const hasChanges = computed(
27
- () => pendingFiles.value.length > 0
29
+ () => pendingFiles.value.length > 0 || removedUrls.value.size > 0
28
30
  );
29
31
  function handleFileSelect(event) {
30
32
  const target = event.target;
@@ -40,21 +42,27 @@ export function useWorkspaceContextFiles(searchQuery, currentContextFiles, updat
40
42
  if (idx !== -1)
41
43
  pendingFiles.value = pendingFiles.value.filter((_, i) => i !== idx);
42
44
  }
43
- async function removeContextFile(url) {
44
- const newFiles = (currentContextFiles.value ?? []).filter((f) => f.url !== url);
45
- await updateSettings({ contextFiles: newFiles.length > 0 ? newFiles : null });
45
+ function removeContextFile(url) {
46
+ const next = new Set(removedUrls.value);
47
+ next.add(url);
48
+ removedUrls.value = next;
46
49
  }
47
50
  function getFileType(fileName) {
48
51
  return fileName.split(".").pop()?.toUpperCase() ?? "";
49
52
  }
50
53
  function initialize() {
51
54
  pendingFiles.value = [];
55
+ removedUrls.value = /* @__PURE__ */ new Set();
52
56
  }
53
57
  function getPendingFiles() {
54
58
  return [...pendingFiles.value];
55
59
  }
60
+ function getKeptContextFiles() {
61
+ return [...effectiveContextFiles.value];
62
+ }
56
63
  function clearPendingFiles() {
57
64
  pendingFiles.value = [];
65
+ removedUrls.value = /* @__PURE__ */ new Set();
58
66
  }
59
67
  return {
60
68
  pendingFiles: readonly(pendingFiles),
@@ -69,6 +77,7 @@ export function useWorkspaceContextFiles(searchQuery, currentContextFiles, updat
69
77
  getFileType,
70
78
  initialize,
71
79
  getPendingFiles,
80
+ getKeptContextFiles,
72
81
  clearPendingFiles
73
82
  };
74
83
  }
@@ -2,14 +2,14 @@ import type { WorkspaceCredential } from '../types/credential.js';
2
2
  export declare function useWorkspaceCredentials(searchQuery?: Ref<string>): {
3
3
  credentials: any;
4
4
  loading: any;
5
- fetchCredentials: () => Promise<any>;
5
+ fetchCredentials: () => Promise<WorkspaceCredential[]>;
6
6
  createCredential: (payload: {
7
7
  key: string;
8
8
  value: string;
9
- }) => Promise<any>;
9
+ }) => Promise<WorkspaceCredential>;
10
10
  updateCredential: (id: string, payload: {
11
11
  value: string;
12
- }) => Promise<any>;
12
+ }) => Promise<WorkspaceCredential>;
13
13
  deleteCredential: (id: string) => Promise<void>;
14
14
  filteredCredentials: any;
15
15
  credentialModalOpen: any;
@@ -1,5 +1,5 @@
1
1
  import type { ExternalSkill } from '../server/db/schema.js';
2
- export declare function useWorkspaceExternalSkills(searchQuery?: Ref<string>): {
2
+ export declare function useWorkspaceExternalSkills(currentExternalSkills: Ref<readonly ExternalSkill[] | null | undefined> | ComputedRef<readonly ExternalSkill[] | null | undefined>, searchQuery?: Ref<string>): {
3
3
  displayedSkills: any;
4
4
  filteredSkills: any;
5
5
  hasChanges: any;
@@ -1,15 +1,14 @@
1
- export function useWorkspaceExternalSkills(searchQuery) {
2
- const { settings } = useWorkspaceSettings();
1
+ export function useWorkspaceExternalSkills(currentExternalSkills, searchQuery) {
3
2
  const { user } = useTelaApplicationAuth();
4
3
  const { connection: skillsConnection, fetchConnection: fetchGitHubConnection, connect: connectGitHub } = useGitHubSkills();
5
- const pendingSkills = useState("workspace-external-skills-pending", () => []);
6
- const removedRefs = useState("workspace-external-skills-removed", () => []);
4
+ const pendingSkills = ref([]);
5
+ const removedRefs = ref([]);
7
6
  const skillModalOpen = ref(false);
8
7
  const skillRefInput = ref("");
9
8
  const skillError = ref("");
10
9
  const discoveringSkills = ref(false);
11
10
  const displayedSkills = computed(() => {
12
- const current = (settings.value?.externalSkills ?? []).filter((s) => !removedRefs.value.includes(s.ref));
11
+ const current = (currentExternalSkills.value ?? []).filter((s) => !removedRefs.value.includes(s.ref));
13
12
  return [...current, ...pendingSkills.value];
14
13
  });
15
14
  const filteredSkills = computed(() => {
@@ -38,7 +37,7 @@ export function useWorkspaceExternalSkills(searchQuery) {
38
37
  removedRefs.value = [...removedRefs.value, ref2];
39
38
  }
40
39
  function buildExternalSkills() {
41
- const currentSkills = (settings.value?.externalSkills ?? []).filter((s) => !removedRefs.value.includes(s.ref)).map((s) => ({
40
+ const currentSkills = (currentExternalSkills.value ?? []).filter((s) => !removedRefs.value.includes(s.ref)).map((s) => ({
42
41
  ...s,
43
42
  allowedTools: [...s.allowedTools],
44
43
  addedBy: { ...s.addedBy }
@@ -1,4 +1,4 @@
1
- export declare function useWorkspacePersonalization(): {
1
+ export declare function useWorkspacePersonalization(currentSystemMessage: Ref<string | null | undefined> | ComputedRef<string | null | undefined>): {
2
2
  localSystemMessage: any;
3
3
  hasChanges: any;
4
4
  getSystemMessage: () => string | null;
@@ -1,14 +1,13 @@
1
- export function useWorkspacePersonalization() {
2
- const { settings } = useWorkspaceSettings();
3
- const localSystemMessage = useState("workspace-personalization-system-message", () => "");
1
+ export function useWorkspacePersonalization(currentSystemMessage) {
2
+ const localSystemMessage = ref("");
4
3
  const hasChanges = computed(
5
- () => localSystemMessage.value !== (settings.value?.systemMessage ?? "")
4
+ () => localSystemMessage.value !== (currentSystemMessage.value ?? "")
6
5
  );
7
6
  function getSystemMessage() {
8
7
  return localSystemMessage.value.trim() || null;
9
8
  }
10
9
  function initialize() {
11
- localSystemMessage.value = settings.value?.systemMessage ?? "";
10
+ localSystemMessage.value = currentSystemMessage.value ?? "";
12
11
  }
13
12
  return {
14
13
  localSystemMessage,
@@ -2,7 +2,8 @@ import * as Sentry from "@sentry/nuxt";
2
2
  export function useWorkspaceSettings() {
3
3
  const chatApi = useChatApi();
4
4
  const embedConfig = useEmbedConfig();
5
- const workspaceScope = computed(() => embedConfig?.workspaceId.value.trim() || "default");
5
+ const { activeOrganization } = useTelaApplicationAuth();
6
+ const workspaceScope = computed(() => embedConfig?.workspaceId.value.trim() || activeOrganization.value?.id?.trim() || "default");
6
7
  const settingsBuckets = useState("workspace-settings", () => ({}));
7
8
  const loadingBuckets = useState("workspace-settings-loading", () => ({}));
8
9
  const errorBuckets = useState("workspace-settings-error", () => ({}));
@@ -35,7 +36,8 @@ export function useWorkspaceSettings() {
35
36
  });
36
37
  const isModalOpen = useState("workspace-settings-modal-open", () => false);
37
38
  const initialTab = useState("workspace-settings-initial-tab", () => null);
38
- if (embedConfig !== null && embedConfig.workspaceSettings.value !== void 0) {
39
+ const hasWorkspaceSettingsOverride = computed(() => embedConfig?.workspaceSettings.value !== void 0);
40
+ if (embedConfig !== null && hasWorkspaceSettingsOverride.value) {
39
41
  settings.value = embedConfig.workspaceSettings.value;
40
42
  }
41
43
  if (embedConfig !== null) {
@@ -64,7 +66,9 @@ export function useWorkspaceSettings() {
64
66
  try {
65
67
  const currentSettings = settings.value;
66
68
  let data;
67
- if (embedConfig !== null) {
69
+ if (hasWorkspaceSettingsOverride.value) {
70
+ return settings.value;
71
+ } else if (embedConfig !== null) {
68
72
  data = await $fetch(
69
73
  chatApi.path("/workspace/settings"),
70
74
  chatApi.withChatHeaders()
@@ -88,7 +92,7 @@ export function useWorkspaceSettings() {
88
92
  externalSkills: data.externalSkills
89
93
  };
90
94
  if (JSON.stringify(hydratedSettings) !== JSON.stringify(trustedSettings)) {
91
- console.warn("[TelaChat] Hydrated workspace settings differ from trusted server settings");
95
+ console.warn("[MeistrariChatEmbed] Hydrated workspace settings differ from trusted server settings");
92
96
  }
93
97
  }
94
98
  settings.value = data;
@@ -102,15 +106,14 @@ export function useWorkspaceSettings() {
102
106
  }
103
107
  }
104
108
  async function updateSettings(updates) {
105
- if (embedConfig !== null)
109
+ if (hasWorkspaceSettingsOverride.value)
106
110
  return settings.value;
107
111
  loading.value = true;
108
112
  error.value = null;
109
113
  try {
110
- const data = await $fetch("/api/workspace/settings", {
111
- method: "PATCH",
112
- body: updates
113
- });
114
+ const path = embedConfig !== null ? chatApi.path("/workspace/settings") : "/api/workspace/settings";
115
+ const options = embedConfig !== null ? chatApi.withChatHeaders({ method: "PATCH", body: updates }) : { method: "PATCH", body: updates };
116
+ const data = await $fetch(path, options);
114
117
  settings.value = data;
115
118
  return data;
116
119
  } catch (e) {
@@ -0,0 +1,25 @@
1
+ import type { DeepReadonly } from 'vue';
2
+ import type { WorkspaceSettings, WorkspaceSettingsUpdate } from '../../composables/useWorkspaceSettings.js';
3
+ export type ChatConfigurationTab = 'personalization' | 'context-files' | 'knowledge-sources' | 'tela-tools' | 'external-skills' | 'credentials';
4
+ export type ChatConfigurationSavePayload = {
5
+ updates: WorkspaceSettingsUpdate;
6
+ onSaved: () => void;
7
+ };
8
+ type __VLS_Props = {
9
+ open: boolean;
10
+ settings?: DeepReadonly<WorkspaceSettings> | WorkspaceSettings | null;
11
+ initialTab?: ChatConfigurationTab;
12
+ saving?: boolean;
13
+ };
14
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
15
+ save: (payload: ChatConfigurationSavePayload) => any;
16
+ "update:open": (value: boolean) => any;
17
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
18
+ onSave?: ((payload: ChatConfigurationSavePayload) => any) | undefined;
19
+ "onUpdate:open"?: ((value: boolean) => any) | undefined;
20
+ }>, {
21
+ initialTab: ChatConfigurationTab;
22
+ saving: boolean;
23
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
24
+ declare const _default: typeof __VLS_export;
25
+ export default _default;