@meistrari/chat-nuxt 4.8.0 → 4.9.0-rc.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/module.d.mts CHANGED
@@ -1,4 +1,4 @@
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';
1
+ export { AvailableChatModels, ChatActionPayload, ChatActor, ChatEmbedSharedProps, ChatEmbedVariant, ChatEmbedVariantProps, ChatFeatureConfig, ChatLabels, ChatMessageSentPayload, ChatMessageTerminalPayload, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, MessageFeedbackConfig, MessageFeedbackPayload, MessageFeedbackRating, MessageFeedbackSubmitHandler, MessageFeedbackSubmitResult, MessageOverviewResponse, TelaAgentChatEmbedProps, TelaAgentExecutionInput } from '../dist/runtime/types/embed.js';
2
2
  export { ChatMessageStatus } from '../dist/runtime/types/message-status.js';
3
3
 
4
4
  type ChatNuxtConfigValidationMode = false | 'warn' | 'error';
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
3
  "configKey": "chatNuxt",
4
- "version": "4.8.0-rc.4",
4
+ "version": "4.9.0-rc.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -4,6 +4,7 @@ import { provideConversationCreatorFilterState } from "../../conversations/compo
4
4
  import { provideChatAction } from "../../messages/composables/chat-action";
5
5
  import { provideMessageFeedback } from "../../messages/composables/chat-feedback";
6
6
  import { provideChatMessageTerminal } from "../../messages/composables/chat-message-terminal";
7
+ import { provideChatMessageSent } from "../../messages/composables/chat-message-sent";
7
8
  import { provideChatRequestContext } from "../../shared/composables/chat-request-context";
8
9
  import { provideEmbedConfig, useEmbedConfig } from "../composables/embed-config";
9
10
  import { normalizeConversationScope, normalizeTelaAgentId, resolveConversationScopeKeySegment } from "../../conversations/scope";
@@ -49,7 +50,7 @@ const props = defineProps({
49
50
  keepMounted: { type: Boolean, required: false },
50
51
  launcherLabel: { type: String, required: false }
51
52
  });
52
- const emit = defineEmits(["update:conversationId", "update:conversationTitle", "update:conversationCreatorFilter", "action", "messageFeedback", "messageTerminal"]);
53
+ const emit = defineEmits(["update:conversationId", "update:conversationTitle", "update:conversationCreatorFilter", "action", "messageFeedback", "messageTerminal", "messageSent"]);
53
54
  const LightweightAdapter = defineAsyncComponent(() => import("../../lightweight/embed/components/chat-embed-adapter.vue"));
54
55
  const parentEmbedConfig = useEmbedConfig();
55
56
  const { activeOrganization } = useChatAuth();
