@sveda-ai/vue 0.3.1 → 0.3.2

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 (80) hide show
  1. package/README.md +1 -1
  2. package/dist/appearance.d.ts +4 -53
  3. package/dist/appearance.d.ts.map +1 -1
  4. package/dist/composables/useSvedaChat.d.ts +7 -149
  5. package/dist/composables/useSvedaChat.d.ts.map +1 -1
  6. package/dist/composables/useSvedaChatLayout.d.ts +1 -1
  7. package/dist/composables/useSvedaChatLayout.d.ts.map +1 -1
  8. package/dist/composables/useSvedaChatPage.d.ts +6 -91
  9. package/dist/composables/useSvedaChatPage.d.ts.map +1 -1
  10. package/dist/composables/useSvedaPrompts.d.ts +1 -1
  11. package/dist/composables/useSvedaPrompts.d.ts.map +1 -1
  12. package/dist/composables/useSvedaStreaming.d.ts +3 -6
  13. package/dist/composables/useSvedaStreaming.d.ts.map +1 -1
  14. package/dist/index.d.ts +3 -10
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +3035 -4437
  17. package/dist/plugin.d.ts.map +1 -1
  18. package/dist/styles.css +2 -1
  19. package/dist/ui/sheet/index.d.ts +1 -1
  20. package/dist/ui/toast/Toast.vue.d.ts +2 -2
  21. package/dist/vue.css +1 -1
  22. package/package.json +20 -28
  23. package/src/appearance.ts +44 -652
  24. package/src/components/chat/ChatMessageActivityBlock.vue +1 -1
  25. package/src/components/chat/ChatMessageItem.vue +3 -3
  26. package/src/components/chat/ChatMessageList.vue +1 -1
  27. package/src/components/shell/SvedaTabs.vue +1 -1
  28. package/src/composables/useSvedaChat.ts +53 -573
  29. package/src/composables/useSvedaChatLayout.ts +1 -1
  30. package/src/composables/useSvedaChatPage.ts +1 -1
  31. package/src/composables/useSvedaPrompts.ts +1 -1
  32. package/src/composables/useSvedaStreaming.ts +41 -368
  33. package/src/index.ts +14 -11
  34. package/src/plugin.ts +1 -3
  35. package/src/theme.test.mjs +5 -4
  36. package/dist/i18n/locales/en.d.ts +0 -4
  37. package/dist/i18n/locales/en.d.ts.map +0 -1
  38. package/dist/i18n/locales/ru.d.ts +0 -4
  39. package/dist/i18n/locales/ru.d.ts.map +0 -1
  40. package/dist/lib/assistantMessage.d.ts +0 -90
  41. package/dist/lib/assistantMessage.d.ts.map +0 -1
  42. package/dist/lib/chatHistoryMerge.d.ts +0 -20
  43. package/dist/lib/chatHistoryMerge.d.ts.map +0 -1
  44. package/dist/lib/chatI18nKeys.d.ts +0 -2
  45. package/dist/lib/chatI18nKeys.d.ts.map +0 -1
  46. package/dist/lib/chatMessageVisibility.d.ts +0 -6
  47. package/dist/lib/chatMessageVisibility.d.ts.map +0 -1
  48. package/dist/lib/chatResize.d.ts +0 -42
  49. package/dist/lib/chatResize.d.ts.map +0 -1
  50. package/dist/lib/chatTabs.d.ts +0 -9
  51. package/dist/lib/chatTabs.d.ts.map +0 -1
  52. package/dist/lib/chatTitle.d.ts +0 -3
  53. package/dist/lib/chatTitle.d.ts.map +0 -1
  54. package/dist/lib/chatUiStorage.d.ts +0 -6
  55. package/dist/lib/chatUiStorage.d.ts.map +0 -1
  56. package/dist/lib/finalizeMessages.d.ts +0 -21
  57. package/dist/lib/finalizeMessages.d.ts.map +0 -1
  58. package/dist/lib/markdown.d.ts +0 -8
  59. package/dist/lib/markdown.d.ts.map +0 -1
  60. package/dist/lib/modelLabels.d.ts +0 -3
  61. package/dist/lib/modelLabels.d.ts.map +0 -1
  62. package/dist/lib/toolConfirmation.d.ts +0 -11
  63. package/dist/lib/toolConfirmation.d.ts.map +0 -1
  64. package/dist/lib/userMessage.d.ts +0 -17
  65. package/dist/lib/userMessage.d.ts.map +0 -1
  66. package/src/i18n/locales/en.ts +0 -64
  67. package/src/i18n/locales/ru.ts +0 -65
  68. package/src/lib/assistantMessage.ts +0 -439
  69. package/src/lib/chatHistoryMerge.ts +0 -93
  70. package/src/lib/chatI18nKeys.ts +0 -64
  71. package/src/lib/chatMessageVisibility.ts +0 -92
  72. package/src/lib/chatResize.ts +0 -123
  73. package/src/lib/chatTabs.ts +0 -54
  74. package/src/lib/chatTitle.ts +0 -30
  75. package/src/lib/chatUiStorage.ts +0 -69
  76. package/src/lib/finalizeMessages.ts +0 -81
  77. package/src/lib/markdown.ts +0 -90
  78. package/src/lib/modelLabels.ts +0 -24
  79. package/src/lib/toolConfirmation.ts +0 -31
  80. package/src/lib/userMessage.ts +0 -55
