@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.
- package/dist/components/chat/ChatInput.vue.d.ts +2 -0
- package/dist/components/chat/ChatInput.vue.d.ts.map +1 -1
- package/dist/components/chat/ChatMessageActivityBlock.vue.d.ts +1 -1
- package/dist/components/chat/ChatMessageList.vue.d.ts.map +1 -1
- package/dist/components/shell/SvedaInputSection.vue.d.ts +2 -0
- package/dist/components/shell/SvedaLandingView.vue.d.ts +2 -0
- package/dist/components/shell/SvedaLandingView.vue.d.ts.map +1 -1
- package/dist/composables/useSvedaChat.d.ts +5 -0
- package/dist/composables/useSvedaChat.d.ts.map +1 -1
- package/dist/composables/useSvedaChatPage.d.ts +5 -0
- package/dist/composables/useSvedaChatPage.d.ts.map +1 -1
- package/dist/composables/useSvedaMessaging.d.ts +1 -0
- package/dist/composables/useSvedaMessaging.d.ts.map +1 -1
- package/dist/composables/useSvedaStreaming.d.ts +1 -0
- package/dist/composables/useSvedaStreaming.d.ts.map +1 -1
- package/dist/i18n/locales/en.d.ts.map +1 -1
- package/dist/i18n/locales/ru.d.ts.map +1 -1
- package/dist/index.js +3341 -3235
- package/dist/lib/assistantMessage.d.ts +1 -0
- package/dist/lib/assistantMessage.d.ts.map +1 -1
- package/dist/lib/toolConfirmation.d.ts +11 -0
- package/dist/lib/toolConfirmation.d.ts.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/vue.css +1 -1
- package/package.json +9 -2
- package/src/components/chat/ChatInput.vue +13 -5
- package/src/components/chat/ChatMessageActivityBlock.vue +55 -2
- package/src/components/chat/ChatMessageItem.vue +2 -0
- package/src/components/chat/ChatMessageList.vue +2 -0
- package/src/components/shell/SvedaChat.vue +10 -1
- package/src/components/shell/SvedaInputSection.vue +2 -0
- package/src/components/shell/SvedaLandingView.vue +3 -1
- package/src/composables/useSvedaChatPage.ts +8 -0
- package/src/composables/useSvedaMessaging.ts +3 -2
- package/src/composables/useSvedaStreaming.ts +23 -0
- package/src/i18n/locales/en.ts +3 -0
- package/src/i18n/locales/ru.ts +3 -0
- package/src/lib/assistantMessage.ts +2 -0
- 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,
|
package/src/i18n/locales/en.ts
CHANGED
|
@@ -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;
|
package/src/i18n/locales/ru.ts
CHANGED
|
@@ -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
|
+
}
|