@@ -141,6 +142,9 @@ provideMessageFeedback((payload) => {
141
142
  provideChatMessageTerminal((payload) => {
142
143
  emit("messageTerminal", payload);
143
144
  });
145
+ provideChatMessageSent((payload) => {
146
+ emit("messageSent", payload);
147
+ });
144
148
  </script>
145
149
 
146
150
  <template>
@@ -2,6 +2,7 @@ import type { DefineSetupFnComponent, SlotsType } from 'vue';
2
2
  import type { ChatActionPayload } from '../../messages/composables/chat-action.js';
3
3
  import type { MessageFeedbackPayload } from '../../messages/composables/chat-feedback.js';
4
4
  import type { ChatMessageTerminalPayload } from '../../messages/composables/chat-message-terminal.js';
5
+ import type { ChatMessageSentPayload } from '../../messages/composables/chat-message-sent.js';
5
6
  import type { Message } from '../../types/schemas/chat/conversations.js';
6
7
  import type { ChatFeatureConfig } from '../feature-config.js';
7
8
  import type { AvailableChatModels, ChatEmbedVariant, ChatEmbedVariantProps, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, TelaAgentChatEmbedProps } from '../types.js';
@@ -19,6 +20,8 @@ type MeistrariChatEmbedEmits = {
19
20
  'messageFeedback': (payload: MessageFeedbackPayload) => any;
20
21
  /** Fired after polling observes an assistant message reach a terminal status. */
21
22
  'messageTerminal': (payload: ChatMessageTerminalPayload) => any;
23
+ /** Fired once the server accepts a user message, including retries of a failed answer. */
24
+ 'messageSent': (payload: ChatMessageSentPayload) => any;
22
25
  };
23
26
 
24
27
  type MeistrariChatEmbedSlots = SlotsType<{
@@ -61,4 +64,4 @@ type MeistrariChatEmbedSlots = SlotsType<{
61
64
  declare const MeistrariChatEmbed: DefineSetupFnComponent<MeistrariChatEmbedProps, MeistrariChatEmbedEmits, MeistrariChatEmbedSlots>;
62
65
 
63
66
  export default MeistrariChatEmbed;
64
- export type { AvailableChatModels, ChatActionPayload, ChatEmbedVariant, ChatEmbedVariantProps, ChatFeatureConfig, ChatMessageTerminalPayload, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, Message, MessageFeedbackPayload, TelaAgentChatEmbedProps };
67
+ export type { AvailableChatModels, ChatActionPayload, ChatEmbedVariant, ChatEmbedVariantProps, ChatFeatureConfig, ChatMessageSentPayload, ChatMessageTerminalPayload, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, Message, MessageFeedbackPayload, TelaAgentChatEmbedProps };
@@ -41,7 +41,7 @@ const { hideSidebar = void 0, syncBrowserState = true, closeOnOutsideClick = tru
41
41
  keepMounted: { type: Boolean, required: false },
42
42
  launcherLabel: { type: String, required: false }
43
43
  });
44
- const emit = defineEmits(["update:conversationId", "update:conversationCreatorFilter", "update:open", "action", "messageFeedback", "messageTerminal"]);
44
+ const emit = defineEmits(["update:conversationId", "update:conversationCreatorFilter", "update:open", "action", "messageFeedback", "messageTerminal", "messageSent"]);
45
45
  defineSlots();
46
46
  provideConversationCreatorFilterState({
47
47
  defaultConversationCreatorFilter: () => props.defaultConversationCreatorFilter,
@@ -118,6 +118,7 @@ const widgetEmbedProps = computed(() => ({
118
118
  @action="emit('action', $event)"
119
119
  @message-feedback="emit('messageFeedback', $event)"
120
120
  @message-terminal="emit('messageTerminal', $event)"
121
+ @message-sent="emit('messageSent', $event)"
121
122
  >
122
123
  <template v-if="$slots['sidebar-bottom']" #sidebar-bottom>
123
124
  <slot name="sidebar-bottom" />
@@ -160,6 +161,7 @@ const widgetEmbedProps = computed(() => ({
160
161
  @action="emit('action', $event)"
161
162
  @message-feedback="emit('messageFeedback', $event)"
162
163
  @message-terminal="emit('messageTerminal', $event)"
164
+ @message-sent="emit('messageSent', $event)"
163
165
  >
164
166
  <template v-if="$slots['failed-message-actions']" #failed-message-actions="slotProps">
165
167
  <slot name="failed-message-actions" v-bind="slotProps" />
@@ -189,6 +191,7 @@ const widgetEmbedProps = computed(() => ({
189
191
  @action="emit('action', $event)"
190
192
  @message-feedback="emit('messageFeedback', $event)"
191
193
  @message-terminal="emit('messageTerminal', $event)"
194
+ @message-sent="emit('messageSent', $event)"
192
195
  >
193
196
  <template v-if="$slots['failed-message-actions']" #failed-message-actions="slotProps">
194
197
  <slot name="failed-message-actions" v-bind="slotProps" />
@@ -2,6 +2,7 @@ import type { DefineSetupFnComponent, SlotsType } from 'vue';
2
2
  import type { ChatActionPayload } from '../../messages/composables/chat-action.js';
3
3
  import type { MessageFeedbackPayload } from '../../messages/composables/chat-feedback.js';
4
4
  import type { ChatMessageTerminalPayload } from '../../messages/composables/chat-message-terminal.js';
5
+ import type { ChatMessageSentPayload } from '../../messages/composables/chat-message-sent.js';
5
6
  import type { Message } from '../../types/schemas/chat/conversations.js';
6
7
  import type { ChatFeatureConfig } from '../feature-config.js';
7
8
  import type { AvailableChatModels, ChatEmbedVariant, ChatEmbedVariantProps, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, TelaAgentChatEmbedProps } from '../types.js';
@@ -19,6 +20,8 @@ type MeistrariChatEmbedEmits = {
19
20
  'messageFeedback': (payload: MessageFeedbackPayload) => any;
20
21
  /** Fired after polling observes an assistant message reach a terminal status. */
21
22
  'messageTerminal': (payload: ChatMessageTerminalPayload) => any;
23
+ /** Fired once the server accepts a user message, including retries of a failed answer. */
24
+ 'messageSent': (payload: ChatMessageSentPayload) => any;
22
25
  };
23
26
 
24
27
  type MeistrariChatEmbedSlots = SlotsType<{
@@ -61,4 +64,4 @@ type MeistrariChatEmbedSlots = SlotsType<{
61
64
  declare const MeistrariChatEmbed: DefineSetupFnComponent<MeistrariChatEmbedProps, MeistrariChatEmbedEmits, MeistrariChatEmbedSlots>;
62
65
 
63
66
  export default MeistrariChatEmbed;
64
- export type { AvailableChatModels, ChatActionPayload, ChatEmbedVariant, ChatEmbedVariantProps, ChatFeatureConfig, ChatMessageTerminalPayload, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, Message, MessageFeedbackPayload, TelaAgentChatEmbedProps };
67
+ export type { AvailableChatModels, ChatActionPayload, ChatEmbedVariant, ChatEmbedVariantProps, ChatFeatureConfig, ChatMessageSentPayload, ChatMessageTerminalPayload, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, Message, MessageFeedbackPayload, TelaAgentChatEmbedProps };
@@ -0,0 +1,15 @@
1
+ export type ChatMessageSentPayload = {
2
+ conversationId: string;
3
+ /** Persisted id of the user message the server accepted. */
4
+ messageId: string;
5
+ /** Assistant message answering it; the same id a later `messageTerminal` event carries. */
6
+ assistantMessageId: string;
7
+ hasFiles: boolean;
8
+ /** True when the user retried a failed answer instead of writing a new message. */
9
+ retry: boolean;
10
+ };
11
+ export type ChatMessageSentHandler = (payload: ChatMessageSentPayload) => void;
12
+ export declare function provideChatMessageSent(handler: ChatMessageSentHandler): void;
13
+ export declare function useChatMessageSent(): {
14
+ emit(payload: ChatMessageSentPayload): void;
15
+ };
@@ -0,0 +1,13 @@
1
+ import { inject, provide } from "vue";
2
+ const CHAT_MESSAGE_SENT_KEY = Symbol("chat-nuxt:message-sent");
3
+ export function provideChatMessageSent(handler) {
4
+ provide(CHAT_MESSAGE_SENT_KEY, handler);
5
+ }
6
+ export function useChatMessageSent() {
7
+ const handler = inject(CHAT_MESSAGE_SENT_KEY, null);
8
+ return {
9
+ emit(payload) {
10
+ handler?.(payload);
11
+ }
12
+ };
13
+ }
@@ -27,6 +27,7 @@ import { useEmbedConfig } from "../../embed/composables/embed-config.js";
27
27
  import { CHAT_PREPARING_STEPS, nextChatPreparingStepDelay } from "../../embed/loading-messages.js";
28
28
  import { usePolling } from "../../shared/composables/polling.js";
29
29
  import { ChatMessageStatus, terminalMessageTransitions, useChatMessageTerminal } from "./chat-message-terminal.js";
30
+ import { useChatMessageSent } from "./chat-message-sent.js";
30
31
  import { useDirectStream } from "./use-direct-stream.js";
31
32
  import { overlayStreamedMessage } from "../stream-overlay.js";
32
33
  import { useOutboundQueue } from "./outbound-queue.js";
@@ -53,6 +54,7 @@ export function useChat(options = {}, adapter = {}) {
53
54
  const runtimeBlocked = ref(false);
54
55
  let streamConnecting = false;
55
56
  const chatMessageTerminal = useChatMessageTerminal();
57
+ const chatMessageSent = useChatMessageSent();
56
58
  const embedConfig = useEmbedConfig();
57
59
  const { user: authUser, activeOrganization } = useChatAuth();
58
60
  const { addFilesToConversation } = useConversationFileActions();
@@ -615,7 +617,21 @@ export function useChat(options = {}, adapter = {}) {
615
617
  ...standInOutputAtMs !== null ? { standInOutputAtMs } : {}
616
618
  }
617
619
  };
620
+ let sentEmitted = false;
621
+ const emitMessageSent = (response2) => {
622
+ if (sentEmitted)
623
+ return;
624
+ sentEmitted = true;
625
+ chatMessageSent.emit({
626
+ conversationId: response2.userMessage.conversationId,
627
+ messageId: response2.userMessage.id,
628
+ assistantMessageId: response2.assistantMessage.id,
629
+ hasFiles: (files?.length ?? 0) > 0,
630
+ retry: false
631
+ });
632
+ };
618
633
  const acceptMessagePair = (response2) => {
634
+ emitMessageSent(response2);
619
635
  messages.value = messages.value.map((msg) => {
620
636
  if (msg.id === optimisticUserMessage.id)
621
637
  return response2.userMessage;
@@ -648,6 +664,7 @@ export function useChat(options = {}, adapter = {}) {
648
664
  chatApi.withChatHeaders({ method: "POST", body: v2Body, retry: 1, timeout: CHAT_REQUEST_TIMEOUT_MS })
649
665
  );
650
666
  response = accepted;
667
+ emitMessageSent(accepted);
651
668
  if (currentConversation.value?.id !== conversationId2)
652
669
  return accepted.userMessage;
653
670
  runtimeBlocked.value = accepted.conversation.runtimeState === "blocked";
@@ -939,6 +956,16 @@ export function useChat(options = {}, adapter = {}) {
939
956
  chatApi.path(`/conversations/${conversationId}/messages/${messageId}/retry`),
940
957
  chatApi.withChatHeaders({ method: "POST", ...prepared?.executionSettings ? { body: { executionSettings: prepared.executionSettings } } : {} })
941
958
  );
959
+ const retriedUserMessage = retry.messages.slice(0, retry.messages.findIndex((message) => message.id === messageId)).findLast((message) => message.role === "user");
960
+ if (retriedUserMessage) {
961
+ chatMessageSent.emit({
962
+ conversationId,
963
+ messageId: retriedUserMessage.id,
964
+ assistantMessageId: messageId,
965
+ hasFiles: (retriedUserMessage.files?.length ?? 0) > 0,
966
+ retry: true
967
+ });
968
+ }
942
969
  if (currentConversation.value?.id !== conversationId)
943
970
  return true;
944
971
  messages.value = messages.value.map((message) => message.id === messageId ? { ...message, ...retriedMessage } : message);
@@ -4,6 +4,7 @@ export type { ChatFeatureConfig } from '../embed/feature-config.js';
4
4
  export type { AvailableChatModels, ChatActor, ChatEmbedSharedProps, ChatEmbedVariant, ChatEmbedVariantProps, ChatLabels, ChatSidebarConfig, ChatSuggestion, DefaultChatEmbedProps, MeistrariChatEmbedProps, TelaAgentChatEmbedProps, } from '../embed/types.js';
5
5
  export type { ChatActionPayload } from '../messages/composables/chat-action.js';
6
6
  export type { MessageFeedbackConfig, MessageFeedbackPayload, MessageFeedbackRating, MessageFeedbackSubmitHandler, MessageFeedbackSubmitResult, } from '../messages/composables/chat-feedback.js';
7
+ export type { ChatMessageSentPayload } from '../messages/composables/chat-message-sent.js';
7
8
  export type { ChatMessageTerminalPayload } from '../messages/composables/chat-message-terminal.js';
8
9
  export { ChatMessageStatus } from './message-status.js';
9
10
  export type { ConversationEvent, Message } from './schemas/chat/conversations.js';
package/dist/types.d.mts CHANGED
@@ -4,7 +4,7 @@ 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 { 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'
7
+ export { type AvailableChatModels, type ChatActionPayload, type ChatActor, type ChatEmbedSharedProps, type ChatEmbedVariant, type ChatEmbedVariantProps, type ChatFeatureConfig, type ChatLabels, type ChatMessageSentPayload, 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'
8
8
 
9
9
  export { ChatMessageStatus } from '../dist/runtime/types/message-status.js'
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
- "version": "4.8.0",
3
+ "version": "4.9.0-rc.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {