@meistrari/chat-nuxt 3.13.0-rc.2 → 3.13.0-rc.4
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/README.md +1 -1
- package/dist/module.d.mts +1 -1
- package/dist/module.json +1 -1
- package/dist/runtime/embed/composables/embed-config.js +6 -1
- package/dist/runtime/embed/feature-config.d.ts +5 -4
- package/dist/runtime/embed/feature-config.js +4 -4
- package/dist/runtime/embed/types.d.ts +5 -4
- package/dist/runtime/messages/components/chat-message-feedback.vue +15 -6
- package/dist/runtime/messages/composables/chat-feedback.d.ts +14 -0
- package/dist/runtime/messages/composables/chat-feedback.js +6 -0
- package/dist/runtime/messages/composables/chat.js +1 -1
- package/dist/runtime/types/embed.d.ts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ Declared in `src/runtime/embed/types.ts`; prop, feature-flag, and event payload
|
|
|
59
59
|
| `telaAgentInputs` | `TelaAgentExecutionInput[] \| null` | `undefined` | Inputs sent with each Tela agent run; hides the variables panel when non-null |
|
|
60
60
|
| `workspaceSettings` | `WorkspaceSettings \| null` | `null` | Override settings from host app; not accepted in Tela agent mode |
|
|
61
61
|
| `user` | `ChatActor \| null` | `null` | Override current user display info; not accepted in Tela agent mode |
|
|
62
|
-
| `features` | `Partial<ChatFeatureConfig>` | `{}` | Toggle
|
|
62
|
+
| `features` | `Partial<ChatFeatureConfig>` | `{}` | Toggle `showUsageTab`, `showDebugOption`, `showCancelButton`, `showTtft`, and `chatOutboundQueue`; all released features default to `true` |
|
|
63
63
|
| `loadingMessages` | `readonly string[] \| null` | Default chat messages | Override pending-response messages |
|
|
64
64
|
| `loadingMessagesMode` | `'ordered' \| 'random' \| null` | `'ordered'` | Rotate custom messages in order or at random; only applies when `loadingMessages` has a non-empty message |
|
|
65
65
|
| `customComponents` | `Record<string, Component>` | `undefined` | Custom markdown renderers keyed by markdown node or tag name |
|
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ChatMessageStatus } from '../dist/runtime/messages/composables/chat-message-terminal.js';
|
|
2
|
-
export { ChatActionPayload, ChatActor, ChatEmbedSharedProps, ChatEmbedVariant, ChatEmbedVariantProps, ChatFeatureConfig, ChatMessageTerminalPayload, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, MessageFeedbackConfig, MessageFeedbackPayload, MessageFeedbackRating, MessageOverviewResponse, TelaAgentChatEmbedProps, TelaAgentExecutionInput } from '../dist/runtime/types/embed.js';
|
|
2
|
+
export { ChatActionPayload, ChatActor, ChatEmbedSharedProps, ChatEmbedVariant, ChatEmbedVariantProps, ChatFeatureConfig, ChatMessageTerminalPayload, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, MessageFeedbackConfig, MessageFeedbackPayload, MessageFeedbackRating, MessageFeedbackSubmitHandler, MessageFeedbackSubmitResult, MessageOverviewResponse, TelaAgentChatEmbedProps, TelaAgentExecutionInput } from '../dist/runtime/types/embed.js';
|
|
3
3
|
|
|
4
4
|
type ChatNuxtConfigValidationMode = false | 'warn' | 'error';
|
|
5
5
|
|
package/dist/module.json
CHANGED
|
@@ -10,6 +10,11 @@ function useGlobalCitationsState() {
|
|
|
10
10
|
nuxtApp._chatEmbedConfigCitations ??= shallowRef(void 0);
|
|
11
11
|
return nuxtApp._chatEmbedConfigCitations;
|
|
12
12
|
}
|
|
13
|
+
function useGlobalFeedbackState() {
|
|
14
|
+
const nuxtApp = useNuxtApp();
|
|
15
|
+
nuxtApp._chatEmbedConfigFeedback ??= shallowRef(void 0);
|
|
16
|
+
return nuxtApp._chatEmbedConfigFeedback;
|
|
17
|
+
}
|
|
13
18
|
function useGlobalEmbedConfigState() {
|
|
14
19
|
return {
|
|
15
20
|
provided: useState("chat-embed-config-provided", () => false),
|
|
@@ -26,7 +31,7 @@ function useGlobalEmbedConfigState() {
|
|
|
26
31
|
customComponents: useGlobalCustomComponentsState(),
|
|
27
32
|
customHtmlTags: useState("chat-embed-config-custom-html-tags", () => void 0),
|
|
28
33
|
citations: useGlobalCitationsState(),
|
|
29
|
-
feedbackConfig:
|
|
34
|
+
feedbackConfig: useGlobalFeedbackState(),
|
|
30
35
|
messageFeedback: useState("chat-embed-config-message-feedback", () => void 0)
|
|
31
36
|
};
|
|
32
37
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
/** Optional
|
|
1
|
+
/** Optional feature toggles the host passes per embed instance. */
|
|
2
2
|
export type ChatFeatureConfig = {
|
|
3
|
-
/** Usage tab in the chat topbar, with per-conversation token and cost stats. */
|
|
3
|
+
/** Usage tab in the chat topbar, with per-conversation token and cost stats. Defaults to true. */
|
|
4
4
|
showUsageTab?: boolean;
|
|
5
|
-
/** Debug entry in the topbar overflow menu. */
|
|
5
|
+
/** Debug entry in the topbar overflow menu. Defaults to true. */
|
|
6
6
|
showDebugOption?: boolean;
|
|
7
|
-
/** "Stop generation" button while a response streams. */
|
|
7
|
+
/** "Stop generation" button while a response streams. Defaults to true. */
|
|
8
8
|
showCancelButton?: boolean;
|
|
9
9
|
/** Time to first token shown in assistant message metadata. Defaults to true. */
|
|
10
10
|
showTtft?: boolean;
|
|
11
|
+
/** Reliable outbound delivery and sandbox readiness handling. Defaults to true. */
|
|
11
12
|
chatOutboundQueue?: boolean;
|
|
12
13
|
};
|
|
13
14
|
export type ResolvedChatFeatureConfig = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export function resolveChatFeatures(features) {
|
|
2
2
|
return {
|
|
3
|
-
showUsageTab: features?.showUsageTab ??
|
|
4
|
-
showDebugOption: features?.showDebugOption ??
|
|
5
|
-
showCancelButton: features?.showCancelButton ??
|
|
3
|
+
showUsageTab: features?.showUsageTab ?? true,
|
|
4
|
+
showDebugOption: features?.showDebugOption ?? true,
|
|
5
|
+
showCancelButton: features?.showCancelButton ?? true,
|
|
6
6
|
showTtft: features?.showTtft ?? true,
|
|
7
|
-
chatOutboundQueue: features?.chatOutboundQueue ??
|
|
7
|
+
chatOutboundQueue: features?.chatOutboundQueue ?? true
|
|
8
8
|
};
|
|
9
9
|
}
|
|
@@ -93,14 +93,15 @@ export type ChatEmbedSharedProps = {
|
|
|
93
93
|
citations?: ChatCitationsConfig | null;
|
|
94
94
|
/**
|
|
95
95
|
* Enables 👍/👎 feedback on assistant messages and configures the reason
|
|
96
|
-
* popovers. Providing the prop (even `{}`) shows the controls
|
|
97
|
-
*
|
|
96
|
+
* popovers. Providing the prop (even `{}`) shows the controls. Prefer the
|
|
97
|
+
* async `submit` callback when persistence can fail; without it, votes reach
|
|
98
|
+
* the host through the legacy `message-feedback` event.
|
|
98
99
|
*/
|
|
99
100
|
feedbackConfig?: MessageFeedbackConfig | null;
|
|
100
101
|
/**
|
|
101
102
|
* Ratings the host persisted, keyed by message id. When provided, this map is
|
|
102
|
-
* the single source of truth for the selected thumbs — update it
|
|
103
|
-
*
|
|
103
|
+
* the single source of truth for the selected thumbs — update it only after
|
|
104
|
+
* persistence succeeds.
|
|
104
105
|
* When omitted, votes are kept in component-local state only.
|
|
105
106
|
*/
|
|
106
107
|
messageFeedback?: Readonly<Record<string, MessageFeedbackRating>> | null;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { useEmbedConfig } from "../../embed/composables/embed-config";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
dispatchMessageFeedback,
|
|
5
|
+
useMessageFeedback
|
|
6
|
+
} from "../composables/chat-feedback";
|
|
4
7
|
const props = defineProps({
|
|
5
8
|
message: { type: null, required: true }
|
|
6
9
|
});
|
|
@@ -13,15 +16,18 @@ const persistedMap = computed(() => embedConfig?.messageFeedback.value ?? null);
|
|
|
13
16
|
const persistedRating = computed(() => persistedMap.value?.[props.message.id] ?? null);
|
|
14
17
|
const localRating = ref(null);
|
|
15
18
|
const rating = computed(() => persistedMap.value ? persistedRating.value : localRating.value);
|
|
16
|
-
function handleSubmit(payload) {
|
|
17
|
-
|
|
19
|
+
async function handleSubmit(payload) {
|
|
20
|
+
const completePayload = {
|
|
18
21
|
conversationId: props.message.conversationId,
|
|
19
22
|
messageId: props.message.id,
|
|
20
23
|
rating: payload.rating,
|
|
21
24
|
reasons: payload.reasons,
|
|
22
25
|
comment: payload.comment
|
|
23
|
-
}
|
|
24
|
-
|
|
26
|
+
};
|
|
27
|
+
const result = await dispatchMessageFeedback(completePayload, config.value?.submit, emitFeedback);
|
|
28
|
+
if (result.ok)
|
|
29
|
+
localRating.value = payload.rating;
|
|
30
|
+
return result;
|
|
25
31
|
}
|
|
26
32
|
</script>
|
|
27
33
|
|
|
@@ -31,6 +37,7 @@ function handleSubmit(payload) {
|
|
|
31
37
|
:positive-reasons="positiveReasons"
|
|
32
38
|
:negative-reasons="negativeReasons"
|
|
33
39
|
:require-reason="config?.requireReason ?? false"
|
|
40
|
+
:submit="handleSubmit"
|
|
34
41
|
positive-title="O que ajudou?"
|
|
35
42
|
positive-description="Marcar o que funcionou refina as próximas respostas."
|
|
36
43
|
positive-comment-placeholder="Comentário (opcional)…"
|
|
@@ -39,9 +46,11 @@ function handleSubmit(payload) {
|
|
|
39
46
|
negative-comment-placeholder="Conte o que faltou (opcional)…"
|
|
40
47
|
cancel-label="Cancelar"
|
|
41
48
|
submit-label="Enviar"
|
|
49
|
+
submitting-label="Enviando feedback…"
|
|
50
|
+
retry-label="Tentar novamente"
|
|
51
|
+
submit-error-message="Não foi possível enviar o feedback. Tente novamente."
|
|
42
52
|
helpful-label="Resposta útil"
|
|
43
53
|
not-helpful-label="Resposta não útil"
|
|
44
54
|
comment-label="Comentário"
|
|
45
|
-
@submit="handleSubmit"
|
|
46
55
|
/>
|
|
47
56
|
</template>
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export type MessageFeedbackRating = 'positive' | 'negative';
|
|
2
|
+
export type MessageFeedbackSubmitResult = {
|
|
3
|
+
ok: true;
|
|
4
|
+
} | {
|
|
5
|
+
ok: false;
|
|
6
|
+
message?: string;
|
|
7
|
+
};
|
|
2
8
|
export type MessageFeedbackConfig = {
|
|
3
9
|
/** Reason chips offered on a positive vote. Empty or omitted: 👍 submits directly. */
|
|
4
10
|
positiveReasons?: readonly string[];
|
|
@@ -6,6 +12,12 @@ export type MessageFeedbackConfig = {
|
|
|
6
12
|
negativeReasons?: readonly string[];
|
|
7
13
|
/** Require a justification on a negative vote: at least one reason chip when negativeReasons are configured, otherwise a non-empty comment. */
|
|
8
14
|
requireReason?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Persists a vote. While this promise is pending the form remains open and
|
|
17
|
+
* disabled; it closes only after `{ ok: true }`. On failure, return a safe
|
|
18
|
+
* user-facing message and the draft remains available for retry.
|
|
19
|
+
*/
|
|
20
|
+
submit?: MessageFeedbackSubmitHandler;
|
|
9
21
|
};
|
|
10
22
|
export type MessageFeedbackPayload = {
|
|
11
23
|
conversationId: string;
|
|
@@ -15,6 +27,8 @@ export type MessageFeedbackPayload = {
|
|
|
15
27
|
comment: string;
|
|
16
28
|
};
|
|
17
29
|
export type MessageFeedbackHandler = (payload: MessageFeedbackPayload) => void;
|
|
30
|
+
export type MessageFeedbackSubmitHandler = (payload: MessageFeedbackPayload) => Promise<MessageFeedbackSubmitResult>;
|
|
31
|
+
export declare function dispatchMessageFeedback(payload: MessageFeedbackPayload, submit: MessageFeedbackSubmitHandler | undefined, emit: MessageFeedbackHandler): Promise<MessageFeedbackSubmitResult>;
|
|
18
32
|
export declare function provideMessageFeedback(handler: MessageFeedbackHandler): void;
|
|
19
33
|
export declare function useMessageFeedback(): {
|
|
20
34
|
emit(payload: MessageFeedbackPayload): void;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export async function dispatchMessageFeedback(payload, submit, emit) {
|
|
2
|
+
if (submit)
|
|
3
|
+
return await submit(payload);
|
|
4
|
+
emit(payload);
|
|
5
|
+
return { ok: true };
|
|
6
|
+
}
|
|
1
7
|
const MESSAGE_FEEDBACK_KEY = Symbol("chat-nuxt:message-feedback");
|
|
2
8
|
export function provideMessageFeedback(handler) {
|
|
3
9
|
provide(MESSAGE_FEEDBACK_KEY, handler);
|
|
@@ -86,7 +86,7 @@ export function useChat(options = {}) {
|
|
|
86
86
|
set: (value) => agentSessionRewakeableBuckets.value = { ...agentSessionRewakeableBuckets.value, [chatScope.value]: value }
|
|
87
87
|
});
|
|
88
88
|
const outbound = useOutboundQueue(chatScope);
|
|
89
|
-
const outboundQueueEnabled = computed(() => toValue(options.outboundQueueEnabled) ??
|
|
89
|
+
const outboundQueueEnabled = computed(() => toValue(options.outboundQueueEnabled) ?? true);
|
|
90
90
|
const loading = ref(false);
|
|
91
91
|
const sending = ref(false);
|
|
92
92
|
const gateHolding = ref(false);
|
|
@@ -2,7 +2,7 @@ export type { ChatCitationsConfig, CitationMeta, CitationRef, } from '../citatio
|
|
|
2
2
|
export type { ChatFeatureConfig } from '../embed/feature-config.js';
|
|
3
3
|
export type { ChatActor, ChatEmbedSharedProps, ChatEmbedVariant, ChatEmbedVariantProps, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, TelaAgentChatEmbedProps, } from '../embed/types.js';
|
|
4
4
|
export type { ChatActionPayload } from '../messages/composables/chat-action.js';
|
|
5
|
-
export type { MessageFeedbackConfig, MessageFeedbackPayload, MessageFeedbackRating, } from '../messages/composables/chat-feedback.js';
|
|
5
|
+
export type { MessageFeedbackConfig, MessageFeedbackPayload, MessageFeedbackRating, MessageFeedbackSubmitHandler, MessageFeedbackSubmitResult, } from '../messages/composables/chat-feedback.js';
|
|
6
6
|
export { ChatMessageStatus } from '../messages/composables/chat-message-terminal.js';
|
|
7
7
|
export type { ChatMessageTerminalPayload } from '../messages/composables/chat-message-terminal.js';
|
|
8
8
|
export type { MessageOverviewResponse } from './schemas/chat/messages.js';
|
package/dist/types.d.mts
CHANGED
|
@@ -6,7 +6,7 @@ export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<
|
|
|
6
6
|
|
|
7
7
|
export { ChatMessageStatus } from '../dist/runtime/messages/composables/chat-message-terminal.js'
|
|
8
8
|
|
|
9
|
-
export { type ChatActionPayload, type ChatActor, type ChatEmbedSharedProps, type ChatEmbedVariant, type ChatEmbedVariantProps, type ChatFeatureConfig, type ChatMessageTerminalPayload, type ChatSidebarConfig, type ChatSuggestion, type DefaultChatEmbedProps, type MeistrariChatEmbedProps, type MessageFeedbackConfig, type MessageFeedbackPayload, type MessageFeedbackRating, type MessageOverviewResponse, type TelaAgentChatEmbedProps, type TelaAgentExecutionInput } from '../dist/runtime/types/embed.js'
|
|
9
|
+
export { type ChatActionPayload, type ChatActor, type ChatEmbedSharedProps, type ChatEmbedVariant, type ChatEmbedVariantProps, type ChatFeatureConfig, 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
10
|
|
|
11
11
|
export { default } from './module.mjs'
|
|
12
12
|
|