@sveda-ai/vue 0.2.4 → 0.3.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 (39) hide show
  1. package/dist/components/chat/ChatInput.vue.d.ts +2 -0
  2. package/dist/components/chat/ChatInput.vue.d.ts.map +1 -1
  3. package/dist/components/chat/ChatMessageActivityBlock.vue.d.ts +1 -1
  4. package/dist/components/chat/ChatMessageList.vue.d.ts.map +1 -1
  5. package/dist/components/shell/SvedaInputSection.vue.d.ts +2 -0
  6. package/dist/components/shell/SvedaLandingView.vue.d.ts +2 -0
  7. package/dist/components/shell/SvedaLandingView.vue.d.ts.map +1 -1
  8. package/dist/composables/useSvedaChat.d.ts +5 -0
  9. package/dist/composables/useSvedaChat.d.ts.map +1 -1
  10. package/dist/composables/useSvedaChatPage.d.ts +5 -0
  11. package/dist/composables/useSvedaChatPage.d.ts.map +1 -1
  12. package/dist/composables/useSvedaMessaging.d.ts +1 -0
  13. package/dist/composables/useSvedaMessaging.d.ts.map +1 -1
  14. package/dist/composables/useSvedaStreaming.d.ts +1 -0
  15. package/dist/composables/useSvedaStreaming.d.ts.map +1 -1
  16. package/dist/i18n/locales/en.d.ts.map +1 -1
  17. package/dist/i18n/locales/ru.d.ts.map +1 -1
  18. package/dist/index.js +3341 -3235
  19. package/dist/lib/assistantMessage.d.ts +1 -0
  20. package/dist/lib/assistantMessage.d.ts.map +1 -1
  21. package/dist/lib/toolConfirmation.d.ts +11 -0
  22. package/dist/lib/toolConfirmation.d.ts.map +1 -0
  23. package/dist/styles.css +1 -1
  24. package/dist/vue.css +1 -1
  25. package/package.json +9 -2
  26. package/src/components/chat/ChatInput.vue +13 -5
  27. package/src/components/chat/ChatMessageActivityBlock.vue +55 -2
  28. package/src/components/chat/ChatMessageItem.vue +2 -0
  29. package/src/components/chat/ChatMessageList.vue +2 -0
  30. package/src/components/shell/SvedaChat.vue +10 -1
  31. package/src/components/shell/SvedaInputSection.vue +2 -0
  32. package/src/components/shell/SvedaLandingView.vue +3 -1
  33. package/src/composables/useSvedaChatPage.ts +8 -0
  34. package/src/composables/useSvedaMessaging.ts +3 -2
  35. package/src/composables/useSvedaStreaming.ts +23 -0
  36. package/src/i18n/locales/en.ts +3 -0
  37. package/src/i18n/locales/ru.ts +3 -0
  38. package/src/lib/assistantMessage.ts +2 -0
  39. package/src/lib/toolConfirmation.ts +31 -0
@@ -393,6 +393,28 @@ export function useSvedaStreaming(
393
393
  scrollToBottom();
394
394
  };
395
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
+
396
418
  onUnmounted(() => {
397
419
  for (const [chatId, unsubscribes] of subscriptions.entries()) {
398
420
  client.session(chatId).stop();
@@ -405,6 +427,7 @@ export function useSvedaStreaming(
405
427
  return {
406
428
  sendMessage,
407
429
  continueAfterMaxSteps,
430
+ resolveToolConfirmation,
408
431
  isStreaming,
409
432
  isThinking,
410
433
  thinkingMessage,
@@ -56,6 +56,9 @@ const en: SvedaMessages = {
56
56
  commonError: 'Error',
57
57
  'tools.web_search': 'Search the web',
58
58
  'tools.web_fetch': 'Read page',
59
+ toolConfirmationPrompt: 'This action needs your confirmation before it runs.',
60
+ toolConfirm: 'Confirm',
61
+ toolDeny: 'Deny',
59
62
  };
60
63
 
61
64
  export default en;
@@ -57,6 +57,9 @@ const ru: SvedaMessages = {
57
57
  commonError: 'Ошибка',
58
58
  'tools.web_search': 'Поиск в интернете',
59
59
  'tools.web_fetch': 'Чтение страницы',
60
+ toolConfirmationPrompt: 'Это действие выполнится только после вашего подтверждения.',
61
+ toolConfirm: 'Подтвердить',
62
+ toolDeny: 'Отказать',
60
63
  };
61
64
 
62
65
  export default ru;
@@ -19,6 +19,7 @@ export type SvedaAssistantMessagePart = {
19
19
  errorText?: string;
20
20
  renderHint?: string;
21
21
  renderData?: Record<string, unknown>;
22
+ confirmation?: string;
22
23
  };
23
24
 
24
25
  export type SvedaLegacyActivity = {
@@ -100,6 +101,7 @@ function svedaToolPartToInvocation(
100
101
  output: result?.output,
101
102
  renderHint: result?.renderHint,
102
103
  renderData: result?.renderData,
104
+ confirmation: call?.confirmation,
103
105
  state: result ? 'result' : 'call',
104
106
  };
105
107
  }
@@ -0,0 +1,31 @@
1
+ type ToolPart = {
2
+ type?: string;
3
+ toolCallId?: string;
4
+ confirmation?: string;
5
+ };
6
+
7
+ type ToolMessage = {
8
+ parts?: ToolPart[];
9
+ };
10
+
11
+ export function hasPendingToolConfirmation(messages: ToolMessage[] | null | undefined): boolean {
12
+ const resolved = new Set<string>();
13
+ for (const message of messages ?? []) {
14
+ for (const part of message.parts ?? []) {
15
+ if (part.type === 'tool-result' && part.toolCallId) {
16
+ resolved.add(part.toolCallId);
17
+ }
18
+ }
19
+ }
20
+
21
+ return (messages ?? []).some(message =>
22
+ (message.parts ?? []).some(
23
+ part =>
24
+ part.type === 'tool-call' &&
25
+ part.confirmation === 'required' &&
26
+ typeof part.toolCallId === 'string' &&
27
+ part.toolCallId !== '' &&
28
+ !resolved.has(part.toolCallId)
29
+ )
30
+ );
31
+ }