@meistrari/chat-nuxt 4.6.1-rc.0 → 4.6.1-rc.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.d.mts +1 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/embed/components/mobile/chat-mobile-shell.d.vue.ts +2 -2
- package/dist/runtime/embed/components/mobile/chat-mobile-shell.vue.d.ts +2 -2
- package/dist/runtime/messages/composables/chat-message-terminal.d.ts +2 -5
- package/dist/runtime/messages/composables/chat-message-terminal.js +33 -12
- package/dist/runtime/types/embed.d.ts +1 -1
- package/dist/runtime/types/embed.js +1 -1
- package/dist/runtime/types/message-status.d.ts +5 -0
- package/dist/runtime/types/message-status.js +6 -0
- package/dist/runtime/usage/composables/conversation-usage.js +11 -6
- package/dist/types.d.mts +2 -2
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ChatMessageStatus } from '../dist/runtime/messages/composables/chat-message-terminal.js';
|
|
2
1
|
export { AvailableChatModels, ChatActionPayload, ChatActor, ChatEmbedSharedProps, ChatEmbedVariant, ChatEmbedVariantProps, ChatFeatureConfig, ChatLabels, ChatMessageTerminalPayload, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, MessageFeedbackConfig, MessageFeedbackPayload, MessageFeedbackRating, MessageFeedbackSubmitHandler, MessageFeedbackSubmitResult, MessageOverviewResponse, TelaAgentChatEmbedProps, TelaAgentExecutionInput } from '../dist/runtime/types/embed.js';
|
|
2
|
+
export { ChatMessageStatus } from '../dist/runtime/types/message-status.js';
|
|
3
3
|
|
|
4
4
|
type ChatNuxtConfigValidationMode = false | 'warn' | 'error';
|
|
5
5
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { createRequire } from 'node:module';
|
|
|
3
3
|
import { join, dirname, isAbsolute } from 'node:path';
|
|
4
4
|
import { defineNuxtModule, createResolver, addTemplate, addTypeTemplate, addPlugin, addImportsDir, addComponent, addComponentsDir } from 'nuxt/kit';
|
|
5
5
|
import { TOOL_ICON_SAFELIST } from '../dist/runtime/messages/tool-registry.js';
|
|
6
|
-
export { ChatMessageStatus } from '../dist/runtime/
|
|
6
|
+
export { ChatMessageStatus } from '../dist/runtime/types/message-status.js';
|
|
7
7
|
|
|
8
8
|
const localRequire = createRequire(import.meta.url);
|
|
9
9
|
const runtimeAliasPackages = [
|
|
@@ -67,8 +67,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
67
67
|
copyLink: () => any;
|
|
68
68
|
debug: () => any;
|
|
69
69
|
selectConversation: (id: string) => any;
|
|
70
|
-
settings: () => any;
|
|
71
70
|
send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
|
|
71
|
+
settings: () => any;
|
|
72
72
|
tabChange: (tab: TopbarTab) => any;
|
|
73
73
|
newConversation: (groupId?: string | null | undefined) => any;
|
|
74
74
|
switchWorkspace: () => any;
|
|
@@ -88,8 +88,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
88
88
|
onCopyLink?: (() => any) | undefined;
|
|
89
89
|
onDebug?: (() => any) | undefined;
|
|
90
90
|
onSelectConversation?: ((id: string) => any) | undefined;
|
|
91
|
-
onSettings?: (() => any) | undefined;
|
|
92
91
|
onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
|
|
92
|
+
onSettings?: (() => any) | undefined;
|
|
93
93
|
"onUpdate:selectedModel"?: ((value: string | null) => any) | undefined;
|
|
94
94
|
"onUpdate:selectedReasoningEffort"?: ((value: any) => any) | undefined;
|
|
95
95
|
onTabChange?: ((tab: TopbarTab) => any) | undefined;
|
|
@@ -67,8 +67,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
67
67
|
copyLink: () => any;
|
|
68
68
|
debug: () => any;
|
|
69
69
|
selectConversation: (id: string) => any;
|
|
70
|
-
settings: () => any;
|
|
71
70
|
send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
|
|
71
|
+
settings: () => any;
|
|
72
72
|
tabChange: (tab: TopbarTab) => any;
|
|
73
73
|
newConversation: (groupId?: string | null | undefined) => any;
|
|
74
74
|
switchWorkspace: () => any;
|
|
@@ -88,8 +88,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
88
88
|
onCopyLink?: (() => any) | undefined;
|
|
89
89
|
onDebug?: (() => any) | undefined;
|
|
90
90
|
onSelectConversation?: ((id: string) => any) | undefined;
|
|
91
|
-
onSettings?: (() => any) | undefined;
|
|
92
91
|
onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
|
|
92
|
+
onSettings?: (() => any) | undefined;
|
|
93
93
|
"onUpdate:selectedModel"?: ((value: string | null) => any) | undefined;
|
|
94
94
|
"onUpdate:selectedReasoningEffort"?: ((value: any) => any) | undefined;
|
|
95
95
|
onTabChange?: ((tab: TopbarTab) => any) | undefined;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { Message } from '../../types/schemas/chat/conversations.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Completed = "completed",
|
|
5
|
-
Failed = "failed"
|
|
6
|
-
}
|
|
2
|
+
import { ChatMessageStatus } from '../../types/message-status.js';
|
|
3
|
+
export { ChatMessageStatus } from '../../types/message-status.js';
|
|
7
4
|
export type ChatMessageTerminalPayload = {
|
|
8
5
|
conversationId: string;
|
|
9
6
|
messageId: string;
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
import { inject, provide } from "vue";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
ChatMessageStatus2["Failed"] = "failed";
|
|
6
|
-
return ChatMessageStatus2;
|
|
7
|
-
})(ChatMessageStatus || {});
|
|
1
|
+
import { inject, onScopeDispose, provide, ref } from "vue";
|
|
2
|
+
import { useConversationUsage } from "../../usage/composables/conversation-usage.js";
|
|
3
|
+
import { ChatMessageStatus } from "../../types/message-status.js";
|
|
4
|
+
export { ChatMessageStatus } from "../../types/message-status.js";
|
|
8
5
|
const CHAT_MESSAGE_TERMINAL_KEY = Symbol("chat-nuxt:message-terminal");
|
|
6
|
+
const USAGE_REFRESH_DELAYS_MS = [1e3, 3e3, 1e4];
|
|
9
7
|
export function terminalMessageTransitions(previousMessages, nextMessages) {
|
|
10
8
|
const previousById = new Map(previousMessages.map((message) => [message.id, message]));
|
|
11
9
|
const transitions = [];
|
|
12
10
|
for (const message of nextMessages) {
|
|
13
|
-
if (message.role !== "assistant" || previousById.get(message.id)?.status !==
|
|
11
|
+
if (message.role !== "assistant" || previousById.get(message.id)?.status !== ChatMessageStatus.Pending)
|
|
14
12
|
continue;
|
|
15
|
-
if (message.status ===
|
|
13
|
+
if (message.status === ChatMessageStatus.Completed) {
|
|
16
14
|
transitions.push({
|
|
17
15
|
conversationId: message.conversationId,
|
|
18
16
|
messageId: message.id,
|
|
19
|
-
status:
|
|
17
|
+
status: ChatMessageStatus.Completed,
|
|
20
18
|
content: message.content
|
|
21
19
|
});
|
|
22
|
-
} else if (message.status ===
|
|
20
|
+
} else if (message.status === ChatMessageStatus.Failed) {
|
|
23
21
|
transitions.push({
|
|
24
22
|
conversationId: message.conversationId,
|
|
25
23
|
messageId: message.id,
|
|
26
|
-
status:
|
|
24
|
+
status: ChatMessageStatus.Failed
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
}
|
|
@@ -34,8 +32,31 @@ export function provideChatMessageTerminal(handler) {
|
|
|
34
32
|
}
|
|
35
33
|
export function useChatMessageTerminal() {
|
|
36
34
|
const handler = inject(CHAT_MESSAGE_TERMINAL_KEY, null);
|
|
35
|
+
const conversationId = ref(null);
|
|
36
|
+
const { fetchUsage } = useConversationUsage(conversationId);
|
|
37
|
+
const scheduledRefreshes = /* @__PURE__ */ new Map();
|
|
38
|
+
function refreshUsage(id) {
|
|
39
|
+
conversationId.value = id;
|
|
40
|
+
void fetchUsage();
|
|
41
|
+
}
|
|
42
|
+
onScopeDispose(() => {
|
|
43
|
+
for (const timers of scheduledRefreshes.values()) {
|
|
44
|
+
for (const timer of timers)
|
|
45
|
+
clearTimeout(timer);
|
|
46
|
+
}
|
|
47
|
+
scheduledRefreshes.clear();
|
|
48
|
+
});
|
|
37
49
|
return {
|
|
38
50
|
emit(payload) {
|
|
51
|
+
const id = payload.conversationId;
|
|
52
|
+
for (const timer of scheduledRefreshes.get(id) ?? [])
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
scheduledRefreshes.set(id, USAGE_REFRESH_DELAYS_MS.map((delay, index) => setTimeout(() => {
|
|
55
|
+
refreshUsage(id);
|
|
56
|
+
if (index === USAGE_REFRESH_DELAYS_MS.length - 1)
|
|
57
|
+
scheduledRefreshes.delete(id);
|
|
58
|
+
}, delay)));
|
|
59
|
+
refreshUsage(id);
|
|
39
60
|
handler?.(payload);
|
|
40
61
|
}
|
|
41
62
|
};
|
|
@@ -3,8 +3,8 @@ export type { ChatFeatureConfig } from '../embed/feature-config.js';
|
|
|
3
3
|
export type { AvailableChatModels, ChatActor, ChatEmbedSharedProps, ChatEmbedVariant, ChatEmbedVariantProps, ChatLabels, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, TelaAgentChatEmbedProps, } from '../embed/types.js';
|
|
4
4
|
export type { ChatActionPayload } from '../messages/composables/chat-action.js';
|
|
5
5
|
export type { MessageFeedbackConfig, MessageFeedbackPayload, MessageFeedbackRating, MessageFeedbackSubmitHandler, MessageFeedbackSubmitResult, } from '../messages/composables/chat-feedback.js';
|
|
6
|
-
export { ChatMessageStatus } from '../messages/composables/chat-message-terminal.js';
|
|
7
6
|
export type { ChatMessageTerminalPayload } from '../messages/composables/chat-message-terminal.js';
|
|
7
|
+
export { ChatMessageStatus } from './message-status.js';
|
|
8
8
|
export type { ConversationEvent, Message } from './schemas/chat/conversations.js';
|
|
9
9
|
export type { MessageOverviewResponse } from './schemas/chat/messages.js';
|
|
10
10
|
export type { ConversationCreatorFilter } from './schemas/chat/primitives.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ChatMessageStatus } from "
|
|
1
|
+
export { ChatMessageStatus } from "./message-status.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var ChatMessageStatus = /* @__PURE__ */ ((ChatMessageStatus2) => {
|
|
2
|
+
ChatMessageStatus2["Pending"] = "pending";
|
|
3
|
+
ChatMessageStatus2["Completed"] = "completed";
|
|
4
|
+
ChatMessageStatus2["Failed"] = "failed";
|
|
5
|
+
return ChatMessageStatus2;
|
|
6
|
+
})(ChatMessageStatus || {});
|
|
@@ -3,12 +3,14 @@ import { useChatApi } from "../../shared/composables/chat-api.js";
|
|
|
3
3
|
export function useConversationUsage(conversationId) {
|
|
4
4
|
const chatApi = useChatApi();
|
|
5
5
|
const cache = useState("conversation-usage", () => ({}));
|
|
6
|
+
const requestVersions = useState("conversation-usage-request-versions", () => ({}));
|
|
7
|
+
const errors = useState("conversation-usage-errors", () => ({}));
|
|
6
8
|
const cached = computed(() => conversationId.value ? cache.value[conversationId.value] : void 0);
|
|
7
9
|
const usageData = computed(() => cached.value?.usage ?? null);
|
|
8
10
|
const billing = computed(() => cached.value?.billing ?? null);
|
|
9
11
|
const loaded = computed(() => cached.value !== void 0);
|
|
10
12
|
const loading = ref(false);
|
|
11
|
-
const error =
|
|
13
|
+
const error = computed(() => conversationId.value ? errors.value[conversationId.value] ?? null : null);
|
|
12
14
|
function formatBillingCost(cost) {
|
|
13
15
|
if (!billing.value || billing.value.mode === "credits") {
|
|
14
16
|
return formatCredits(cost);
|
|
@@ -22,25 +24,28 @@ export function useConversationUsage(conversationId) {
|
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
24
26
|
const requestId = ++latestRequestId;
|
|
27
|
+
const version = (requestVersions.value[id] ?? 0) + 1;
|
|
28
|
+
requestVersions.value[id] = version;
|
|
25
29
|
loading.value = true;
|
|
26
|
-
|
|
30
|
+
errors.value[id] = null;
|
|
27
31
|
try {
|
|
28
32
|
const response = await $fetch(
|
|
29
33
|
chatApi.path(`/conversations/${id}/usage`),
|
|
30
34
|
chatApi.withChatHeaders()
|
|
31
35
|
);
|
|
32
|
-
if (
|
|
36
|
+
if (requestVersions.value[id] !== version)
|
|
33
37
|
return;
|
|
34
38
|
if (response.error) {
|
|
35
|
-
|
|
39
|
+
errors.value[id] = response.error;
|
|
36
40
|
} else {
|
|
37
41
|
cache.value = { ...cache.value, [id]: { usage: response.usage, billing: response.billing } };
|
|
42
|
+
errors.value[id] = null;
|
|
38
43
|
}
|
|
39
44
|
} catch (err) {
|
|
40
|
-
if (
|
|
45
|
+
if (requestVersions.value[id] !== version)
|
|
41
46
|
return;
|
|
42
47
|
console.error("Failed to fetch usage data:", err);
|
|
43
|
-
|
|
48
|
+
errors.value[id] = "Falha ao carregar dados de uso";
|
|
44
49
|
} finally {
|
|
45
50
|
if (requestId === latestRequestId)
|
|
46
51
|
loading.value = false;
|
package/dist/types.d.mts
CHANGED
|
@@ -4,10 +4,10 @@ import type { default as Module } from './module.mjs'
|
|
|
4
4
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
|
-
export { ChatMessageStatus } from '../dist/runtime/messages/composables/chat-message-terminal.js'
|
|
8
|
-
|
|
9
7
|
export { type AvailableChatModels, type ChatActionPayload, type ChatActor, type ChatEmbedSharedProps, type ChatEmbedVariant, type ChatEmbedVariantProps, type ChatFeatureConfig, type ChatLabels, type ChatMessageTerminalPayload, type ChatSidebarConfig, type ChatSuggestion, type DefaultChatEmbedProps, type MeistrariChatEmbedProps, type MessageFeedbackConfig, type MessageFeedbackPayload, type MessageFeedbackRating, type MessageFeedbackSubmitHandler, type MessageFeedbackSubmitResult, type MessageOverviewResponse, type TelaAgentChatEmbedProps, type TelaAgentExecutionInput } from '../dist/runtime/types/embed.js'
|
|
10
8
|
|
|
9
|
+
export { ChatMessageStatus } from '../dist/runtime/types/message-status.js'
|
|
10
|
+
|
|
11
11
|
export { default } from './module.mjs'
|
|
12
12
|
|
|
13
13
|
export { type ChatNuxtModuleOptions } from './module.mjs'
|