@@ -10,7 +10,7 @@ import {
10
10
  SVEDA_CHAT_LAYOUT_MIN_HEIGHT,
11
11
  SVEDA_CHAT_LAYOUT_MIN_WIDTH,
12
12
  SVEDA_HISTORY_SIDEBAR_WIDTH,
13
- } from '../lib/chatResize';
13
+ } from '@sveda-ai/chat';
14
14
  import { SvedaFillHostKey, SvedaHostEmbedKey } from '../plugin';
15
15
 
16
16
  const CHAT_STORAGE_KEY = 'sveda.chat-dimensions';
@@ -13,7 +13,7 @@ import { useSvedaPrompts, type SvedaQuickPromptItem } from './useSvedaPrompts';
13
13
  import { useSvedaScroll, type SvedaScrollContainer } from './useSvedaScroll';
14
14
  import { useSvedaShell, type SvedaBrandInfo } from './useSvedaShell';
15
15
  import { useSvedaStreaming } from './useSvedaStreaming';
16
- import { hasPendingToolConfirmation } from '../lib/toolConfirmation';
16
+ import { hasPendingToolConfirmation } from '@sveda-ai/chat';
17
17
 
18
18
  export const svedaErrorMessage = (error: unknown, fallback: string): string => {
19
19
  if (error instanceof Error && error.message.trim()) {
@@ -1,5 +1,5 @@
1
1
  import { computed, type ComputedRef, type Ref } from 'vue';
2
- import { userMessageHasVisibleContent, type SvedaUserMessageLike } from '../lib/userMessage';
2
+ import { userMessageHasVisibleContent, type SvedaUserMessageLike } from '@sveda-ai/chat';
3
3
 
4
4
  export interface SvedaQuickPromptItem {
5
5
  label: string;
@@ -1,15 +1,13 @@
1
- import type {
2
- SvedaChatSession,
3
- SvedaClient,
4
- SvedaDisplayMessage,
5
- SvedaMessagePart,
6
- SvedaSendOptions,
7
- SvedaSessionStatus,
8
- } from '@sveda-ai/core';
9
- import type { SvedaContextUsageEvent, SvedaMaxStepsEvent, SvedaToolProgressEvent } from '@sveda-ai/protocol';
10
- import { computed, inject, nextTick, onUnmounted, ref, watch, type Ref } from 'vue';
1
+ import {
2
+ createSvedaStreaming,
3
+ type SvedaSendPayload,
4
+ type SvedaStreamingOptions as HeadlessStreamingOptions,
5
+ type SvedaStreamingStore as HeadlessStreamingStore,
6
+ } from '@sveda-ai/chat';
7
+ import type { SvedaClient, SvedaDisplayMessage, SvedaSendOptions } from '@sveda-ai/core';
8
+ import type { SvedaContextUsageEvent, SvedaToolProgressEvent } from '@sveda-ai/protocol';
9
+ import { computed, inject, onUnmounted, ref, watch, type Ref } from 'vue';
11
10
  import { useSvedaT } from '../i18n/index';
12
- import { deriveProvisionalChatTitle, isChatTitlePlaceholder } from '../lib/chatTitle';
13
11
  import { SvedaBeforeSendKey, SvedaClientKey } from '../plugin';
14
12
 
15
13
  export interface SvedaStreamingStore {
@@ -35,13 +33,7 @@ export interface SvedaStreamingOptions {
35
33
  onDone?: (chatId: string) => void;
36
34
  }
37
35
 
38
- export type SvedaSendPayload =
39
- | string
40
- | {
41
- displayText: string;
42
- promptText: string;
43
- attachmentNames?: string[];
44
- };
36
+ export type { SvedaSendPayload };
45
37
 
46
38
  export function useSvedaStreaming(
47
39
  store: SvedaStreamingStore,
@@ -59,381 +51,62 @@ export function useSvedaStreaming(
59
51
  const thinkingMessage = ref('');
60
52
  const streamingChatIds = ref(new Set<string>());
61
53
  const unreadChatIds = ref(new Set<string>());
62
- const statusByChatId = ref<Record<string, SvedaSessionStatus>>({});
63
54
 
64
- const subscriptions = new Map<string, Array<() => void>>();
65
- const displayTextOverrides = new Map<string, Map<string, string>>();
66
-
67
- const setChatStreaming = (chatId: string, streaming: boolean) => {
68
- const next = new Set(streamingChatIds.value);
69
- if (streaming) {
70
- next.add(chatId);
71
- } else {
72
- next.delete(chatId);
73
- }
74
- streamingChatIds.value = next;
75
- };
76
-
77
- const clearChatUnread = (chatId?: string | null) => {
78
- if (!chatId) {
79
- return;
80
- }
81
- const next = new Set(unreadChatIds.value);
82
- next.delete(chatId);
83
- unreadChatIds.value = next;
55
+ const headlessStore: HeadlessStreamingStore = {
56
+ getCurrentChat: () => store.currentChat.value,
57
+ setChatMessages: store.setChatMessages,
58
+ setChatTitle: store.setChatTitle,
59
+ refreshChatTitleFromServer: store.refreshChatTitleFromServer,
60
+ incrementChatTokens: store.incrementChatTokens,
61
+ setChatContextWindowTokens: store.setChatContextWindowTokens,
84
62
  };
85
63
 
86
- const resolveNewChatLabel = () => {
87
- if (typeof options.newChatLabel === 'function') {
88
- return options.newChatLabel();
89
- }
90
- return t('newChat');
91
- };
92
-
93
- const applyProvisionalChatTitle = (chatId: string, userRequest: string) => {
94
- if (!store.currentChat.value || store.currentChat.value.id !== chatId) {
95
- return;
96
- }
97
-
98
- const newChatLabel = resolveNewChatLabel();
99
- if (!isChatTitlePlaceholder((store.currentChat.value.title || '').trim(), newChatLabel)) {
100
- return;
101
- }
102
-
103
- const provisionalTitle = deriveProvisionalChatTitle(userRequest);
104
- if (provisionalTitle) {
105
- store.setChatTitle(chatId, provisionalTitle);
106
- }
64
+ const headlessOptions: HeadlessStreamingOptions = {
65
+ ...options,
66
+ translate: t,
67
+ beforeSend,
107
68
  };
108
69
 
109
- const scheduleChatTitleRefresh = (chatId: string) => {
110
- const newChatLabel = resolveNewChatLabel();
111
- const delays = [800, 2500, 6000];
70
+ const controller = createSvedaStreaming(client, headlessStore, scrollToBottom, headlessOptions);
112
71
 
113
- delays.forEach(delay => {
114
- setTimeout(async () => {
115
- const title = await store.refreshChatTitleFromServer(chatId);
116
- if (!title || isChatTitlePlaceholder(title, newChatLabel)) {
117
- return;
118
- }
119
- store.setChatTitle(chatId, title);
120
- }, delay);
121
- });
72
+ const sync = () => {
73
+ const state = controller.getState();
74
+ isThinking.value = state.isThinking;
75
+ thinkingMessage.value = state.thinkingMessage;
76
+ streamingChatIds.value = state.streamingChatIds;
77
+ unreadChatIds.value = state.unreadChatIds;
122
78
  };
123
79
 
124
- const setChatStatus = (chatId: string, status: SvedaSessionStatus) => {
125
- const previous = statusByChatId.value[chatId];
126
- statusByChatId.value = {
127
- ...statusByChatId.value,
128
- [chatId]: status,
129
- };
130
-
131
- const wasStreaming = previous === 'streaming' || previous === 'submitted';
132
- const isStreamingNow = status === 'streaming' || status === 'submitted';
133
- setChatStreaming(chatId, isStreamingNow);
134
-
135
- if (wasStreaming && !isStreamingNow && store.currentChat.value?.id !== chatId) {
136
- const next = new Set(unreadChatIds.value);
137
- next.add(chatId);
138
- unreadChatIds.value = next;
139
- }
140
-
141
- if (isStreamingNow) {
142
- clearChatUnread(chatId);
143
- }
144
- };
145
-
146
- const applyDisplayOverrides = (
147
- chatId: string,
148
- messages: SvedaDisplayMessage[]
149
- ): SvedaDisplayMessage[] => {
150
- const overrides = displayTextOverrides.get(chatId);
151
- if (!overrides || overrides.size === 0) {
152
- return messages;
153
- }
154
-
155
- return messages.map(message => {
156
- const override = overrides.get(message.id);
157
- if (override === undefined || message.role !== 'user') {
158
- return message;
159
- }
160
-
161
- const fileParts = message.parts.filter(part => part.type === 'file');
162
- const parts: SvedaMessagePart[] = [
163
- ...(override ? [{ type: 'text', text: override } as SvedaMessagePart] : []),
164
- ...fileParts,
165
- ];
166
-
167
- return { ...message, parts };
168
- });
169
- };
170
-
171
- const ensureSession = (chatId: string): SvedaChatSession => {
172
- const session = client.session(chatId);
173
- if (subscriptions.has(chatId)) {
174
- return session;
175
- }
176
-
177
- const offMessages = session.on('messages', () => {
178
- store.setChatMessages(chatId, applyDisplayOverrides(chatId, session.messages));
179
- });
180
-
181
- const offStatus = session.on('status', payload => {
182
- setChatStatus(chatId, payload as SvedaSessionStatus);
183
- });
184
-
185
- const offTitle = session.on('title', payload => {
186
- if (typeof payload === 'string' && payload.trim()) {
187
- store.setChatTitle(chatId, payload);
188
- }
189
- });
190
-
191
- const offMaxSteps = session.on('maxSteps', payload => {
192
- const event = payload as SvedaMaxStepsEvent | undefined;
193
- options.onMaxStepsReached?.(chatId, {
194
- maxSteps: typeof event?.maxSteps === 'number' ? event.maxSteps : 0,
195
- });
196
- });
197
-
198
- const offContextUsage = session.on('contextUsage', payload => {
199
- const event = payload as SvedaContextUsageEvent | undefined;
200
- if (event && typeof event.usedTokens === 'number') {
201
- store.setChatContextWindowTokens(chatId, event.usedTokens);
202
- }
203
- if (event) {
204
- options.onContextUsage?.(chatId, event);
205
- }
206
- });
207
-
208
- const offToolProgress = session.on('toolProgress', payload => {
209
- options.onToolProgress?.(chatId, payload as SvedaToolProgressEvent);
210
- });
211
-
212
- const offFinish = session.on('finish', payload => {
213
- const event = payload as
214
- | { usage?: { totalTokens?: number; promptTokens?: number } }
215
- | undefined;
216
- if (event?.usage) {
217
- if (typeof event.usage.totalTokens === 'number') {
218
- store.incrementChatTokens(chatId, event.usage.totalTokens);
219
- }
220
- if (typeof event.usage.promptTokens === 'number') {
221
- store.setChatContextWindowTokens(chatId, event.usage.promptTokens);
222
- }
223
- }
224
- void nextTick(() => {
225
- options.onDone?.(chatId);
226
- scheduleChatTitleRefresh(chatId);
227
- if (store.currentChat.value?.id === chatId) {
228
- scrollToBottom();
229
- }
230
- });
231
- });
232
-
233
- const offError = session.on('error', payload => {
234
- options.onError?.(chatId, payload);
235
- void nextTick(() => {
236
- options.onDone?.(chatId);
237
- if (store.currentChat.value?.id === chatId) {
238
- scrollToBottom();
239
- }
240
- });
241
- });
242
-
243
- subscriptions.set(chatId, [
244
- offMessages,
245
- offStatus,
246
- offTitle,
247
- offMaxSteps,
248
- offContextUsage,
249
- offToolProgress,
250
- offFinish,
251
- offError,
252
- ]);
253
- setChatStatus(chatId, session.status);
254
-
255
- return session;
256
- };
80
+ const unsubscribe = controller.subscribe(sync);
81
+ sync();
257
82
 
83
+ const pollCurrentChat = controller.watchCurrentChatId(() => store.currentChat.value?.id);
258
84
  watch(
259
85
  () => store.currentChat.value?.id,
260
- (newId, oldId) => {
261
- if (!newId || newId === oldId || !subscriptions.has(newId)) {
262
- return;
263
- }
264
-
265
- const session = client.session(newId);
266
- if (session.isStreaming) {
267
- return;
268
- }
269
-
270
- session.setMessages(store.currentChat.value?.messages ?? []);
86
+ () => {
87
+ pollCurrentChat();
271
88
  }
272
89
  );
273
90
 
274
- watch(
275
- () => statusByChatId.value[store.currentChat.value?.id ?? ''],
276
- status => {
277
- if (status === 'streaming' || status === 'submitted') {
278
- isThinking.value = true;
279
- thinkingMessage.value = t('analyzingRequest');
280
- } else {
281
- isThinking.value = false;
282
- thinkingMessage.value = '';
283
- }
284
- },
285
- { immediate: true }
286
- );
287
-
288
91
  const isStreaming = computed(() =>
289
- streamingChatIds.value.has(store.currentChat.value?.id ?? '')
92
+ controller.isStreamingFor(store.currentChat.value?.id)
290
93
  );
291
94
 
292
- const stopStreaming = (chatId: string | null | undefined = store.currentChat.value?.id) => {
293
- if (!chatId || !subscriptions.has(chatId)) {
294
- return;
295
- }
296
- client.session(chatId).stop();
297
- setChatStreaming(chatId, false);
298
- isThinking.value = false;
299
- thinkingMessage.value = '';
300
- };
301
-
302
- const resolveSendOptions = (): SvedaSendOptions => ({
303
- ...(options.resolveSendOptions?.() ?? {}),
304
- });
305
-
306
- const sendMessage = async (
307
- userPayload: SvedaSendPayload,
308
- pageContext: Record<string, unknown> = {}
309
- ) => {
310
- let displayText = '';
311
- let promptText = '';
312
- let attachmentNames: string[] = [];
313
-
314
- if (typeof userPayload === 'string') {
315
- displayText = userPayload.trim();
316
- promptText = displayText;
317
- } else if (userPayload && typeof userPayload === 'object') {
318
- displayText = String(userPayload.displayText ?? '').trim();
319
- promptText = String(userPayload.promptText ?? '').trim();
320
- attachmentNames = Array.isArray(userPayload.attachmentNames)
321
- ? userPayload.attachmentNames.map(name => String(name).trim()).filter(Boolean)
322
- : [];
323
- } else {
324
- return;
325
- }
326
-
327
- if (!promptText || !store.currentChat.value) {
328
- return;
329
- }
330
-
331
- try {
332
- await beforeSend?.();
333
- } catch (error) {
334
- options.onError?.(store.currentChat.value.id, error);
335
- return;
336
- }
337
-
338
- const chatId = store.currentChat.value.id;
339
- applyProvisionalChatTitle(chatId, promptText || displayText);
340
- const session = ensureSession(chatId);
341
- session.setMessages(store.currentChat.value.messages ?? []);
342
-
343
- const sendOptions: SvedaSendOptions = {
344
- ...resolveSendOptions(),
345
- context: { ...pageContext },
346
- ...(attachmentNames.length > 0
347
- ? { files: attachmentNames.map(name => ({ name })) }
348
- : {}),
349
- };
350
-
351
- const sendPromise = session.send(promptText, sendOptions);
352
-
353
- if (displayText !== promptText) {
354
- const userMessage = [...session.messages].reverse().find(message => message.role === 'user');
355
- if (userMessage) {
356
- if (!displayTextOverrides.has(chatId)) {
357
- displayTextOverrides.set(chatId, new Map());
358
- }
359
- displayTextOverrides.get(chatId)!.set(userMessage.id, displayText);
360
- store.setChatMessages(chatId, applyDisplayOverrides(chatId, session.messages));
361
- }
362
- }
363
-
364
- try {
365
- await sendPromise;
366
- } catch {
367
- return;
368
- }
369
-
370
- scrollToBottom();
371
- };
372
-
373
- const continueAfterMaxSteps = async (pageContext: Record<string, unknown> = {}) => {
374
- const chatId = store.currentChat.value?.id;
375
- if (!chatId) {
376
- return;
377
- }
378
-
379
- const session = ensureSession(chatId);
380
- if (session.messages.length === 0) {
381
- session.setMessages(store.currentChat.value?.messages ?? []);
382
- }
383
-
384
- try {
385
- await session.continueAfterMaxSteps({
386
- ...resolveSendOptions(),
387
- context: { ...pageContext },
388
- });
389
- } catch {
390
- return;
391
- }
392
-
393
- scrollToBottom();
394
- };
395
-
396
- const resolveToolConfirmation = async (
397
- toolCallId: string,
398
- decision: 'approve' | 'deny',
399
- pageContext: Record<string, unknown> = {}
400
- ) => {
401
- const chatId = store.currentChat.value?.id;
402
- if (!chatId || !toolCallId) {
403
- return;
404
- }
405
- const session = ensureSession(chatId);
406
- session.setMessages(store.currentChat.value?.messages ?? []);
407
- try {
408
- await session.resolveToolConfirmation(toolCallId, decision, {
409
- ...resolveSendOptions(),
410
- context: { ...pageContext },
411
- });
412
- } catch {
413
- return;
414
- }
415
- scrollToBottom();
416
- };
417
-
418
95
  onUnmounted(() => {
419
- for (const [chatId, unsubscribes] of subscriptions.entries()) {
420
- client.session(chatId).stop();
421
- unsubscribes.forEach(off => off());
422
- }
423
- subscriptions.clear();
424
- displayTextOverrides.clear();
96
+ unsubscribe();
97
+ controller.dispose();
425
98
  });
426
99
 
427
100
  return {
428
- sendMessage,
429
- continueAfterMaxSteps,
430
- resolveToolConfirmation,
101
+ sendMessage: controller.sendMessage,
102
+ continueAfterMaxSteps: controller.continueAfterMaxSteps,
103
+ resolveToolConfirmation: controller.resolveToolConfirmation,
431
104
  isStreaming,
432
105
  isThinking,
433
106
  thinkingMessage,
434
- stopStreaming,
107
+ stopStreaming: controller.stopStreaming,
435
108
  streamingChatIds,
436
109
  unreadChatIds,
437
- clearChatUnread,
110
+ clearChatUnread: controller.clearChatUnread,
438
111
  };
439
112
  }
package/src/index.ts CHANGED
@@ -131,24 +131,27 @@ export { useSvedaReadable } from './composables/useSvedaReadable';
131
131
  export { useSvedaTool } from './composables/useSvedaTool';
132
132
  export type { UseSvedaToolOptions } from './composables/useSvedaTool';
133
133
 
134
- export { isNewChatPlaceholder, buildChatTabTitleMap } from './lib/chatTabs';
135
- export type { SvedaTabChat } from './lib/chatTabs';
136
- export { isChatTitlePlaceholder, deriveProvisionalChatTitle } from './lib/chatTitle';
137
134
  export {
135
+ isNewChatPlaceholder,
136
+ buildChatTabTitleMap,
137
+ isChatTitlePlaceholder,
138
+ deriveProvisionalChatTitle,
138
139
  SVEDA_CHAT_MINIMIZED_STORAGE_KEY,
139
140
  readPersistedMinimized,
140
141
  readPersistedMinimizedPreference,
141
142
  isPersistedSessionChatOpen,
142
143
  writePersistedMinimized,
143
- } from './lib/chatUiStorage';
144
- export { humanizeModelId, getSvedaModelDisplayName } from './lib/modelLabels';
145
- export { finalizeMessagesForDisplay } from './lib/finalizeMessages';
146
- export type { SvedaFinalizableMessage } from './lib/finalizeMessages';
147
- export {
144
+ humanizeModelId,
145
+ getSvedaModelDisplayName,
146
+ finalizeMessagesForDisplay,
148
147
  getUserMessageText,
149
148
  getUserMessageAttachmentNames,
150
149
  userMessageHasVisibleContent,
151
- } from './lib/userMessage';
152
- export type { SvedaUserMessageLike } from './lib/userMessage';
150
+ } from '@sveda-ai/chat';
151
+ export type {
152
+ SvedaTabChat,
153
+ SvedaFinalizableMessage,
154
+ SvedaUserMessageLike,
155
+ } from '@sveda-ai/chat';
153
156
 
154
- export const SVEDA_VUE_VERSION = '0.1.0';
157
+ export const SVEDA_VUE_VERSION = '0.3.1';
package/src/plugin.ts CHANGED
@@ -11,9 +11,7 @@ import {
11
11
  type SvedaI18n,
12
12
  type SvedaMessages,
13
13
  } from './i18n/index';
14
- import en from './i18n/locales/en';
15
- import ru from './i18n/locales/ru';
16
- import { chatComponentI18nKeys } from './lib/chatI18nKeys';
14
+ import { chatComponentI18nKeys, enMessages as en, ruMessages as ru } from '@sveda-ai/chat';
17
15
 
18
16
  export interface SvedaModelOption {
19
17
  id: string;
@@ -7,7 +7,8 @@ import { fileURLToPath } from 'node:url';
7
7
  const dir = dirname(fileURLToPath(import.meta.url));
8
8
  const theme = readFileSync(join(dir, 'theme.css'), 'utf8');
9
9
  const chat = readFileSync(join(dir, 'components/shell/SvedaChat.vue'), 'utf8');
10
- const appearance = readFileSync(join(dir, 'appearance.ts'), 'utf8');
10
+ const appearanceVue = readFileSync(join(dir, 'appearance.ts'), 'utf8');
11
+ const appearance = readFileSync(join(dir, '../../chat/src/appearance.ts'), 'utf8');
11
12
  const trigger = readFileSync(join(dir, 'components/shell/SvedaMinimizedTrigger.vue'), 'utf8');
12
13
  const selectContent = readFileSync(join(dir, 'ui/select/SelectContent.vue'), 'utf8');
13
14
  const tooltipContent = readFileSync(join(dir, 'ui/tooltip/TooltipContent.vue'), 'utf8');
@@ -64,12 +65,12 @@ test('appearance helper injects radius and token declarations onto .sveda-chat',
64
65
  assert.match(appearance, /theme === 'dark'/);
65
66
  assert.match(appearance, /theme === 'light'/);
66
67
  assert.match(appearance, /SVEDA_LAUNCHER_ICON_IDS/);
67
- assert.match(appearance, /useSvedaLauncher/);
68
+ assert.match(appearanceVue, /useSvedaLauncher/);
68
69
  assert.match(appearance, /sanitizeSvedaLauncher/);
69
70
  assert.match(appearance, /sanitizeSvedaLauncherImage/);
70
71
  assert.match(appearance, /sanitizeSvedaChrome/);
71
- assert.match(appearance, /useSvedaChrome/);
72
- assert.match(appearance, /svedaChrome/);
72
+ assert.match(appearanceVue, /useSvedaChrome/);
73
+ assert.match(appearanceVue, /svedaChrome/);
73
74
  assert.match(appearance, /SVEDA_LAUNCHER_IMAGE_MAX_BYTES/);
74
75
  });
75
76
 
@@ -1,4 +0,0 @@
1
- import type { SvedaMessages } from '../index';
2
- declare const en: SvedaMessages;
3
- export default en;
4
- //# sourceMappingURL=en.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,QAAA,MAAM,EAAE,EAAE,aA2DT,CAAC;AAEF,eAAe,EAAE,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { SvedaMessages } from '../index';
2
- declare const ru: SvedaMessages;
3
- export default ru;
4
- //# sourceMappingURL=ru.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ru.d.ts","sourceRoot":"","sources":["../../../src/i18n/locales/ru.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,QAAA,MAAM,EAAE,EAAE,aA4DT,CAAC;AAEF,eAAe,EAAE,CAAC"}
@@ -1,90 +0,0 @@
1
- export interface SvedaResourceLink {
2
- label: string;
3
- url: string;
4
- icon?: string;
5
- kind?: 'created' | 'reference';
6
- }
7
- export type SvedaAssistantMessagePart = {
8
- type?: string;
9
- text?: string;
10
- state?: string;
11
- toolName?: string;
12
- toolCallId?: string;
13
- target?: string;
14
- output?: unknown;
15
- result?: unknown;
16
- input?: unknown;
17
- args?: unknown;
18
- errorText?: string;
19
- renderHint?: string;
20
- renderData?: Record<string, unknown>;
21
- confirmation?: string;
22
- };
23
- export type SvedaLegacyActivity = {
24
- phase?: string;
25
- steps?: Array<{
26
- id: string;
27
- label: string;
28
- status: string;
29
- detail?: string;
30
- kind?: string;
31
- activityGroupKey?: string;
32
- activityGroupLabel?: string;
33
- display?: {
34
- name?: string;
35
- link?: string;
36
- };
37
- }>;
38
- };
39
- export type SvedaChatMessageLike = {
40
- id?: string;
41
- role?: string;
42
- content?: string;
43
- parts?: SvedaAssistantMessagePart[];
44
- reasoningStream?: string;
45
- activity?: SvedaLegacyActivity;
46
- toolInvocations?: SvedaAssistantMessagePart[];
47
- resources?: SvedaResourceLink[];
48
- streaming?: boolean;
49
- isError?: boolean;
50
- attachmentNames?: string[];
51
- metadata?: {
52
- attachmentNames?: string[];
53
- };
54
- };
55
- export type AssistantMessageSegment = {
56
- kind: 'activity';
57
- id: string;
58
- invocations: SvedaAssistantMessagePart[];
59
- legacyActivity?: SvedaLegacyActivity;
60
- } | {
61
- kind: 'comment';
62
- id: string;
63
- text: string;
64
- streaming: boolean;
65
- } | {
66
- kind: 'answer';
67
- id: string;
68
- text: string;
69
- streaming: boolean;
70
- } | {
71
- kind: 'reasoning';
72
- id: string;
73
- text: string;
74
- streaming: boolean;
75
- };
76
- export declare function isAssistantToolPart(part: SvedaAssistantMessagePart | null | undefined): boolean;
77
- export declare function buildAssistantMessageSegments(message: SvedaChatMessageLike): AssistantMessageSegment[];
78
- export declare function getToolNameFromPart(part: {
79
- toolName?: string;
80
- type?: string;
81
- }): string;
82
- export declare function parseToolResultOutput(output: unknown): Record<string, unknown> | null;
83
- export declare function getActivityGroupKey(toolName: string): string;
84
- export declare function getActivityGroupLabel(_toolName: string, translatedToolName: string): string;
85
- export declare function collectResourceLinks(message: SvedaChatMessageLike): SvedaResourceLink[];
86
- export declare function enrichMessagesWithResourceLinks<T extends {
87
- role?: string;
88
- resources?: SvedaResourceLink[];
89
- }>(messages: T[]): T[];
90
- //# sourceMappingURL=assistantMessage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assistantMessage.d.ts","sourceRoot":"","sources":["../../src/lib/assistantMessage.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;CAChC;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,KAAK,CAAC;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC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