@meistrari/chat-nuxt 1.7.0 → 1.8.1
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/module.json +1 -1
- package/dist/module.mjs +2 -0
- package/dist/runtime/components/MeistrariChatEmbed.vue +5 -1
- package/dist/runtime/components/chat/bash-widget.vue +3 -3
- package/dist/runtime/components/chat/doc-sdk-widget.vue +3 -3
- package/dist/runtime/components/chat/files-view.vue +3 -64
- package/dist/runtime/components/chat/generic-tool-widget.vue +3 -3
- package/dist/runtime/components/chat/grep-widget.vue +3 -3
- package/dist/runtime/components/chat/message-bubble.vue +1 -1
- package/dist/runtime/components/chat/message-input.d.vue.ts +2 -0
- package/dist/runtime/components/chat/message-input.vue +21 -5
- package/dist/runtime/components/chat/message-input.vue.d.ts +2 -0
- package/dist/runtime/components/chat/message-list.vue +1 -1
- package/dist/runtime/components/chat/mobile/files/file-preview.d.vue.ts +11 -0
- package/dist/runtime/components/chat/mobile/files/file-preview.vue +112 -0
- package/dist/runtime/components/chat/mobile/files/file-preview.vue.d.ts +11 -0
- package/dist/runtime/components/chat/mobile/files/files-view.d.vue.ts +10 -0
- package/dist/runtime/components/chat/mobile/files/files-view.vue +384 -0
- package/dist/runtime/components/chat/mobile/files/files-view.vue.d.ts +10 -0
- package/dist/runtime/components/chat/mobile/home/header.d.vue.ts +19 -0
- package/dist/runtime/components/chat/mobile/home/header.vue +55 -0
- package/dist/runtime/components/chat/mobile/home/header.vue.d.ts +19 -0
- package/dist/runtime/components/chat/mobile/home/recents.d.vue.ts +14 -0
- package/dist/runtime/components/chat/mobile/home/recents.vue +48 -0
- package/dist/runtime/components/chat/mobile/home/recents.vue.d.ts +14 -0
- package/dist/runtime/components/chat/mobile/home/suggestions.d.vue.ts +7 -0
- package/dist/runtime/components/chat/mobile/home/suggestions.vue +31 -0
- package/dist/runtime/components/chat/mobile/home/suggestions.vue.d.ts +7 -0
- package/dist/runtime/components/chat/mobile/primitives/bottom-sheet.d.vue.ts +21 -0
- package/dist/runtime/components/chat/mobile/primitives/bottom-sheet.vue +48 -0
- package/dist/runtime/components/chat/mobile/primitives/bottom-sheet.vue.d.ts +21 -0
- package/dist/runtime/components/chat/mobile/primitives/info-bubble.d.vue.ts +6 -0
- package/dist/runtime/components/chat/mobile/primitives/info-bubble.vue +50 -0
- package/dist/runtime/components/chat/mobile/primitives/info-bubble.vue.d.ts +6 -0
- package/dist/runtime/components/chat/mobile/shell/drawer.d.vue.ts +22 -0
- package/dist/runtime/components/chat/mobile/shell/drawer.vue +143 -0
- package/dist/runtime/components/chat/mobile/shell/drawer.vue.d.ts +22 -0
- package/dist/runtime/components/chat/mobile/shell/header.d.vue.ts +40 -0
- package/dist/runtime/components/chat/mobile/shell/header.vue +139 -0
- package/dist/runtime/components/chat/mobile/shell/header.vue.d.ts +40 -0
- package/dist/runtime/components/chat/mobile/shell/outdated-settings-sheet.d.vue.ts +14 -0
- package/dist/runtime/components/chat/mobile/shell/outdated-settings-sheet.vue +47 -0
- package/dist/runtime/components/chat/mobile/shell/outdated-settings-sheet.vue.d.ts +14 -0
- package/dist/runtime/components/chat/mobile/shell/shell.d.vue.ts +122 -0
- package/dist/runtime/components/chat/mobile/shell/shell.vue +283 -0
- package/dist/runtime/components/chat/mobile/shell/shell.vue.d.ts +122 -0
- package/dist/runtime/components/chat/mobile/shell/workspace-sheet.d.vue.ts +19 -0
- package/dist/runtime/components/chat/mobile/shell/workspace-sheet.vue +51 -0
- package/dist/runtime/components/chat/mobile/shell/workspace-sheet.vue.d.ts +19 -0
- package/dist/runtime/components/chat/mobile/usage/usage-view.d.vue.ts +8 -0
- package/dist/runtime/components/chat/mobile/usage/usage-view.vue +243 -0
- package/dist/runtime/components/chat/mobile/usage/usage-view.vue.d.ts +8 -0
- package/dist/runtime/components/chat/model-selector.vue +6 -0
- package/dist/runtime/components/chat/read-widget.vue +3 -3
- package/dist/runtime/components/chat/reasoning-step-item.vue +1 -1
- package/dist/runtime/components/chat/reasoning-steps.vue +1 -1
- package/dist/runtime/components/chat/reasoning-thought.vue +2 -3
- package/dist/runtime/components/chat/tela-skill-widget.vue +3 -3
- package/dist/runtime/components/chat/thinking-widget.vue +3 -3
- package/dist/runtime/components/chat/usage-view.vue +20 -101
- package/dist/runtime/components/chat/web-search-widget.vue +3 -3
- package/dist/runtime/components/chat/workstation-query-widget.vue +6 -6
- package/dist/runtime/components/chat/write-widget.vue +3 -3
- package/dist/runtime/composables/useConversationFileDownloads.d.ts +6 -0
- package/dist/runtime/composables/useConversationFileDownloads.js +50 -0
- package/dist/runtime/composables/useConversationUsage.d.ts +13 -0
- package/dist/runtime/composables/useConversationUsage.js +121 -0
- package/dist/runtime/composables/useEmbedConfig.d.ts +2 -0
- package/dist/runtime/composables/useEmbedConfig.js +4 -0
- package/dist/runtime/composables/useMentionAutocomplete.d.ts +6 -0
- package/dist/runtime/composables/useMentionAutocomplete.js +71 -23
- package/dist/runtime/composables/usePdf.js +2 -2
- package/dist/runtime/composables/useWorkspaceSwitchModal.d.ts +5 -0
- package/dist/runtime/composables/useWorkspaceSwitchModal.js +14 -0
- package/dist/runtime/embed/components/ChatConfigurationModal.vue +119 -13
- package/dist/runtime/embed/components/ChatEmbed.vue +4 -0
- package/dist/runtime/embed/components/ChatEmbedInner.d.vue.ts +2 -0
- package/dist/runtime/embed/components/ChatEmbedInner.vue +201 -11
- package/dist/runtime/embed/components/ChatEmbedInner.vue.d.ts +2 -0
- package/dist/runtime/embed/components/configuration/ChatConfigurationMobileShell.d.vue.ts +34 -0
- package/dist/runtime/embed/components/configuration/ChatConfigurationMobileShell.vue +95 -0
- package/dist/runtime/embed/components/configuration/ChatConfigurationMobileShell.vue.d.ts +34 -0
- package/dist/runtime/server/api/conversations/[id]/messages/[messageId]/retry.post.js +3 -1
- package/dist/runtime/server/api/conversations/[id]/messages/index.get.js +29 -5
- package/dist/runtime/server/utils/conversation-agent-turn.js +4 -0
- package/dist/runtime/server/utils/conversation-message-sync.d.ts +8 -2
- package/dist/runtime/server/utils/conversation-message-sync.js +52 -6
- package/dist/runtime/types/chat-auth.d.ts +1 -0
- package/dist/runtime/types/embed.d.ts +2 -0
- package/dist/runtime/utils/breakpoints.d.ts +1 -0
- package/dist/runtime/utils/breakpoints.js +1 -0
- package/package.json +1 -1
|
@@ -1,19 +1,53 @@
|
|
|
1
1
|
import { schema } from "#chat-runtime/server/db";
|
|
2
|
-
import { extractContentFromSession } from "#chat-runtime/server/utils/agent-api";
|
|
2
|
+
import { extractContentFromReasoning, extractContentFromSession } from "#chat-runtime/server/utils/agent-api";
|
|
3
3
|
import { logger } from "#chat-runtime/server/utils/logger";
|
|
4
|
+
const STALE_TERMINAL_CONTENT_GRACE_MS = 5e3;
|
|
5
|
+
const STALE_TERMINAL_CONTENT_ERROR = "Erro: O servi\xE7o retornou uma resposta final inconsistente. Tente enviar a mensagem novamente.";
|
|
6
|
+
export const PENDING_RESPONSE_GRACE_MS = 3e4;
|
|
7
|
+
export const THREAD_SESSION_START_ERROR = "Erro: N\xE3o foi poss\xEDvel iniciar a sess\xE3o de resposta. Tente enviar a mensagem novamente.";
|
|
8
|
+
export const SESSION_STATUS_CHECK_ERROR = "Erro: N\xE3o foi poss\xEDvel verificar o andamento da resposta. Tente enviar a mensagem novamente.";
|
|
9
|
+
const NO_RESULT_ERROR = "Erro: O servi\xE7o terminou sem retornar uma resposta. Tente enviar a mensagem novamente.";
|
|
4
10
|
function toMilliseconds(timestamp) {
|
|
5
11
|
if (typeof timestamp !== "number" || !Number.isFinite(timestamp))
|
|
6
12
|
return null;
|
|
7
13
|
return timestamp < 1e10 ? timestamp * 1e3 : timestamp;
|
|
8
14
|
}
|
|
15
|
+
function resolveTerminalContentForPendingMessage(agentSession, newReasoning, lastAssistantMessage) {
|
|
16
|
+
const sessionContent = extractContentFromSession(agentSession);
|
|
17
|
+
if (!newReasoning?.length)
|
|
18
|
+
return sessionContent === lastAssistantMessage?.content ? null : sessionContent;
|
|
19
|
+
const reasoningContent = extractContentFromReasoning(newReasoning);
|
|
20
|
+
const hasSessionResultContent = typeof agentSession.result?.content === "string";
|
|
21
|
+
if (hasSessionResultContent && reasoningContent && sessionContent !== reasoningContent)
|
|
22
|
+
return null;
|
|
23
|
+
if (hasSessionResultContent && !reasoningContent && sessionContent === lastAssistantMessage?.content)
|
|
24
|
+
return null;
|
|
25
|
+
return sessionContent || reasoningContent;
|
|
26
|
+
}
|
|
27
|
+
export function hasPendingMessageExceededGraceWindow(pendingMessage, now = /* @__PURE__ */ new Date()) {
|
|
28
|
+
return now.getTime() - pendingMessage.createdAt.getTime() >= PENDING_RESPONSE_GRACE_MS;
|
|
29
|
+
}
|
|
30
|
+
export function buildFailedPendingMessageUpdate(content, now = /* @__PURE__ */ new Date()) {
|
|
31
|
+
return {
|
|
32
|
+
content,
|
|
33
|
+
status: "failed",
|
|
34
|
+
updatedAt: now
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function resolveFailedSessionContent(error) {
|
|
38
|
+
if (error === "no_result")
|
|
39
|
+
return NO_RESULT_ERROR;
|
|
40
|
+
return `Error: ${error || "Agent execution failed"}`;
|
|
41
|
+
}
|
|
9
42
|
export function mapAgentApiSessionToMessageUpdate(agentSession, options) {
|
|
10
43
|
const updateData = {};
|
|
11
|
-
const
|
|
44
|
+
const lastSyncedMessage = options.lastSyncedMessage ?? options.lastAssistantMessage;
|
|
45
|
+
const lastSyncedUuid = lastSyncedMessage?.externalUuid;
|
|
12
46
|
const lastSyncedIndex = lastSyncedUuid ? agentSession.reasoning?.findIndex((item) => item.uuid === lastSyncedUuid) ?? -1 : -1;
|
|
13
47
|
const newReasoning = agentSession.reasoning?.slice(lastSyncedIndex + 1);
|
|
14
48
|
const hasNewReasoning = newReasoning && newReasoning.length > 0;
|
|
15
49
|
const sessionUpdatedAtMs = toMilliseconds(agentSession.updatedAt);
|
|
16
|
-
const terminalSessionBelongsToPendingMessage = hasNewReasoning ||
|
|
50
|
+
const terminalSessionBelongsToPendingMessage = hasNewReasoning || !!options.pendingMessage.updatedAt || !lastSyncedMessage || sessionUpdatedAtMs !== null && sessionUpdatedAtMs >= options.pendingMessage.createdAt.getTime();
|
|
17
51
|
if (hasNewReasoning) {
|
|
18
52
|
updateData.reasoningData = newReasoning;
|
|
19
53
|
const lastReasoningItem = newReasoning.at(-1);
|
|
@@ -27,13 +61,25 @@ export function mapAgentApiSessionToMessageUpdate(agentSession, options) {
|
|
|
27
61
|
}
|
|
28
62
|
if (agentSession.status === "completed" || agentSession.status === "waiting_messages") {
|
|
29
63
|
if (terminalSessionBelongsToPendingMessage) {
|
|
30
|
-
|
|
64
|
+
const content = resolveTerminalContentForPendingMessage(agentSession, newReasoning, options.lastAssistantMessage);
|
|
65
|
+
if (content === null) {
|
|
66
|
+
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
67
|
+
const staleSince = options.pendingMessage.updatedAt;
|
|
68
|
+
if (staleSince && now.getTime() - staleSince.getTime() >= STALE_TERMINAL_CONTENT_GRACE_MS) {
|
|
69
|
+
updateData.content = STALE_TERMINAL_CONTENT_ERROR;
|
|
70
|
+
updateData.status = "failed";
|
|
71
|
+
updateData.updatedAt = now;
|
|
72
|
+
} else if (!staleSince) {
|
|
73
|
+
updateData.updatedAt = now;
|
|
74
|
+
}
|
|
75
|
+
return updateData;
|
|
76
|
+
}
|
|
77
|
+
updateData.content = content;
|
|
31
78
|
updateData.status = "completed";
|
|
32
79
|
updateData.updatedAt = options.now ?? /* @__PURE__ */ new Date();
|
|
33
80
|
}
|
|
34
81
|
} else if (agentSession.status === "failed") {
|
|
35
|
-
|
|
36
|
-
updateData.content = `Error: ${errorContent}`;
|
|
82
|
+
updateData.content = resolveFailedSessionContent(agentSession.error);
|
|
37
83
|
updateData.status = "failed";
|
|
38
84
|
updateData.updatedAt = options.now ?? /* @__PURE__ */ new Date();
|
|
39
85
|
}
|
|
@@ -29,6 +29,7 @@ type ChatAuthOrganization = {
|
|
|
29
29
|
export function useChatAuth(): {
|
|
30
30
|
user: Ref<ChatAuthUser | null>
|
|
31
31
|
activeOrganization: Ref<ChatAuthOrganization | null>
|
|
32
|
+
logout: () => Promise<void>
|
|
32
33
|
getToken: () => Promise<string | null | undefined>
|
|
33
34
|
getAvailableOrganizations: () => Promise<ChatAuthOrganization[]>
|
|
34
35
|
switchOrganization: (organizationId: string) => Promise<void>
|
|
@@ -12,6 +12,8 @@ export type ChatEmbedSharedProps = {
|
|
|
12
12
|
conversationScope?: string | null;
|
|
13
13
|
/** Hide the conversation list and render only the active chat surface. */
|
|
14
14
|
hideSidebar?: boolean;
|
|
15
|
+
/** Hide workspace settings actions while keeping the chat header and content unchanged. */
|
|
16
|
+
hideSettings?: boolean;
|
|
15
17
|
/** Custom pending-response messages shown while the assistant is working. */
|
|
16
18
|
loadingMessages?: readonly string[] | null;
|
|
17
19
|
/** How custom loading messages rotate. Defaults to ordered behavior when omitted. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CHAT_MOBILE_BREAKPOINT = 481;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CHAT_MOBILE_BREAKPOINT = 481;
|